Skip to content

Codex and Claude Code ​

Codex and Claude Code can run on Yi Cloud's models. Every request they send is an ordinary call to the Models API, paid from your balance.

Before you start ​

  1. Create a key for the agent. Under "Use for", choose only "Model API", and set a spend limit. See API keys and limits.

  2. Put the key in an environment variable in the shell where you start the agent:

    sh
    export YI_CLOUD_API_KEY="pwc_live_..."
  3. Pick models from the price page or GET https://cloud.theyilabs.com/v1/catalog.

Codex ​

Codex uses the Responses API, so it needs a model whose catalog entry has responses_api: true. To list them:

sh
curl -s https://cloud.theyilabs.com/v1/catalog | jq -r '.models[] | select(.responses_api) | .id'

Add Yi Cloud as a provider in ~/.codex/config.toml:

toml
model = "gpt-6.1-sol"
model_provider = "yicloud"

[model_providers.yicloud]
name = "Yi Cloud"
base_url = "https://cloud.theyilabs.com/v1"
env_key = "YI_CLOUD_API_KEY"
wire_api = "responses"

Then start Codex in your project as usual: codex, or codex exec "..." for a single task.

  • base_url ends in /v1.
  • Codex reads the key from the variable named in env_key. You don't sign in to Codex.
  • A model without responses_api: true gets 400 invalid_request with "This model does not support Responses".

Claude Code ​

Claude Code uses Anthropic Messages, which every chat model in the catalog answers. Set these in the shell, then start Claude Code in your project:

sh
export ANTHROPIC_BASE_URL="https://cloud.theyilabs.com"
export ANTHROPIC_AUTH_TOKEN="$YI_CLOUD_API_KEY"
export ANTHROPIC_MODEL="gemini-3.1-pro"
export ANTHROPIC_DEFAULT_OPUS_MODEL="gemini-3.1-pro"
export ANTHROPIC_DEFAULT_SONNET_MODEL="gemini-3.1-pro"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="gemini-3.5-flash"
claude
  • ANTHROPIC_BASE_URL is the console's address, without /v1. Claude Code adds the path itself.
  • ANTHROPIC_AUTH_TOKEN sends the key as Authorization: Bearer. You don't sign in to Claude Code.
  • Claude Code asks for models by the names Opus, Sonnet and Haiku for different jobs. Small background jobs go to the Haiku one. Set all four model variables to IDs from the catalog. An ID that isn't in the catalog gets 404 not_found.
  • Web search in Claude Code needs a server tool, which Yi Cloud refuses. The search fails and Claude Code carries on without it.
  • Claude Code's own cost figures use its own price list, not Yi Cloud's. The console shows what you were charged.

What it costs ​

Each step of an agent is one request, and each request sends the whole conversation so far. Input tokens add up quickly. When the model caches the part that repeats, that part is charged at the cached input price.

Before each request, Yi Cloud holds the most it can cost, counting every output token the request allows. See What a call costs. Codex and Claude Code allow about 32,000 output tokens per request, so a hold is much larger than what a step usually costs. It is released when the request ends.

  • A key's spend limit needs room for one full hold above what the key has spent. Otherwise the next request gets 402 key_limit_reached, even when the step itself would cost less, and the agent stops. Your balance works the same way, with 402 insufficient_funds.
  • For Claude Code, set CLAUDE_CODE_MAX_OUTPUT_TOKENS to a smaller number, such as 8000, to make each hold smaller. A step that needs a longer answer is then cut short.
  • "Recent requests" on the console's Model API page shows each request with its cost. See Billing and receipts.

When something fails ​

What you seeWhat to check
401 invalid_keyThe key in the variable is wrong or was revoked.
403 forbiddenThe key doesn't have "Model API", or the model is outside what the key allows.
404 not_foundA model ID isn't in the catalog. For Claude Code, check all four model variables.
400 invalid_request, "This model does not support Responses"Codex needs a model with responses_api: true.
402 insufficient_fundsYour balance doesn't cover the hold for the next request. See Billing and receipts.
402 key_limit_reachedThe key's spend limit is reached, or has no room for the next hold. See What it costs.

Every error has a request_id. Give it to us when you ask about a request.