Responses API

Use the Responses API for applications and coding tools built around OpenAI's response-item format.

POST https://getrouter.ai/v1/responses

Basic request

curl https://getrouter.ai/v1/responses \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "MODEL_ID",
    "instructions": "Answer in one short paragraph.",
    "input": "Explain what a reverse proxy does."
  }'

The response includes an output array containing response items. SDKs may provide an output_text convenience property for aggregated text.

Python

from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://getrouter.ai/v1",
)

response = client.responses.create(
    model="MODEL_ID",
    instructions="Answer in one short paragraph.",
    input="Explain what a reverse proxy does.",
)

print(response.output_text)

Node.js / TypeScript

import OpenAI from 'openai'

const client = new OpenAI({
  apiKey: 'YOUR_API_KEY',
  baseURL: 'https://getrouter.ai/v1',
})

const response = await client.responses.create({
  model: 'MODEL_ID',
  instructions: 'Answer in one short paragraph.',
  input: 'Explain what a reverse proxy does.',
})

console.log(response.output_text)

Common request fields

FieldDescription
modelRequired model ID
inputString or array of input items
instructionsHigh-level instructions for the response
streamStream response events when true
max_output_tokensMaximum output token limit
toolsTool definitions for compatible models
tool_choiceTool selection behavior
reasoningReasoning configuration for compatible models
previous_response_idContinue from an earlier response
truncationauto or disabled

Continue a response

For workflows that support response continuation, pass the previous response ID:

{
  "model": "MODEL_ID",
  "previous_response_id": "RESPONSE_ID",
  "input": "Now give me a concrete example."
}

Support for stateful continuation can depend on the selected model and upstream service.

Compact context

GetRouter exposes the Responses compaction endpoint:

POST https://getrouter.ai/v1/responses/compact

It accepts model plus input, instructions, or previous_response_id. Use it only when your client implements the Responses compaction workflow.

curl https://getrouter.ai/v1/responses/compact \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "MODEL_ID",
    "input": "CONVERSATION_INPUT"
  }'

Streaming

Set stream to true to receive Responses API events. These are not the same as Chat Completions chunks. See Streaming.

Compatibility notes

  • Use a model that supports the Responses endpoint.
  • Do not assume a model that works with Chat Completions also supports Responses.
  • Tools such as Codex may depend on Responses-specific event and tool formats, so configure them with a dedicated integration guide.

Next steps