Responses
The recommended API for new OpenAI integrations.
Create a response
Responses accepts a text string or an array of messages, reasoning items, and tool results. Use the official OpenAI SDK; its output_text helper extracts text from the native output array.
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://www.cheapinference.dev/v1",
apiKey: process.env.CHEAPINFERENCE_API_KEY,
});
const response = await client.responses.create({
model: "gpt-5.4-mini",
input: "Build something great.",
max_output_tokens: 1024,
store: false,
});
console.log(response.output_text);Parameters
| Field | Type | Behavior |
|---|---|---|
| model | string · required | Supported OpenAI ID; optional openai/ prefix |
| input | string or array · required | Full input/history for this independent request |
| instructions | string | System-level instructions for this request |
| max_output_tokens | positive integer | Output ceiling, including reasoning; bounded by model capability |
| reasoning | object | Model-specific effort and optional summary settings |
| text | object | format for text/JSON/schema; verbosity where supported |
| tools / tool_choice | array / string or object | Client tools and tool-selection behavior |
| parallel_tool_calls | boolean | Permit multiple tool calls in one response |
| stream | boolean | Typed server-sent events |
| include | array | reasoning.encrypted_content or message.output_text.logprobs |
| store | false or omitted | true is rejected |
| truncation | disabled or auto | Upstream model’s context-overflow handling |
| temperature / top_p | number | Optional sampling controls where the model supports them |
See parameter ranges and the OpenAPI schema. Unrecognized model-specific fields are validated by OpenAI; router-specific fields are rejected locally.
Read the response
{
"id": "resp_example",
"object": "response",
"status": "completed",
"output": [{
"type": "message", "role": "assistant",
"content": [{ "type": "output_text", "text": "Hello!", "annotations": [] }]
}],
"usage": { "input_tokens": 12, "output_tokens": 4, "total_tokens": 16 }
}Check status. completed is a finished generation; incomplete carries incomplete_details, often because an output limit was reached; failed carries an error. Not every output item is a message—reasoning and tool calls have separate types. Raw HTTP clients should inspect the output array instead of assuming a top-level output_text field.
Continue a conversation without server storage
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://www.cheapinference.dev/v1",
apiKey: process.env.CHEAPINFERENCE_API_KEY,
});
const history: OpenAI.Responses.ResponseInput = [
{ role: "user", content: "Suggest a name for a reading app." },
];
const first = await client.responses.create({
model: "gpt-5.4-mini", input: history, store: false,
include: ["reasoning.encrypted_content"],
});
const second = await client.responses.create({
model: "gpt-5.4-mini", store: false,
include: ["reasoning.encrypted_content"],
input: [...history, ...first.output,
{ role: "user", content: "Give me two more options." }],
});
console.log(second.output_text);Keep complete output items when replaying, including their IDs, call IDs, and encrypted reasoning. Do not invent or strip fields. Stored response IDs, item references, conversations, prompt templates, file IDs, and background generation are not supported.
Build on Responses
Structured outputs · Client tools · Reasoning · Streaming · Image and PDF input