Codex & Claude Code
Use your account balance for your coding agent's model requests. Configure the client once, then work from your terminal.
On this page
Create a key
Use your Xava Inference balance for the coding agent's own model requests. Install your client first, then set its base URL, API key and model. MCP sign-in connects tools; it does not configure the agent's model API.
- Sign in on this site, add funds and open Dashboard → API keys. Create a key for the client and copy it when shown; the full key is only shown once.
- In your terminal, replace the placeholder below with that key. These examples use Bash or Zsh. Treat the value as a secret; use your secret manager for ongoing use.
- Apply the client settings below, then launch it from the same terminal. Shell exports last for that terminal session; an app opened from your dock may not inherit them.
export XINF_API_KEY="xk_live_REPLACE_WITH_YOUR_KEY"
The examples use this site's origin. Keep the dashboard, key and API URL on the same environment; staging and production keys are separate. Codex uses https://xavainf.com/v1; Claude Code uses https://xavainf.com.
| agent | native API we serve |
|---|---|
| Claude Code | Anthropic Messages (/v1/messages) |
| Codex | OpenAI Responses (/v1/responses) |
| Gemini CLI | Gemini API (/v1beta/models/...:generateContent) |
Claude Code
export ANTHROPIC_BASE_URL="https://xavainf.com" export ANTHROPIC_AUTH_TOKEN="$XINF_API_KEY" export ANTHROPIC_DEFAULT_HAIKU_MODEL="claude-haiku-4-5" claude --model claude-sonnet-5
Set XINF_API_KEY to your dashboard key first. Use the site origin without /v1: Claude Code adds /v1/messages. ANTHROPIC_AUTH_TOKEN sends your key as a bearer token; ANTHROPIC_API_KEY is an alternative for x-api-key authentication. Use one credential variable, clearing a conflicting one if needed. The example pins Sonnet and background Haiku; select models available in this site's catalog. Run /status to check the base URL and credential source.
Codex
model = "openai/gpt-5.4-mini" model_provider = "xinf" web_search = "disabled" [model_providers.xinf] name = "Xava Inference" base_url = "https://xavainf.com/v1" env_key = "XINF_API_KEY" wire_api = "responses" requires_openai_auth = false # then, in the terminal with your key exported: # codex --profile xinf
Create this separate file alongside ~/.codex/config.toml, then run codex --profile xinf in the terminal where XINF_API_KEY is exported. Current Codex uses top-level profile settings, not a [profiles.xinf] table in config.toml. Include /v1 in base_url; Codex adds /responses. env_key is the variable's name, not the secret. Choose an available OpenAI text model; bare ids such as gpt-5.4-mini also work. Web search is disabled because hosted search tools are not supported by this API.
Gemini CLI
export GOOGLE_GEMINI_BASE_URL=https://xavainf.com export GEMINI_API_KEY=$XINF_API_KEY gemini -m gemini-2.5-flash
Choose "Use Gemini API key" when Gemini CLI asks how to sign in. Gemini model ids map to our catalog; any other chat model works by its full id. Token counts are estimates; cached content and the file API are not supported.
Verify the URL, key and model
Check available model ids in Models or GET /v1/models (public; no key required). The model names above are examples, not a promise of availability. Then send a small authenticated request; it spends your balance.
curl --fail-with-body "https://xavainf.com/v1/responses" \
-H "Authorization: Bearer $XINF_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"openai/gpt-5.4-mini","input":"Say hello.","max_output_tokens":128}'curl --fail-with-body "https://xavainf.com/v1/messages" \
-H "Authorization: Bearer $XINF_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{"model":"claude-sonnet-5","max_tokens":64,"messages":[{"role":"user","content":"Say hello."}]}'A successful JSON response confirms the API connection. Start codex --profile xinf or claude --model claude-sonnet-5, send a short prompt, then check dashboard usage. In Claude Code, /status shows the base URL and credential source; existing settings-file values can override shell exports.
| problem | what to check |
|---|---|
| 401 / authentication error | Export the complete XINF_API_KEY value in the launching terminal. Use a key created on the same site; replace a revoked key. |
| 402 / balance or spending cap | Add funds, or review the applicable account/connection spending limit in the dashboard. |
| 404 / unknown route or model | Codex base_url ends in /v1; Claude Code's base URL does not. Choose an available model from this site's catalog. |
| 400 / unsupported feature | Use standard service. Fast/priority tiers and provider-hosted tools such as web search are unsupported; the coding agents' local tools are separate. |
| 429 / rate limit | Wait for Retry-After before trying again. |
Errors come back in each API's own shape (Anthropic's {"type":"error",...}, Google's {"error":{"code","status"}}), so the agents retry and report them as usual. Token-count endpoints (/v1/messages/count_tokens, :countTokens) return free estimates.