One API Key for Claude Code and Codex
Claude Code and Codex can use the same Vana API key without using the same protocol or model. Each tool keeps its own configuration, while requests go through one service and usage is billed to one account. This walkthrough sets up both tools, verifies the connection, and explains the boundaries of sharing a credential.
§ 1. Get your key and model identifiers
Create a Vana API account, then generate an API key and check the available models. Copy the exact API model identifiers shown by the service. Display names such as Claude Sonnet 5.5 and GPT-6.1 Sol are useful for choosing models, but do not assume their spelling is the identifier your client expects.
Vana API provides an OpenAI-compatible endpoint at https://api.vanaapi.com and also supports Anthropic Messages and Gemini native protocols. Claude Code uses the Anthropic-compatible route; Codex uses an OpenAI-compatible provider configuration. Sharing a key does not require translating either tool's requests yourself.
§ 2. Make the key available locally
Use a dedicated terminal session for this setup. Store the credential in a secret manager or load it into an environment variable named VANA_API_KEY. For a temporary Bash session, the following command reads it without displaying it or placing the key itself in shell history:
read -r -s -p 'Vana API key: ' VANA_API_KEY; echo; export VANA_API_KEY
Paste the key when prompted. The variable lasts for that shell session and is inherited by programs launched from it. Do not put the real key in a repository, shared configuration file, screenshot, or support message.
§ 3. Point Claude Code at Vana API
In that terminal, set the Anthropic-compatible base URL and authentication token with these commands:
1 export ANTHROPIC_BASE_URL='https://api.vanaapi.com' 2 export ANTHROPIC_AUTH_TOKEN="$VANA_API_KEY"
If this shell already defines ANTHROPIC_API_KEY, clear it with unset ANTHROPIC_API_KEY for this test to avoid competing credentials. This affects the current shell, not credentials stored elsewhere.
Next, run export ANTHROPIC_MODEL='YOUR_CLAUDE_MODEL_ID', replacing the placeholder with the exact identifier you copied. Launch Claude Code from this same terminal. The base URL is the service origin; do not append the Messages resource path, because the client constructs its own request path.
§ 4. Add Vana API as a Codex provider
Open your Codex configuration file, normally ~/.codex/config.toml. Preserve unrelated settings, and merge the following entries rather than creating duplicate keys or provider sections. Each paragraph below represents one line of TOML. Replace the model placeholder before saving.
1 model = "YOUR_CODEX_MODEL_ID" 2 model_provider = "vana" 3 [model_providers.vana] 4 name = "Vana API" 5 base_url = "https://api.vanaapi.com/v1" 6 env_key = "VANA_API_KEY" 7 wire_api = "responses" # Codex talks to Vana over the Responses API
Keep the first two entries at the top level, before any table header. The provider section tells Codex where to send requests and which environment variable contains its credential. It does not store the key in the file. This configuration uses the Responses transport, so choose a model supported by Vana API for Codex use.
§ 5. Verify both connections
Start each tool from the configured terminal and send a small request, such as asking it to summarize a short function. Check the tools' reported provider and model settings, then confirm the requests appear in your Vana API usage records.
- Authentication error: check that the key is active and available in the launching shell.
- Model error: verify the exact model identifier and its supported protocol.
- Route error: check the base URL and Codex transport setting before changing credentials.
§ 6. Keep sharing deliberate
Vana API bills per real token with no monthly fee. One key consolidates access and billing; it does not combine conversations, permissions, or local tool settings. Both clients can incur usage independently.
If the key is exposed, rotate it and update both clients. For separate machines, teams, or spending boundaries, separate keys are usually easier to revoke and audit than a shared credential.