Set baseURL
Point the OpenAI SDK at https://api.virouter.com/v1.
OpenAI-compatible API gateway
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
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." }],
});Point the OpenAI SDK at https://api.virouter.com/v1.
Send Authorization: Bearer vr_sk_... from a server environment variable.
Use GPT ids for OpenAI lanes or Claude ids for Anthropic lanes.
Track cost, remaining quota, and token breakdown from each response.
Drop-in examples
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
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-usdBilling USD cost for the request.
x-virouter-remaining-usdRemaining Billing USD Quota after charge.
x-virouter-input-tokensFresh input tokens; for OpenAI this is prompt_tokens.
x-virouter-cached-input-tokensCache-read/cached input tokens when available.
x-virouter-cache-creation-input-tokensAnthropic cache-write input tokens when available.
x-virouter-output-tokensOutput tokens reported by upstream.
x-virouter-total-tokensTotal tokens for the completed request.
FAQ
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.
Use https://api.virouter.com/v1 as the OpenAI SDK baseURL or base_url. Chat completions requests go to /v1/chat/completions.
Yes. With Virouter, pass a Claude model id in the same chat completions request shape and the gateway routes it to the Anthropic lane.
Start with up to $50 in trial Billing USD Quota: $5 per rolling 24 hours for 10 periods after Telegram verification, with no rollover.