Create Response
Send input items and get back a response with message, reasoning, and tool call output items. Supports streaming, function calling, structured output, and image and file input.
Creates a model response in the OpenAI Responses format. Supports both
streaming and non-streaming modes. Any OpenAI SDK works out of the box -
just point baseURL at https://api.aivene.com/v1 and call
responses.create.
POST /v1/responsesAuthentication
AuthorizationBearerrequiredAPI key as bearer token in the Authorization header. Create keys at
Manage API Keys.
Headers
Content-TypestringrequiredMust be application/json.
Body
modelstringrequiredModel id from GET /v1/models. Example: gpt-5.4, gpt-5.4-mini,
claude-sonnet-4-6.
inputstring | Item[]requiredThe conversation. A string is a single user message. A list holds
message items and the tool call and reasoning items from earlier turns.
See Input items.
instructionsstringoptionalSystem instructions placed before input.
streambooleanoptionalDefault falseStream the response as typed server-sent events instead of returning a single JSON body. See Streaming events.
max_output_tokensintegeroptionalCap on output tokens, reasoning included. Must not exceed the model's output limit.
temperaturenumberoptionalDefault 1Between 0 and 2. Higher = more random.
top_pnumberoptionalDefault 1Between 0 and 1. Nucleus sampling. Use temperature or top_p,
not both.
toolsTool[]optionalTools the model may call. See Tool calling.
tool_choicestring | objectoptional'auto', 'none', 'required', or { type: 'function', name } to
force a specific function.
autononerequiredparallel_tool_callsbooleanoptionalDefault trueAllow the model to call several tools in one turn.
max_tool_callsintegeroptionalMaximum number of tool calls in one response, on models that support it.
reasoningobjectoptionalControls reasoning on reasoning models:
effort-max,xhigh,high,medium,low,minimalornone. Pick a level the model supports: a level it doesn't support may return an error.summary-auto,conciseordetailedto receive reasoning summaries, on models that return them.
See Reasoning.
includestring[]optionalExtra data to include in the output. Add reasoning.encrypted_content
to receive encrypted reasoning that you pass back in the next request.
textobjectoptionalOutput text options:
format-{ type: 'text' },{ type: 'json_object' }, or{ type: 'json_schema', name, schema, strict }. Withjson_schema, the model is asked to return JSON that follows your schema. Validate the output if your app relies on it.verbosity-low,mediumorhigh, on models that support it.
truncation'auto' | 'disabled'optionalDefault disabledauto lets the model drop items from the start of the conversation when
it exceeds the context window, on models that support it. With
disabled, such a request fails.
prompt_cache_keystringoptionalGroups requests that share a long prefix to improve prompt cache hits, on models that support it. See Prompt caching.
cache_controlobjectoptional{ type: 'ephemeral' } turns on automatic prompt caching for models that
use explicit caching. See Prompt caching.
safety_identifierstringoptionalA stable identifier for your end user, used to help detect abuse. Hash usernames or email addresses before sending them.
userstringoptionalA stable identifier for your end user. Prefer safety_identifier.
Input items
type Item =
| { type?: 'message'; role: 'user' | 'assistant' | 'system' | 'developer'; content: string | Part[] }
| { type: 'function_call'; call_id: string; name: string; arguments: string }
| { type: 'function_call_output'; call_id: string; output: string }
| { type: 'reasoning'; id: string; summary: Summary[]; encrypted_content?: string };Output items from an earlier response (message, reasoning,
function_call and other tool calls) can be sent back as they are.
Content part types
| Type | Used in | Example |
|---|---|---|
input_text | user, system, developer | { "type": "input_text", "text": "Hello" } |
input_image | user | { "type": "input_image", "image_url": "https://..." } or { "type": "input_image", "file_id": "file-..." } |
input_file | user | { "type": "input_file", "file_id": "file-..." } or { "type": "input_file", "filename": "report.pdf", "file_data": "data:application/pdf;base64,..." } |
output_text | assistant | { "type": "output_text", "text": "Hi there!" } |
file_id values come from Files. input_image and
input_file are only accepted by models with the matching input capability.
See Image understanding and
Documents.
Response
idstringoptionalUnique response id, prefixed avn_.
object'response'optionalAlways response.
created_atintegeroptionalUnix timestamp (seconds) when the response was created.
statusstringoptionalcompleted, or incomplete when generation stopped early.
incomplete_detailsobject | nulloptional{ reason } when status is incomplete, for example
max_output_tokens or content_filter.
errorobject | nulloptionalAlways null on a successful response.
modelstringoptionalThe model id you sent in the request.
outputItem[]optionalOutput items in order: reasoning, message (with output_text or
refusal parts), function_call, and other tool call items.
usageobjectoptional{ input_tokens, output_tokens, total_tokens }, plus
input_tokens_details.cached_tokens and
output_tokens_details.reasoning_tokens when the model reports them.
Streams carry it on the terminal response.completed or
response.incomplete event.
Reading the text
The OpenAI SDKs expose the concatenated text of all output_text parts as
response.output_text. If you call the API directly, join the text of
each output_text part in the message items yourself.
Streaming
When stream: true, the response is text/event-stream with typed events
such as response.created, response.output_text.delta and
response.completed. There is no [DONE] sentinel: the stream closes after
response.completed, response.incomplete or response.failed. See
Streaming events.
Tool calling
Provide a tools array. A function tool has a name, a description, a
JSON Schema parameters object and an optional strict flag:
{
"type": "function",
"name": "get_weather",
"description": "Get the current weather for a city.",
"parameters": {
"type": "object",
"properties": { "city": { "type": "string" } },
"required": ["city"]
}
}When the model calls a function, output contains a function_call item
with a call_id and JSON arguments. Run the function yourself, then send
a new request whose input includes that function_call item followed by a
function_call_output item with the same call_id:
[
{ "role": "user", "content": "What's the weather in Tokyo?" },
{ "type": "function_call", "call_id": "call_abc123", "name": "get_weather", "arguments": "{\"city\":\"Tokyo\"}" },
{ "type": "function_call_output", "call_id": "call_abc123", "output": "{\"temp_c\":18}" }
]function tools work with every model that supports tool use. GPT models
also accept the other tool types your own code executes: custom,
namespace, local_shell, shell (local environment), apply_patch,
computer and tool_search with execution: "client". Other models
receive function tools only. See Tool calling.
Reasoning across turns
Reasoning models return reasoning items before their answer. To keep the
model's train of thought across tool calls, request
include: ["reasoning.encrypted_content"] and pass the reasoning items
back in input unchanged, in the same position. Don't edit them: an item
the model can't read is dropped. See Reasoning.
Errors
Errors returned before the response starts share one shape:
{ "error": { "message": "...", "type": "invalid_request_error" } }| Status | error.type | Meaning |
|---|---|---|
400 | validation_error | The body failed schema validation. The message names the offending field. |
400 | invalid_request_error | Unknown model, content or a feature the model does not support (for example images, tools or text.format), or max_output_tokens above the model's limit. |
401 | authentication_error | Missing or invalid API key. |
402 | invalid_request_error | Not enough credit for the request, an unpaid balance, or a spend limit was reached. |
403 | permission_denied_error | The account is suspended, an Admin key was used, or the model isn't included in your organization's tier. |
404 | not_found_error | The model is deprecated. The message names its replacement. |
408 | timeout_error | The model did not finish before the request timed out (non-streaming requests). |
429 | rate_limit_error | Your organization hit its rate limit for this model. Back off and retry. |
500 | internal_server_error | Unexpected server error. |
502 / 503 | upstream_error | The model is temporarily unavailable. Safe to retry. |
When the model itself rejects a request, the response keeps the model's
4xx status with type upstream_error or invalid_request_error, and
error.code names the cause when it is known (context_length_exceeded,
content_filter, request_too_large). A non-streaming request whose
response fails returns an error in this shape instead of a failed
response object. Errors after a stream has started arrive as
events.