Gateway provider configuration
Configure provider credentials, choose exact model identifiers and understand upstream limits.
Nirmos uses organization-owned provider credentials for inference. Your Nirmos API key authenticates to Nirmos; upstream keys belong in Gateway Credentials. Providers and models come from the reviewed catalog, not a live upstream discovery request on every call.
Configure credentials
Choose Groq, OpenRouter, Vercel AI Gateway or Cloudflare Workers AI in Gateway → Credentials. Groq and OpenRouter require their API key. Cloudflare requires an API Token and the Account ID of its account. Use account-scoped Workers AI Read and Write permissions; a Global API Key is not the API token expected here.
Keys are encrypted before storage. Editing Cloudflare's account preserves the existing token unless you supply a replacement. Token or account edits reset connection validation. Test connection checks authenticated upstream discovery; it does not prove access to every model, sufficient credits or inference permission on every endpoint. Rate-limit/network failures leave validation unknown.
Server-side configuration uses existing SDK methods:
await nirmos.providerCredentials.create({
name: "Workers AI",
providerId: "catalog-provider-id",
credentialType: "api_key",
secretData: { apiKey: process.env.CLOUDFLARE_API_TOKEN! },
config: { accountId: process.env.CLOUDFLARE_ACCOUNT_ID! },
});Never print tokens or embed them in client bundles. The credential API returns previews and whitelisted account configuration, never stored secrets.
Model identifiers
| Provider | Example gateway model |
|---|---|
| Groq | groq/openai/gpt-oss-20b |
| OpenRouter | openrouter/openai/gpt-oss-20b |
| Vercel AI Gateway | vercel/openai/gpt-4o-mini |
| Cloudflare Workers AI | cloudflare-workers-ai/@cf/openai/gpt-oss-20b |
Keep the entire upstream identifier, including nested slashes, @cf and any :free suffix. OpenRouter is the upstream provider even when the model's developer is OpenAI, Anthropic or another company. Direct OpenAI credentials do not configure OpenRouter models.
Discover entries with nirmos.models.list() and nirmos.providers.list(), following pagination. Use catalog IDs in saved resource relationships. For direct inference, prefer ${provider.slug}/${model.externalId ?? model.slug}. Credential availability is informational; lifecycle, adapter support, account entitlement and upstream health still determine execution.
Reasoning and upstream routing
const completion = await nirmos.gateway.chat.create({
model: "groq/openai/gpt-oss-20b",
messages: [{ role: "user", content: "Explain this tradeoff." }],
maxOutputTokens: 256,
providerOptions: {
groq: { reasoning_effort: "low", include_reasoning: false },
},
});
console.log(completion.outputText);providerOptions maps upstream provider slugs to options. HTTP clients use provider_options. Each attempt receives only its provider's options; these cannot replace the selected model, authentication, endpoint or Nirmos route. Different options produce different exact-cache entries.
OpenRouter options support reasoning and upstream-provider preferences under providerOptions.openrouter.provider, including order, only, ignore, allow_fallbacks and require_parameters. Nirmos requires parameter support for tools/structured output. OpenRouter may fall back between upstream hosts of the selected model. Nirmos controls cross-model and cross-provider fallback; upstream models arrays are not forwarded.
Groq GPT-OSS supports reasoning_effort and include_reasoning, not reasoning_format. Other permitted reasoning controls remain model-specific. Cloudflare exposes reasoning_effort for verified GPT-OSS identifiers and synchronous options.rejectIfBusy. Invalid combinations fail instead of silently dropping controls.
Reasoning text/details, where returned, are separate from answer text. Preserve returned messages when continuing reasoning/tool conversations, including signed reasoning details. Streaming exposes reasoning.delta events.
Capabilities and limitations
| Capability | Groq | OpenRouter | Cloudflare Workers AI |
|---|---|---|---|
| Chat and streaming | Selected chat models | Selected chat models | Selected compatible chat models |
| Tools and image input | Model-specific | Model-specific; upstream parameter support enforced | Model-specific REST support |
| JSON/schema output | Selected models; schema output cannot combine with tools or streaming | Selected models | Nonstreaming native JSON mode; best effort, no native strict guarantee |
| Text embeddings | Not supported | Seeded embedding models | Seeded BGE models |
Unsupported transcription, speech generation, hosted function execution and image-generation tasks are not added by registering a provider. Catalog capabilities describe executable Nirmos paths, not every upstream API product. Streaming errors terminate the response; Nirmos never splices a fallback answer after output has begun.
Cloudflare BGE Base produces 768 dimensions and BGE Large produces 1024; their dimension counts are fixed. OpenRouter's seeded text-embedding-3-small/large entries include dimension metadata. Embeddings do not fall back across models because vector spaces differ. See embeddings.
Pricing, free variants and lifecycle
OpenRouter :free variants are distinct catalog entries and may have separate availability/limits. Zero token rates are shown as Free tokens, not a promise that tools, requests or account usage are free. Cloudflare's free neuron allowance is account-level, not a zero-price label for all models.
Nirmos records reported usage, cached/reasoning tokens and available charges. Catalog-derived costs are estimates; missing data stays unknown. Catalog prices are reviewed snapshots and may change upstream. Groq's retired Compound and developer-tier legacy models are not offered as active default choices. Existing saved references remain visible but cannot execute retired entries.
Official references: Groq models, Groq structured outputs, OpenRouter provider routing, Cloudflare compatibility, Cloudflare JSON mode.
Vercel AI Gateway
- Open your Vercel team's AI Gateway → API Keys page and create an API key. Follow Vercel's key setup.
- In Nirmos, open Gateway → Credentials, choose Vercel AI Gateway, and add the key. Use Test connection to check authentication through Vercel's authenticated credits endpoint. A valid result does not guarantee model access or sufficient balance.
- Browse Gateway → Models, filter by Vercel, and select an active chat or embedding model. The catalog is a reviewed snapshot; it is not downloaded during inference. You can also use
nirmos.models.list()andnirmos.providers.list(), following pagination. - In the routing editor, add a target using the Vercel provider and its model. Enable the route and configure weights or round robin. For fallback, add another configured provider's model and choose the trigger errors, attempt limit and timeout. Both providers need organization credentials.
- Call the route with your Nirmos API key. Applications never receive the stored Vercel key.
const completion = await nirmos.gateway.chat.create({
route: "production-chat",
messages: [{ role: "user", content: "Explain this deployment." }],
});
console.log(completion.outputText);
const stream = await nirmos.gateway.chat.stream({
route: "production-chat",
messages: [{ role: "user", content: "Explain this deployment." }],
});
for await (const event of stream) {
if (event.type === "content.delta") console.log(event.delta);
}The same route is available through the OpenAI-compatible endpoint:
curl "$NIRMOS_RUNTIME_URL/v1/chat/completions" \
-H "Authorization: Bearer $NIRMOS_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"nirmos/production-chat","messages":[{"role":"user","content":"Hello"}]}'Direct calls retain both provider identities when the same model is available through multiple gateways:
await nirmos.gateway.chat.create({
model: "vercel/openai/gpt-4o-mini",
fallbackModels: ["openrouter/openai/gpt-4o-mini"],
messages: [{ role: "user", content: "Hello" }],
providerOptions: {
vercel: { providerOptions: { gateway: { order: ["openai"], sort: "cost" } } },
},
});Vercel receives the exact upstream ID openai/gpt-4o-mini. OpenAI credentials do not configure this Vercel model. Vercel-scoped options never reach OpenRouter during fallback.
Supported Vercel options are reasoning, reasoning_effort, include_reasoning, parallel_tool_calls, frequency_penalty, presence_penalty, and providerOptions.gateway.order/sort. Choose reasoning controls supported by the selected model. Nirmos rejects request-scoped BYOK, arbitrary credentials, endpoint overrides in options, and upstream cross-model fallback lists. Configure cross-provider fallback through Nirmos.
Chat supports streaming, tool calls, structured outputs and multimodal content where the selected model supports them. Embeddings use direct physical models such as vercel/openai/text-embedding-3-small; route aliases and embedding fallback remain unavailable. Missing embedding dimensions do not become guessed Knowledge configuration options. Image generation, video, speech, realtime and reranking APIs are outside this integration.
Vercel reports token usage and may report a decimal USD cost under providerMetadata.gateway.cost. Nirmos normalizes that value into its existing request accounting. Missing reported cost uses known catalog pricing when usage is available; missing usage or pricing remains unknown. Catalog pricing can vary by upstream host and is an estimate.
The upstream environment convention is AI_GATEWAY_API_KEY. Server-side credential provisioning can read that variable and pass it as secretData.apiKey through the existing credential API. The Nirmos runtime uses the selected organization's stored credential, with no process-environment fallback.
Endpoint and metadata behavior was checked against Vercel's official documentation and public catalog on 2026-11-04. See compatible endpoints, REST discovery and credits, reasoning, and provider configuration. Authenticated inference requires live verification with your key.