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 Completions | Responses |
|---|---|
| client.chat.completions.create() | client.responses.create() |
| messages | input; optional instructions |
| max_completion_tokens | max_output_tokens |
| response_format.json_schema | text.format |
| reasoning_effort | reasoning.effort |
| tools[].function.name/parameters | tools[].name/parameters |
| message.tool_calls | output items with type=function_call |
| role=tool + tool_call_id | type=function_call_output + call_id |
| choices[0].message.content | SDK output_text helper or output array |
| choices[].delta SSE chunks | Typed 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.