cheapinference.dev
FEATURE GUIDES

SDKs & migration

Use the official OpenAI SDK and move from Chat to Responses.

Keep the official OpenAI client

No custom SDK is necessary. Change your base URL and API key. Existing OpenRouter integrations can keep an openai/ prefix, but must remove routing, plugin, and non-OpenAI fields. Existing OpenAI integrations can keep their native model IDs.

import OpenAI from "openai";
const client = new OpenAI({
  baseURL: "https://www.cheapinference.dev/v1",
  apiKey: process.env.CHEAPINFERENCE_API_KEY,
});

Use the compatibility table to audit an integration before switching traffic. Request a small output limit for an initial test, inspect the response and Usage page, then increase traffic.

Chat Completions → Responses

Chat CompletionsResponses
client.chat.completions.create()client.responses.create()
messagesinput; optional instructions
max_completion_tokensmax_output_tokens
response_format.json_schematext.format
reasoning_effortreasoning.effort
tools[].function.name/parameterstools[].name/parameters
message.tool_callsoutput items with type=function_call
role=tool + tool_call_idtype=function_call_output + call_id
choices[0].message.contentSDK output_text helper or output array
choices[].delta SSE chunksTyped response.* SSE events

Differences from OpenRouter

This service uses a single provider and explicit OpenAI model IDs. It does not perform automatic model/provider fallback, expose BYOK, execute OpenRouter plugins, or add OpenRouter-specific cost and normalized-response fields. Inference is stateless here, as in OpenRouter’s Responses interface.

Native OpenAI Chat usage chunks may have choices: []; check for a choice before reading its delta. Stream cancellation does not guarantee upstream cancellation here: the proxy drains upstream work to capture usage. Neither the gateway nor the API adds inference retry deduplication.

Hosted tools and media-generation services require separate metering and are outside this release. Do not silently route them to an unrelated endpoint.