Login
API ReferenceFeatured

Responses API

Build stateless text, vision, JSON, and function workflows.

All documentation

POST /v1/responses is the recommended stateless endpoint for new text, vision, structured-output, and custom-function integrations.

Basic response

const response = await client.responses.create({
  model: "your-chat-model",
  instructions: "Answer clearly and briefly.",
  input: "How should I split documents for semantic search?"
})

console.log(response.output_text)

The response uses the OpenAI response object shape, including id, status, output, output_text, usage, and token-detail objects.

Vision input

Use a public HTTPS image URL or a supported base64 data URL:

const response = await client.responses.create({
  model: "your-vision-model",
  input: [
    {
      role: "user",
      content: [
        { type: "input_text", text: "Describe the important details." },
        { type: "input_image", image_url: "https://example.com/product.png" }
      ]
    }
  ]
})

The selected model must advertise image-analysis support.

Streaming

const stream = await client.responses.create({
  model: "your-chat-model",
  input: "Write a short launch announcement.",
  stream: true
})

for await (const event of stream) {
  if (event.type === "response.output_text.delta") {
    process.stdout.write(event.delta)
  }
}

Streams emit typed lifecycle events, text deltas, function-argument deltas, completed output items, and a final response.completed event with usage. For a tool-only response, the stream contains only function-call output items; it does not add a synthetic empty assistant message.

Supported request fields

  • model
  • input as a string or an array of message/function items
  • instructions
  • max_output_tokens
  • temperature, top_p
  • stream
  • tools with type: "function"
  • tool_choice, parallel_tool_calls
  • text.format for text, JSON object, or JSON Schema output
  • metadata (returned with the response; not persisted)

Stateless boundary

Responses are not persisted. background, conversation, previous_response_id, stored prompt templates, and non-function built-in tools return 400 unsupported_parameter. File-backed input, reasoning controls, automatic truncation, include, top_logprobs, and text.verbosity are also outside the current contract. The error response identifies the exact rejected field in error.param. Keep prior messages and function results in your own application and send them in the next input array.