Connect apps and coding agents

Choose a path, apply the CostRouter Base URL and API Key, then verify the first request in Usage Logs.

Path 1

Connect your AI application

Keep your compatible SDK or HTTP client. Replace only the Base URL, API Key, and model ID.

Three values to set

  • Base URL: https://costrouter.ai/v1
  • Authorization: Bearer YOUR_COSTROUTER_API_KEY
  • Model: copy the exact ID from Models

First working request

curl https://costrouter.ai/v1/chat/completions \
  -H "Authorization: Bearer YOUR_COSTROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-4o","messages":[{"role":"user","content":"Hello"}]}'

Path 2

Configure a coding agent

Use a separate CostRouter key for each tool, then apply the matching provider configuration below.

Codex

Codex

CostRouter-compatible setup

Configure

Install Codex

npm install -g @openai/codex

~/.codex/config.toml

model = "gpt-4o"
model_provider = "costrouter"

[model_providers.costrouter]
base_url = "https://costrouter.ai/v1"
env_key = "OPENAI_API_KEY"
  • Use a dedicated API Key for this tool.
  • Choose an available model from Models.
  • Restart the tool and verify the request in Usage Logs.
Antigravity

Claude Code

CostRouter-compatible setup

Configure

Install Claude Code

npm install -g @anthropic-ai/claude-code

Environment variables

export ANTHROPIC_BASE_URL="https://costrouter.ai"
export ANTHROPIC_AUTH_TOKEN="YOUR_COSTROUTER_API_KEY"
  • Use a dedicated API Key for this tool.
  • Choose an available model from Models.
  • Restart the tool and verify the request in Usage Logs.
Gemini

Gemini CLI

CostRouter-compatible setup

Configure

Install Gemini CLI

npm install -g @google/gemini-cli

Environment variables

export GEMINI_API_KEY="YOUR_COSTROUTER_API_KEY"
export GEMINI_MODEL="gemini-2.5-flash"
  • Use a dedicated API Key for this tool.
  • Choose an available model from Models.
  • Restart the tool and verify the request in Usage Logs.
Cursor

Cursor

CostRouter-compatible setup

Configure

Install Cursor

winget install Anysphere.Cursor

Project environment

COSTROUTER_API_KEY=YOUR_COSTROUTER_API_KEY
COSTROUTER_BASE_URL=https://costrouter.ai/v1
  • Use a dedicated API Key for this tool.
  • Choose an available model from Models.
  • Restart the tool and verify the request in Usage Logs.

Manage local agent profiles

cc-switch can store and switch local provider profiles. Add your CostRouter Base URL and API Key once.

Get cc-switch

Production

Before you ship

Keep access controlled and costs observable as traffic grows.

  • Use one key per app, environment, or agent.
  • Set quotas, expiry, model limits, and IP allowlists.
  • Review Usage Logs after configuration and model changes.
  • Load secrets from environment variables or a secret manager.

Copyright 2026 CostRouter. All rights reserved.

CostRouter is prohibited for users located in mainland China. If use from mainland China is discovered, CostRouter may suspend or terminate the account, and any paid fees or remaining balance will not be refunded.

Contact us

Choose the channel that best matches your request.

Contact us
Connect AI Apps and Coding Agents | CostRouter