AI Proxy (Preview)
POST/api/v2/aiproxy/responses
> ๐งช Preview โ This endpoint is in preview and its contract may change.
Executes an AI Proxy agent through an OpenAI-compatible Responses API. Call it with the OpenAI SDKs by pointing the base URL at this route and passing your Serenity API key as a Bearer token.
Select the agent with the standard model property using the format agentCode:vendor:model (e.g. generic-proxy:OpenAI:gpt-5.4-mini). Use extra_body for execution attribution only (channel, user_identifier, group_identifier).
The tools array accepts OpenAI function (client) tools โ declaration-only: when the model calls one, it emits a function_call output item that is returned to you to run, and you replay it plus a function_call_output on a follow-up request โ and AI Proxy server tools that run entirely on the server: web_search, image_generation, speech_generation and workbench. For each server tool, model/vendor (and voice/speed for speech_generation) are optional and fall back to the agent's configured defaults.
Structured output is supported through text.format: text returns plain text, json_object returns free-form JSON, and json_schema constrains the reply to a JSON schema you supply. The requested format is validated against the selected model's capabilities, so a model that cannot honour it is rejected rather than silently ignoring it.
Reasoning models are steered with the reasoning object: effort controls how much the model thinks and detail controls how much of its reasoning is returned (auto, none, summary or full). OpenAI's reasoning.summary is accepted in place of detail and mapped onto it, so a standard OpenAI client works unchanged. The accepted values come from the selected model's own configuration, so a model that does not expose the parameter rejects the request rather than ignoring it.
When a skill on the agent is configured to require approval, the run pauses and both the approval request and your decision travel as messages in the conversation history. See Skill Approvals for the message shapes and the full flow.
When stream is true, the response is delivered as Server-Sent Events (SSE).
Requestโ
Query Parameters
Use this param to override the culture of the response. Options: - en (default) - es
- application/json
Body
required
- ResponseTextFormatConfigurationText
- ResponseTextFormatConfigurationJsonObject
- ResponseTextFormatConfigurationJsonSchema
extra_body
object
The OpenAI extra_body extension object of an AI Proxy request. Carries fields that are not part of the standard OpenAI request body but are used to attribute the AI Proxy agent execution. The agent, vendor and model are selected through the standard model property (agentCode:vendor:model), not here.
The channel the execution is attributed to.
Identifies the end user the execution is attributed to (usage tracking and per-user attribution).
Identifies the group the execution is attributed to.
input
object
required
agent
object
reasoning
object
Reasoning configuration. Honoured on the AI Proxy routes; the inference routes accept the object but ignore it.
How much the model should think before answering. The accepted values come from the selected model's own configuration; a model that does not expose the parameter rejects the request.
Possible values: [auto, none, summary, full]
How much of the reasoning trace is returned. auto leaves the decision to the vendor and is always accepted; the other values must be supported by the selected model's configuration.
OpenAI's equivalent of detail, accepted so a standard OpenAI client works unchanged. auto maps to detail: auto, concise to detail: summary and detailed to detail: full. Any other value is ignored. Used only when detail is absent.
metadata
object
nullable
conversation
object
metadata
object
nullable
prompt
object
variables
object
nullable
stream_options
object
text
object
format
object
nullable
oneOf
Responsesโ
- 200
- 400
- 401
- 403
- 500
OK
There was a validation error. Please check your request data.
- application/json
- Schema
- Example (from schema)
Schema
errors
object
nullable
{
"message": "string",
"errors": {}
}
The user is unauthorized or the session expired
The user does not have permission
There was an unexpected error