Agent CLI Overview: Connect Any Mainstream AI Coding Tool to CodeGateway in 5 Minutes

(Unofficial)

This guide is independently community-maintained. It is not affiliated with, endorsed by, or sponsored by the vendor of the third-party tool it covers. All third-party trademarks are the property of their respective owners.

Quick overview of endpoints, model routing rules, and per-tool setup entries for mainstream Agent CLIs.

Supported tools

CodeGateway exposes three compatible surfaces, so most mainstream Agent CLIs can connect directly:

Step 1: Register and create an API key

  1. Open codegateway.dev and click Sign up — email + password, and you get a trial credit after you bind a card (current amount shown on the signup/pricing page).

  2. Log into the Dashboard, go to API Keys, and create a key.

  3. Keys start with sk-cg-. The full key is shown only once — save it immediately.

  4. You can create multiple keys (one per project or tool).

Step 2: Choose your endpoint

CodeGateway speaks three compatible protocols; pick the one your tool speaks:

  • Anthropic Messages (Claude Code, Crush, etc.): base URL https://api.codegateway.dev, path /v1/messages.

  • OpenAI Chat Completions (Codex CLI, Qwen Code, opencode, Aider, Copilot CLI, etc.): base URL https://api.codegateway.dev/v1, path /v1/chat/completions.

  • OpenAI Responses (Codex CLI response mode): same base URL, path /v1/responses.

Step 3: Configure your tool

Each tool stores its config differently (env vars vs config files). The two most common setups:

  • Claude Code:

bash
export ANTHROPIC_BASE_URL="https://api.codegateway.dev"
export ANTHROPIC_AUTH_TOKEN="sk-cg-your-key"
  • Codex CLI:

bash
export OPENAI_BASE_URL="https://api.codegateway.dev/v1"
export OPENAI_API_KEY="sk-cg-your-key"

For the rest (Qwen Code, DeepSeek Harness, Reasonix, opencode, Aider, Crush, Copilot CLI), see each tool's page.

Step 4: Verify the connection

Verify the underlying link before touching the tool:

bash
curl https://api.codegateway.dev/v1/models \
-H "Authorization: Bearer sk-cg-your-key"

A model list means the link is up. Then send one short prompt inside your tool.

Model routing rules (important)

Model support differs per protocol — this is the most common stumbling block:

  • Anthropic Messages protocol: Claude models (e.g. claude-sonnet-4-6) and Gemini models (e.g. gemini-3.8-flash) work with standard payloads.

  • OpenAI Chat Completions protocol: DeepSeek (deepseek-v4-pro), Kimi (kimi-k2.7-code), GLM (glm-5.3), Qwen (qwen3.8-27b) and others work. GPT-series models (gpt-5.3-codex, gpt-5.5, etc.) can be affected by upstream regional policy — affected requests are rejected with unsupported country/region/territory. This is usually transient (retrying recovers it); the gateway returns 503 (retryable) with Retry-After and the SDK retries automatically. Switch model or egress only if it keeps failing.

  • Claude- and Gemini-series text models are not available on the OpenAI-compatible protocol, and vice versa GPT-series models can hit the same transient regional rejection on the Messages protocol (retryable 503 — retry first).

  • The full model list is always available in the Dashboard Models page, or via the models endpoint above.

For coding, we recommend deepseek-v4-pro, kimi-k2.7-code, or glm-5.3 for OpenAI-protocol tools; claude-sonnet-4-6 for Claude Code.

Billing and trial credit

  • Pay as you go per token, with tiered markup — see Tier pricing explained.

  • Free trial credit (after card binding) covers any model.

  • Top up by credit card (Visa / Mastercard / AmEx), Stripe Link, Alipay, or bank transfer — see Billing & recharge guide.

FAQ

Q: Can one key be used across multiple tools? Yes. Keys are scoped to your account/project, not to a protocol — the same key works for Claude Code and Qwen Code.

Q: 401 Unauthorized after configuration? Check that the whole key was copied (sk-cg- prefix included) and that it hasn't expired; you can regenerate keys in the Dashboard. See Troubleshooting.

Q: GPT models return an unsupported-region error (503 unsupported country/region/territory)?This is usually transient: the gateway returns 503 with Retry-After and the SDK retries automatically — retrying recovers it (one controlled retry succeeded after 94 s; median recovery across 10 cases in 48 h was ~3 min, an upper bound). If it keeps failing, switch to DeepSeek / Kimi / GLM / Qwen models, or use a supported network region.

Q: Can I use Gemini models in Claude Code? Yes. gemini-3.8-flash is available on the Anthropic Messages protocol — set the model to gemini-3.8-flash in your Claude Code config.

Q: Where do I find the latest model IDs? Dashboard → Models, or the models endpoint above. Docs list a review date, but the endpoint is authoritative.

Q: I lost my key. Keys are shown once. Delete and recreate one in the Dashboard; your balance is unaffected.

Q: Can I get an invoice? Yes. Contact support after a recharge — see Billing & recharge guide.

References

Turn this doc into a real API call

Lacking an official key or facing overseas card payment issues? Create an sk-cg- key after signing up, point your base URL at CodeGateway, and keep your existing SDK or CLI unchanged. Pay per token; binding a card adds free credit.

Sign up free
Author:CodeGateway Team