VanaAPI

← Writing

A new base URL for a Python script

Wire formatsEN2026-10-28

The OpenAI Python SDK normally sends requests to OpenAI's own API. The base_url setting lets you point the same SDK at another service that follows the OpenAI API format. This is useful when you want to keep your existing Python code while choosing a different model provider.

Vana API provides one OpenAI-compatible endpoint at https://api.vanaapi.com. It also supports the Anthropic Messages and Gemini native protocols, but this note focuses on the OpenAI Python SDK. Requests are billed by real token usage, with no monthly fee.

§ The small change

Install the SDK if it is not already in your project: pip install openai. Then create the client with a Vana API key and a different base URL. In most OpenAI-compatible SDK setups, the versioned endpoint is written as https://api.vanaapi.com/v1.

A minimal example looks like this: from openai import OpenAI; client = OpenAI(api_key="your-vana-api-key", base_url="https://api.vanaapi.com/v1").

The important part is base_url. Without it, the SDK uses its default OpenAI endpoint. The api_key still matters because it authenticates your request with Vana API.

§ Keep the key out of your code

For a quick local test, placing the key in the client constructor can be convenient. For a real project, use an environment variable so the key does not end up in source control, screenshots, or shared configuration.

Set the variable in your shell: export VANA_API_KEY="your-vana-api-key". Your Python code can then be written as from openai import OpenAI; import os; client = OpenAI(api_key=os.environ["VANA_API_KEY"], base_url="https://api.vanaapi.com/v1").

On Windows, the command for setting an environment variable differs by shell. The Python principle is the same: read the secret from the environment and pass it to the SDK.

§ Choose a model explicitly

The base URL selects the service, but it does not select a model. You choose the model in each request. For example, this request uses Claude Sonnet 5.5 through the OpenAI-compatible chat interface: response = client.chat.completions.create(model="Claude Sonnet 5.5", messages=[{"role": "user", "content": "Explain Python lists in simple terms."}]); print(response.choices[0].message.content).

You can use the same client with another available model, such as GPT-6 Astra, by changing only the model name. Keep the model name exactly as provided by Vana API. A spelling or capitalization difference can produce a model-not-found error.

§ Understanding what base_url changes

Setting base_url changes where the SDK sends its HTTP requests. It does not change Python syntax, message structure, or the way you read the response. This is why existing OpenAI SDK examples often need only a small configuration change before they can work with Vana API.

  • api_key identifies and authorizes your Vana API account.
  • base_url points the SDK at the Vana API endpoint.
  • model selects the model that should answer the request.
  • messages contains the conversation sent to that model.

§ Common setup mistakes

If the request fails, check the URL first. An incorrect path, a missing /v1, or an extra path segment can prevent the SDK from reaching the compatible API route. Next, check that the key is present in the same shell or process where Python is running.

Also confirm that you are using a model name supported by Vana API and that your account has sufficient balance. A successful connection does not guarantee that every model request is valid, because model availability and request formats can differ.

Vana API works with OpenAI SDK applications as well as tools such as Claude Code, Codex, and Gemini CLI. Create an account when you are ready to obtain a key and try the same configuration with your own Python script.