Curated models for your best work
Join the waitlistRouter docs
Codex with TokenSpend
Add TokenSpend as a custom provider in your Codex config.
Paste it into your coding agent. It carries no key and states how far this setup has been tested.
See what gets copied
# Connect Codex to TokenSpend API format: Responses API key: a TokenSpend key, read from the environment variable TOKENSPEND_API_KEY. Never write it into a project file or print it. Back up any existing config before you change it, and tell the user what you changed. Models: exact IDs are listed at https://tokenspend.dev/models (for example anthropic/claude-sonnet-4-6). Add this provider to the Codex config: ```toml model_provider = "tokenspend" [model_providers.tokenspend] name = "TokenSpend" base_url = "https://api.tokenspend.dev/v1" env_key = "TOKENSPEND_API_KEY" wire_api = "responses" ``` Stored-response chaining and hosted tools are not supported. Check: 1. Send one small request with synthetic content. It is billable. Note the request ID, not the key. 2. Open https://tokenspend.dev/dashboard/router and match the request ID, model, status, token counts and cost. If something fails, check the error code at https://tokenspend.dev/docs/router/reliability#errors and https://tokenspend.dev/status. Do not send keys or private prompts to support.
1. Set your key
Create a rail key in Router, then load it into this terminal. It stays in your environment, not in a project file.
printf 'TokenSpend rail key: ' read -r -s TOKENSPEND_API_KEY printf '\n' export TOKENSPEND_API_KEY
2. Connect Codex
Codex
Codex talks to custom providers over the Responses API. Add TokenSpend as a provider in your Codex config, with the key in TOKENSPEND_API_KEY.
model_provider = "tokenspend" [model_providers.tokenspend] name = "TokenSpend" base_url = "https://api.tokenspend.dev/v1" env_key = "TOKENSPEND_API_KEY" wire_api = "responses"
Function tools, tool-result continuation and reasoning controls work on Astra and the GPT-5 models. Stored-response chaining and hosted tools are not supported.
3. Check the receipt
A response is only half the check. Send one small request, then match its request ID, model and cost in Router activity. The full steps are in Verify the receipt.