POST /v1/responses
POST /openai/v1/responses
OpenAI Responses API — newer alternative to Chat Completions with a unified
response object, native tool handles, and built-in reasoning state.
Works with all supported model families: Gemini, GPT and Claude.
How it works per model family
| Model family | Behavior |
|---|---|
GPT (gpt-6.1-sol, gpt-6.1-terra, …) |
Native Responses API with tool, streaming and reasoning support. |
Gemini (gemini-*) |
Transparently translated to/from Chat Completions internally. |
Claude (claude-*) |
Transparently translated to/from Chat Completions internally. |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
model |
string | Yes | Any supported model ID |
input |
string or array | Yes | User input (string for simple, array for multi-turn) |
instructions |
string | No | System instructions |
stream |
boolean | No | Enable SSE streaming (default: false) |
tools |
array | No | Function definitions for tool use |
temperature |
number | No | Sampling temperature |
max_output_tokens |
integer | No | Maximum output tokens |
top_p |
number | No | Nucleus sampling |
Input format
Simple string:
{"model": "gpt-5.6-terra", "input": "Write hello world in Python"}
Multi-turn conversation:
{
"model": "gpt-5.6-terra",
"input": [
{"type": "message", "role": "user", "content": [{"type": "input_text", "text": "What is 2+2?"}]},
{"type": "message", "role": "assistant", "content": [{"type": "output_text", "text": "4"}]},
{"type": "message", "role": "user", "content": [{"type": "input_text", "text": "Now multiply by 3"}]}
],
"instructions": "You are a math tutor."
}
With tool calls:
{
"model": "gpt-5.6-terra",
"input": [
{"type": "message", "role": "user", "content": [{"type": "input_text", "text": "Weather in NYC?"}]},
{"type": "function_call", "name": "get_weather", "call_id": "call_1", "arguments": "{\"city\":\"NYC\"}"},
{"type": "function_call_output", "call_id": "call_1", "output": "{\"temp\":72,\"condition\":\"sunny\"}"}
],
"tools": [
{"type": "function", "name": "get_weather", "description": "Get weather", "parameters": {"type": "object", "properties": {"city": {"type": "string"}}}}
]
}
With images:
{
"model": "gemini-3.1-pro",
"input": [
{"type": "message", "role": "user", "content": [
{"type": "input_text", "text": "Describe this image"},
{"type": "input_image", "image_url": "https://example.com/photo.jpg"}
]}
]
}
Examples
Python (OpenAI SDK)
from openai import OpenAI
client = OpenAI(
base_url="https://gateway.api429.com/v1",
api_key="YOUR_API_KEY",
)
# Simple request
resp = client.responses.create(
model="gpt-5.6-terra",
input="Write a Python function to sort a list",
)
print(resp.output_text)
Python (Streaming)
stream = client.responses.create(
model="gpt-5.6-terra-high",
input="Explain quantum computing in simple terms",
stream=True,
)
completed = False
for event in stream:
if event.type == "response.output_text.delta":
print(event.delta, end="", flush=True)
elif event.type in {"response.failed", "response.incomplete", "error"}:
raise RuntimeError("Generation failed or is incomplete; preserve partial output")
elif event.type == "response.completed":
completed = event.response.status == "completed"
if not completed:
raise RuntimeError("Stream ended without a completed response")
Python (With tools)
resp = client.responses.create(
model="gemini-3.1-pro",
input="What is the weather in London?",
tools=[{
"type": "function",
"name": "get_weather",
"description": "Get current weather",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
},
}],
)
for item in resp.output:
if item.type == "function_call":
print(f"Call: {item.name}({item.arguments})")
cURL (non-streaming)
curl https://gateway.api429.com/v1/responses \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.6-terra",
"input": "Hello!",
"stream": false
}'
cURL (streaming)
curl -N https://gateway.api429.com/v1/responses \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.6-terra",
"input": "Write a hello world in Rust",
"stream": true
}'
Non-streaming Response
{
"id": "resp_abc123",
"object": "response",
"created_at": 1712345678,
"status": "completed",
"model": "gpt-5.6-terra",
"output": [
{
"id": "msg_def456",
"type": "message",
"role": "assistant",
"content": [
{"type": "output_text", "text": "Here is the code..."}
]
}
],
"usage": {
"input_tokens": 12,
"output_tokens": 45,
"total_tokens": 57
}
}
Streaming Events (SSE)
When stream: true, the server sends SSE events:
event: response.created
data: {"type":"response.created","response":{"id":"resp_abc","status":"in_progress"},"sequence_number":1}
event: response.output_item.added
data: {"type":"response.output_item.added","output_index":0,"item":{"id":"msg_1","type":"message","role":"assistant"},"sequence_number":2}
event: response.output_text.delta
data: {"type":"response.output_text.delta","output_index":0,"delta":"Hello","sequence_number":3}
event: response.output_text.delta
data: {"type":"response.output_text.delta","output_index":0,"delta":" world","sequence_number":4}
event: response.completed
data: {"type":"response.completed","response":{"id":"resp_abc","status":"completed","usage":{...}},"sequence_number":10}
data: [DONE]
Event types:
| Event | Description |
|---|---|
response.created |
Stream started |
response.in_progress |
Processing |
response.output_item.added |
New message/reasoning/function_call item |
response.content_part.added |
New text content part |
response.output_text.delta |
Text chunk |
response.output_text.done |
Text content finished |
response.reasoning_summary_text.delta |
Reasoning/thinking chunk |
response.function_call_arguments.delta |
Tool call arguments chunk |
response.function_call_arguments.done |
Tool call complete |
response.output_item.done |
Item finished |
response.completed |
Stream done, includes usage |
response.failed / response.incomplete / error |
Failed or incomplete generation; do not treat partial output as success |
Image Generation via Responses API
GPT models can generate images through the image_generation tool in
the Responses API. The gateway fulfils the tool call through the
dedicated GPT Image route and returns a base64 image.
resp = client.responses.create(
model="gpt-6.1-sol",
input="Draw a cute orange cat sitting on a windowsill",
tools=[{"type": "image_generation"}],
)
for item in resp.output:
if item.type == "image_generation_call":
import base64
with open("cat.png", "wb") as f:
f.write(base64.b64decode(item.result))
GPT Image 2
Use model:"gpt-image-2" for GPT Image workloads. It is served by the
dedicated GPT Image path on both:
POST /v1/images/generationsPOST /v1/images/edits
Clients using the OpenAI SDK can point their existing Images API calls
at the API429 base URL and keep model:"gpt-image-2".
Text-to-image:
curl https://gateway.api429.com/v1/images/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2",
"prompt": "A cinematic product photo of a matte black espresso machine",
"size": "1024x1024",
"quality": "low",
"response_format": "b64_json"
}'
Image edit / reference image:
curl https://gateway.api429.com/v1/images/edits \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "model=gpt-image-2" \
-F "prompt=Replace the background with a clean white studio backdrop" \
-F "image=@product.png;type=image/png" \
-F "size=1024x1024" \
-F "quality=low" \
-F "response_format=b64_json"
Supported edit upload formats: PNG, JPEG and WebP. A request may include
multiple image form fields and an optional mask image. Transparent
backgrounds are currently unsupported. Use opaque or auto.
When a supported non-GPT image model is requested with mask, API429 routes
the edit to gpt-image-2. The response model is the effective
model and api429.requested_model records the original selection; GPT Image 2
pricing applies. JSON /v1/images/generations requests with an inline
base64/data-URI source image (or images / reference_images) and mask
use the same edit route; remote files should use multipart upload. Mask and
first source must be valid PNG images with matching dimensions, and the mask
must have an alpha channel. Invalid masks, unavailable image generation, and
unsupported transparency fail before a successful-generation charge; masked
requests never fall back to Gemini.
Both generation and edit endpoints forward size, quality, background,
output_format (png, jpeg, webp), and output_compression (0–100).
The requested tool model is explicitly gpt-image-2, not an alias for Gemini
or GPT Image 2.5. xhigh/max and unverified image model IDs are rejected
rather than charged using the old auto tariff.
The default image reasoning effort is medium.
response_format:"url" currently returns a data URI, not an externally
hosted download link. Its MIME type is detected from the generated bytes.
Use b64_json for SDK integrations that require raw base64. The optional
api429.outputs metadata reports actual dimensions and format; any observed
difference from requested parameters appears in api429.parameter_mismatches.
The result can have a different size; API429 does not silently resize art.
All attempts and all n images share one deadline (currently 250 seconds).
An ambiguous timeout returns 504 without automatic resubmission or Gemini
fallback. If an n>1 request has already produced images before another fails,
those images are returned and billed, with api429.warning.code set to
partial_image_batch; inspect failed_images before deciding what to retry.
The file field may be named either image or image[] (the name the
official OpenAI SDKs use when you pass a list of files); both accept several
files and may be mixed in one request.
API429's GPT Image 2 tariff is an estimate, not a pass-through of measured
OpenAI image token usage. The existing prices are unchanged: estimated text
input, a fixed high-fidelity equivalent per input image/mask, and the output
table below with size multipliers. Omitted/auto quality uses the high tariff.
The reference OpenAI token rates used to derive the tariff are:
| Component | Reference token rate |
|---|---|
| Text input | $5.00 / 1M tokens |
| Cached text input | $1.25 / 1M tokens |
| Image input | $8.00 / 1M tokens |
| Cached image input | $2.00 / 1M tokens |
| Image output | $30.00 / 1M tokens |
For convenience, OpenAI's image calculator gives these approximate output prices for common GPT Image 2 sizes:
| Quality | 1024x1024 | 1024x1536 | 1536x1024 |
|---|---|---|---|
low |
$0.006 | $0.005 | $0.005 |
medium |
$0.053 | $0.041 | $0.041 |
high |
$0.211 | $0.165 | $0.165 |
The response identifies this pricing basis as
api429.billing.basis:"api429_estimate". api429.provider_usage preserves
reported mainline Responses usage separately from image-tool usage. Missing
usage is null, not zero; mainline output tokens are not image output tokens.
Do not use these counters as a wallet receipt. Prices and per-token discounts
continue to be applied by the existing billing system. For smoke tests and
drafts, use quality:"low" and a 1024-class size.
image_generation calls through /v1/responses are charged once
at the same GPT Image 2 tariff. Earlier versions omitted the image charge on
that early-return path; this release closes that accounting gap. This does not
retroactively debit old requests. Failed calls do not create a successful image
charge, and reported mainline usage is not billed again as image output usage.
GPT Image 2.5
gpt-image-2.5-flare and gpt-image-2.5-sunburst generate images on
POST /v1/images/generations. The model ID selects the rendering mode:
Flare is the fast mode, Sunburst the thinking mode. There is no separate
quality switch, and a request always renders in the mode its ID names.
curl https://gateway.api429.com/v1/images/generations \
-H "Authorization: Bearer $API429_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2.5-flare",
"prompt": "A paper boat on a calm lake at sunset",
"size": "1536x1024",
"response_format": "b64_json"
}'
| Parameter | Behavior |
|---|---|
prompt |
Required. |
size / aspect_ratio |
Set the shape: 1024x1024 is square, 1536x1024 is 3:2, 1024x1536 is 2:3, and any other WIDTHxHEIGHT uses the nearest supported ratio. The model chooses the pixel dimensions (a square image is 1254×1254), so they do not match size exactly. |
n |
1–8. Each image is a separate generation and is billed separately. |
image / images / reference_images |
Up to 10 reference images in total, as data URIs or URLs. |
response_format |
b64_json, or url, which returns a data URI as for the other image models. |
Not supported on these models: quality, background, output_format
other than PNG, output_compression, mask, moderation and streaming. These
fields are currently ignored rather than rejected, and the output is always
PNG. /v1/images/edits does not accept these models; to pass reference
images, send them in images on /v1/images/generations.
Each image is billed at a fixed price, whatever its size: Flare at OpenAI's medium-quality 1024×1024 rate for GPT Image 2.5 ($0.053, $0.0159 API429 standard) and Sunburst at the high-quality rate ($0.211, $0.0633). A per-client billing profile may change the discount.
Gemini Batch Images
Gemini image batches are async/non-realtime jobs for large image runs. The public submit flow follows the OpenAI-compatible Files + Batch pattern:
curl https://gateway.api429.com/v1/files \
-H "Authorization: Bearer YOUR_API_KEY" \
-F purpose="batch" \
-F file="@batchinput.jsonl"
curl https://gateway.api429.com/v1/batches \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input_file_id": "file_abc123",
"endpoint": "/v1/responses",
"completion_window": "24h",
"metadata": {"job": "nightly-image-generation"}
}'
Official OpenAI-compatible Phase 1 rows target /v1/responses and request the
image_generation tool:
{"custom_id":"row-000001","method":"POST","url":"/v1/responses","body":{"model":"gemini-3.1-flash-image","input":"studio product photo of a red ceramic mug","tools":[{"type":"image_generation"}]}}
Reference images (image editing / compose) are supported via input_image
content parts. Inline the image as a data: URI (base64) or use a gs://
URI; external http(s) URLs are rejected at submit because batch workers
cannot fetch them at execution time:
{"custom_id":"row-000002","method":"POST","url":"/v1/responses","body":{"model":"gemini-3.1-flash-image","input":[{"role":"user","content":[{"type":"input_text","text":"replace the mug logo with the one from the reference"},{"type":"input_image","image_url":"data:image/png;base64,iVBORw0KGgo..."}]}],"tools":[{"type":"image_generation"}]}}
/v1/images/generations in batch JSONL is an API429 extension only; it is not
an official OpenAI Batch endpoint. If you use the API429 image edits extension,
prefer JSONL-friendly image_url inputs rather than inline base64. The official
Phase 1 endpoint remains /v1/responses.
Batch limits and behavior:
| Area | Contract |
|---|---|
| Runtime | Async/non-realtime. OpenAI-compatible completion_window is 24h; Google may queue jobs for capacity for up to 72h. |
| Output size | Google batch image output is 1K only. Do not submit unsupported 2K/4K batch image requests. |
| Input file | JSONL uploaded with purpose=batch; default size limit is 1GB. |
| Billing | API429 reserves balance at submit, charges completed rows only, and releases failed rows. Batch image price is 50% of the configured realtime image unit price, or the account’s configured batch image rate. |
| Storage | Completed outputs are exposed through API429 file IDs; generated image artifacts include CDN URLs when present. |
| Access | Batch image generation requires separate permission from realtime image generation. |
Quickstart: the first request · Models and prices · Get an API key