cheapinference.dev
API REFERENCE

Chat Completions

Message-based generation with native OpenAI request and response shapes.

Create a chat completion

POST /chat/completions

Keep this endpoint for existing message-based integrations. Send the full conversation, including tool-call messages and tool results, on each request.

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

const result = await client.chat.completions.create({
  model: "gpt-5.4-mini",
  messages: [
    { role: "developer", content: "Be concise." },
    { role: "user", content: "Explain an embedding." },
  ],
  max_completion_tokens: 1024,
});
console.log(result.choices[0]?.message.content);

Messages and output

RoleUse
system / developerApplication instructions; support varies by model
userText or supported multimodal content parts
assistantPrevious model messages, including tool_calls
toolResult of a tool call; include its tool_call_id

Non-streaming text is under choices[0].message.content. Tool calls live under message.tool_calls; content can be null. The endpoint supports a single completion (n=1), not multi-choice generation.

{
  "id": "chatcmpl_example", "object": "chat.completion",
  "choices": [{ "index": 0, "finish_reason": "stop",
    "message": { "role": "assistant", "content": "Hello!" } }],
  "usage": { "prompt_tokens": 12, "completion_tokens": 4, "total_tokens": 16 }
}

Finish reasons

ValueMeaning
stopNormal completion or stop sequence
lengthToken ceiling reached; output may be incomplete
tool_callsYour application should inspect and execute tool calls
content_filterOutput stopped by provider filtering

We preserve the native provider value rather than normalizing it. A reasoning model can use its entire output budget internally and return little or no visible text.

Supported options

Common OpenAI options—including temperature, top_p, penalties, seed, log probabilities, response_format, function tools, reasoning_effort, and prediction—are forwarded on compatible models. No sampling defaults are injected.

Use max_completion_tokens where supported; max_tokens is available for compatible legacy integrations. Persisted completions, audio, native web-search options, hosted tools, and n > 1 are rejected in this release.

Parameter reference · Predicted Outputs · Move to Responses