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/responses

Authentication

AuthorizationBearerrequired

API key as bearer token in the Authorization header. Create keys at Manage API Keys.

Headers

Content-Typestringrequired

Must be application/json.

Body

modelstringrequired

Model id from GET /v1/models. Example: gpt-5.4, gpt-5.4-mini, claude-sonnet-4-6.

inputstring | Item[]required

The 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.

instructionsstringoptional

System instructions placed before input.

streambooleanoptionalDefault false

Stream the response as typed server-sent events instead of returning a single JSON body. See Streaming events.

max_output_tokensintegeroptional

Cap on output tokens, reasoning included. Must not exceed the model's output limit.

temperaturenumberoptionalDefault 1

Between 0 and 2. Higher = more random.

top_pnumberoptionalDefault 1

Between 0 and 1. Nucleus sampling. Use temperature or top_p, not both.

toolsTool[]optional

Tools the model may call. See Tool calling.

tool_choicestring | objectoptional

'auto', 'none', 'required', or { type: 'function', name } to force a specific function.

Allowed values:autononerequired
parallel_tool_callsbooleanoptionalDefault true

Allow the model to call several tools in one turn.

max_tool_callsintegeroptional

Maximum number of tool calls in one response, on models that support it.

reasoningobjectoptional

Controls reasoning on reasoning models:

  • effort - max, xhigh, high, medium, low, minimal or none. Pick a level the model supports: a level it doesn't support may return an error.
  • summary - auto, concise or detailed to receive reasoning summaries, on models that return them.

See Reasoning.

includestring[]optional

Extra data to include in the output. Add reasoning.encrypted_content to receive encrypted reasoning that you pass back in the next request.

textobjectoptional

Output text options:

  • format - { type: 'text' }, { type: 'json_object' }, or { type: 'json_schema', name, schema, strict }. With json_schema, the model is asked to return JSON that follows your schema. Validate the output if your app relies on it.
  • verbosity - low, medium or high, on models that support it.
truncation'auto' | 'disabled'optionalDefault disabled

auto 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_keystringoptional

Groups 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_identifierstringoptional

A stable identifier for your end user, used to help detect abuse. Hash usernames or email addresses before sending them.

userstringoptional

A 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

TypeUsed inExample
input_textuser, system, developer{ "type": "input_text", "text": "Hello" }
input_imageuser{ "type": "input_image", "image_url": "https://..." } or { "type": "input_image", "file_id": "file-..." }
input_fileuser{ "type": "input_file", "file_id": "file-..." } or { "type": "input_file", "filename": "report.pdf", "file_data": "data:application/pdf;base64,..." }
output_textassistant{ "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

idstringoptional

Unique response id, prefixed avn_.

object'response'optional

Always response.

created_atintegeroptional

Unix timestamp (seconds) when the response was created.

statusstringoptional

completed, or incomplete when generation stopped early.

incomplete_detailsobject | nulloptional

{ reason } when status is incomplete, for example max_output_tokens or content_filter.

errorobject | nulloptional

Always null on a successful response.

modelstringoptional

The model id you sent in the request.

outputItem[]optional

Output 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" } }
Statuserror.typeMeaning
400validation_errorThe body failed schema validation. The message names the offending field.
400invalid_request_errorUnknown 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.
401authentication_errorMissing or invalid API key.
402invalid_request_errorNot enough credit for the request, an unpaid balance, or a spend limit was reached.
403permission_denied_errorThe account is suspended, an Admin key was used, or the model isn't included in your organization's tier.
404not_found_errorThe model is deprecated. The message names its replacement.
408timeout_errorThe model did not finish before the request timed out (non-streaming requests).
429rate_limit_errorYour organization hit its rate limit for this model. Back off and retry.
500internal_server_errorUnexpected server error.
502 / 503upstream_errorThe 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.