Text generation
Generate text or code from a prompt.
AI & ML · Function
The Responses API makes direct model requests for text, structured outputs, tools, and multimodal workflows. Submit a model and input, then read generated output from the returned response.
The Responses API accepts a model identifier and input, then returns a response containing generated output items. The official SDK exposes the resulting text through output_text, while the API also supports multimodal inputs, tools, structured outputs, and stateful interactions.
client.responses.create({ model, input })| Name | Type | Description |
|---|---|---|
model | string | The model identifier used to generate the response. |
input | string or array | Text or other supported input supplied to the model. |
A response object containing generated output items; SDK clients expose convenient text through output_text.
import OpenAI from "openai";
const client = new OpenAI();
const response = await client.responses.create({
model: "gpt-5",
input: "Summarize this sentence in five words: Responses API is direct.",
});
console.log(response.output_text);Creates a model response from text input and prints the SDK's combined text output.
Generate text or code from a prompt.
Extract or classify information from images or documents.
Return data that downstream code can validate against a schema.
Connect model requests to external capabilities.
Call responses.create with a model and input. The returned object contains generated output, and the SDK provides output_text for convenient text access.
Follow-up: How would you handle structured results? Use the Responses API's structured-output capability and consume the response according to the declared schema.
Responses is intended for direct model requests and supports text, image, audio, tools, and stateful interactions. The API returns output items rather than only a single text field.
Follow-up: What changes for tool use? Attach the relevant tool and explicitly process the returned tool-call output before continuing the interaction.
Use the official SDK or call the HTTP endpoint directly. SDK usage requires a client, a model, and input; HTTP requests target the Responses endpoint with bearer authentication.
Follow-up: What should be reviewed before deployment? Check authentication, errors, rate limits, and request-ID logging in the API reference.
Structured OutputsChat Completions APIToolsConversations APIReasoning models