OpenAI-Compatible API: OpenAI-compatible unified LLM API for multi-model production applications.
nRouter provides a unified LLM API on the OpenAI request format, allowing teams to route traffic across frontier providers, enforce guardrails, and control budgets simply by changing their base URL.
Why adopt a unified LLM API?
A unified LLM API standardizes communication across disparate model providers (OpenAI, Anthropic, Google, Meta, and open-source models) using the industry-standard OpenAI REST and SDK format. With nRouter, switching providers requires zero code refactoring: simply update your base URL and API key to gain smart routing, in-path safety, and provider failover.
Changes
Base URL and API key
2
BYOK keys
Provider credentials managed for you
0
Model
Any live catalog model
How it works.
Base URL migration: change two values
Create an nRouter virtual key, point the client at https://api.nrouter.ai/v1, and choose a live model ID.
- Set NROUTER_API_KEY
- Set OPENAI_BASE_URL to https://api.nrouter.ai/v1
- Verify the selected model ID in the live catalogue
Streaming and endpoint behavior
Chat completions can use stream: true and server-sent events. Handle partial chunks and stream errors.
- /v1/chat/completions for chat and streaming
- /v1/models and /v1/embeddings for discovery and vectors
- /v1/images, /v1/audio, and /v1/videos where supported
Compatibility limits by provider
Tool calling, JSON mode, vision, streaming, and context windows vary by model and provider.
- Test model capabilities instead of assuming parity
- Check endpoint and parameter support before migration
- Verify errors, retries, streaming, and cost headers in staging
Verify a migration before production
Change the base URL and key, test streaming and errors, confirm cost headers, then roll out gradually.
- Base URL and API key changed
- Streaming, tools, errors, budget, and guardrails tested
- Cost records verified before gradual production rollout
Copy-paste migration examples.
The simplest migration changes the base URL and key. Confirm model support in the API reference.
// Node.js — OpenAI SDK
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.NROUTER_API_KEY,
baseURL: "https://api.nrouter.ai/v1",
});
const response = await client.chat.completions.create({
model: "gpt-6-luna",
messages: [{ role: "user", content: "Explain model routing in one sentence." }],
});
console.log(response.choices[0].message.content);
# Python
from openai import OpenAI
client = OpenAI(api_key="your-nrouter-key", base_url="https://api.nrouter.ai/v1")
response = client.chat.completions.create(
model="gpt-6-luna",
messages=[{"role": "user", "content": "What is an OpenAI-compatible API?"}],
)
# Environment variables
export OPENAI_API_KEY="your-nrouter-key"
export OPENAI_BASE_URL="https://api.nrouter.ai/v1"
# cURL
curl https://api.nrouter.ai/v1/chat/completions \
-H "Authorization: Bearer $NROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-6-luna","messages":[{"role":"user","content":"Explain provider failover."}]}'
# Streaming: add stream: true and consume server-sent event chunks.
# LangChain, LlamaIndex, Vercel AI SDK, and CrewAI can use the same base URL
# when their OpenAI-compatible provider accepts a custom endpoint.How it compares.
Supported OpenAI-compatible endpoints
| Capability / Platform | Focus | nRouter Approach |
|---|---|---|
| /v1/chat/completions | Chat and streaming completions | Supported through the OpenAI-compatible request format; model capability and streaming behavior vary by model. |
| /v1/models | Model discovery | Returns the live catalogue surface used to verify IDs and capabilities. |
| /v1/embeddings | Embeddings | Available where the selected embedding model and provider support the endpoint. |
| /v1/images | Image generation | Available where supported by the selected model and provider. |
| /v1/audio and /v1/videos | Audio operations and video jobs | Available where supported; consult the API reference for request and polling behavior. |
Pricing.
Compatible API with governance included
Inference settles at the served provider’s exact list price with 0% token markup. Pay as you go carries a 0% platform fee with a $5 minimum credit purchase, no subscriptions sold, and a $100 no-card promotional credit spent on promo-labeled models subject to the daily limits shown on the Pricing page.
0%
FAQs
What is an OpenAI-compatible API?
It is an API that follows familiar OpenAI client and request conventions so applications can use a compatible SDK or REST shape against another gateway or provider layer.
Does nRouter work with the OpenAI Python SDK?
Yes. Set the client base_url to https://api.nrouter.ai/v1 and use an nRouter virtual key, then select a model from the live catalogue.
What base URL does nRouter use?
The canonical base URL is https://api.nrouter.ai/v1.
Can I use an OpenAI-compatible API with Claude or Gemini models?
Yes, where the model is available in the nRouter catalogue and supports the requested endpoint. Check the model capability metadata because provider features and parameters vary.
Does nRouter support streaming?
Streaming chat completions use stream: true and server-sent event chunks. Your client should handle partial output and stream errors; do not assume mid-stream replay to another provider.
Can I use embeddings through nRouter?
Yes, where the selected embedding model and provider support /v1/embeddings. Verify the live catalogue and API reference before rollout.
Can I migrate from OpenRouter without rewriting my application?
Usually the migration starts with changing the endpoint, key, and model ID, followed by testing provider-specific parameters, streaming, errors, budgets, and guardrails.
Does nRouter support tool calling?
Tool calling is supported where the selected model and provider expose it. Test the exact model, schema, and response behavior because tool support is not identical across providers.
Are provider-specific parameters supported?
Some parameters are provider- or model-specific and may not transfer through a common API. The API reference and model catalogue are the source of truth.
How does nRouter handle model failover?
Configured routing can select eligible fallback providers or models for retryable failures, subject to capability, budget, timeout, and policy checks.
How is nRouter’s unified LLM API priced?
nRouter passes through provider list prices with 0% token markup. Pay-as-you-go credit purchases carry a 0% platform fee with a $5 minimum purchase and no subscriptions sold. Every new account receives a $100 no-card promotional credit spent on promo-labeled models subject to the daily limits shown on the Pricing page.
- Written by Suresh, Senior SEO Engineer · Technically reviewed by Rama Surasani, Founder & CEO, CloudAct Inc. · Last updated October 6, 2026