Create an AI Model Provider entity to define your connection and store your authentication credentials.
Create an AI Model entity to declare which upstream models are available, configure how client requests are routed, and specify which AI Model Provider to use.
kongctl apply -f - --auto-approve --pat "$KONNECT_TOKEN" << 'EOF'
ai_gateway_model_providers:
- ref: openai
ai_gateway: !lookup {id: !env AI_GATEWAY_ID}
name: openai
type: openai
display_name: "OpenAI"
config:
auth:
type: basic
headers:
- name: Authorization
value: !secret {source: !env OPENAI_AUTH_HEADER}
ai_gateway_models:
- ref: codex-openai
ai_gateway: !lookup {id: !env AI_GATEWAY_ID}
name: codex-openai
display_name: "Codex - OpenAI Responses API"
type: model
enabled: true
formats: [{ type: openai }]
config:
route:
paths:
- /
model:
body_param: model
values:
- codex-openai
capabilities: [agentic]
targets:
- name: gpt-5.4
provider: openai
config:
type: openai
upstream_url: "https://api.openai.com/v1/responses"
EOF
In this example, we’re setting up the AI Model Provider with:
-
type: openai: Specifies that this provider connects using OpenAI’s standard API format.
-
config.auth.headers[0].value: !secret {source: !env OPENAI_AUTH_HEADER}: Loads the API key from your environment at apply time so it is not embedded in the config, and kongctl redacts it in plan and diff output.
In this example, we’re setting up the AI Model with:
-
capabilities: [agentic]: Routes requests to the OpenAI Responses API, which the Codex CLI uses.
-
formats: [{ type: openai }]: Accepts OpenAI-format requests.
-
config.route.model: { body_param: model, values: [codex-openai] }: The model name the Codex CLI sends in each request.
-
route.paths: [/]: The base path Codex points at. The Responses API is served at /responses.