Documentation/App integrations

Use router in the apps you already know

Connect coding tools, agents and chat apps with a base URL, an API key and a model ID. Use Chat Completions, stateless Responses or Anthropic-compatible Messages.

SDKs and frameworks#

Router accepts familiar API shapes. Start with the compatible base URL for your client and an active key from your workspace.

OpenAI-compatible base URL
https://your-router-domain/v1

The Messages base URL is the site origin without /v1. Find current model identifiers in the catalog.

chat/completionscURL
curl 'https://your-router-domain/v1/chat/completions' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "model": "deepseek-v4-flash",
  "messages": [
    {
      "role": "user",
      "content": "Hello!"
    }
  ],
  "max_tokens": 128
}'
One request, one serving model
Your chosen model stays explicit. Router selects its underlying provider automatically and reports the settled cost for each completed request.

OpenAI Node#

JavaScript SDK · Chat Completions

Use the OpenAI JavaScript SDK with your router endpoint.

  1. Install openai in your own server-side application.
  2. Set ROUTER_API_KEY to the full key saved at creation.
  3. Set baseURL to the /v1 URL and choose an exact catalog model ID.
openai-node configurationJavaScript · npm install openai
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env.ROUTER_API_KEY,
  baseURL: "https://your-router-domain/v1",
});

const response = await client.chat.completions.create({
  model: "deepseek-v4-flash",
  messages: [{ role: 'user', content: 'Hello' }],
  max_tokens: 128,
});
console.log(response.choices[0].message.content);
The example uses chat.completions explicitly. Do not put API keys in a browser bundle. Running an inference example uses your wallet.

OpenAI Python#

Python SDK · Chat Completions

Use the OpenAI Python SDK with a custom base_url.

  1. Install openai in your Python environment.
  2. Set ROUTER_API_KEY without committing it to source control.
  3. Pass the /v1 base_url and exact model ID to the client.
openai-python configurationPython · pip install openai
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ['ROUTER_API_KEY'],
    base_url="https://your-router-domain/v1",
)

response = client.chat.completions.create(
    model="deepseek-v4-flash",
    messages=[{'role': 'user', 'content': 'Hello'}],
    max_tokens=128,
)
print(response.choices[0].message.content)
Running this example sends a billable model request. A successful catalog read alone does not verify inference capacity or wallet balance.

Vercel AI SDK#

AI framework · Chat Completions

Use the OpenAI-compatible provider and select its chat model explicitly.

  1. Install ai and @ai-sdk/openai-compatible in your application.
  2. Create a provider with name, baseURL and your server-side API key.
  3. Pass router.chatModel(modelId) to generateText.
vercel-ai-sdk configurationJavaScript · npm install ai @ai-sdk/openai-compatible
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
import { generateText } from 'ai';

const router = createOpenAICompatible({
  name: 'router',
  baseURL: "https://your-router-domain/v1",
  apiKey: process.env.ROUTER_API_KEY,
});

const { text } = await generateText({
  model: router.chatModel("deepseek-v4-flash"),
  prompt: 'Hello',
  maxOutputTokens: 128,
});
console.log(text);
Use the Chat Completions adapter shown here. Hosted tools, embeddings and image generation are not enabled by choosing this provider package.

LangChain#

Agent framework · Chat Completions

Configure ChatOpenAI for the compatible Chat endpoint.

  1. Install @langchain/openai and @langchain/core in your application.
  2. Set configuration.baseURL and apiKey, and leave useResponsesApi false.
  3. Invoke the model with ordinary messages; run client-side tools in your application.
langchain configurationJavaScript · npm install @langchain/openai @langchain/core
import { ChatOpenAI } from '@langchain/openai';

const model = new ChatOpenAI({
  model: "deepseek-v4-flash",
  apiKey: process.env.ROUTER_API_KEY,
  configuration: { baseURL: "https://your-router-domain/v1" },
  useResponsesApi: false,
  maxTokens: 128,
});

const response = await model.invoke('Hello');
console.log(response.content);
Do not attach provider-hosted search tools or stored conversation features. Those features can switch LangChain to a different API surface.

Codex#

Responses API

Add router as a model provider and use the Responses wire format.

  1. Set ROUTER_API_KEY in your shell environment.
  2. Add the provider configuration to ~/.codex/config.toml.
  3. Use an exact model ID from the catalog, then start Codex.
codex configurationTOML · ~/.codex/config.toml
model = "deepseek-v4-flash"
model_provider = "router"

[model_providers.router]
name = "router"
base_url = "https://your-router-domain/v1"
wire_api = "responses"
env_key = "ROUTER_API_KEY"
Responses requests must use store: false. Stored-response continuation, background mode and hosted search tools are not supported.

Claude Code#

Anthropic Messages

Point Claude Code at the Messages-compatible endpoint with environment variables.

  1. Create an API key in your workspace.
  2. Set the base URL, API key and exact model identifier.
  3. Start Claude Code from the same shell.
claude-code configurationShell
export ANTHROPIC_BASE_URL="https://your-router-domain"
export ANTHROPIC_API_KEY="YOUR_API_KEY"
export ANTHROPIC_MODEL="deepseek-v4-flash"

claude
Use the origin as ANTHROPIC_BASE_URL. The client appends /v1/messages. Client-side tools run on your computer.

OpenClaw#

OpenAI-compatible

Register router as a custom model provider for your agent.

  1. Add a router provider to your OpenClaw configuration.
  2. Set ROUTER_API_KEY in your environment.
  3. Select router/model-id as the agent model.
openclaw configurationJSON
{
  "models": {
    "providers": {
      "router": {
        "baseUrl": "https://your-router-domain/v1",
        "apiKey": "${ROUTER_API_KEY}",
        "api": "openai-completions",
        "models": [
          {
            "id": "deepseek-v4-flash",
            "name": "deepseek-v4-flash"
          }
        ]
      }
    }
  },
  "agents": {
    "defaults": {
      "model": {
        "primary": "router/deepseek-v4-flash"
      }
    }
  }
}
Keep provider configuration server-side. Add only models that appear in your router catalog.

Hermes Agent#

OpenAI-compatible

Use a custom OpenAI-compatible endpoint in the Hermes model setup.

  1. Run the model configuration command.
  2. Choose a custom endpoint and enter your router base URL.
  3. Supply your API key and exact model ID.
hermes configurationShell
hermes model

# Select a custom OpenAI-compatible endpoint
# Base URL: https://your-router-domain/v1
# API key: YOUR_API_KEY
# Model: deepseek-v4-flash
Use the model setup flow provided by your installed Hermes version.

OpenCode#

OpenAI-compatible

Configure an OpenAI-compatible provider in opencode.json.

  1. Set ROUTER_API_KEY in your environment.
  2. Add the router provider and model entry to your configuration.
  3. Select the configured router model in OpenCode.
opencode configurationJSON · opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "router": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "router",
      "options": {
        "baseURL": "https://your-router-domain/v1",
        "apiKey": "{env:ROUTER_API_KEY}"
      },
      "models": {
        "deepseek-v4-flash": {
          "name": "deepseek-v4-flash"
        }
      }
    }
  },
  "model": "router/deepseek-v4-flash"
}
The model entry must use the same identifier as the public catalog.

OpenWork#

OpenAI-compatible

Connect the workspace to router using a custom provider.

  1. Open the provider configuration in your workspace.
  2. Choose an OpenAI-compatible provider.
  3. Enter your router base URL, API key and catalog model ID.
openwork configurationConnection settings
Provider: OpenAI Compatible
Base URL: https://your-router-domain/v1
API key: YOUR_API_KEY
Model: deepseek-v4-flash
OpenWork uses OpenCode underneath; the OpenCode provider configuration can also supply the connection.

Open WebUI#

OpenAI-compatible

Add router as an OpenAI-compatible connection in the admin panel.

  1. Open Admin Panel → Settings → Connections.
  2. Add a new OpenAI API connection.
  3. Save the base URL and key, then select a model in chat.
open-webui configurationConnection settings
Admin Panel → Settings → Connections → OpenAI API

URL: https://your-router-domain/v1
API key: YOUR_API_KEY
Model: deepseek-v4-flash
Connection keys are server configuration. Avoid sharing an administrator key with untrusted users.

Cline#

OpenAI-compatible

Use Cline’s OpenAI Compatible provider option.

  1. Open Cline settings and select OpenAI Compatible.
  2. Enter the base URL and API key.
  3. Set Model ID to the exact model you want to use.
cline configurationConnection settings
API Provider: OpenAI Compatible
Base URL: https://your-router-domain/v1
API Key: YOUR_API_KEY
Model ID: deepseek-v4-flash
Tool support and context length depend on the selected model.

Continue#

OpenAI-compatible

Add router to your Continue YAML model configuration.

  1. Store ROUTER_API_KEY using Continue’s secret configuration.
  2. Add an OpenAI provider entry with apiBase set to router.
  3. Reload the configuration and choose your model.
continue configurationYAML
name: router
version: 1.0.0
schema: v1
models:
  - name: deepseek-v4-flash
    provider: openai
    model: deepseek-v4-flash
    apiBase: https://your-router-domain/v1
    apiKey: ${{ secrets.ROUTER_API_KEY }}
Keep secrets out of configuration files that are committed to source control.

Cursor#

OpenAI-compatible

Keep the editor and override the OpenAI base URL in model settings.

  1. Open Settings → Models and add your OpenAI API key.
  2. Enable Override OpenAI Base URL and enter the router URL.
  3. Add the exact catalog model ID and verify the connection.
cursor configurationConnection settings
OpenAI API key: YOUR_API_KEY
Override OpenAI Base URL: https://your-router-domain/v1
Model: deepseek-v4-flash
Availability of custom keys for individual Cursor features depends on your Cursor version and plan.

Aider#

OpenAI-compatible

Set the OpenAI-compatible environment variables and select your model.

  1. Export your router base URL and API key.
  2. Start Aider with openai/ followed by the exact model ID.
  3. Check the model’s context and output limits before large changes.
aider configurationShell
export OPENAI_API_BASE="https://your-router-domain/v1"
export OPENAI_API_KEY="YOUR_API_KEY"

aider --model openai/deepseek-v4-flash
The openai/ prefix selects the compatible provider in Aider; the remainder is the router model ID.

LibreChat#

OpenAI-compatible

Add router as a custom endpoint in librechat.yaml.

  1. Set ROUTER_API_KEY in the server environment.
  2. Add the custom endpoint configuration.
  3. Restart LibreChat and select router from the model menu.
librechat configurationYAML · librechat.yaml
endpoints:
  custom:
    - name: router
      apiKey: ${ROUTER_API_KEY}
      baseURL: https://your-router-domain/v1
      models:
        default: ["deepseek-v4-flash"]
        fetch: true
Fetching the model catalog requires an active API key.

Verify the connection#

Reference

Start with an authenticated catalog read before running inference.

  1. Replace YOUR_API_KEY with your saved full key and run the catalog request below. It does not call a model.
  2. A 401 means authentication failed; a 403 can indicate missing permission or an IP restriction. Use a key with inference permission.
  3. For an end-to-end check, run one small text example with an exact available model and wallet credit, then inspect Requests. That inference is billable.
verify configurationcURL · read only
curl 'https://your-router-domain/v1/models' \
  -H 'Authorization: Bearer YOUR_API_KEY'
A catalog response confirms authentication and connectivity only. Model availability, key limits and funding are checked separately when you send inference.

Prompt cache and long-session savings#

Reference

Keep a compatible route preference and inspect actual supplier cache usage.

  1. API keys default to passthrough. Advanced key settings choose on, off or passthrough; x-ci-prompt-cache overrides the key for one request. off keeps customer cache_control and disables only the routing preference.
  2. on adds automatic cache_control only when you supplied no marker. Non-Claude models remain unchanged. Claude needs a native Messages candidate: the current verified catalog has one for claude-opus-4.8 only. Automatic markers use the five-minute default. Supported Chat/Responses to Messages conversions preserve 5m markers but reject explicit 1h with unsupported_conversion until supplier alias pricing is verified. Native same-protocol 1h behavior remains unchanged, with its pricing dimension not independently verified; other Claude models can be unavailable.
  3. Set x-ci-prompt-cache-scope to session, user or org. Session uses the key and a printable ASCII x-ci-prompt-cache-session label (1–256 characters, nonblank; omit for the key alone); user uses the responsible actor; org shares within the workspace or personal account. Never use a secret as the label.
  4. x-ci-prompt-cache-affinity new/hit/stale/miss describes a five-minute route hint for a cacheable prefix, not a supplier cache hit. Price, health, protocol and ZDR rules still apply; a different-route fallback is miss.
  5. In Requests, hit means positive reported cache reads, zero means an explicit zero read, and unknown means the supplier did not report reads. Writes are independent. Exact-response cache hits use not_applicable; pending requests have no settled cache state.
prompt-cache configurationcURL · billable inference; compatible capacity required
curl 'https://your-router-domain/v1/messages' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'anthropic-version: 2023-06-01' \
  -H 'x-ci-prompt-cache: on' \
  -H 'x-ci-prompt-cache-scope: session' \
  -H 'x-ci-prompt-cache-session: example-session' \
  -H 'Content-Type: application/json' \
  -d '{
  "model": "claude-opus-4.8",
  "max_tokens": 128,
  "system": "Keep reusable instructions and context here.",
  "messages": [
    {
      "role": "user",
      "content": "Summarize our task."
    }
  ]
}'
The example sends billable inference if compatible capacity exists. Cache discounts and successful live caching are not guaranteed. Use GET /v1/usage/requests with usage:read permission to inspect the actual billed result; routing affinity and the optional exact-response cache are separate.