Coding tools
Codex, Claude Code and Cursor can use the AI Gateway as their model provider. Every request then goes through your model grants, guardrails, budgets, fallback and AI Logs, and the developer never sees a provider key.
You need an AI key for a profile with AI access, and the name of a model the profile may use. Store the key in your shell:
export ZERQ_KEY=zk_...
Replace https://api.example.com below with your gateway host and /llm with your LLM_GATEWAY_PATH.
Codex
Codex uses the OpenAI Responses API (POST /llm/v1/responses). Add a provider to ~/.codex/config.toml:
model_provider = "zerq"
model = "coding-default"
[model_providers.zerq]
name = "Zerq"
base_url = "https://api.example.com/llm/v1"
env_key = "ZERQ_KEY"
wire_api = "responses"
Codex's tools (shell commands, apply_patch) are passed to the model as functions, so any chat model with tool calling can serve Codex, not only OpenAI models.
Claude Code
Claude Code uses the Anthropic Messages API (POST /llm/v1/messages):
export ANTHROPIC_BASE_URL="https://api.example.com/llm"
export ANTHROPIC_AUTH_TOKEN="$ZERQ_KEY"
export ANTHROPIC_MODEL="coding-default"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="coding-default" # background tasks
claude
Claude Code also uses a small model for background tasks such as titles; ANTHROPIC_DEFAULT_HAIKU_MODEL points those at a model you granted. ANTHROPIC_API_KEY (sent as x-api-key) works as well.
Cursor
In Settings › Models, set the OpenAI API key to your AI key, enable Override OpenAI Base URL with https://api.example.com/llm/v1, and add your model name.
Tips
- Give coding tools their own model alias (for example
coding-default) with a tag such ascoding, so you can change the provider behind it without touching developer machines. - Set a generous
max_tokenscap and context window on coding models: agents send long prompts. - Turn on fallback so a provider outage does not stop work.
- Use an AI Budget and a profile token cap to bound spend per team or developer.
- Every call appears in AI Logs with the endpoint (
/v1/responsesfor Codex,/v1/messagesfor Claude Code).
Troubleshooting
| Symptom | Fix |
|---|---|
401 authentication_error | The key is wrong, revoked or rotated. Issue a new one. |
403 AI access is not enabled | Turn on AI access for the profile. |
403 model_not_allowed / Anthropic permission_error | Grant the model to the client (and to the profile subset if it has one). |
404 model_not_found | The model name does not exist or is inactive. For Claude Code, check ANTHROPIC_MODEL and ANTHROPIC_DEFAULT_HAIKU_MODEL. |
400 previous_response_id is not supported | Configure the client to resend the full conversation instead of referencing a stored response. |
429 rate_limit_exceeded / budget_exceeded | A budget limit or profile token cap was reached; see Retry-After. |