Ampersand developer documentation
Responses API
Agents API guide · View as Markdown
Generate a response, then decide what your app does next.
At a glance
Send a prompt to POST /v1/responses with your API key. Read the answer from the response. If the model asks to call a function, run it in your app and send the result in a follow-up request.
New to the API? Send your first request.
To continue a conversation, send the previous messages and output items with your next request. If your account supports saved responses, you can send the previous response ID instead. See Continue a conversation for both examples.
For chat, use send_message and pass. This follows the Agents API guide: the model calls send_message to post a reply, or pass to stay quiet. Your application declares and handles both tools. See Chat actions for the complete pattern.
| Setting | Value |
|---|---|
| Base URL | https://ampersand.humansand.ai/v1 |
| Create a response | POST /responses |
| Supported model | ampersand-v0.1 |
| Input and output | Text, function calls and results, encrypted reasoning |
| Reasoning effort | low, medium, high, max; high is the default and recommended setting |
| Default output token budgets | low: 8,192; medium / high: 16,384; max: 32,768, including reasoning |
| Client libraries | OpenAI Python SDK and Vercel AI SDK; supported Responses subset |
| Default storage option | store:true; no-content-storage accounts must send store:false |
Storage: Standard storage retains content even when
store:false. Your account policy determines whether standard storage or no-content-storage applies. See Storage and deletion for the scope and deletion rules.
For an existing OpenAI integration, check Compatibility before using options from the SDK.
Send your first request
Get an API key from your Ampersand contact or the developer console. Keep it on your server. The examples read it from AMPERSAND_API_KEY.
Start with a short text request. For a chat app that posts messages on behalf of the model, see Chat actions.
With curl
curl --fail-with-body https://ampersand.humansand.ai/v1/responses \
-H "Authorization: Bearer $AMPERSAND_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "ampersand-v0.1",
"input": "Write one short greeting.",
"store": false,
"max_output_tokens": 2048
}'Check the response's status before using the answer: HTTP 200 can also contain a failed or incomplete response. Keep the returned id for deletion and support.
With Python
Add the SDK to your project:
uv add openaiimport asyncio
import os
from openai import AsyncOpenAI
async def main() -> None:
async with AsyncOpenAI(
api_key=os.environ["AMPERSAND_API_KEY"],
base_url="https://ampersand.humansand.ai/v1",
max_retries=0,
timeout=1000.0,
) as client:
response = await client.responses.create(
model="ampersand-v0.1",
input="Write one short greeting.",
store=False,
max_output_tokens=2048,
)
print("Response ID:", response.id)
if response.status != "completed":
raise RuntimeError(
f"Response {response.id}: {response.status}; "
f"error={response.error}; "
f"incomplete={response.incomplete_details}"
)
print(response.output_text)
asyncio.run(main())output_text is an SDK convenience property. The HTTP response carries text in output items. In a server application, keep one client open and reuse it. Close it when the application stops.
Disable automatic retries unless you use a stable retry key. A UUID v4 Idempotency-Key prevents a second generation on your account. Repeats return 409 duplicate_request; they do not replay the result. Without a key, another POST can start another generation and incur another charge. See Errors and retries.
Chat actions: send_message and pass
Ampersand is trained to act in chat through function tools. Use the same action pattern as the Agents API guide:
| Action | Application behavior |
|---|---|
send_message |
Check access, post the message to the current conversation, and record the delivery result. |
pass |
Post nothing. Record the tool result and wait for the next incoming message. |
Declare both tools on each request. They are application functions; the Responses API does not install or execute them. Only your send_message handler publishes a message. Ordinary assistant text is separate API output, even when it appears beside a tool call.
Declare other chat actions, such as reactions or sharing links, as tools too. Do not ask the model to encode actions as <message>, <reaction … />, or <noop /> text.
Request and handle one action
Keep a separate history for each conversation and process its messages in order. Reuse the client from the quickstart, with automatic creation retries disabled.
Save the response before you post a message. If delivery fails, retry your deliver_message(content, receipt) callback with the same receipt. The callback checks access to the conversation, posts the message once, and returns its ID.
import json
from collections.abc import Awaitable, Callable
from typing import cast
from openai import AsyncOpenAI
from openai.types.responses import (
FunctionToolParam,
Response,
ResponseInputItemParam,
)
CHAT_TOOLS: list[FunctionToolParam] = [
{
"type": "function",
"name": "send_message",
"description": "Send one message to this chat. Other text is not delivered.",
"strict": False,
"parameters": {
"type": "object",
"properties": {"content": {"type": "string", "minLength": 1}},
"required": ["content"],
"additionalProperties": False,
},
},
{
"type": "function",
"name": "pass",
"description": "Stay quiet when no useful action is needed. Call pass alone.",
"strict": False,
"parameters": {
"type": "object",
"properties": {},
"required": [],
"additionalProperties": False,
},
},
]
CHAT_INSTRUCTIONS = (
"You are Ampersand, the assistant in this conversation. "
"Use send_message when you have something useful to contribute. "
"Use pass when no message is needed. Choose one action. "
"Plain text outside these tools is not delivered to chat."
)
async def request_chat_action(
client: AsyncOpenAI,
history: list[ResponseInputItemParam],
) -> Response:
return await client.responses.create(
model="ampersand-v0.1",
input=history,
instructions=CHAT_INSTRUCTIONS,
tools=CHAT_TOOLS,
parallel_tool_calls=False,
tool_choice="auto",
store=False,
)
async def complete_chat_action(
response: Response,
history: list[ResponseInputItemParam],
deliver_message: Callable[[str, str], Awaitable[str]],
) -> list[ResponseInputItemParam]:
if response.status != "completed":
raise RuntimeError(f"Response {response.id}: {response.status}")
calls = [item for item in response.output if item.type == "function_call"]
if len(calls) != 1 or calls[0].name not in {"send_message", "pass"}:
raise RuntimeError("Expected one send_message or pass call; nothing posted")
call = calls[0]
arguments = json.loads(call.arguments)
if call.name == "send_message":
receipt = f"{response.id}:{call.call_id}"
message_id = await deliver_message(arguments["content"], receipt)
result = json.dumps({"message_id": message_id})
else:
result = "Passing."
return [
*history,
*(cast(ResponseInputItemParam, item.to_dict()) for item in response.output),
{"type": "function_call_output", "call_id": call.call_id, "output": result},
]For each incoming message:
- Append a user message to your saved history, for example
{"role":"user","content":"Maya: Ampersand, can you help?"}. Save that input. - Call
request_chat_action(client, history)and save the returned response before delivery. - Call
complete_chat_action(response, history, deliver_message)with that same input history. Save the new history it returns. - Wait for the next incoming message. The saved history now contains every output item and the matching tool result, before the next user message.
For a delivery retry, reuse the saved response, its original input history, and the same receipt. Do not create a new response to retry the delivery. A new generation has new IDs and can choose another action. This example leaves durable storage and chat delivery to your application.
This example uses tool_choice: "auto", so the model can finish without calling a tool. To require one of the two chat actions, use tool_choice:"required" with parallel_tool_calls:false. It does not accept the Agents setting agent.ampersand.allow_silent_completion. If a response has no expected call, the example raises an error and posts nothing. Empty output is not an explicit pass result.
Do not make another generation just to acknowledge a completed send_message or pass. Save its result and include it with the next incoming message. For saved continuation, send the matching function_call_output before the new user message in input, with previous_response_id. Repeat the instructions and tools on that request.
Responses messages do not accept the Agents message metadata fields. You can put readable sender and channel context in the message text. Keep routing and access checks in your application; text is not proof of a sender's identity or permission.
Authentication and endpoints
Use HTTPS and these headers for JSON requests:
Authorization: Bearer <your API key>
Content-Type: application/jsonResponses does not require the Agents API's OpenAI-Beta: agents=v1 header. Your key identifies your account. Request fields cannot change the account or its retention policy.
For safe creation retries, use a stable UUID v4 Idempotency-Key for one logical request. Use a new key for each new generation, including each tool-loop step. See Errors and retries.
Append the following paths to the base URL. Successful endpoint calls return HTTP 200. Creation can return a failed or incomplete response object with HTTP 200; always inspect its status.
| Method | Path | Request | Success body |
|---|---|---|---|
| POST | /responses |
ResponseRequest | Response or SSE events |
| GET | /responses/{response_id} |
No body | Saved Response |
| GET | /responses/{response_id}/input_items |
Pagination parameters | List of resolved public input items |
| DELETE | /responses/{response_id} |
No body | {"id":"resp_…","object":"response.deleted","deleted":true} |
Response IDs have the form resp_ followed by 32 lowercase hexadecimal characters. Use the ID returned by the service. Retrieval and input listing require a saved response under standard storage. Deletion also supports standard records created with store:false.
There is no endpoint to list all responses, create a hosted session, or run a background task. To request cancellation, close the active request. Work completed before cancellation can still incur a charge.
All reads and deletes verify current account access. They do not generate model output or require available inference credit. Service capacity limits can still apply.
Create request fields
POST /responses accepts the following fields. Unknown fields are rejected. Types are strict: use JSON booleans and numbers, not strings such as "false" or "2048".
| Field | Type / values | Meaning |
|---|---|---|
modelRequired | string | Use ampersand-v0.1. |
inputRequired | string | array<Message | FunctionCall | FunctionResult | ReasoningItem | ItemReference> | Required. A string becomes one user message. A list can contain messages, complete function calls with matching results, encrypted reasoning items, and stored output-item references. See Item types. |
instructionsOptional | string | null | Instructions for this generation. Omit or use null for none. A continuation does not inherit the parent request’s top-level instructions; supply them again when needed. |
storeOptional | boolean | Default true. Under standard storage, true enables retrieval, saved continuation, and stored output-item references. Both values retain standard payloads until deletion. No-content-storage accounts must explicitly use false; omission and true return 400. null is rejected. |
previous_response_idOptional | string | null | Optional ID of a completed, saved, compatible response on the same account. Send only the new input. Available under standard storage only. See Continuation. |
streamOptional | boolean | Default false. Set true for ordered server-sent events. Content arrives after generation and validation, not token by token during inference. |
toolsOptional | array<FunctionTool> | Function definitions within the schema byte budget. Accepts flat Responses definitions or nested Chat Completions function definitions. Default []. Each function defaults to strict:false. Names must be unique. defer_loading:false is accepted; true is unsupported. |
textOptional | object | null | Choose plain text (default), a JSON object, or a JSON object that matches a schema. Set verbosity to "low", "medium", or "high" to guide the level of detail. See Text and JSON output. |
parallel_tool_callsOptional | boolean | null | Defaults to true; null also enables parallel calls. A generation can return up to 128 complete function calls. Explicit false limits generation to one call. |
tool_choiceOptional | "auto" | "none" | "required" | object | Use "auto" (default) to let the model choose, "none" to disable calls, or "required" to require a call. To select one function, pass its type and name. See Function tools. |
max_output_tokensOptional | integer | null | Positive integer from 1 to 999,999. The prompt and output budget must fit the model context, including the reserve when compaction is enabled. Omit this field or use null for the effort default. The budget includes reasoning, visible text, and function arguments. See Reasoning effort. |
reasoningOptional | ReasoningOptions | null | Optional object. effort accepts low, medium, high, or max. High is the default and recommended setting. An empty object, null, or an omitted field uses high. summary accepts null, auto, or detailed, but returned summaries remain empty. |
includeOptional | array<"reasoning.encrypted_content"> | Omit, use [], or use ["reasoning.encrypted_content"]. Encrypted reasoning is already returned when produced; this option does not change that behavior. |
userOptional | string | null | End-user identifier that some gateways send. A string of at most 200 characters, or null. Accepted and not used: it does not change ownership, limits, billing, or output, and the response does not return it. |
safety_identifierOptional | string | null | End-user identifier that some gateways send. A string of at most 200 characters, or null. Accepted and not used: it does not change ownership, limits, billing, or output, and the response does not return it. |
prompt_cache_keyOptional | string | null | Optional hint for requests from one chat. Use the same value for every request in a chat and a different value for each chat. It can improve cache reuse but does not guarantee it. It does not change output or access. Cached input is billed at the cached-input rate. |
metadataOptional | object | null | Accepts up to 16 string pairs for SDK compatibility. Keys can contain up to 64 characters and values up to 512. Metadata is ignored. |
service_tierOptional | string | null | Accepts standard service tier names for SDK compatibility. The endpoint uses its configured tier. |
Only fields marked nullable accept null. The schema appendix contains the full request JSON Schema. Requests must also meet the history, tool, and size rules in this guide.
Text and JSON output
Plain text is the default. For a JSON object, send {"text":{"format":{"type":"json_object"}}}. To check the final answer against a schema, use json_schema with a name and an object schema. The following request asks for an object with one required string field.
{
"model": "ampersand-v0.1",
"input": "Return the city named in this sentence: I live in Paris.",
"store": false,
"text": {
"format": {
"type": "json_schema",
"name": "city_lookup",
"schema": {
"type": "object",
"properties": {
"city": {
"type": "string"
}
},
"required": [
"city"
],
"additionalProperties": false
}
},
"verbosity": "low"
}
}Read JSON only from a completed text answer. An incomplete response can contain partial JSON. A tool call can arrive first. Run the function and send its result to continue. A completed text answer that fails schema validation produces invalid_model_output with error.param set to "output".
Use a Draft 2020-12 schema with an object at the root. Supported constraints include properties, required fields, array items, enums, numeric bounds, and acyclic local references. The schema size limit is 32 KiB before reference expansion. Unsupported keywords, including pattern and format, cause a 400 error. The service checks the final text against the schema for either value of strict.
text.verbosity guides the amount of detail. Use max_output_tokens to set the token budget.
The response object
JSON results and terminal SSE events use the same response object. The IDs, token counts, and encrypted value below are examples. Use the output returned by the service when you continue a conversation.
{
"id": "resp_11111111111111111111111111111111",
"object": "response",
"created_at": 1793620800,
"model": "ampersand-v0.1",
"status": "completed",
"output": [
{
"type": "message",
"role": "assistant",
"content": [
{
"type": "output_text",
"text": "Hello!",
"annotations": [],
"logprobs": []
}
],
"id": "msg_22222222222222222222222222222222",
"status": "completed"
},
{
"type": "reasoning",
"id": "rs_33333333333333333333333333333333",
"summary": [],
"encrypted_content": "opaque_encrypted_value_from_the_service"
}
],
"error": null,
"incomplete_details": null,
"usage": {
"input_tokens": 10,
"output_tokens": 6,
"total_tokens": 16,
"input_tokens_details": {
"cached_tokens": 0,
"cache_write_tokens": null
},
"output_tokens_details": {
"reasoning_tokens": null
}
},
"store": false,
"previous_response_id": null,
"parallel_tool_calls": false,
"tools": [],
"tool_choice": "auto",
"instructions": null,
"max_output_tokens": 2048,
"reasoning": null
}| Status | Meaning | Client action |
|---|---|---|
in_progress |
Work has started; used in early status events. | Continue reading. Do not use partial items as final output. |
completed |
Generation and output validation succeeded. It can contain a function call. | Read the answer or run the returned function in your application. |
incomplete |
The response stopped before the answer was complete. It may contain usable text. | Inspect incomplete_details. Output may contain incomplete assistant text, but no executable partial call or partial encrypted reasoning. |
failed |
Generation, validation, or a required service failed. | Read error. Do not treat the HTTP status alone as the result. |
| Field | Type / values | Meaning |
|---|---|---|
idRequired | string | Service-generated response ID. Keep it for retrieval, deletion, and support. |
objectOptional | "response" | Always response. |
created_atRequired | integer | Creation time as Unix seconds in UTC. |
modelRequired | string | The requested public model alias. |
statusRequired | "in_progress" | "completed" | "incomplete" | "failed" | in_progress, completed, incomplete, or failed. See the status table below. |
outputOptional | array<Message | FunctionCall | ReasoningItem> | Ordered output items: assistant messages, complete function calls, and encrypted reasoning when produced. Preserve all items for continuation. |
errorOptional | ResponseError | null | null, or an object with string type, code, and message, plus an optional param that identifies an invalid request field. Failed responses return an empty output list. |
incomplete_detailsOptional | IncompleteDetails | null | null, {"reason":"max_output_tokens"}, or {"reason":"invalid_model_output"}. |
usageOptional | ResponseUsage | null | Measured token usage, or null when unavailable or invalid. See Usage and billing. |
storeOptional | boolean | Controls retrieval through the API. Your account policy determines content retention. |
previous_response_idOptional | string | null | The parent ID supplied on the request, or null. |
parallel_tool_callsOptional | boolean | The effective parallel-call setting. True permits up to 128 calls; false permits at most one. |
toolsOptional | array<FunctionTool> | Function definitions supplied on the request. |
tool_choiceOptional | "auto" | "none" | "required" | object | The tool selection supplied on the request, or "auto" by default. |
textOptional | object | Output format and verbosity when the request uses nondefault text options. |
instructionsOptional | string | null | The request’s top-level instructions, or null. |
max_output_tokensOptional | integer | null | The resolved output budget for the generation. |
reasoningOptional | ReasoningOptions | null | The supplied reasoning options, or null. Null uses the default high effort; it does not disable thinking. |
If the response contains a function call, run the function and send its result in another request. See Function tools.
Input and output items
A string input is one user message. For a conversation, pass an ordered list of the item types below.
{
"model": "ampersand-v0.1",
"input": [
{"role": "developer", "content": "Keep answers brief."},
{"role": "user", "content": [{"type": "input_text", "text": "Explain a rainbow."}]}
],
"store": false
}Top-level instructions apply to the current generation and take priority over historical system and developer messages.
Every function call in a submitted batch needs exactly one matching result before the next message or call batch. Results may be supplied in any order. A request cannot end with an unanswered call. Call IDs must be unique. Message, function-call, and reasoning item IDs must also be unique. Keep all returned output items in their original order.
Message
| Field | Type / values | Meaning |
|---|---|---|
typeOptional | "message" | message. It can be omitted on input when role is present. |
roleRequired | Role | system, developer, user, or assistant. Returned messages use assistant. |
contentRequired | string | array<InputText | OutputText> | Input accepts a string or an array of text parts. Returned messages contain output_text parts. Images, files, and audio parts are not supported. |
idOptional | string | null | Optional on input; generated for output messages. Keep returned IDs unchanged. At most 100 characters. |
statusOptional | "completed" | "in_progress" | "incomplete" | null | Omit or use null on ordinary input. Replayed assistant items can be completed or incomplete. Input items with in_progress are rejected. Only assistant input may be incomplete. |
Input text part
| Field | Type / values | Meaning |
|---|---|---|
typeOptional | "input_text" | Always input_text. |
textRequired | string | Plain text supplied by your application. |
Output text part
| Field | Type / values | Meaning |
|---|---|---|
typeOptional | "output_text" | Always output_text. |
textRequired | string | Visible assistant text. |
annotationsOptional | array<JsonValue> | Always an empty array. |
logprobsOptional | array<JsonValue> | Always an empty array. |
Function call
| Field | Type / values | Meaning |
|---|---|---|
typeOptional | "function_call" | Always function_call. |
idOptional | string | null | Stable output item ID. Optional on input; at most 100 characters. The call_id binds the result. |
call_idRequired | string | Stable call ID. Match it in the next function result. From 1 to 100 characters. |
nameRequired | string | The registered function name. See Function tools. |
argumentsRequired | string | A JSON-encoded object, carried as a string. Parse it as JSON and use the complete validated call. |
statusOptional | "completed" | "in_progress" | Use complete output only. A replayed call must be completed. Stream placeholders with in_progress are not executable. |
Function result
| Field | Type / values | Meaning |
|---|---|---|
typeOptional | "function_call_output" | Always function_call_output. |
idOptional | string | null | Optional item ID, at most 100 characters. |
call_idRequired | string | Must match the pending function call. From 1 to 100 characters. |
outputRequired | string | array<input_text> | Text from your application. Multiple text parts are joined in order with a newline. Serialize structured data into text. There is no separate tool-result error flag. |
Encrypted reasoning item
| Field | Type / values | Meaning |
|---|---|---|
typeOptional | "reasoning" | Always reasoning. |
idRequired | string | Stable item ID, from 1 to 100 characters. Keep the returned ID. |
summaryOptional | array<JsonValue> | Empty array. Plaintext reasoning and reasoning summaries are not returned. |
encrypted_contentRequired | string | Opaque value returned by this service. Preserve it and its position in history. Do not decrypt, edit, or construct it. |
Stored output-item reference
| Field | Type / values | Meaning |
|---|---|---|
typeOptional | "item_reference" | Always item_reference. Input only; standard storage only. |
idRequired | string | Service-issued output ID from a completed saved response. The service checks ownership, deletion, model compatibility, and ordered history before use. Caller-assigned input IDs are not handles. |
Continue a conversation
Choose one history method. Each follow-up runs a new generation and has its own response ID and usage.
Send the full history
This works with both retention profiles. Append all returned output items to the input you sent. Then append the new user message. If your request used top-level instructions, send those instructions again as needed.
from openai import AsyncOpenAI
async def continue_with_history(client: AsyncOpenAI) -> str:
history = [{"role": "user", "content": "Explain rainbows in one sentence."}]
first = await client.responses.create(
model="ampersand-v0.1", input=history, store=False,
)
if first.status != "completed":
raise RuntimeError(f"First response: {first.status}")
history.extend(item.to_dict() for item in first.output)
history.append({"role": "user", "content": "Now explain that to a child."})
second = await client.responses.create(
model="ampersand-v0.1", input=history, store=False,
)
if second.status != "completed":
raise RuntimeError(f"Follow-up: {second.status}")
return second.output_textWhen you send the full history, use the output from the final response. Keep the items in order, including their call IDs and encrypted reasoning. Use the same account, model, and reasoning effort for the follow-up.
Effort is not inherited from a saved parent or private history. Send the same effort on each continuation request. To change effort, start with visible history and omit encrypted items, stored item references, and the saved parent. See Reasoning effort.
Encrypted reasoning expires after 30 days. A chain expires when its earliest item expires. An incompatible chain returns invalid_reasoning; an expired chain returns expired_reasoning. If you cannot restore a valid chain, remove the encrypted reasoning items and restart with visible history. Reasoning from another service or account cannot be used.
An incomplete assistant text item can be replayed as returned. It contains no partial encrypted reasoning and no executable partial function call.
Use a saved parent
This method requires standard storage. First create a response with store:true. For the follow-up, pass its id as previous_response_id and send only the new input. Do not also resend the complete parent history.
from openai import AsyncOpenAI
async def continue_with_saved_response(client: AsyncOpenAI) -> str:
first = await client.responses.create(
model="ampersand-v0.1",
input="Explain rainbows in one sentence.",
instructions="Use simple language.",
store=True,
)
if first.status != "completed":
raise RuntimeError(f"First response: {first.status}")
second = await client.responses.create(
model="ampersand-v0.1",
previous_response_id=first.id,
input="Make that shorter.",
instructions="Use simple language.",
store=True,
)
if second.status != "completed":
raise RuntimeError(f"Follow-up: {second.status}")
return second.output_textStart with a completed response that you saved under the same account and a compatible model. If you delete a response earlier in the chain, follow-ups that depend on it return 404. You can still retrieve a saved child by its own ID.
Supply current instructions and tool settings on each new request; they are not inherited as top-level options. The child has its own store setting and its own copy of resolved history. Deleting a parent does not erase those child copies.
Stored output-item references
Under standard storage, input can contain {"type":"item_reference","id":"<service-issued output ID>"} from a completed response saved with store:true. Missing, deleted, unowned, or store:false sources return 404 response_not_found. Stored reasoning must match the model and ordered conversation. A reference does not authorize omitted, substituted, or reordered history.
Deleting a source blocks new continuation and stops active dependent work. References are unavailable under no-content-storage. Use full history with encrypted reasoning in that profile.
Saved continuation uses retained history. The 30-day expiry of client-held encrypted reasoning does not expire a saved response. Deletion, model compatibility, and the other continuation checks still apply.
Function tools
The API returns function names and arguments for your application to execute. It does not run functions or hosted tools.
For chat delivery, start with send_message and pass. The weather example below shows a separate data lookup and a plain-text result.
Function definitions can use the flat Responses format or the Chat Completions wrapper {"type":"function","function":{"name":...,"parameters":...}}. Do not mix the two formats in one tool. Put defer_loading:false inside the function definition to select immediate loading; true is unsupported. The response lists functions in the flat format.
Each tool must have type:"function", a unique name, an object parameters schema, and strict:false (the default). parallel_tool_calls defaults to true; null also enables parallel calls. Set false to require at most one call. A generation can return up to 128 complete calls.
Use tool_choice:"required" to require at least one call from the functions in tools. To require a specific function, use {"type":"function","name":"get_weather"} as the value of tool_choice and include that function in tools. Set parallel_tool_calls:false with either choice to require exactly one call in a completed response. Validate the arguments before execution.
Give each function a name of 1 to 96 letters, digits, underscores, or hyphens. The API returns arguments as a JSON object. Validate the arguments against your schema before you run the function.
{
"model": "ampersand-v0.1",
"input": "What is the weather in Paris?",
"store": false,
"parallel_tool_calls": false,
"tool_choice": "auto",
"tools": [
{
"type": "function",
"name": "get_weather",
"description": "Get a weather report for one city.",
"strict": false,
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"],
"additionalProperties": false
}
}
]
}Return the result
Wait for a completed response. Preserve all its output items, including reasoning, then append a function_call_output with the matching call_id. The output field accepts a string or an array of {"type":"input_text","text":"..."} parts. Send the full history for the next generation, or send the result as new input with a saved parent ID.
import json
from openai import AsyncOpenAI
async def tool_round_trip(client: AsyncOpenAI) -> str:
tools = [{
"type": "function",
"name": "get_weather",
"description": "Get a weather report for one city.",
"strict": False,
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"],
"additionalProperties": False,
},
}]
history = [{"role": "user", "content": "What is the weather in Paris?"}]
first = await client.responses.create(
model="ampersand-v0.1", input=history, store=False,
tools=tools, parallel_tool_calls=False,
)
if first.status != "completed":
raise RuntimeError(f"Tool request: {first.status}")
calls = [item for item in first.output if item.type == "function_call"]
if not calls:
return first.output_text
history.extend(item.to_dict() for item in first.output)
for call in calls:
if call.name != "get_weather":
raise RuntimeError("Unexpected function")
arguments = json.loads(call.arguments)
# Validate every constraint in this example's schema before execution.
if (not isinstance(arguments, dict) or set(arguments) != {"city"}
or not isinstance(arguments["city"], str)):
result = {"error": "Expected exactly one string-valued city property."}
else:
# Example data only. Replace with your authorized function implementation.
result = {"city": arguments["city"], "forecast": "sunny"}
history.append({
"type": "function_call_output",
"call_id": call.call_id,
"output": json.dumps(result),
})
final = await client.responses.create(
model="ampersand-v0.1", input=history, store=False,
tools=tools, parallel_tool_calls=False, tool_choice="none",
)
if final.status != "completed":
raise RuntimeError(f"Tool follow-up: {final.status}")
return final.output_textThis lookup example uses tool_choice:"none" for a plain-text result. In a chat integration, keep send_message and pass registered with tool_choice:"auto" after a lookup. Handle the resulting chat action; do not post output_text. A larger application can run more tool rounds, with its own limits and authorization checks. Never execute arguments from an incomplete or failed response.
Supported JSON Schema subset
For a function’s parameters, the supported JSON Schema dialects are Draft 4, 6, 7, 2019-09, and 2020-12 (the default). Remote references and unbounded reference cycles are rejected.
If a call has a missing field or an invalid value, you can send a description of the problem as the function result. The model can use that feedback on the next request. See Limits for schema size and depth.
Streaming events
Set stream:true to receive text/event-stream. The stream sends early status events, then validated content, then one terminal response event.
Answer content is buffered. Status events arrive while the model runs. Text and function arguments arrive after generation, validation, and reasoning encryption succeed. SSE does not deliver answer tokens as the model produces them.
curl --no-buffer --fail-with-body https://ampersand.humansand.ai/v1/responses \
-H "Authorization: Bearer $AMPERSAND_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "ampersand-v0.1",
"input": "Explain rainbows in one sentence.",
"store": false,
"stream": true,
"max_output_tokens": 2048
}'Each event has an event: name and a JSON data: body. The JSON includes the same type and a zero-based, increasing sequence_number. IDs and output indexes remain consistent through the stream. SSE comments such as : heartbeat can arrive during a wait; they are not output events. The service sends a heartbeat after one second without an event.
| Event | Additional data |
|---|---|
response.created |
Initial response with status:"in_progress" |
response.in_progress |
In-progress response |
response.output_item.added |
item, output_index |
response.content_part.added |
part, item_id, output_index, content_index |
response.output_text.delta |
delta, item_id, output_index, content_index, empty logprobs |
response.output_text.done |
Complete text, item/content indexes, empty logprobs |
response.content_part.done |
Complete part, item/content indexes |
response.function_call_arguments.delta |
delta, item_id, output_index; arguments are already validated |
response.function_call_arguments.done |
Complete arguments, item_id, output_index |
response.output_item.done |
Complete item, output_index |
response.completed |
Final completed response |
response.incomplete |
Final response, with response.incomplete_details |
response.failed |
Final response, with response.error |
There are no plaintext reasoning delta events. Reasoning appears as an encrypted output item. A stream can omit content events, for example when a generation fails. Do not require a particular number of text chunks or assume the first output item is always a message.
The example below prints API text to a console. For chat, do not post text deltas. Wait for response.completed, then handle its complete send_message or pass call as shown in Chat actions.
from openai import AsyncOpenAI
async def stream_response(client: AsyncOpenAI) -> None:
stream = await client.responses.create(
model="ampersand-v0.1",
input="Explain rainbows in one sentence.",
store=False,
stream=True,
max_output_tokens=2048,
)
final = None
async with stream:
async for event in stream:
if event.type == "response.output_text.delta":
print(event.delta, end="", flush=True)
elif event.type in {
"response.completed", "response.incomplete", "response.failed"
}:
final = event.response
print()
if final is None:
raise RuntimeError("Stream closed without a terminal response")
if final.status != "completed":
raise RuntimeError(f"Response {final.id}: {final.status}; {final.error}")
# Keep final.output, not early stream placeholders, for continuation.Wait for the terminal event before you use the result or run a tool. If the connection closes first, the generation may still have run and incurred a charge. Streams cannot be replayed or resumed with Last-Event-ID. The terminal response event ends the stream; there is no [DONE] marker.
Storage and deletion
Your account policy determines how content is stored. The store request field controls retrieval through the API. Contact Ampersand to confirm which storage policy applies to your account.
| Behavior | Standard storage | No-content-storage |
|---|---|---|
store omitted |
Defaults to true; enables retrieval and saved continuation | Rejected with 400; send explicit false |
store:false |
Content retained; no retrieval through the API or saved continuation | User content is not retained by the Responses service; see the scope below |
store:true |
Enables retrieval, input listing, and saved continuation | Rejected with 400 |
previous_response_id |
Supported for a compatible completed saved parent | Rejected with 400 |
| Stored output-item references | Supported for completed saved responses, with ownership and history checks | Unavailable |
| Full-history continuation | Supported | Supported; keep encrypted reasoning in your application |
| Billing metadata | Retained separately | Retained separately |
| Earlier standard records | Remain until deleted | Changing the storage policy does not erase earlier records |
Standard retention
Standard storage keeps encrypted request and response content until deletion, including reasoning and content from failed requests. Records are not deleted automatically after a fixed period. This also applies to store:false and to records whose encrypted reasoning has expired.
Retrieval requires store:true and an available response object. A store:false record can be deleted by ID, but cannot be retrieved, listed as input, or used as a saved parent. Errors before generation do not create retrievable response objects.
No-content-storage scope
Under the no-content-storage policy, the Responses service does not retain your content. Model and moderation providers still process it, and the service keeps billing metadata. This is not an end-to-end zero-data-retention guarantee. Confirm the applicable retention terms with Ampersand.
This option must be enabled for your account. Setting store:false does not enable it.
Retrieve and delete
from openai import AsyncOpenAI
async def retrieve_and_delete(client: AsyncOpenAI, response_id: str) -> None:
saved = await client.responses.retrieve(response_id)
print(saved.id, saved.status)
await client.responses.delete(response_id)
print("Deleted:", response_id)The retrieval example requires store:true. To delete a standard store:false record, call client.responses.delete(response_id) directly. The Python SDK's delete method returns None on success and raises an exception on an HTTP error. The HTTP endpoint returns the JSON body below.
Deletion blocks further retrieval and saved continuation, and stops active requests that depend on the record. The success response is:
{"id":"resp_11111111111111111111111111111111","object":"response.deleted","deleted":true}Physical cleanup continues after the API response. deleted:true confirms that the API has blocked access. It does not confirm removal from all storage or backups. Retry a deletion that times out. The timeout does not restore access.
Deleting a parent blocks saved continuation through its descendants, but leaves their stored history copies in place. Saved child responses can still be retrieved and must be deleted separately. Copies in your application are also separate. Financial records keep their own retention rules. Keep response IDs for selective deletion. For records without a returned ID, or account-wide erasure, contact Ampersand.
If your account changes to no-content-storage, earlier standard records can still be deleted by ID with a valid API key. They can no longer be retrieved through the API. Changing the storage policy alone does not delete those records.
List saved input items
GET /responses/{response_id}/input_items returns the input used for a saved response, including any saved parent history. It does not expose plaintext reasoning.
| Query parameter | Accepted values |
|---|---|
limit |
Integer from 1 to 100. Default: 20. |
order |
asc or desc. Default: desc. |
after |
Continue after an item ID in the selected order. |
before |
Read the adjacent items before an item ID in the selected order. |
Use at most one of after and before. An unknown cursor, duplicate parameter, or unsupported query parameter returns 400. The result has object:"list", data, first_id, last_id, and has_more. An empty page has null first and last IDs. Items without an original ID receive stable IDs for pagination.
curl --fail-with-body \
"https://ampersand.humansand.ai/v1/responses/$RESPONSE_ID/input_items?limit=20&order=asc" \
-H "Authorization: Bearer $AMPERSAND_API_KEY"For forward pagination, keep the same order and use the previous page's last_id as after while has_more is true.
from openai import AsyncOpenAI
async def show_input_items(client: AsyncOpenAI, response_id: str) -> None:
page = await client.responses.input_items.list(
response_id, limit=20, order="asc",
)
async for item in page:
print(item.id, item.type)The SDK page iterator requests later pages as needed. Listing input items is not a way to obtain a response created with store:false.
Reasoning effort and output limits
Set reasoning.effort to low, medium, high, or max. High is the default and recommended setting. When you omit max_output_tokens, the selected effort sets the output budget.
| Effort | Default output tokens per generation |
|---|---|
low |
8,192 |
medium |
16,384 |
high (default, recommended) |
16,384 |
max |
32,768 |
The limit includes private reasoning, visible text, and function arguments. The model can finish before it reaches the limit. Max can use more tokens and take longer.
async def respond_with_max(client: AsyncOpenAI) -> str:
response = await client.responses.create(
model="ampersand-v0.1",
input="Check this argument carefully.",
reasoning={"effort": "max"},
store=False,
)
if response.status != "completed":
raise RuntimeError(f"Response: {response.status}")
return response.output_textYou can set max_output_tokens above the effort default. The largest field value is the context window minus one token, or 999,999 for ampersand-v0.1. Choose a smaller budget to leave room for your input and any compaction reserve. The budget applies to one generation.
Effort applies to the current request and is not inherited. Repeat it when continuing through encrypted reasoning, stored item references, or previous_response_id. A different effort returns invalid_reasoning. To change effort, start a new request with visible history and no encrypted items, stored references, or saved parent.
Limits and validation
These values apply to ampersand-v0.1. Account credit, policy, and capacity limits also apply.
| Limit | Reference value |
|---|---|
| Model context window | 1,000,000 tokens |
| Default output budget | 16,384 tokens (high) |
| Maximum requested output budget | 999,999 tokens before accounting for the prompt and compaction reserve. See Reasoning effort and output limits. |
| Encoded request body | 16 MiB (16,777,216 bytes) |
| Resolved history | 10,000 items, including saved parent history |
| Encrypted reasoning items in history | Within the same 10,000-item history budget |
| Function definitions | Bounded by schema bytes, with unique names |
| Combined serialized function parameters | 128 KiB total; 32 KiB per schema |
| Function parameters schema depth | 32 JSON object/array levels in the schema itself |
| Request-body upload time | 30 seconds, then 408 upload_timeout; parsing uses the whole request deadline |
| Whole request processing deadline | Up to 600 seconds, or up to 900 seconds with compaction |
| Client-held encrypted reasoning lifetime | 30 days; an earlier item can expire the chain |
The context window includes instructions, conversation history, tool definitions, and the output budget. Leave room for compaction when you set max_output_tokens.
Request size and item limits also apply, even when the conversation fits the token window.
Allow enough time to receive the answer. The Python quickstart sets a 1,000-second timeout to cover long requests and network delays.
Schema depth counts every JSON object and array in parameters, including containers such as properties and required. It is not the allowed nesting depth of function arguments.
If the model tries to call a function while tool_choice:"none" is in effect, the service discards that call and asks for a final answer with the remaining output tokens and time. The function does not run. The correction can add output tokens. The visible input counts once.
Check incomplete_details.reason before using a partial answer. If the model reached its token budget, the reason is max_output_tokens. If the service recovered usable text from an invalid plain-text answer, the reason is invalid_model_output. Only the recovered text is returned. Usage includes all generated tokens. An incomplete response has no new encrypted reasoning and cannot serve as a saved parent. If validation fails without recoverable text, the response fails.
Responses has its own request rate and capacity limits, in addition to shared account limits. Ask your Ampersand contact for the limits that apply to your account.
Compaction
For a long conversation, the API can summarize earlier messages to make room for the next answer. Compaction can happen before the context window is full. Output usage includes the accepted summary and the answer. The conversation and restored model output count once toward input usage.
Continue the conversation as usual. Send the full history, including encrypted reasoning items, or use a saved response ID. Compaction does not change how long the service keeps your messages. If you receive context_exceeded, shorten the input or lower max_output_tokens.
Usage and billing
Responses uses the same token pricing as the Agents API. Each request has its own usage and charge. The serving tokenizer counts caller instructions, visible messages, client tool definitions and tool results once per request. Internal rereads add no customer input. Rejected or unfinished summaries are not charged. A follow-up after a tool result is another request. Any costs for functions you run are separate from API charges.
| Usage field | Meaning |
|---|---|
input_tokens |
Request input tokens, including cached input and restored conversation context, capped at the measured prompt size |
input_tokens_details.cached_tokens |
Cached portion of input, or null when unknown; this is not added on top of input_tokens |
input_tokens_details.cache_write_tokens |
Currently returned as null |
output_tokens |
Measured output tokens, including reasoning |
output_tokens_details.reasoning_tokens |
Reasoning subset when available; otherwise null. Do not add it to output_tokens. |
total_tokens |
input_tokens plus output_tokens |
A saved or encrypted continuation counts restored model output once as input on the next request. Discarded generations and repeated internal reads add no input. Cache credit is capped at the request input count. A shared provider prefix can qualify a short prompt for the cached rate. When the provider omits cache detail, the API charges output only.
The whole usage value can be null when valid usage measurements are unavailable. Missing cache or reasoning detail is not the same as zero. No plaintext reasoning is returned with usage.
| Result | Charging behavior |
|---|---|
| Completed generation | Measured uncached input, cached input, and output at their applicable rates |
| Output-token limit | Measured usage, even though the response is incomplete |
| Client disconnect | Measured work when usage remains valid; a charge can still occur |
| Unknown cache detail | Measured output only; input is not guessed |
| Invalid or unavailable usage measurement | No estimated usage charge |
| Provider, validation, encryption, deadline, or server failure | Unbilled failed work |
A successful response can incur a charge even if the connection closes before you receive it. Reads and deletes require account access and can be rate-limited. They do not require inference credit or incur an inference charge.
Use your account's pricing agreement and usage statement for rates and totals.
Errors and retries
Pre-generation failures use an HTTP error status and this JSON shape:
{
"error": {
"type": "invalid_request_error",
"code": "invalid_request",
"message": "The request does not match the supported Responses contract."
}
}Once generation starts, an application failure can instead appear inside a response with status:"failed", or in response.failed on an SSE stream. JSON may still have HTTP 200. A transport failure after headers can close the connection without a terminal event.
| Code | HTTP status when reported as an HTTP error | Action |
|---|---|---|
invalid_request |
400; 413 for an oversized body | Check fields, types, tool settings, history, and size. |
access_denied |
401 or 403 | Check the key, product access, expiration, and account policy. |
insufficient_credit |
402 | Restore available account credit. |
response_not_found |
404 | Check account ownership, saved state, ID, and deletion. Missing and inaccessible records share this result. |
duplicate_request |
409 | This retry key was already claimed. Do not create a new key merely to retry uncertain delivery. Retrieve a saved result when available. |
capacity_exceeded |
429 or 503 | Reduce concurrency. When the response includes Retry-After, wait at least that many seconds before trying again. Follow the retry-key rules below. |
context_exceeded |
400 before generation; HTTP 200 failed response or SSE failure with compaction | Reduce input, tool definitions, or the output budget. Compaction cannot fit every request. |
moderation_blocked |
400 | The input was refused. Review the input instead of repeating it unchanged. |
invalid_reasoning |
400 | Restore the valid ordered chain, or restart from visible history without encrypted items. |
expired_reasoning |
400 | Restart from visible history without expired encrypted items. |
billing_unavailable |
503 | Required account or billing service is unavailable. |
storage_unavailable |
503 | Required response storage is unavailable. |
moderation_unavailable |
503 | The required input check is unavailable. |
key_service_unavailable |
503 | The service could not process encrypted reasoning. Try again later. |
provider_failed |
502 or 503 | A required model service is unavailable or failed. Try again later using the retry rules below. |
invalid_model_output |
502 | Output failed validation. In generation results, inspect the failed response. |
deadline_exceeded |
504 | The request exceeded its deadline. |
upload_timeout |
408 | The request body did not arrive within 30 seconds. No model work started and nothing is charged. Send the request again. If reusing the Idempotency-Key returns 409 duplicate_request, use a new key. |
A proxy can also return its own transport error or a plain not-found response for an unsupported path. Do not assume every failure body is a Response object.
Retry rules
- Use Python
max_retries=0or VercelmaxRetries:0unless every logical request has a stable random UUID v4Idempotency-Key. Reuse that key only for retries. Use a new key for every new generation or tool-loop step; never set one permanent key on a shared provider. - If delivery is uncertain, record the response ID and check a saved result when the account and
storesetting permit it. Retrieval is not a background status or replay endpoint. - Once the service claims a key, another request with that key returns
409 duplicate_request, even if you change the input or the first request fails. A429 capacity_exceededor402 insufficient_creditreply does not claim the key: retry with the same key afterRetry-Afteror after adding credit. The key prevents duplicate generation for at least one day. Use a new key for a new request. It can incur a new charge. - Correct invalid requests, expired reasoning, or account policy issues before resubmitting.
- Retry a timed-out deletion. Deletion does not create model work, and a timeout does not restore access.
For support, keep the response ID when available, approximate UTC time, model, HTTP status, and error code. Errors before generation may not include a response ID. Keep API keys and customer content out of diagnostic logs.
Compatibility with Agents and OpenAI clients
The Python examples use the OpenAI SDK. Ampersand supports the Responses features listed below. Other SDK options may be rejected.
| Area | Support |
|---|---|
| Execution | One answer per POST; enabled compaction can add summary calls. Your application runs the conversation and function loop. |
| Hosted Agents resources | No /agents or session resource is created. Agent/session IDs cannot be used as response IDs. |
| Authentication | Send your API key in the Authorization header. |
| Conversation input | Text and text messages; complete calls/results; encrypted reasoning; owned stored output references |
| Saved continuation | store:true and previous_response_id, for standard accounts only |
| Client history | Supported for both profiles; keep every returned output item |
| Reasoning | low, medium, high, max; high is the default and recommended setting. Summary options null, auto, and detailed are accepted; returned summaries remain empty. No plaintext reasoning input. |
| Tools | Custom functions only; strict:false by default; parallel_tool_calls defaults to true |
| Chat actions | Use application-defined send_message and pass, as in the Agents guide. Only the send handler posts to chat. |
| Tool selection | "auto", "none", "required", or a named function from tools. See Function tools. |
| Tool results | Parse the call's JSON-string arguments. Return a function_call_output with its call_id; no hosted turn ID or Agents event envelope. |
| Message context | No message metadata fields. Put readable context in text; enforce routing and access in your application. |
| Streaming | Ordered SSE with early status events and validated, buffered content |
| Output budget | Set max_output_tokens within the available context, or use the effort default. The budget includes reasoning. |
| Output format | Plain text, json_object, or json_schema, with optional text.verbosity. See Text and JSON output. |
| Sampling | Omit temperature and top_p at every supported reasoning effort. Supplying either field returns HTTP 400 and identifies the field in error.param. |
| Media | No image, file, audio, or video input/output |
| Hosted tools | No web search, file search, code interpreter, computer use, or MCP tool execution |
| Background work | No background, conversation IDs, webhooks, polling workflow, or cancel endpoint |
| Request extras | metadata, service_tier, user and safety_identifier are accepted and ignored. Unknown fields return 400. |
| Replay | No duplicate-generation replay, SSE resume, or portable reasoning from another service |
| Retry protection | UUID v4 Idempotency-Key; repeat claims return 409 without new generation or output replay |
Unknown JSON fields are rejected. Use the request table as the full list of accepted top-level fields.
Vercel AI SDK
Use createOpenAI from @ai-sdk/openai, then select provider.responses("ampersand-v0.1"). The example uses ai 7.0.162, @ai-sdk/openai 4.0.108, and Zod 4.3.6.
AI SDK 7 configures HTTP retries (maxRetries) and retries after streaming starts (streamRetries) separately. With stream retries enabled, text deltas from a failed attempt can remain visible while its replacement is generated. Use the SDK's final text and check finishReason before saving an answer as complete. A clean disconnect can yield interrupted even after text arrives.
When starting a new user turn after a multi-step tool loop in AI SDK 7, append ...(await result.responseMessages) to your existing history before adding the new user message. This works with both generateText and streamText. The messages in (await result.response).messages cover only the last step and can omit earlier tool calls and results, causing invalid_reasoning on the next turn.
With AI SDK 7, a client tool can declare outputSchema: readingSchema. To validate a lookup at runtime, return readingSchema.parse(await lookup(input)) from its execute callback. The declaration alone lets an out-of-schema value reach the model in a tool loop. Omit the tool's providerOptions.openai.outputSchema on these endpoints. That option sends output_schema, which the API rejects with HTTP 400.
Replay each assistant tool call with its original name, call ID, and arguments. A Zod transform, a stripped object key, or experimental_repairToolCall can change the replay and cause invalid_reasoning after the tool has already executed. Use a lossless SDK schema such as z.looseObject({city: z.string()}) and validate and normalize inside execute. For argument repairs, retain the original arguments for assistant history in prepareStep. With a saved parent, you can send previousResponseId and just that step’s tool results. Reuse results from callbacks that already ran when resuming a failed continuation.
For client tools with needsApproval: true, collect decisions for every pending call before invoking the SDK again. It can execute an approved callback before reporting a missing decision for another call. The simplest continuation uses the full history and omits previousResponseId, even for stored responses.
When using a saved parent, give the SDK the original history and approval decisions for local execution. In prepareStep, send the parent only the resulting tool-result parts for its pending call IDs in a tool message. Resending its original calls returns HTTP 400. Retain completed results before sending the request. Replaying a decision can execute the same toolCallId twice.
import { createOpenAI } from '@ai-sdk/openai';
import { generateText } from 'ai';
const provider = createOpenAI({
baseURL: 'https://ampersand.humansand.ai/v1',
apiKey: process.env.AMPERSAND_API_KEY,
});
const result = await generateText({
model: provider.responses('ampersand-v0.1'),
prompt: 'Write one short greeting.',
maxRetries: 0,
providerOptions: {
openai: { store: false, forceReasoning: true, reasoningEffort: 'high' },
},
});
console.log(result.text);Set forceReasoning:true so the adapter sends the selected effort for the Ampersand model name. reasoningEffort accepts low, medium, high, or max; use the same value throughout a tool loop.
This example sets store:false, so the response cannot be retrieved later. Your account’s storage policy still applies. If your account uses no-content-storage, send store:false on every request.
Standard accounts can use saved item references. Common Zod schemas can use the local references and combinations described in Function tools. Other adapter options must remain within the request contract.
The Vercel SDK does not create idempotency keys automatically. Keep maxRetries:0, or supply a fresh UUID v4 key for each logical HTTP generation and reuse it only for its retries. A fixed provider header is unsafe for a loop with several generations.
JSON Schema appendix
Use these JSON Schemas to check request and response fields. History, tool, storage, and size rules also apply; see the relevant sections above. All schemas are included in this file.
ResponseRequest JSON Schema
{
"$defs": {
"FunctionCall": {
"additionalProperties": false,
"properties": {
"type": {
"const": "function_call",
"default": "function_call",
"title": "Type",
"type": "string"
},
"id": {
"anyOf": [
{
"maxLength": 100,
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Id"
},
"call_id": {
"maxLength": 100,
"minLength": 1,
"title": "Call Id",
"type": "string"
},
"name": {
"maxLength": 96,
"minLength": 1,
"pattern": "^[a-zA-Z0-9_-]+$",
"title": "Name",
"type": "string"
},
"arguments": {
"title": "Arguments",
"type": "string"
},
"status": {
"default": "completed",
"enum": [
"completed",
"in_progress"
],
"title": "Status",
"type": "string"
}
},
"required": [
"call_id",
"name",
"arguments"
],
"title": "FunctionCall",
"type": "object"
},
"FunctionDefinition": {
"additionalProperties": false,
"properties": {
"name": {
"maxLength": 96,
"minLength": 1,
"pattern": "^[a-zA-Z0-9_-]+$",
"title": "Name",
"type": "string"
},
"description": {
"default": "",
"title": "Description",
"type": "string"
},
"parameters": {
"additionalProperties": {
"$ref": "#/$defs/JsonValue"
},
"title": "Parameters",
"type": "object"
},
"strict": {
"const": false,
"default": false,
"title": "Strict",
"type": "boolean"
},
"defer_loading": {
"const": false,
"default": false,
"title": "Defer Loading",
"type": "boolean"
}
},
"required": [
"name",
"parameters"
],
"title": "FunctionDefinition",
"type": "object"
},
"FunctionResult": {
"additionalProperties": false,
"properties": {
"type": {
"const": "function_call_output",
"default": "function_call_output",
"title": "Type",
"type": "string"
},
"id": {
"anyOf": [
{
"maxLength": 100,
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Id"
},
"call_id": {
"maxLength": 100,
"minLength": 1,
"title": "Call Id",
"type": "string"
},
"output": {
"anyOf": [
{
"type": "string"
},
{
"items": {
"$ref": "#/$defs/ToolOutputText"
},
"type": "array"
}
],
"title": "Output"
}
},
"required": [
"call_id",
"output"
],
"title": "FunctionResult",
"type": "object"
},
"FunctionTool": {
"additionalProperties": false,
"properties": {
"name": {
"maxLength": 96,
"minLength": 1,
"pattern": "^[a-zA-Z0-9_-]+$",
"title": "Name",
"type": "string"
},
"description": {
"default": "",
"title": "Description",
"type": "string"
},
"parameters": {
"additionalProperties": {
"$ref": "#/$defs/JsonValue"
},
"title": "Parameters",
"type": "object"
},
"strict": {
"const": false,
"default": false,
"title": "Strict",
"type": "boolean"
},
"defer_loading": {
"const": false,
"default": false,
"title": "Defer Loading",
"type": "boolean"
},
"type": {
"const": "function",
"default": "function",
"title": "Type",
"type": "string"
}
},
"required": [
"name",
"parameters"
],
"title": "FunctionTool",
"type": "object"
},
"InputText": {
"additionalProperties": false,
"properties": {
"type": {
"const": "input_text",
"default": "input_text",
"title": "Type",
"type": "string"
},
"text": {
"title": "Text",
"type": "string"
}
},
"required": [
"text"
],
"title": "InputText",
"type": "object"
},
"ItemReference": {
"additionalProperties": false,
"properties": {
"type": {
"const": "item_reference",
"default": "item_reference",
"title": "Type",
"type": "string"
},
"id": {
"maxLength": 100,
"minLength": 1,
"title": "Id",
"type": "string"
}
},
"required": [
"id"
],
"title": "ItemReference",
"type": "object"
},
"JsonObjectFormat": {
"additionalProperties": false,
"properties": {
"type": {
"const": "json_object",
"default": "json_object",
"title": "Type",
"type": "string"
}
},
"title": "JsonObjectFormat",
"type": "object"
},
"JsonSchemaFormat": {
"additionalProperties": false,
"properties": {
"type": {
"const": "json_schema",
"default": "json_schema",
"title": "Type",
"type": "string"
},
"name": {
"maxLength": 64,
"minLength": 1,
"pattern": "^[a-zA-Z0-9_-]+$",
"title": "Name",
"type": "string"
},
"description": {
"anyOf": [
{
"maxLength": 4096,
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Description"
},
"schema": {
"additionalProperties": {
"$ref": "#/$defs/JsonValue"
},
"title": "Schema",
"type": "object"
},
"strict": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
],
"default": null,
"title": "Strict"
}
},
"required": [
"name",
"schema"
],
"title": "JsonSchemaFormat",
"type": "object"
},
"JsonValue": {},
"Message": {
"additionalProperties": false,
"properties": {
"type": {
"const": "message",
"default": "message",
"title": "Type",
"type": "string"
},
"role": {
"$ref": "#/$defs/Role"
},
"content": {
"anyOf": [
{
"type": "string"
},
{
"items": {
"discriminator": {
"mapping": {
"input_text": "#/$defs/InputText",
"output_text": "#/$defs/OutputText"
},
"propertyName": "type"
},
"oneOf": [
{
"$ref": "#/$defs/InputText"
},
{
"$ref": "#/$defs/OutputText"
}
]
},
"type": "array"
}
],
"title": "Content"
},
"id": {
"anyOf": [
{
"maxLength": 100,
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Id"
},
"status": {
"anyOf": [
{
"enum": [
"completed",
"in_progress",
"incomplete"
],
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Status"
}
},
"required": [
"role",
"content"
],
"title": "Message",
"type": "object"
},
"NamedFunctionChoice": {
"additionalProperties": false,
"properties": {
"type": {
"const": "function",
"default": "function",
"title": "Type",
"type": "string"
},
"name": {
"maxLength": 96,
"minLength": 1,
"pattern": "^[a-zA-Z0-9_-]+$",
"title": "Name",
"type": "string"
}
},
"required": [
"name"
],
"title": "NamedFunctionChoice",
"type": "object"
},
"NestedFunctionTool": {
"additionalProperties": false,
"properties": {
"type": {
"const": "function",
"default": "function",
"title": "Type",
"type": "string"
},
"function": {
"$ref": "#/$defs/FunctionDefinition"
}
},
"required": [
"function"
],
"title": "NestedFunctionTool",
"type": "object"
},
"OutputText": {
"additionalProperties": false,
"properties": {
"type": {
"const": "output_text",
"default": "output_text",
"title": "Type",
"type": "string"
},
"text": {
"title": "Text",
"type": "string"
},
"annotations": {
"items": {
"$ref": "#/$defs/JsonValue"
},
"maxItems": 0,
"title": "Annotations",
"type": "array"
},
"logprobs": {
"items": {
"$ref": "#/$defs/JsonValue"
},
"maxItems": 0,
"title": "Logprobs",
"type": "array"
}
},
"required": [
"text"
],
"title": "OutputText",
"type": "object"
},
"PlainTextFormat": {
"additionalProperties": false,
"properties": {
"type": {
"const": "text",
"default": "text",
"title": "Type",
"type": "string"
}
},
"title": "PlainTextFormat",
"type": "object"
},
"ReasoningItem": {
"additionalProperties": false,
"properties": {
"type": {
"const": "reasoning",
"default": "reasoning",
"title": "Type",
"type": "string"
},
"id": {
"maxLength": 100,
"minLength": 1,
"title": "Id",
"type": "string"
},
"summary": {
"items": {
"$ref": "#/$defs/JsonValue"
},
"maxItems": 0,
"title": "Summary",
"type": "array"
},
"encrypted_content": {
"minLength": 1,
"title": "Encrypted Content",
"type": "string"
}
},
"required": [
"id",
"encrypted_content"
],
"title": "ReasoningItem",
"type": "object"
},
"ReasoningOptions": {
"additionalProperties": false,
"properties": {
"effort": {
"default": "high",
"enum": [
"low",
"medium",
"high",
"max"
],
"title": "Effort",
"type": "string"
},
"summary": {
"anyOf": [
{
"enum": [
"auto",
"detailed"
],
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Summary"
}
},
"title": "ReasoningOptions",
"type": "object"
},
"Role": {
"enum": [
"system",
"developer",
"user",
"assistant"
],
"title": "Role",
"type": "string"
},
"TextOptions": {
"additionalProperties": false,
"properties": {
"format": {
"discriminator": {
"mapping": {
"json_object": "#/$defs/JsonObjectFormat",
"json_schema": "#/$defs/JsonSchemaFormat",
"text": "#/$defs/PlainTextFormat"
},
"propertyName": "type"
},
"oneOf": [
{
"$ref": "#/$defs/PlainTextFormat"
},
{
"$ref": "#/$defs/JsonObjectFormat"
},
{
"$ref": "#/$defs/JsonSchemaFormat"
}
],
"title": "Format"
},
"verbosity": {
"anyOf": [
{
"enum": [
"low",
"medium",
"high"
],
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Verbosity"
}
},
"title": "TextOptions",
"type": "object"
},
"ToolOutputText": {
"additionalProperties": false,
"properties": {
"type": {
"const": "input_text",
"title": "Type",
"type": "string"
},
"text": {
"title": "Text",
"type": "string"
}
},
"required": [
"type",
"text"
],
"title": "ToolOutputText",
"type": "object"
}
},
"additionalProperties": false,
"properties": {
"model": {
"maxLength": 100,
"minLength": 1,
"title": "Model",
"type": "string"
},
"input": {
"anyOf": [
{
"type": "string"
},
{
"items": {
"discriminator": {
"mapping": {
"function_call": "#/$defs/FunctionCall",
"function_call_output": "#/$defs/FunctionResult",
"item_reference": "#/$defs/ItemReference",
"message": "#/$defs/Message",
"reasoning": "#/$defs/ReasoningItem"
},
"propertyName": "type"
},
"oneOf": [
{
"$ref": "#/$defs/Message"
},
{
"$ref": "#/$defs/FunctionCall"
},
{
"$ref": "#/$defs/FunctionResult"
},
{
"$ref": "#/$defs/ReasoningItem"
},
{
"$ref": "#/$defs/ItemReference"
}
]
},
"type": "array"
}
],
"title": "Input"
},
"instructions": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Instructions"
},
"store": {
"default": true,
"title": "Store",
"type": "boolean"
},
"previous_response_id": {
"anyOf": [
{
"pattern": "^resp_[0-9a-f]{32}$",
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Previous Response Id"
},
"stream": {
"default": false,
"title": "Stream",
"type": "boolean"
},
"tools": {
"items": {
"anyOf": [
{
"$ref": "#/$defs/FunctionTool"
},
{
"$ref": "#/$defs/NestedFunctionTool"
}
]
},
"title": "Tools",
"type": "array"
},
"text": {
"anyOf": [
{
"$ref": "#/$defs/TextOptions"
},
{
"type": "null"
}
],
"default": null
},
"parallel_tool_calls": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
],
"default": true,
"title": "Parallel Tool Calls"
},
"tool_choice": {
"anyOf": [
{
"enum": [
"auto",
"none",
"required"
],
"type": "string"
},
{
"$ref": "#/$defs/NamedFunctionChoice"
}
],
"default": "auto",
"title": "Tool Choice"
},
"max_output_tokens": {
"anyOf": [
{
"exclusiveMinimum": 0,
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Max Output Tokens"
},
"reasoning": {
"anyOf": [
{
"$ref": "#/$defs/ReasoningOptions"
},
{
"type": "null"
}
],
"default": null
},
"include": {
"items": {
"const": "reasoning.encrypted_content",
"type": "string"
},
"maxItems": 1,
"title": "Include",
"type": "array"
},
"user": {
"anyOf": [
{
"maxLength": 200,
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "User"
},
"safety_identifier": {
"anyOf": [
{
"maxLength": 200,
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Safety Identifier"
},
"prompt_cache_key": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Prompt Cache Key"
},
"metadata": {
"anyOf": [
{
"additionalProperties": {
"maxLength": 512,
"type": "string"
},
"maxProperties": 16,
"propertyNames": {
"maxLength": 64
},
"type": "object"
},
{
"type": "null"
}
],
"default": null,
"title": "Metadata"
},
"service_tier": {
"anyOf": [
{
"enum": [
"auto",
"default",
"flex",
"scale",
"priority",
"fast",
"ultrafast"
],
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Service Tier"
}
},
"required": [
"model",
"input"
],
"title": "ResponseRequest",
"type": "object"
}Response JSON Schema
{
"$defs": {
"FunctionCall": {
"additionalProperties": false,
"properties": {
"type": {
"const": "function_call",
"default": "function_call",
"title": "Type",
"type": "string"
},
"id": {
"anyOf": [
{
"maxLength": 100,
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Id"
},
"call_id": {
"maxLength": 100,
"minLength": 1,
"title": "Call Id",
"type": "string"
},
"name": {
"maxLength": 96,
"minLength": 1,
"pattern": "^[a-zA-Z0-9_-]+$",
"title": "Name",
"type": "string"
},
"arguments": {
"title": "Arguments",
"type": "string"
},
"status": {
"default": "completed",
"enum": [
"completed",
"in_progress"
],
"title": "Status",
"type": "string"
}
},
"required": [
"call_id",
"name",
"arguments"
],
"title": "FunctionCall",
"type": "object"
},
"FunctionTool": {
"additionalProperties": false,
"properties": {
"name": {
"maxLength": 96,
"minLength": 1,
"pattern": "^[a-zA-Z0-9_-]+$",
"title": "Name",
"type": "string"
},
"description": {
"default": "",
"title": "Description",
"type": "string"
},
"parameters": {
"additionalProperties": {
"$ref": "#/$defs/JsonValue"
},
"title": "Parameters",
"type": "object"
},
"strict": {
"const": false,
"default": false,
"title": "Strict",
"type": "boolean"
},
"type": {
"const": "function",
"default": "function",
"title": "Type",
"type": "string"
}
},
"required": [
"name",
"parameters"
],
"title": "FunctionTool",
"type": "object"
},
"IncompleteDetails": {
"additionalProperties": false,
"properties": {
"reason": {
"$ref": "#/$defs/IncompleteReason"
}
},
"required": [
"reason"
],
"title": "IncompleteDetails",
"type": "object"
},
"IncompleteReason": {
"enum": [
"max_output_tokens",
"invalid_model_output"
],
"title": "IncompleteReason",
"type": "string"
},
"InputText": {
"additionalProperties": false,
"properties": {
"type": {
"const": "input_text",
"default": "input_text",
"title": "Type",
"type": "string"
},
"text": {
"title": "Text",
"type": "string"
}
},
"required": [
"text"
],
"title": "InputText",
"type": "object"
},
"JsonObjectFormat": {
"additionalProperties": false,
"properties": {
"type": {
"const": "json_object",
"default": "json_object",
"title": "Type",
"type": "string"
}
},
"title": "JsonObjectFormat",
"type": "object"
},
"JsonSchemaFormat": {
"additionalProperties": false,
"properties": {
"type": {
"const": "json_schema",
"default": "json_schema",
"title": "Type",
"type": "string"
},
"name": {
"maxLength": 64,
"minLength": 1,
"pattern": "^[a-zA-Z0-9_-]+$",
"title": "Name",
"type": "string"
},
"description": {
"anyOf": [
{
"maxLength": 4096,
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Description"
},
"schema": {
"additionalProperties": {
"$ref": "#/$defs/JsonValue"
},
"title": "Schema",
"type": "object"
},
"strict": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
],
"default": null,
"title": "Strict"
}
},
"required": [
"name",
"schema"
],
"title": "JsonSchemaFormat",
"type": "object"
},
"JsonValue": {},
"Message": {
"additionalProperties": false,
"properties": {
"type": {
"const": "message",
"default": "message",
"title": "Type",
"type": "string"
},
"role": {
"$ref": "#/$defs/Role"
},
"content": {
"anyOf": [
{
"type": "string"
},
{
"items": {
"discriminator": {
"mapping": {
"input_text": "#/$defs/InputText",
"output_text": "#/$defs/OutputText"
},
"propertyName": "type"
},
"oneOf": [
{
"$ref": "#/$defs/InputText"
},
{
"$ref": "#/$defs/OutputText"
}
]
},
"type": "array"
}
],
"title": "Content"
},
"id": {
"anyOf": [
{
"maxLength": 100,
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Id"
},
"status": {
"anyOf": [
{
"enum": [
"completed",
"in_progress",
"incomplete"
],
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Status"
}
},
"required": [
"role",
"content"
],
"title": "Message",
"type": "object"
},
"NamedFunctionChoice": {
"additionalProperties": false,
"properties": {
"type": {
"const": "function",
"default": "function",
"title": "Type",
"type": "string"
},
"name": {
"maxLength": 96,
"minLength": 1,
"pattern": "^[a-zA-Z0-9_-]+$",
"title": "Name",
"type": "string"
}
},
"required": [
"name"
],
"title": "NamedFunctionChoice",
"type": "object"
},
"OutputText": {
"additionalProperties": false,
"properties": {
"type": {
"const": "output_text",
"default": "output_text",
"title": "Type",
"type": "string"
},
"text": {
"title": "Text",
"type": "string"
},
"annotations": {
"items": {
"$ref": "#/$defs/JsonValue"
},
"maxItems": 0,
"title": "Annotations",
"type": "array"
},
"logprobs": {
"items": {
"$ref": "#/$defs/JsonValue"
},
"maxItems": 0,
"title": "Logprobs",
"type": "array"
}
},
"required": [
"text"
],
"title": "OutputText",
"type": "object"
},
"OutputTokenDetails": {
"additionalProperties": false,
"properties": {
"reasoning_tokens": {
"anyOf": [
{
"minimum": 0,
"type": "integer"
},
{
"type": "null"
}
],
"title": "Reasoning Tokens"
}
},
"required": [
"reasoning_tokens"
],
"title": "OutputTokenDetails",
"type": "object"
},
"PlainTextFormat": {
"additionalProperties": false,
"properties": {
"type": {
"const": "text",
"default": "text",
"title": "Type",
"type": "string"
}
},
"title": "PlainTextFormat",
"type": "object"
},
"ReasoningItem": {
"additionalProperties": false,
"properties": {
"type": {
"const": "reasoning",
"default": "reasoning",
"title": "Type",
"type": "string"
},
"id": {
"maxLength": 100,
"minLength": 1,
"title": "Id",
"type": "string"
},
"summary": {
"items": {
"$ref": "#/$defs/JsonValue"
},
"maxItems": 0,
"title": "Summary",
"type": "array"
},
"encrypted_content": {
"minLength": 1,
"title": "Encrypted Content",
"type": "string"
}
},
"required": [
"id",
"encrypted_content"
],
"title": "ReasoningItem",
"type": "object"
},
"ReasoningOptions": {
"additionalProperties": false,
"properties": {
"effort": {
"default": "high",
"enum": [
"low",
"medium",
"high",
"max"
],
"title": "Effort",
"type": "string"
},
"summary": {
"anyOf": [
{
"enum": [
"auto",
"detailed"
],
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Summary"
}
},
"title": "ReasoningOptions",
"type": "object"
},
"ResponseError": {
"additionalProperties": false,
"properties": {
"code": {
"title": "Code",
"type": "string"
},
"message": {
"title": "Message",
"type": "string"
},
"type": {
"title": "Type",
"type": "string"
},
"param": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Param"
}
},
"required": [
"code",
"message"
],
"title": "ResponseError",
"type": "object"
},
"ResponseUsage": {
"additionalProperties": false,
"properties": {
"input_tokens": {
"minimum": 0,
"title": "Input Tokens",
"type": "integer"
},
"output_tokens": {
"minimum": 0,
"title": "Output Tokens",
"type": "integer"
},
"total_tokens": {
"minimum": 0,
"title": "Total Tokens",
"type": "integer"
},
"input_tokens_details": {
"$ref": "#/$defs/TokenDetails"
},
"output_tokens_details": {
"$ref": "#/$defs/OutputTokenDetails"
}
},
"required": [
"input_tokens",
"output_tokens",
"total_tokens",
"input_tokens_details",
"output_tokens_details"
],
"title": "ResponseUsage",
"type": "object"
},
"Role": {
"enum": [
"system",
"developer",
"user",
"assistant"
],
"title": "Role",
"type": "string"
},
"TextOptions": {
"additionalProperties": false,
"properties": {
"format": {
"discriminator": {
"mapping": {
"json_object": "#/$defs/JsonObjectFormat",
"json_schema": "#/$defs/JsonSchemaFormat",
"text": "#/$defs/PlainTextFormat"
},
"propertyName": "type"
},
"oneOf": [
{
"$ref": "#/$defs/PlainTextFormat"
},
{
"$ref": "#/$defs/JsonObjectFormat"
},
{
"$ref": "#/$defs/JsonSchemaFormat"
}
],
"title": "Format"
},
"verbosity": {
"anyOf": [
{
"enum": [
"low",
"medium",
"high"
],
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Verbosity"
}
},
"title": "TextOptions",
"type": "object"
},
"TokenDetails": {
"additionalProperties": false,
"properties": {
"cached_tokens": {
"anyOf": [
{
"minimum": 0,
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Cached Tokens"
},
"cache_write_tokens": {
"anyOf": [
{
"minimum": 0,
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Cache Write Tokens"
}
},
"title": "TokenDetails",
"type": "object"
}
},
"additionalProperties": false,
"properties": {
"id": {
"title": "Id",
"type": "string"
},
"object": {
"const": "response",
"default": "response",
"title": "Object",
"type": "string"
},
"created_at": {
"title": "Created At",
"type": "integer"
},
"model": {
"title": "Model",
"type": "string"
},
"status": {
"enum": [
"in_progress",
"completed",
"incomplete",
"failed"
],
"title": "Status",
"type": "string"
},
"output": {
"items": {
"anyOf": [
{
"$ref": "#/$defs/Message"
},
{
"$ref": "#/$defs/FunctionCall"
},
{
"$ref": "#/$defs/ReasoningItem"
}
]
},
"title": "Output",
"type": "array"
},
"error": {
"anyOf": [
{
"$ref": "#/$defs/ResponseError"
},
{
"type": "null"
}
],
"default": null
},
"incomplete_details": {
"anyOf": [
{
"$ref": "#/$defs/IncompleteDetails"
},
{
"type": "null"
}
],
"default": null
},
"usage": {
"anyOf": [
{
"$ref": "#/$defs/ResponseUsage"
},
{
"type": "null"
}
],
"default": null
},
"store": {
"default": false,
"title": "Store",
"type": "boolean"
},
"previous_response_id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Previous Response Id"
},
"parallel_tool_calls": {
"default": true,
"title": "Parallel Tool Calls",
"type": "boolean"
},
"tools": {
"items": {
"$ref": "#/$defs/FunctionTool"
},
"title": "Tools",
"type": "array"
},
"tool_choice": {
"anyOf": [
{
"enum": [
"auto",
"none",
"required"
],
"type": "string"
},
{
"$ref": "#/$defs/NamedFunctionChoice"
}
],
"default": "auto",
"title": "Tool Choice"
},
"text": {
"anyOf": [
{
"$ref": "#/$defs/TextOptions"
},
{
"type": "null"
}
],
"default": null
},
"instructions": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Instructions"
},
"max_output_tokens": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Max Output Tokens"
},
"reasoning": {
"anyOf": [
{
"$ref": "#/$defs/ReasoningOptions"
},
{
"type": "null"
}
],
"default": null
}
},
"required": [
"id",
"created_at",
"model",
"status"
],
"title": "Response",
"type": "object"
}StreamEvent JSON Schema
{
"$defs": {
"FunctionCall": {
"additionalProperties": false,
"properties": {
"type": {
"const": "function_call",
"default": "function_call",
"title": "Type",
"type": "string"
},
"id": {
"anyOf": [
{
"maxLength": 100,
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Id"
},
"call_id": {
"maxLength": 100,
"minLength": 1,
"title": "Call Id",
"type": "string"
},
"name": {
"maxLength": 96,
"minLength": 1,
"pattern": "^[a-zA-Z0-9_-]+$",
"title": "Name",
"type": "string"
},
"arguments": {
"title": "Arguments",
"type": "string"
},
"status": {
"default": "completed",
"enum": [
"completed",
"in_progress"
],
"title": "Status",
"type": "string"
}
},
"required": [
"call_id",
"name",
"arguments"
],
"title": "FunctionCall",
"type": "object"
},
"FunctionTool": {
"additionalProperties": false,
"properties": {
"name": {
"maxLength": 96,
"minLength": 1,
"pattern": "^[a-zA-Z0-9_-]+$",
"title": "Name",
"type": "string"
},
"description": {
"default": "",
"title": "Description",
"type": "string"
},
"parameters": {
"additionalProperties": {
"$ref": "#/$defs/JsonValue"
},
"title": "Parameters",
"type": "object"
},
"strict": {
"const": false,
"default": false,
"title": "Strict",
"type": "boolean"
},
"type": {
"const": "function",
"default": "function",
"title": "Type",
"type": "string"
}
},
"required": [
"name",
"parameters"
],
"title": "FunctionTool",
"type": "object"
},
"IncompleteDetails": {
"additionalProperties": false,
"properties": {
"reason": {
"$ref": "#/$defs/IncompleteReason"
}
},
"required": [
"reason"
],
"title": "IncompleteDetails",
"type": "object"
},
"IncompleteReason": {
"enum": [
"max_output_tokens",
"invalid_model_output"
],
"title": "IncompleteReason",
"type": "string"
},
"InputText": {
"additionalProperties": false,
"properties": {
"type": {
"const": "input_text",
"default": "input_text",
"title": "Type",
"type": "string"
},
"text": {
"title": "Text",
"type": "string"
}
},
"required": [
"text"
],
"title": "InputText",
"type": "object"
},
"JsonObjectFormat": {
"additionalProperties": false,
"properties": {
"type": {
"const": "json_object",
"default": "json_object",
"title": "Type",
"type": "string"
}
},
"title": "JsonObjectFormat",
"type": "object"
},
"JsonSchemaFormat": {
"additionalProperties": false,
"properties": {
"type": {
"const": "json_schema",
"default": "json_schema",
"title": "Type",
"type": "string"
},
"name": {
"maxLength": 64,
"minLength": 1,
"pattern": "^[a-zA-Z0-9_-]+$",
"title": "Name",
"type": "string"
},
"description": {
"anyOf": [
{
"maxLength": 4096,
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Description"
},
"schema": {
"additionalProperties": {
"$ref": "#/$defs/JsonValue"
},
"title": "Schema",
"type": "object"
},
"strict": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
],
"default": null,
"title": "Strict"
}
},
"required": [
"name",
"schema"
],
"title": "JsonSchemaFormat",
"type": "object"
},
"JsonValue": {},
"Message": {
"additionalProperties": false,
"properties": {
"type": {
"const": "message",
"default": "message",
"title": "Type",
"type": "string"
},
"role": {
"$ref": "#/$defs/Role"
},
"content": {
"anyOf": [
{
"type": "string"
},
{
"items": {
"discriminator": {
"mapping": {
"input_text": "#/$defs/InputText",
"output_text": "#/$defs/OutputText"
},
"propertyName": "type"
},
"oneOf": [
{
"$ref": "#/$defs/InputText"
},
{
"$ref": "#/$defs/OutputText"
}
]
},
"type": "array"
}
],
"title": "Content"
},
"id": {
"anyOf": [
{
"maxLength": 100,
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Id"
},
"status": {
"anyOf": [
{
"enum": [
"completed",
"in_progress",
"incomplete"
],
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Status"
}
},
"required": [
"role",
"content"
],
"title": "Message",
"type": "object"
},
"NamedFunctionChoice": {
"additionalProperties": false,
"properties": {
"type": {
"const": "function",
"default": "function",
"title": "Type",
"type": "string"
},
"name": {
"maxLength": 96,
"minLength": 1,
"pattern": "^[a-zA-Z0-9_-]+$",
"title": "Name",
"type": "string"
}
},
"required": [
"name"
],
"title": "NamedFunctionChoice",
"type": "object"
},
"OutputText": {
"additionalProperties": false,
"properties": {
"type": {
"const": "output_text",
"default": "output_text",
"title": "Type",
"type": "string"
},
"text": {
"title": "Text",
"type": "string"
},
"annotations": {
"items": {
"$ref": "#/$defs/JsonValue"
},
"maxItems": 0,
"title": "Annotations",
"type": "array"
},
"logprobs": {
"items": {
"$ref": "#/$defs/JsonValue"
},
"maxItems": 0,
"title": "Logprobs",
"type": "array"
}
},
"required": [
"text"
],
"title": "OutputText",
"type": "object"
},
"OutputTokenDetails": {
"additionalProperties": false,
"properties": {
"reasoning_tokens": {
"anyOf": [
{
"minimum": 0,
"type": "integer"
},
{
"type": "null"
}
],
"title": "Reasoning Tokens"
}
},
"required": [
"reasoning_tokens"
],
"title": "OutputTokenDetails",
"type": "object"
},
"PlainTextFormat": {
"additionalProperties": false,
"properties": {
"type": {
"const": "text",
"default": "text",
"title": "Type",
"type": "string"
}
},
"title": "PlainTextFormat",
"type": "object"
},
"ReasoningItem": {
"additionalProperties": false,
"properties": {
"type": {
"const": "reasoning",
"default": "reasoning",
"title": "Type",
"type": "string"
},
"id": {
"maxLength": 100,
"minLength": 1,
"title": "Id",
"type": "string"
},
"summary": {
"items": {
"$ref": "#/$defs/JsonValue"
},
"maxItems": 0,
"title": "Summary",
"type": "array"
},
"encrypted_content": {
"minLength": 1,
"title": "Encrypted Content",
"type": "string"
}
},
"required": [
"id",
"encrypted_content"
],
"title": "ReasoningItem",
"type": "object"
},
"ReasoningOptions": {
"additionalProperties": false,
"properties": {
"effort": {
"default": "high",
"enum": [
"low",
"medium",
"high",
"max"
],
"title": "Effort",
"type": "string"
},
"summary": {
"anyOf": [
{
"enum": [
"auto",
"detailed"
],
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Summary"
}
},
"title": "ReasoningOptions",
"type": "object"
},
"Response": {
"additionalProperties": false,
"properties": {
"id": {
"title": "Id",
"type": "string"
},
"object": {
"const": "response",
"default": "response",
"title": "Object",
"type": "string"
},
"created_at": {
"title": "Created At",
"type": "integer"
},
"model": {
"title": "Model",
"type": "string"
},
"status": {
"enum": [
"in_progress",
"completed",
"incomplete",
"failed"
],
"title": "Status",
"type": "string"
},
"output": {
"items": {
"anyOf": [
{
"$ref": "#/$defs/Message"
},
{
"$ref": "#/$defs/FunctionCall"
},
{
"$ref": "#/$defs/ReasoningItem"
}
]
},
"title": "Output",
"type": "array"
},
"error": {
"anyOf": [
{
"$ref": "#/$defs/ResponseError"
},
{
"type": "null"
}
],
"default": null
},
"incomplete_details": {
"anyOf": [
{
"$ref": "#/$defs/IncompleteDetails"
},
{
"type": "null"
}
],
"default": null
},
"usage": {
"anyOf": [
{
"$ref": "#/$defs/ResponseUsage"
},
{
"type": "null"
}
],
"default": null
},
"store": {
"default": false,
"title": "Store",
"type": "boolean"
},
"previous_response_id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Previous Response Id"
},
"parallel_tool_calls": {
"default": true,
"title": "Parallel Tool Calls",
"type": "boolean"
},
"tools": {
"items": {
"$ref": "#/$defs/FunctionTool"
},
"title": "Tools",
"type": "array"
},
"tool_choice": {
"anyOf": [
{
"enum": [
"auto",
"none",
"required"
],
"type": "string"
},
{
"$ref": "#/$defs/NamedFunctionChoice"
}
],
"default": "auto",
"title": "Tool Choice"
},
"text": {
"anyOf": [
{
"$ref": "#/$defs/TextOptions"
},
{
"type": "null"
}
],
"default": null
},
"instructions": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Instructions"
},
"max_output_tokens": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Max Output Tokens"
},
"reasoning": {
"anyOf": [
{
"$ref": "#/$defs/ReasoningOptions"
},
{
"type": "null"
}
],
"default": null
}
},
"required": [
"id",
"created_at",
"model",
"status"
],
"title": "Response",
"type": "object"
},
"ResponseError": {
"additionalProperties": false,
"properties": {
"code": {
"title": "Code",
"type": "string"
},
"message": {
"title": "Message",
"type": "string"
},
"type": {
"title": "Type",
"type": "string"
},
"param": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Param"
}
},
"required": [
"code",
"message"
],
"title": "ResponseError",
"type": "object"
},
"ResponseUsage": {
"additionalProperties": false,
"properties": {
"input_tokens": {
"minimum": 0,
"title": "Input Tokens",
"type": "integer"
},
"output_tokens": {
"minimum": 0,
"title": "Output Tokens",
"type": "integer"
},
"total_tokens": {
"minimum": 0,
"title": "Total Tokens",
"type": "integer"
},
"input_tokens_details": {
"$ref": "#/$defs/TokenDetails"
},
"output_tokens_details": {
"$ref": "#/$defs/OutputTokenDetails"
}
},
"required": [
"input_tokens",
"output_tokens",
"total_tokens",
"input_tokens_details",
"output_tokens_details"
],
"title": "ResponseUsage",
"type": "object"
},
"Role": {
"enum": [
"system",
"developer",
"user",
"assistant"
],
"title": "Role",
"type": "string"
},
"TextOptions": {
"additionalProperties": false,
"properties": {
"format": {
"discriminator": {
"mapping": {
"json_object": "#/$defs/JsonObjectFormat",
"json_schema": "#/$defs/JsonSchemaFormat",
"text": "#/$defs/PlainTextFormat"
},
"propertyName": "type"
},
"oneOf": [
{
"$ref": "#/$defs/PlainTextFormat"
},
{
"$ref": "#/$defs/JsonObjectFormat"
},
{
"$ref": "#/$defs/JsonSchemaFormat"
}
],
"title": "Format"
},
"verbosity": {
"anyOf": [
{
"enum": [
"low",
"medium",
"high"
],
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Verbosity"
}
},
"title": "TextOptions",
"type": "object"
},
"TokenDetails": {
"additionalProperties": false,
"properties": {
"cached_tokens": {
"anyOf": [
{
"minimum": 0,
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Cached Tokens"
},
"cache_write_tokens": {
"anyOf": [
{
"minimum": 0,
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Cache Write Tokens"
}
},
"title": "TokenDetails",
"type": "object"
}
},
"additionalProperties": false,
"properties": {
"type": {
"title": "Type",
"type": "string"
},
"sequence_number": {
"title": "Sequence Number",
"type": "integer"
},
"response": {
"anyOf": [
{
"$ref": "#/$defs/Response"
},
{
"type": "null"
}
],
"default": null
},
"item": {
"anyOf": [
{
"$ref": "#/$defs/Message"
},
{
"$ref": "#/$defs/FunctionCall"
},
{
"$ref": "#/$defs/ReasoningItem"
},
{
"type": "null"
}
],
"default": null,
"title": "Item"
},
"item_id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Item Id"
},
"output_index": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Output Index"
},
"content_index": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Content Index"
},
"part": {
"anyOf": [
{
"$ref": "#/$defs/OutputText"
},
{
"type": "null"
}
],
"default": null
},
"delta": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Delta"
},
"text": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Text"
},
"arguments": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Arguments"
},
"logprobs": {
"anyOf": [
{
"items": {
"$ref": "#/$defs/JsonValue"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"title": "Logprobs"
}
},
"required": [
"type",
"sequence_number"
],
"title": "StreamEvent",
"type": "object"
}PublicInputItems JSON Schema
{
"$defs": {
"FunctionCall": {
"additionalProperties": false,
"properties": {
"type": {
"const": "function_call",
"default": "function_call",
"title": "Type",
"type": "string"
},
"id": {
"anyOf": [
{
"maxLength": 100,
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Id"
},
"call_id": {
"maxLength": 100,
"minLength": 1,
"title": "Call Id",
"type": "string"
},
"name": {
"maxLength": 96,
"minLength": 1,
"pattern": "^[a-zA-Z0-9_-]+$",
"title": "Name",
"type": "string"
},
"arguments": {
"title": "Arguments",
"type": "string"
},
"status": {
"default": "completed",
"enum": [
"completed",
"in_progress"
],
"title": "Status",
"type": "string"
}
},
"required": [
"call_id",
"name",
"arguments"
],
"title": "FunctionCall",
"type": "object"
},
"FunctionResult": {
"additionalProperties": false,
"properties": {
"type": {
"const": "function_call_output",
"default": "function_call_output",
"title": "Type",
"type": "string"
},
"id": {
"anyOf": [
{
"maxLength": 100,
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Id"
},
"call_id": {
"maxLength": 100,
"minLength": 1,
"title": "Call Id",
"type": "string"
},
"output": {
"title": "Output",
"type": "string"
}
},
"required": [
"call_id",
"output"
],
"title": "FunctionResult",
"type": "object"
},
"InputText": {
"additionalProperties": false,
"properties": {
"type": {
"const": "input_text",
"default": "input_text",
"title": "Type",
"type": "string"
},
"text": {
"title": "Text",
"type": "string"
}
},
"required": [
"text"
],
"title": "InputText",
"type": "object"
},
"JsonValue": {},
"Message": {
"additionalProperties": false,
"properties": {
"type": {
"const": "message",
"default": "message",
"title": "Type",
"type": "string"
},
"role": {
"$ref": "#/$defs/Role"
},
"content": {
"anyOf": [
{
"type": "string"
},
{
"items": {
"discriminator": {
"mapping": {
"input_text": "#/$defs/InputText",
"output_text": "#/$defs/OutputText"
},
"propertyName": "type"
},
"oneOf": [
{
"$ref": "#/$defs/InputText"
},
{
"$ref": "#/$defs/OutputText"
}
]
},
"type": "array"
}
],
"title": "Content"
},
"id": {
"anyOf": [
{
"maxLength": 100,
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Id"
},
"status": {
"anyOf": [
{
"enum": [
"completed",
"in_progress",
"incomplete"
],
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Status"
}
},
"required": [
"role",
"content"
],
"title": "Message",
"type": "object"
},
"OutputText": {
"additionalProperties": false,
"properties": {
"type": {
"const": "output_text",
"default": "output_text",
"title": "Type",
"type": "string"
},
"text": {
"title": "Text",
"type": "string"
},
"annotations": {
"items": {
"$ref": "#/$defs/JsonValue"
},
"maxItems": 0,
"title": "Annotations",
"type": "array"
},
"logprobs": {
"items": {
"$ref": "#/$defs/JsonValue"
},
"maxItems": 0,
"title": "Logprobs",
"type": "array"
}
},
"required": [
"text"
],
"title": "OutputText",
"type": "object"
},
"ReasoningItem": {
"additionalProperties": false,
"properties": {
"type": {
"const": "reasoning",
"default": "reasoning",
"title": "Type",
"type": "string"
},
"id": {
"maxLength": 100,
"minLength": 1,
"title": "Id",
"type": "string"
},
"summary": {
"items": {
"$ref": "#/$defs/JsonValue"
},
"maxItems": 0,
"title": "Summary",
"type": "array"
},
"encrypted_content": {
"minLength": 1,
"title": "Encrypted Content",
"type": "string"
}
},
"required": [
"id",
"encrypted_content"
],
"title": "ReasoningItem",
"type": "object"
},
"Role": {
"enum": [
"system",
"developer",
"user",
"assistant"
],
"title": "Role",
"type": "string"
}
},
"additionalProperties": false,
"properties": {
"object": {
"const": "list",
"default": "list",
"title": "Object",
"type": "string"
},
"data": {
"items": {
"discriminator": {
"mapping": {
"function_call": "#/$defs/FunctionCall",
"function_call_output": "#/$defs/FunctionResult",
"message": "#/$defs/Message",
"reasoning": "#/$defs/ReasoningItem"
},
"propertyName": "type"
},
"oneOf": [
{
"$ref": "#/$defs/Message"
},
{
"$ref": "#/$defs/FunctionCall"
},
{
"$ref": "#/$defs/FunctionResult"
},
{
"$ref": "#/$defs/ReasoningItem"
}
]
},
"title": "Data",
"type": "array"
},
"first_id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "First Id"
},
"last_id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Last Id"
},
"has_more": {
"title": "Has More",
"type": "boolean"
}
},
"required": [
"data",
"first_id",
"last_id",
"has_more"
],
"title": "PublicInputItems",
"type": "object"
}DeletedResponse JSON Schema
{
"additionalProperties": false,
"properties": {
"id": {
"title": "Id",
"type": "string"
},
"object": {
"const": "response.deleted",
"default": "response.deleted",
"title": "Object",
"type": "string"
},
"deleted": {
"const": true,
"default": true,
"title": "Deleted",
"type": "boolean"
}
},
"required": [
"id"
],
"title": "DeletedResponse",
"type": "object"
}