OpenAI-compatible API

Docs

Start with one API key, the OpenAI SDK you already use, and a model ID from the WLRouter catalog.

Quickstart

Create an API key in the console, set it as an environment variable, then send your first chat completion request.

Environment

export WLROUTER_API_KEY="wlrouter_..."
curlbash
curl https://api.wlrouter.com/v1/chat/completions \
  -H "Authorization: Bearer $WLROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4.1-mini",
    "stream": false,
    "messages": [
      { "role": "user", "content": "Write a one sentence product summary." }
    ]
  }'
JavaScriptts
import OpenAI from "openai";

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

const response = await client.chat.completions.create({
  model: "gpt-4.1-mini",
  stream: false,
  messages: [{ role: "user", content: "Write a one sentence product summary." }]
});

console.log(response.choices[0]?.message?.content);
Pythonpy
from openai import OpenAI

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

response = client.chat.completions.create(
    model="gpt-4.1-mini",
    stream=False,
    messages=[{"role": "user", "content": "Write a one sentence product summary."}],
)

print(response.choices[0].message.content)

First request

The primary endpoint for text and multimodal chat models is /v1/chat/completions. Use /v1/models to list available public model IDs.

POST

https://api.wlrouter.com/v1/chat/completions

GET

https://api.wlrouter.com/v1/models

Request basics

Base URL
https://api.wlrouter.com/v1
Authentication
Send Authorization: Bearer <wlrouter_api_key> with every request.
Compatibility
Use the OpenAI SDK by changing the base URL and model ID.
Request IDs
Keep the request_id from errors or responses when contacting support.
Streaming
Set stream: true for token-by-token responses on supported chat models.

Streaming

Use stream: true when your application should receive incremental deltas. Keep stream: false for a single JSON response.

Streaming requestbash
curl https://api.wlrouter.com/v1/chat/completions \
  -H "Authorization: Bearer $WLROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4.1-mini",
    "stream": true,
    "messages": [
      { "role": "user", "content": "Give me three launch checklist items." }
    ]
  }'

Billing note

WLRouter uses USD prepaid balance. The minimum top-up is 10 USD and the service fee is 5%. Usage is deducted by model, input tokens, output tokens, and cache-read tokens where applicable.

Errors

Keep the returned request_id when contacting support. If the balance is too low, WLRouter returns an OpenAI-compatible error with code insufficient_balance.