Responses API
Use Responses-compatible SDKs and Codex with streaming and client-executed tools.
On this page
Create a responseStreaming eventsTool round tripsImages & visionConversation storageSupported featuresCreate a response
POST/v1/responsesUse the same key and exact text-model IDs as Chat Completions. Send input as a string or an array of conversation items, and use instructions for the current turn’s system instructions.
from openai import OpenAI
client = OpenAI(base_url="https://api.cheapai.gay/v1", api_key="YOUR_API_KEY")
response = client.responses.create(
model="gpt-6.1-sol",
input="Say hello.",
store=False,
)
print(response.output_text)The response contains an output array of message, reasoning, or tool-call items, plus input/output token usage. Reasoning effort uses reasoning: {"effort": "low"}. Image requests use reported upstream token counts when available; otherwise usage is estimated.
Streaming events
Set stream: true to receive named server-sent events with increasing sequence numbers.
with client.responses.stream(
model="gpt-6.1-sol", input="Say hello.", store=False
) as stream:
for event in stream:
if event.type == "response.output_text.delta":
print(event.delta, end="", flush=True)
response = stream.get_final_response()| Event | Purpose |
|---|---|
response.created / in_progress | Start of the response |
response.output_item.added / done | Lifecycle of each output item |
response.output_text.delta / done | Incremental text and its completed value |
response.function_call_arguments.delta / done | Function argument JSON |
response.custom_tool_call_input.delta / done | Exact raw input for custom tools |
response.reasoning_summary_text.delta / done | Reasoning text when supplied by the model |
response.completed | Successful final output and usage |
response.failed / error | Generation failed; do not treat it as completed |
Responses streaming finishes with response.completed. Check this event before executing a completed turn’s tools.
Tool round trips
Responses function definitions place name, description, and parameters directly on each tool. Your application executes tools; the API returns their requested arguments.
history = [{"role": "user", "content": "What time is it in Auckland?"}]
tools = [{
"type": "function", "name": "gettime",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"],
"additionalProperties": False,
},
}]
response = client.responses.create(
model="gpt-6.1-sol", input=history, tools=tools, store=False
)
history.extend(response.output)
for item in response.output:
if item.type == "function_call":
history.append({
"type": "function_call_output",
"call_id": item.call_id,
"output": '{"time":"14:30"}',
})
response = client.responses.create(
model="gpt-6.1-sol", input=history, tools=tools, store=False
)Preserve every call ID and return one matching result for every call. Custom text tools use custom_tool_call and custom_tool_call_output; their input preserves raw text and line breaks. Namespaced tool definitions are also accepted. Custom grammar is passed as guidance; your harness validates it before execution.
Images & vision
Choose a model with vision: true from /v1/models using your own key. Currently verified: Claude Opus 5, Gemini 3.8 Flash, DeepSeek V4.1 Flash, and GPT-6.1 Sol on the normal route.
response = client.responses.create(
model="claude-opus-5",
input=[{"role": "user", "content": [
{"type": "input_text", "text": "Describe this image."},
{"type": "input_image", "image_url": "data:image/png;base64,BASE64_IMAGE"},
]}],
store=False,
)
print(response.output_text)Chat Completions accepts image_url blocks with {"url": "data:image/png;base64,..."}. Messages accepts image blocks with source.type set to base64 and matching media_type and data, or url with a public HTTPS URL. Responses accepts input_image. Public HTTPS URLs are downloaded and validated before generation.
Use the Playground attachment button to upload images. Integration downloads advertise image support only for verified Vision models; refresh the configuration after changing nodes.
Conversation storage
For stateless requests, use store: false and replay the full input and output history. Codex uses this mode.
With store: true (the default), a completed response can be fetched or deleted with GET or DELETE /v1/responses/{id}. Continue with previous_response_id and new input using the same key and model. Supply any instructions needed for the new turn again.
Supported features
| Feature | Support |
|---|---|
Text input and output | Supported |
HTTP streaming and reasoning effort | Supported |
Function, custom text, and namespaced tools | Supported; executed by your client |
Previous response IDs, retrieval, deletion | Supported for stored responses owned by your key |
Web search | Supported; see the Web search guide |
Hosted file search and computer use | Not supported |
Image input | Supported for models with vision: true on your selected node |
Audio, structured output, encrypted reasoning | Not supported on this endpoint |
Background jobs, WebSockets, remote compaction | Not supported |
max_output_tokens | Not supported; omit this parameter |
Use the Codex setup guide to configure its supported HTTP transport.