OpenAI provider guide
Route requests to OpenAI models (GPT-4o, GPT-4.1, the o-series, and others) through Otari. See any-llm's supported providers for the current provider list and Models for Otari's model-name format.
What you'll set up
An OpenAI provider entry in your config.yml that reads your key from OPENAI_API_KEY (or the key stored on the dashboard's Providers page), then a first request that Otari routes to OpenAI.
Prerequisites
Otari running locally (see the Quickstart)
An OpenAI account and an API key from https://platform.openai.com/api-keys
Configure
Add OpenAI under providers: in your config.yml:
providers:
openai:
api_key: "sk-..." # your OpenAI API key
# api_base: "https://api.openai.com/v1" # optional; override for a proxy or compatible endpointTo keep your provider key out of the file with environment interpolation:
providers:
openai:
api_key: ${OPENAI_API_KEY}...then export it before starting Otari:
OPENAI_API_KEYalone is not enough, and neither is a bareopenai:entry: Otari reads the variable only where an entry names it, as theapi_key: ${OPENAI_API_KEY}line above does. The dashboard's Providers page and an organization's own key work too. Otari logs a warning at startup when the variable is set and no entry reads it.
Optional settings
client_args are passed through to the underlying any-llm provider client, for options such as custom headers or timeouts:
Choose a model
Models are addressed as openai:<model>:
Everything after the colon is passed straight to OpenAI, so any model your key can access works.
Verify
If you have not already started Otari and created a client key, follow the Quickstart through step 3 first.
Then make a request with the Otari Python SDK (pip install otari; any OpenAI-compatible client also works), using an openai:<model> selector:
Expected (sample) output:
Troubleshooting
HTTP 424 The provider rejected the gateway's credentials (code provider_credential_rejected)
The api_key Otari sent to OpenAI is invalid or lacks access. Check the api_key (or OPENAI_API_KEY) configured on the gateway.
HTTP 404 (OpenAI's own "model not found" text)
The name after openai: is not a model your key can access, or the model name is misspelled. A rejection of your request carries OpenAI's own message, so the detail says which model it could not find. The requested model was not found on the provider appears instead when OpenAI sent no message at all.
HTTP 502 The upstream provider account is out of credit or over its billing limit.
The provider rejected the call because the account Otari billed has no credit left or has hit its billing limit (for example OpenAI's "billing hard limit reached", or Anthropic's "credit balance is too low", which arrives as a 400). Top up the provider account, or point the model at a provider that has credit. The usage log keeps the status the provider actually returned, so these stay countable.
HTTP 502 The provider failed the request with HTTP 5xx, The provider closed the connection before answering, or The gateway could not connect to the provider
OpenAI failed on its side or the connection to it broke. These are retryable. LLM provider error is the same answer for a failure Otari could not place.
HTTP 402 No pricing configured for model ...
Otari could not resolve pricing for that model and require_pricing rejected the request. Add a pricing: entry, enable default_pricing: true for bundled fallback pricing, or use a model that already has pricing coverage.
HTTP 401 Invalid master key on /api/v1/keys
You passed a client (tk-...) key, or the wrong master key, instead of the configured master key.
Pricing (optional)
To track cost for a model, add a pricing: entry in config.yml:
See Configuration for all options.
Last updated
Was this helpful?
