For the complete documentation index, see llms.txt. Markdown versions of all docs pages are available by appending .md to any docs URL.
OpenAI
Verified : Automated tests passed for: Configuration files: The configuration files on this page were checked against their schema. End-to-end run: Every step ran in a fresh test environment and the results were checked.Route agentgateway LLM traffic to OpenAI’s GPT models.
Configure OpenAI as an LLM provider in agentgateway.
Configuration
You can add the model in the UI or in your configuration file.
To add the model in the UI, follow these steps. The steps create the same model as the Config file tab.
Set your API key in the
OPENAI_API_KEYenvironment variable. The UI checks that the variable exists when you save the model.export OPENAI_API_KEY='<your-api-key>'Create a configuration file with an empty
llmsection, and start agentgateway in the same terminal. Without anllmsection, the UI does not show the LLM > Models page.cat > config.yaml <<'EOF' # yaml-language-server: $schema=https://agentgateway.dev/schema/config llm: models: [] EOF agentgateway -f config.yamlOpen LLM > Models, such as http://localhost:15000/ui/llm/models, and click Add model.
From the Provider dropdown, select OpenAI.
Keep the default
openai/*in the Incoming model match field.For the Provider API key, select Env var, and enter
OPENAI_API_KEY.For Outgoing model, keep Strip openai/. This option removes the
openai/prefix before the request is forwarded. To send every request to one model instead, select Explicit, and enter the model name. This option setsparams.model.

Click Save model.
The UI writes the provider as openai instead of openAI. Agentgateway accepts both values.
Whether the UI can save depends on your storage mode. For more information, see Save changes from the UI.
Review the following example configuration.
# yaml-language-server: $schema=https://agentgateway.dev/schema/config
llm:
models:
- name: "openai/*"
provider: openAI
params:
apiKey: "$OPENAI_API_KEY"
transformation:
model: llmRequest.model.stripPrefix("openai/")Review the following table to understand this configuration.
| Setting | Description |
|---|---|
name | The model name to match in incoming requests. When a client sends "model": "<name>", the request is routed to this provider. The openai/* pattern matches any model name that starts with openai/. |
provider | The LLM provider, set to openAI for OpenAI models. |
params.model | The specific OpenAI model to use. If set, this model is used for all requests. If not set, the request must include the model to use. |
params.apiKey | The OpenAI API key for authentication. You can reference environment variables using the $VAR_NAME syntax. |
transformation.model | Removes the openai/ prefix from the model name before the request is forwarded, so the provider receives its own model name. |
Send Decisions API requests to /v1/decisions. When responses include OpenAI usage fields, LLM telemetry records the model and token usage. Guardrails do not apply to these requests.
For supported providers, configuration, and examples, see Decisions.
Note
For advanced routing scenarios that require path-based routing or custom endpoints, use the gateways and routes configuration format. See the Routing-based configuration guide for more information.
Note
To connect Codex to agentgateway, see the Codex integration page.