Point your OpenAI client at Realrouter.

The API keeps familiar OpenAI-style routes for responses, chat completions, files, and models. Replace the base URL, use your Realrouter key, and keep your client code small.

Quickstart

Install the official OpenAI SDK and set the Realrouter base URL. The dashboard will show your API key once when it is created.

import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.REALROUTER_KEY,
  baseURL: "https://api.realrouter.org/v1",
});

const response = await client.responses.create({
  model: "gpt-5.4-mini",
  reasoning: { effort: "low" },
  input: "Summarize this note in Chinese.",
});

console.log(response.output_text);
Starter500 credits / month
API Keysuser-level subscription
Mobile Chatsame account balance

Endpoints

  • POST /v1/responses for the primary OpenAI-compatible responses API.
  • POST /v1/chat/completions for legacy chat completion clients.
  • GET /v1/models for available models, capabilities, and pricing metadata.

Tools and modalities

Realrouter forwards the tools parameter only for tool types it can translate into OpenAI-compatible request and streaming shapes. Unknown or unsupported tool types return 400 with unsupported_tool.

Vision input and PDF input_file are supported input modalities, not tools. PDF uploads use purpose=user_data, are limited to 25 MB per file, and each response request can include up to 50 MB of inline or referenced file content.
Tool type
Status
Notes
web_search
Supported
Also accepts web_search_preview. Streaming emits web search in-progress and completed events on /v1/responses.
image_generation
Supported
Also accepts image_generation_call. Generated images are stored in Realrouter blob storage and returned as signed URLs. Not enabled for gpt-5.3-codex-spark.
function
Supported
Custom function calling. Realrouter forwards declarations and returns function calls, but your client executes tools and sends results in the next request.

Function calling

Function calling is stateless. Realrouter returns function_call items or chat tool_calls; your app runs the function and sends the result back with the relevant conversation context.

const first = await client.responses.create({
  model: "gpt-5.5",
  input: "What is the weather in Toronto?",
  tools: [{
    type: "function",
    name: "get_weather",
    description: "Get current weather for a city.",
    parameters: {
      type: "object",
      properties: { city: { type: "string" } },
      required: ["city"],
      additionalProperties: false,
    },
  }],
  tool_choice: { type: "function", name: "get_weather" },
});

const call = first.output.find((item) => item.type === "function_call");
const toolResult = await getWeather(JSON.parse(call.arguments));

const final = await client.responses.create({
  model: "gpt-5.5",
  input: [
    { role: "user", content: "What is the weather in Toronto?" },
    call,
    { type: "function_call_output", call_id: call.call_id, output: JSON.stringify(toolResult) },
  ],
  tools: first.tools,
});

Structured outputs

Responses supports OpenAI-compatible Structured Outputs with text.format.type=json_schema. Use json_schema when you need schema adherence; json_object remains available for plain JSON mode.

const response = await client.responses.create({
  model: "gpt-5.4-mini",
  input: "Extract the answer. Return exactly pong.",
  text: {
    format: {
      type: "json_schema",
      name: "pong_answer",
      schema: {
        type: "object",
        properties: {
          answer: { type: "string" },
        },
        required: ["answer"],
        additionalProperties: false,
      },
      strict: true,
    },
  },
});

const parsed = JSON.parse(response.output_text);

PDF and file input

curl https://api.realrouter.org/v1/files \
  -H "Authorization: Bearer $REALROUTER_API_KEY" \
  -F purpose=user_data \
  -F file=@document.pdf
const response = await client.responses.create({
  model: "gpt-5.4-mini",
  input: [{
    role: "user",
    content: [
      { type: "input_file", file_id: "file-..." },
      { type: "input_text", text: "Summarize this PDF." },
    ],
  }],
});

Image generation

const response = await client.responses.create({
  model: "gpt-5.4-mini",
  input: "Generate a small product icon for a code API gateway.",
  tools: [{ type: "image_generation" }],
});