nc://cloudflare-ai-gateway

v0.1.0Pinned
Backnodecode-ai
pomterrecells: thirty-three cells, ported from oh-my-pi -- providers oh-my-pi carries (can1357/oh-my-pi at c9383c1, MIT, credited in each folder's NOTICE), each as a cell of its own: Alibaba's Coding and Token Plans, Amazon Bedrock, Anthropic's Pro/Max sign-in, Apple's on-device Foundation Models (macOS), Azure OpenAI, ClinePass, Cloudflare AI Gateway, Cursor, Devin, Factory Droid, GitHub Copilot, GitLab Duo and its agent, Antigravity, the Gemini CLI's Cloud Code Assist, Vertex AI, Kilo, Kimi Code, local ONNX and MLX workers, Muse Code, Ollama Cloud, ChatGPT's Codex sign-in and its device-code variant, OpenRouter, Snowflake Cortex, xAI's SuperGrok sign-in, Xiaomi MiMo and Z.AI's Coding Plan; and four that are not chat providers: language servers (nodecode-lsp), Perplexity search, keyless web search engines (nodecode-web-provider) and TypeSafe judgments. Each stands alone: it loads, starts, stops and tests by itself, depends only on nodecode, and shares no code with another; one whose wire none of the four lanes speaks registers a lane of its own. Written against the cell contract (src/CELLS.md) at nodecode fb4bdabc1. Their tests ran green against that tree with no network (~/nodecode-cells/tools/test-cell.sh, 663 tests over the 33, 0 failed).914a3fe· 8 Oct1 commit
test1 filecell.lisp7.6 KBmodels.json43.1 KBprovider.lisp10.8 KB

nodecode-cloudflare-ai-gateway

A Nodecode cell for Cloudflare AI Gateway. With it, /connect offers Cloudflare AI Gateway, /models lists the models oh-my-pi bundles for it (Claude, GPT, Grok, Qwen, DeepSeek, Kimi and the Workers AI models), and a turn on cloudflare-ai-gateway/<model> goes to https://gateway.ai.cloudflare.com/v1/<account>/<gateway> the way oh-my-pi sends it:

  • the model id's namespace picks the route and the wire:
    • anthropic/<id> goes to /anthropic/v1/messages on the Messages wire, named <id> with its dots turned to dashes (anthropic/claude-sonnet-4.5 is claude-sonnet-4-5)
    • openai/<id> goes to /openai/chat/completions on the chat wire, named <id>
    • workers-ai/<id> goes to /compat/chat/completions on the chat wire, named whole
    • any other id rides the wire its bundled row names (the Messages route for all but the Workers AI rows), named whole
  • every route authenticates to the gateway alone, with cf-aig-authorization: Bearer <token>: no Authorization and no x-api-key leaves for the upstream
  • a chat round names its cap max_completion_tokens and sends no prompt_cache_key, as omp's chat compat does for a host that is not OpenAI's own

Ported from oh-my-pi's cloudflare-ai-gateway provider. See NOTICE.

Token, account and gateway

omp's login is custom: it opens <https://developers.cloudflare.com/ai-gateway/configuration/authentication/>, asks for an AI Gateway token with Run permission, the account id and the gateway id, and stores the three as one credential. This cell splits them by what they are:

  • the token is the secret: save it with /connect, or set CLOUDFLARE_AI_GATEWAY_API_KEY. A saved token wins over the variable.
  • the account id and the gateway id are not secret: they are the section's account_id and gateway_id, else CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_GATEWAY_ID, as omp reads them.

A credential saved as omp's own JSON, {"token": "...", "accountId": "...", "gatewayId": "..."}, is read too, and its ids come first. A round with no account or no gateway is refused before anything is sent, in omp's words.

/connect does not check the token: the gateway's model listing sits behind the account and the gateway, so the picker is answered from the bundled roster without a request.

Install

Copy this folder into ~/.nodecode/cells/nodecode-cloudflare-ai-gateway/ and restart Nodecode, or run (restart-cells).

Configure

{
  "cloudflare-ai-gateway": {
    "account_id": "0123456789abcdef0123456789abcdef",
    "gateway_id": "default",
    // the gateway's root, before /<account>/<gateway>
    "base_url": "https://gateway.ai.cloudflare.com/v1"
  }
}

An operator's providers.cloudflare-ai-gateway.sdk (or a model's sdk) pins a wire, as for any provider.

Test

From this repository's root:

tools/test-cell.sh nodecode-cloudflare-ai-gateway

Not ported

  • Live discovery. omp asks the gateway's Anthropic listing and Workers AI's model list; this cell serves the bundled rows.
  • omp's per-model Messages compat beyond the route: its Claude Code identity headers and system line, strict-tool and context-management toggles. The core's Messages lane builds the body.

MIT licensed.

Add nc://cloudflare-ai-gateway

  1. 1

    Install Nodecode

    Once per machine.

    $ curl -fsSL https://nodecode.ai/install.sh | sh
  2. 2

    Add the cell

    Pinned at 914a3fe.

    $ nodecode add nc://cloudflare-ai-gateway

    Or tell the agent add the cloudflare ai gateway cell.

  3. 3

    Add your key

    Run /connect, pick Cloudflare AI Gateway and paste your key.