← Back to Virouter

OpenAI-compatible API gateway

OpenAI-Compatible API Gateway for GPT and Claude

Keep the OpenAI SDK request shape and swap one base URL. Virouter routes GPT and Claude calls through one API key, one Billing USD Quota wallet, and one set of usage headers.

Base URL: https://api.virouter.com/v1 · Chat completions compatible

Node.jsOpenAI SDK
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.VIROUTER_API_KEY,
  baseURL: "https://api.virouter.com/v1",
});

const reply = await client.chat.completions.create({
  model: "claude-opus-4-7",
  messages: [{ role: "user", content: "Explain this PR." }],
});
1

Set baseURL

Point the OpenAI SDK at https://api.virouter.com/v1.

2

Use your Virouter key

Send Authorization: Bearer vr_sk_... from a server environment variable.

3

Choose a model id

Use GPT ids for OpenAI lanes or Claude ids for Anthropic lanes.

4

Read quota headers

Track cost, remaining quota, and token breakdown from each response.

Drop-in examples

Use the same compatible endpoint from cURL or Python.

Virouter is designed for server-side integrations that already use OpenAI-compatible clients. Change the host, keep the request body, and pick the model id.

curl https://api.virouter.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $VIROUTER_API_KEY" \
  -d '{
    "model": "gpt-5.5",
    "messages": [{"role":"user","content":"Hello"}]
  }'
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["VIROUTER_API_KEY"],
    base_url="https://api.virouter.com/v1",
)

response = client.chat.completions.create(
    model="claude-sonnet-4-6",
    messages=[{"role": "user", "content": "Summarize this"}],
)

Headers

Compatible request shape, richer response visibility.

OpenAI-compatible APIs are easy to call. Virouter adds gateway-level cost and quota headers so you can observe the request after it completes.

x-virouter-cost-usd

Billing USD cost for the request.

x-virouter-remaining-usd

Remaining Billing USD Quota after charge.

x-virouter-input-tokens

Fresh input tokens; for OpenAI this is prompt_tokens.

x-virouter-cached-input-tokens

Cache-read/cached input tokens when available.

x-virouter-cache-creation-input-tokens

Anthropic cache-write input tokens when available.

x-virouter-output-tokens

Output tokens reported by upstream.

x-virouter-total-tokens

Total tokens for the completed request.

FAQ

OpenAI-compatible gateway FAQ

What is an OpenAI-compatible API gateway?

An OpenAI-compatible API gateway accepts familiar OpenAI SDK request shapes and forwards them to configured upstream model providers. Virouter uses this pattern to route GPT and Claude workloads through one endpoint.

What base URL should I use with Virouter?

Use https://api.virouter.com/v1 as the OpenAI SDK baseURL or base_url. Chat completions requests go to /v1/chat/completions.

Can an OpenAI-compatible endpoint call Claude models?

Yes. With Virouter, pass a Claude model id in the same chat completions request shape and the gateway routes it to the Anthropic lane.

Swap one base URL. Keep shipping.

Start with up to $50 in trial Billing USD Quota: $5 per rolling 24 hours for 10 periods after Telegram verification, with no rollover.