← All integrations

Integration · @namzu/openrouter

Namzu × OpenRouter.Many hosted models behind one key.

Many hosted models behind one key and one wire format; switching models is a change to the model string.

@namzu/openrouterv3.0.4FSL-1.1-MITnpm

Install.

pnpm add @namzu/sdk @namzu/openrouter

@namzu/sdk is a peer dependency, so install both. The SDK needs zod@^3 too.

Why pair the kernel with OpenRouter.

The kernel's promise is that no model is a citizen of the core. OpenRouter is that promise in practice: it fronts many vendors behind one key and one wire format, so agent code stays identical while the model string changes. The package description counts 200 or more models.

  • Streaming, tool calls and native JSON-schema responses are forwarded. The driver does not map image or document attachments.
  • Thinking controls map to OpenRouter's reasoning object: enabled with a budget becomes max_tokens, adaptive becomes { enabled: true }, disabled becomes { enabled: false }, and effort is sent as effort. effort: 'max' and 'ultra' are refused rather than sent, because this wire cannot carry them.
  • Reasoning arrives on the kernel's reasoning channel, indexed per block with a done marker when output starts, and usage.reasoningTokens reports the thinking share of the completion tokens. OpenRouter sends each fragment twice; the driver emits it once.
  • siteUrl and siteName are optional attribution headers.

Example.

import { ProviderRegistry, runAgent } from '@namzu/sdk'
import { registerOpenRouter } from '@namzu/openrouter'

registerOpenRouter() // once, at startup

// Swap models in config; the agent code stays identical.
const model = 'anthropic/claude-opus-5'
const { provider } = ProviderRegistry.create({
  type: 'openrouter',
  apiKey: process.env.OPENROUTER_API_KEY ?? '',
  siteUrl: 'https://example.com', // optional
  siteName: 'Example',            // optional
})

const { output } = await runAgent({ provider, model, prompt: 'Hello' })
console.log(output)

Configure.

Configuration (type: 'openrouter')

apiKeystring
Required.
baseUrlstring
Override the OpenRouter base URL.
siteUrlstring
Optional attribution: your site.
siteNamestring
Optional attribution: your app's name.
timeoutnumber (ms)
Request timeout.

What the driver declares.

  • StreamingYes
  • Tool callsYes
  • Image attachmentsNot mapped
  • Document attachmentsNot mapped
  • Native JSON-schema outputYes

Ship OpenRouter agents on a runtime you can own.

OpenRouter owns the gateway. Namzu owns the runtime. The package is a thin adapter, not a wrapper, so you keep everything OpenRouter ships and add the kernel concerns you do not get from the model API alone.