Responses API
Use POST /v1/responses for typed input and output items, function-call continuations, and the newest OpenAI-compatible response shape.
On this page 1 of 6
Request#
For a single text turn, input can be a string:
from getpass import getpass
from openai import OpenAI
client = OpenAI(
base_url="https://api.keirolabs.ai/v1",
api_key=getpass("Keiro API key: "),
)
response = client.responses.create(
model="eb1-preview",
input="Give three practical uses for structured outputs.",
)
print(response.output_text)
{
"model": "eb1-preview",
"input": "Explain token buckets in one sentence."
}
For multimodal or multi-turn work, send an array of typed message, text, image, function-call, and function-output items. Put stable application instructions in instructions.
Response#
OpenAI-compatible SDKs expose response.output_text as a convenience. In raw JSON, inspect output in order and read assistant output_text content parts. The same array can contain function-call and other structured output items.
For tool continuation, resend the complete conversation items, including the model's function_call and your matching function_call_output. Stateful previous_response_id continuation is not a portable public eb1 contract.
Supported controls#
The current Responses surface supports documented input and instructions plus controls including metadata, text response format, function tools and tool choice, parallel tool calls, streaming, maximum output tokens, sampling and stop controls, reasoning, user attribution, include controls, service tier, prompt-cache key, truncation, and idempotency.
Strict validation rejects unknown fields. JSON mode and JSON Schema structured output are not currently supported.
Streaming#
Set stream to true to receive typed server-sent events. Assemble text from response.output_text.delta, process structured items by their output index, and finish only after response.completed or response.incomplete.
from getpass import getpass
from openai import OpenAI
client = OpenAI(
base_url="https://api.keirolabs.ai/v1",
api_key=getpass("Keiro API key: "),
)
stream = client.responses.create(
model="eb1-preview",
input="Write a short haiku about reliable APIs.",
stream=True,
)
for event in stream:
if event.type == "response.output_text.delta":
print(event.delta, end="", flush=True)
The request's reasoning effort also selects the stream's documented time entitlement — how long a run may take before it is stopped with a truthful response.incomplete. See Streaming for the per-effort table, and Streaming for the event taxonomy and in-band errors.
Tools and images#
- Responses function tools use flat
nameandparametersfields and returnfunction_calloutput items; see Tool calling. - Images use
input_imageparts; see Images and vision.