CodePanel
Providers and API keys

Providers and API keys

Bring your own Anthropic, OpenAI, Google, DeepSeek, Groq, xAI, Moonshot, Mistral, Workers AI or custom key. How keys are checked and stored.

On this page›

Model calls run on your own provider API keys, billed to you by the provider, or on CodePanel's keys with prepaid credits, charged at the provider's price with no markup (Billing and credits). Your own keys never spend credits. This page covers your own keys: which providers, how a key is checked and stored, and what happens when one stops working.

Note

A ChatGPT Plus or Pro plan can replace an OpenAI key where CodePanel offers Connect ChatGPT plan in Settings: see Use your ChatGPT plan. A Claude subscription cannot; Anthropic doesn't allow its consumer plans in other apps.

Providers

Provider id Key Default base URL
Anthropic anthropic Must start with sk-ant- https://api.anthropic.com/v1
OpenAI openai Must start with sk- https://api.openai.com/v1
Google Gemini google Usually AIza... (not checked) https://generativelanguage.googleapis.com/v1beta
DeepSeek deepseek Usually sk-... (not checked) https://api.deepseek.com/v1
Groq groq Usually gsk_... (not checked) https://api.groq.com/openai/v1
Cerebras cerebras Usually csk-... (not checked) https://api.cerebras.ai/v1
xAI (Grok) xai Usually xai-... (not checked) https://api.x.ai/v1
Moonshot (Kimi) moonshot Usually sk-... (not checked) https://api.moonshot.ai/v1
Mistral mistral Not checked https://api.mistral.ai/v1
OpenRouter openrouter Must start with sk-or- https://openrouter.ai/api/v1
Cloudflare Workers AI workers-ai Cloudflare API token with Workers AI permission Built from your account ID (Workers AI)
Custom (OpenAI-compatible) custom Any Required

Each row in Settings → Provider keys links to where that provider issues keys. Every provider except Anthropic and Google speaks OpenAI chat completions, so any OpenAI-compatible gateway works.

Add a key

Step 1: Open the provider's row

In Settings → Provider keys, choose Connect on the provider's row (Replace key if it has one).

Step 2: Paste the key

Custom also needs a base URL, and Workers AI an account ID (Workers AI). On any other provider a base URL is optional and overrides the default (Custom base URL).

Step 3: Save

Choose Save key. The key is stored only if it validates. If you have no panel yet, the starter panel is built from it.

Important

Keys can only be entered in the browser, so they never pass through an agent's context. The API, MCP server and CLI can read key health but cannot add or change a key.

Check key health

get_key_status

Each provider reports status (valid, invalid, or null when no key is stored), a model count and a redacted last error, never the key.

It also reports health: what real calls found since the key was last tested, from reviews and the agent app's model proxy. Its status is valid, invalid, expired or rate_limited, with the time of the call that set it. A 401 is invalid, or expired when the provider says the key expired; a 429 or a quota is rate-limited. Invalid and expired hold until you save or re-test the key; rate-limited shows for an hour after the last one. platform reports the same for CodePanel's own key for that provider, which calls on credits use. Only the class and the time are stored, never the provider's message. The desktop app shows both in Settings → Models & providers and in the model picker's detail pane.

Save errors

Message Cause
"That doesn't look like a key (expected )." An Anthropic or OpenAI key with the wrong prefix. Nothing was sent.
" requires a base URL." The custom provider needs a base URL.
"That isn't a Cloudflare account ID. …" The Workers AI field holds neither a 32-character account ID nor a URL containing one. Nothing was sent.
"Base URL must start with http:// or https://" The base URL has no scheme.
"That base URL points at a local address, which is not allowed." (or "a private address", or "resolves to a private address") The base URL targets a non-public network (Custom base URL).
"Could not reach : " The models endpoint did not answer within 15 seconds, or the connection failed.
"The endpoint responded but did not return JSON. Check the base URL." The base URL is not an API.
"The key works but no usable chat models are available to it." The key reaches no chat model CodePanel can use.
The provider's own error The provider rejected the key, for example because it was revoked.

Connect Workers AI

Step 1: Copy the account ID

In the Cloudflare dashboard, open AI → Workers AI and copy the account ID (32 characters, 0-9a-f, also the first part of dash.cloudflare.com/<ACCOUNT_ID>/...). A pasted dashboard address or Workers AI API URL works too; CodePanel keeps the ID and builds https://api.cloudflare.com/client/v4/accounts/<ACCOUNT_ID>/ai/v1.

Step 2: Create a token

Under My Profile → API Tokens, choose Create Token from the Workers AI template, with Account Resources set to only that account.

Step 3: Save it in CodePanel

On the Workers AI row, choose Connect, paste the token and account ID, and save.

CodePanel offers Workers AI's @cf/ text-generation models. Agent runs call them through your AI Gateway when the gateway belongs to the same Cloudflare account (see below), and directly otherwise; reviews call them directly. A key saved earlier with a full base URL keeps working.

Warning

Workers AI allows 300 text-generation requests a minute per account, but only 20 a minute on each frontier @cf/ model that needs the Workers Paid plan, shared by every reviewer on it. Mix models, or put one or two reviewers on each.

AI Gateway for agent runs

Agent runs' model calls can go through your own Cloudflare AI Gateway, for its cache, logs and spend limit. CodePanel still checks each call's caps and records its spend first. Reviews are not affected.

Step 1: Create the gateway

In the Cloudflare dashboard, open AI → AI Gateway and create a gateway. Keep Authenticated Gateway on, then under the gateway's Settings choose Create authentication token (it needs the gateway's Run permission) and copy it.

Step 2: Save it in CodePanel

Under Settings → Provider keys → Advanced → Cloudflare AI Gateway, choose Set up, enter the account ID and the gateway's name, save, then paste the token and choose Save token. The token is entered only here, encrypted, and never shown again. An agent can read the setting and change the account ID, name or on/off through the API (/api/v1/autopilot/gateway), MCP (get_model_gateway, set_model_gateway) or codepanel gateway, but a new account ID or name drops the saved token, so calls go direct until you enter the new gateway's token.

What goes through it

Only calls on your own keys to Anthropic, OpenAI, Google, DeepSeek, Groq, Cerebras, Mistral, xAI and OpenRouter, without a custom base URL of their own, and to Workers AI on a key for the gateway's own Cloudflare account (its workers-ai/v1 endpoint). Calls on CodePanel credits, Workers AI on another account, Moonshot and custom endpoints go direct. Your provider key is still sent by CodePanel with each call, unless the gateway holds your keys (below).

Keys stored in the gateway

If your provider keys live in the gateway itself (BYOK), for example because the gateway has Require Provider Credentials on, turn on Use keys stored in Cloudflare (stored keys): storedKeys: true on POST /api/v1/autopilot/gateway, set_model_gateway or codepanel gateway set --stored-keys on. Then every call to Anthropic, OpenAI, Google, DeepSeek, Groq, Cerebras, Mistral, xAI and OpenRouter:

  • goes through the gateway with its token and no provider key, so the gateway's stored key answers it;
  • needs no key of yours saved in CodePanel for that provider, and sends none if one is saved (nor uses its custom base URL);
  • counts toward your monthly budget like an own-key call, never on CodePanel credits, which would go around the gateway's spend limits;
  • is never sent direct: if the gateway cannot be reached, or has no token or one that cannot be read, the call is refused (gateway_unreachable, gateway_unavailable) and nothing is retried.

Workers AI keeps its own key, since that key names its account. Turning the gateway off ends stored-keys routing too, and a new account ID or gateway name turns stored keys off unless the same change turns them on.

You can also turn stored keys on or off with the Use keys stored in Cloudflare checkbox under Manage on the gateway in Settings → Provider keys.

Check the setup

Saving provider keys does not finish a gateway setup: the gateway is used only once its token is saved. While the gateway is on without its token (needs_token), Settings → Provider keys and Models and keys show a red notice. With stored keys off, calls go direct until you enter the token. With stored keys on, they are refused.

Settings → Setup check test-calls every piece an agent run needs. Each line shows green or red, with the exact fix for a red line:

  • each provider key you saved
  • the gateway token
  • with stored keys on, which providers Cloudflare answers with a key it holds
  • OpenAI zero data retention, which only you can confirm, since no OpenAI API reports it
  • the GitHub App on each connected repository
  • an optional runner key per repository: a key your repository's backend issues so CodePanel runs can get its GitHub token and work leases

The page also says how each provider's calls go now: with Cloudflare's stored key, with your key through the gateway, with your key direct, or refused.

An agent reads the same lines with get_setup_status, GET /api/v1/setup or codepanel setup. Each line has a stable id, such as gateway.token or provider_key.openai, and no answer carries a key or token. The live calls only list models, so they cost nothing, and they run at most once every 30 seconds.

Runs that hold production data

A run on a repository whose run contract names production read connections (productionReads, see the desktop app) is marked before its agent starts. Its calls through the gateway then carry cf-aig-collect-log-payload: false, so the gateway logs the call and its cost but not the prompt or the reply. If the runner cannot mark the run, the run does not start. Such a run's calls never fall back to direct when the gateway fails: if the gateway cannot be reached, or its token cannot be read, the call is refused and the run ends as failed with endReason gateway_unreachable. It waits in the inbox, and once the gateway answers again, retry_task runs it again. Calls that never take the gateway (on CodePanel credits, or with the gateway off) go direct as before.

Metadata and spend per ticket

Each call through the gateway carries cf-aig-metadata, so the gateway's logs read cost per ticket, agent, role, model and repository, and its spend limits can match on them:

Key Value
ticket The task's ticket, such as TKT-008398, when it was started with one (ticket on start_task, POST /api/v1/tasks or codepanel task start --ticket)
agent The run's id, the one an Agent-Run: commit trailer names; a subagent's calls add its tree node, as <runId>/<node>
role The coding agent's role: orchestrator, worker, tester, fixer or researcher
model The model the call ran on; a subagent's is its own
repo The repository, as owner/name

That is five entries, Cloudflare's limit. A run with no ticket sends the other four. The gateway's id for each call (cf-aig-log-id) is kept on the call's spend record, so one call in CodePanel can be found in the gateway's logs.

CodePanel also holds every run of one ticket to the account's optional per-ticket cap, whether or not the call takes the gateway: codepanel autopilot ticket-cap 5, ticketUsd on set_agent_day_cap or POST /api/v1/autopilot/day-cap. A call that would pass it is refused with ticket_cap, and the run stops as a budget stop.

When a spend limit runs out

When one of the gateway's spend limits runs out, the gateway refuses the call with a 429, and the run's agent gets gateway_spend_limit, naming the model. It is told apart from the gateway's own rate limits and from a provider's 429 (rate_limit_error), which a later try can pass and are retried. A spend limit is not retried on the same model. What happens next depends on the work:

Work What happens
A team's subtask It moves one step down the team's member order, to the nearest member on a model whose limit has not run out (one of its own role first). Its route records spend_fallback with cause spend_limit and a note naming both models. If that model runs out too, it steps down again
Protected work: the orchestrator planning the team's split (its own call before any subtask exists); the step after a failed check (a subtask already moved up, or a fixer's); a subtask whose write scope touches the run contract's protectedPaths; a subtask whose task class is root_cause or review_verdict The run stops to ask
A one-agent run, the orchestrator once its split exists, or a subtask with no cheaper member left The run stops to ask

A run that stops to ask starts nothing more, publishes nothing, and ends as failed with endReason spend_limit. It waits in the inbox, and its endNote starts with the reason's code: spend_limit (planning_split), (after_failed_check), (protected_paths), (protected_class) or (no_cheaper_model). Raise the limit in Cloudflare and retry_task, or start the task again on a cheaper model. On a repository with a run contract, the runner also asks on the task's ticket. A run that holds production read tools is started only when every member of its team is inside the data boundary, so a fallback never leaves it.

If no connection to the gateway can be made, the call goes direct and the run counts a fallback; a call that breaks after connecting is not retried (gateway_unreachable), since the provider may already have billed it. If the gateway refuses a call (its token, or its own rate limit), the run's agent gets gateway_refused; the call is not retried around it. A response the gateway serves from its cache costs $0. A run read through the API or get_run counts its gateway calls, fallbacks and cache hits (gateway), and costByModel gives its cost per model, its subagents' included: calls, usd and tokens, and of those, gatewayCalls and gatewayUsd for the part that went through the gateway. That cost is CodePanel's price for the tokens. Compare it with the gateway's own log by cf-aig-log-id.

Models on your machine

Coding agents can also run on models served on your own computer, for $0: Ollama, LM Studio, llama.cpp's llama-server or MLX's mlx_lm.server, each on its default port on 127.0.0.1 (11434, 1234, 8080). The local runner looks for them when it starts, in under 300 ms and without polling, and codepanel local-models --probe looks again on demand. What it finds shows on the Models page under On this machine, in the agent form's model picker, through GET /api/v1/autopilot/models/local, MCP list_local_models and codepanel local-models.

Give a coding agent provider local and a model id such as ollama/qwen3-coder:30b. Its runs call the model straight on 127.0.0.1, never through CodePanel's cloud proxy, and record their tokens at $0 under that id. Only CodePanel's own loop runs local models; the external CLI harnesses do not. No key is involved, and a model drops off the list when the runner no longer finds it.

Validation

CodePanel lists the provider's models with your key (Workers AI: Cloudflare's model search). OpenRouter lists its models to anyone, so its /key endpoint checks the key first. The whole listing must finish within 15 seconds, and redirects are refused. Listing is free and proves the key is live. Non-chat models (embedding, speech, image, video, moderation, rerank, realtime, OCR, guard, search and similar) are dropped, as are OpenAI's -pro models; for Google, only models that support generateContent are kept. The rest is cached with the key.

Model refresh

Model ids are never hard-coded: the picker offers only what your valid keys report, with dated snapshots collapsed and legacy or special-purpose models (gpt-3.5, instruct, computer-use, deep-research) hidden. Refresh models on a provider's row lists them again without the key. A failed refresh marks the key invalid with the provider's error and keeps the last list.

Storage

Keys are encrypted with AES-256-GCM before storage, decrypted only in the backend actions that call the provider, and never returned by any endpoint: a key can be replaced, not read back. See Security and data.

Custom base URL

The custom provider, or a base URL override on any provider, points CodePanel at a gateway, proxy or self-hosted server that speaks OpenAI chat completions. CodePanel calls it from its own servers, so it refuses non-public targets: localhost and .localhost, .local, private and carrier-grade NAT ranges, link-local addresses including the cloud metadata address, and their IPv6 equivalents. The address is checked on save and before each call, and redirects are refused.

Custom endpoints always run on your key, never CodePanel's. Their models are unpriced, so they count as $0 toward spending limits.

Invalid or missing keys

Each round picks one credential per provider on the panel:

Your key Result
Stored and valid The reviewer runs on it.
Stored but invalid When you have credits and CodePanel has a key that offers the model, the reviewer runs on CodePanel's key and spends credits, marked "credits, own key rejected" in the review's footer. Otherwise it is dropped with "Your own API key is invalid. Update it in Settings."
Not stored The reviewer is dropped with "No API key for . Add one in Settings."

The rest of the panel continues. The round fails only if no reviewer or the orchestrator has a working key, with "No reviewer has a working API key." or "The orchestrator cannot run:" and the reason. With credits, a missing or rejected key's reviewer can run on CodePanel's key and spend them (Which key a call uses).

Keys that stop working

Stored keys are not re-checked on a schedule. When a key stops working:

  1. Its reviewer fails that round; the others still post. The comment lists it under "Failed this round, so not part of this review" with the provider's error.
  2. After two failed rounds in a row, the comment adds how many rounds and since when, and who can fix it. The reviewer is marked failing under The panel on the home page and Failing on the reviewers page. GET /api/v1/review and MCP get_review list it in payload.failingReviewers, and nextAction's reason asks the author's agent to tell its user. GET /api/v1/panels and MCP get_panel show the streak as failure on that member. It clears after a successful round or a model change.
  3. If those failures say the account is out of credit or the key was revoked (HTTP 401 or 402, or the provider's out-of-credit message), and the calls ran on your own key, CodePanel turns the key off: its status becomes invalid, and lastError starts "Turned off after reviews failed with:". Later rounds skip its reviewers, listed as "skipped: your own key was rejected or is out of credit, and is off since

Fix it with the provider (add credit or a new key), then Replace key or Refresh models, which turns the key back on. A provider whose models list still answers while the balance is empty passes Refresh models; if the balance is still empty, the next round's call fails and turns the key off again.

Saving a working key also picks up what the dead one stopped. Rounds refused for want of a key or credits, on a panel with a member on that key's provider, are marked resolved, so the home page stops counting them, and the pull requests among them that are still open and were refused in the last 3 days are reviewed again on their own, newest first, up to 25 per save. Older ones are reviewed on their next push. Buying credits does the same for rounds refused for want of credits, and for rounds refused for a rejected key on a provider CodePanel offers on credits. A failed round on a pull request that has since merged or closed is resolved too: nothing reviews a finished pull request, and it is not counted as waiting. While the cause stands, the home page shows it once, with how many pull requests it left unreviewed, not one row per pull request.

Last updated