set_model_gateway
The CodePanel MCP tool that sets the account's Cloudflare AI Gateway (account id, name, on or off) for agent runs' model calls.
On this page›
set_model_gateway sets the account's Cloudflare AI Gateway for agent runs' model calls: its account ID, its name, and whether it is on. It needs the agents:write scope.
When to call it
- To route agent runs through a gateway the owner created, for its cache, logs and spend limit.
- To turn it off (
enabled: false) and send every call straight to the provider, keeping the settings. - When the gateway holds the provider keys (
storedKeys: true): calls send no key and never go direct. See Keys stored in the gateway.
Inputs
| Input | Type | Required | Description |
|---|---|---|---|
accountId |
string | no | The Cloudflare account id: 32 characters, 0-9 and a-f |
gatewayName |
string | no | The gateway's id as Cloudflare shows it |
enabled |
boolean | no | false sends every call direct; the settings are kept |
storedKeys |
boolean | no | true when the gateway holds the provider keys (Cloudflare BYOK) |
It writes: the server marks it readOnlyHint: false and destructiveHint: true (it can change what is already there), so a client that asks before writes asks here.
The first call needs both accountId and gatewayName. The gateway's token is never an input: the owner saves it in the browser, under Settings → Provider keys, so it never passes through an agent. A new accountId or gatewayName drops the saved token, so calls go direct (needs_token) until the owner saves the new gateway's token.
What it returns
{ before, after }, each shaped as get_model_gateway returns it. Calling again with before's values undoes the change, except a dropped token, which only the owner can save again.
The same step without MCP
| Surface | Form |
|---|---|
| HTTP API | POST /autopilot/gateway with the agents:write scope |
| CLI | codepanel gateway set --account-id <id> --name <gateway> [--stored-keys on|off], codepanel gateway on, codepanel gateway off |
What the server tells your agent
The description your agent reads when it lists the tools:
Use it to route agent app model calls through a Cloudflare AI Gateway, or to turn it off. Sets accountId (32 hex), gatewayName (the gateway's id in Cloudflare), enabled and/or storedKeys (true when the gateway holds the provider keys itself: calls then send no key, need none saved in CodePanel, never go direct and never run on credits). Only calls on the owner's own keys to the providers get_model_gateway lists take it; CodePanel credits always go direct. The gateway is used only once its token is saved, which the owner does in the browser (Settings → Provider keys); a new accountId or gatewayName drops the saved token for that reason. Needs agents:write. Returns { before, after }, so one more call with before's values undoes it.
Related
get_model_gateway: read the setting.- Providers and keys: what goes through the gateway, and what goes direct.
- MCP server: install, sign-in and every other tool.