Skip to main content
The Responses API uses a streamlined request format and returns a richer response object compared to Chat Completions. This page covers every key field.

Request Object

A minimal request needs only a model and input:
{
  "model": "gpt-4o",
  "input": "Explain photosynthesis in one sentence."
}

Input Formats

The input field accepts multiple formats:
FormatExampleUse case
Plain string"What is 2+2?"Simple single-turn questions
Message array[{"role": "user", "content": "..."}]Multi-role conversations with system prompts
String input:
{
  "model": "gpt-4o",
  "input": "What is the speed of light?"
}
Message array input (with system prompt):
{
  "model": "gpt-4o",
  "input": [
    { "role": "system", "content": "You are a physics tutor." },
    { "role": "user", "content": "What is the speed of light?" }
  ]
}

Common Parameters

ParameterTypeDefaultDescription
modelstringrequiredModel ID to use (e.g. "gpt-4o", "gpt-4o-mini")
inputstring | arrayrequiredThe user input — a plain string or a messages array
instructionsstringSystem-level instructions (alternative to a system message in input)
max_output_tokensintegermodel defaultMaximum tokens to generate
temperaturenumber1.0Sampling temperature (0 = deterministic, 2 = very random)
top_pnumber1.0Nucleus sampling threshold
streambooleanfalseStream output as Server-Sent Events
toolsarrayBuilt-in tools or custom function schemas
tool_choicestring | object"auto"How the model selects tools
textobjectText output configuration (e.g. {"format": {"type": "json_schema", ...}})
previous_response_idstringChain this response to a previous one for multi-turn
reasoningobjectReasoning configuration for o-series models (e.g. {"effort": "high"})
storebooleantrueWhether to store the response for multi-turn use
Use instructions as a cleaner alternative to embedding a system message inside input. It keeps your input focused on the user’s question.

Full Request Example

import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.routeway.ai/v1",
    api_key=os.getenv("ROUTEWAY_API_KEY")
)

response = client.responses.create(
    model="gpt-4o",
    instructions="You are a concise assistant. Reply in one paragraph.",
    input="Explain how DNS works.",
    max_output_tokens=200,
    temperature=0.3,
)

print(response.output_text)

Response Object

A successful response looks like this:
{
  "id": "resp_abc123",
  "object": "response",
  "created_at": 1749052800,
  "model": "gpt-4o-2024-11-20",
  "status": "completed",
  "output": [
    {
      "type": "message",
      "id": "msg_abc123",
      "role": "assistant",
      "content": [
        {
          "type": "output_text",
          "text": "DNS (Domain Name System) translates human-readable domain names into IP addresses..."
        }
      ]
    }
  ],
  "output_text": "DNS (Domain Name System) translates human-readable domain names into IP addresses...",
  "usage": {
    "input_tokens": 35,
    "output_tokens": 62,
    "total_tokens": 97
  }
}

Key Fields

FieldDescription
idUnique response identifier (used for multi-turn via previous_response_id)
objectAlways "response"
status"completed", "failed", "in_progress", or "cancelled"
outputArray of output items (messages, tool calls, etc.)
output_textConvenience field — the concatenated text content from all output messages
modelThe exact model snapshot used
usageToken counts for billing
The output_text field is a shortcut. For simple text responses, use it directly instead of digging into output[0].content[0].text.

Output Item Types

The output array can contain different item types:
TypeDescription
messageA text response from the model
function_callThe model wants to call a custom function you defined
web_search_callThe model performed a web search (built-in tool)
file_search_callThe model searched uploaded files (built-in tool)
code_interpreter_callThe model executed code (built-in tool)

Status Values

StatusMeaning
"completed"Response generated successfully
"failed"An error occurred during generation
"in_progress"Response is still being generated (streaming or background)
"cancelled"Response was cancelled before completion
Always check the status field. A "failed" status means the response was not generated — check the error field on the response object for details.

Accessing the Response Text

The simplest way to get the model’s reply:
text = response.output_text
For more control, iterate over the output array:
for item in response.output:
    if item.type == "message":
        for content in item.content:
            if content.type == "output_text":
                print(content.text)
When the model calls a function, the output includes a function_call item:
for item in response.output:
    if item.type == "function_call":
        print(f"Function: {item.name}")
        print(f"Arguments: {item.arguments}")

Error Responses

Errors follow the same format as Chat Completions:
{
  "error": {
    "message": "Invalid model: 'gpt-999'.",
    "type": "invalid_request_error",
    "code": "model_not_found"
  }
}
HTTP statusTypeCommon causes
400invalid_request_errorBad parameters, invalid model, context too long
401authentication_errorMissing or invalid API key
429rate_limit_errorToo many requests or insufficient balance
500server_errorUpstream provider error
See the Errors page for the full list and handling guidance.