nc://openrouter

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.lisp4.5 KBmodels.json209.8 KBprovider.lisp7.6 KBsignin.lisp20.7 KB

nodecode-openrouter

A Nodecode cell for OpenRouter. models.dev already makes OpenRouter usable on the chat lane; this cell keeps that and adds what oh-my-pi does:

  • /openrouter login signs in from the browser and saves the key OpenRouter hands back where /connect saves keys (api_keys.openrouter)
  • /models lists omp's bundled OpenRouter rows beside models.dev's
  • every request names the app it comes from (HTTP-Referer, X-OpenRouter-Title, X-OpenRouter-Categories: cli-agent) and asks OpenRouter's cache to keep it an hour (X-OpenRouter-Cache, X-OpenRouter-Cache-TTL: 3600); the attribution names Nodecode
  • a routing variant, when one is chosen, rides the model id (openai/gpt-5.5:nitro), unless the id names one already
  • reasoning goes as OpenRouter's own reasoning: {"effort": ...}, and off as {"enabled": false}, never as reasoning_effort
  • no output cap the operator did not set: a catalog cap above an upstream's own makes OpenRouter skip that upstream
  • routing preferences (only, order) ride as the body's provider

Ported from oh-my-pi's openrouter provider. See NOTICE.

Sign in

/openrouter login

answers at once with the address to open, and listens on http://localhost:54549/callback (another port when that one is taken; OpenRouter accepts any loopback callback). The sign-in is OpenRouter's PKCE flow: no client registration, the S256 verifier is the proof. When the browser comes back, the code is exchanged for a key, the key is saved, and a notice says so. http://localhost:<port>/launch redirects to the sign-in page, for a terminal that cut the long address.

On another machine, paste the address the browser ended on, the code in it, or a key you made by hand:

/openrouter code <address, code or sk-or-... key>

A pasted key is checked against /api/v1/auth/key before it is saved. The key does not expire. /openrouter status says whether a key is saved, /openrouter logout forgets it.

Without the sign-in: make a key at <https://openrouter.ai/settings/keys> and save it with /connect, or set OPENROUTER_API_KEY. A saved key wins over the variable. No other provider's key is ever sent to OpenRouter: with neither, the round goes keyless and OpenRouter says why.

Install

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

Configure

Optional. The section is on unless it says "enabled": false:

{
  "openrouter": {
    "base_url": "https://openrouter.ai/api/v1",
    // default, nitro, floor, online or exacto
    "variant": "nitro",
    "only": ["anthropic", "openai"],
    "order": ["anthropic"]
  }
}

Test

From this repository's root:

tools/test-cell.sh nodecode-openrouter

Not ported

  • omp's per-model compat (strict-tool retry on OpenRouter's Anthropic upstreams, reasoning-history filtering for Muse Spark, the cost OpenRouter reports per request): the core's chat lane has no seam for a retry without strict tools, and reads usage, not OpenRouter's billed cost.
  • omp's OpenRouter Responses, image, video, rerank and decisions transports: this cell serves the chat wire only.

MIT licensed.

Add nc://openrouter

  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://openrouter

    Or tell the agent add the openrouter cell.

  3. 3

    Sign in

    Run /openrouter login and follow what it says.