Skip to content
SupportLogin
Generate a model response

Generate a model response

responses.create(ResponseCreateParams**kwargs) -> Response
POST/api/v1/responses

Creates a Responses API response through the inference gateway.

ParametersExpand Collapse
x_organization_id: Optional[str]
traceparent: Optional[str]
model: str

Hosted model identifier, or stack/<slug> to call one of your inference stacks (stack:<slug> is still accepted). A stack supplies its model and default tools; explicitly requested MCP tools must be enabled on the stack, while file_search can name any of the caller’s authorized adapted datasets.

input: Optional[Union[str, Iterable[InputUnionMember1]]]

Text input, or an ordered array of messages and items replayed from earlier responses. May be omitted when previous_response_id supplies stored conversation history.

One of the following:
str
Iterable[InputUnionMember1]
One of the following:
class InputUnionMember1ResponseInputMessageDto: …
role: Literal["user", "assistant", "system", "developer"]
One of the following:
"user"
"assistant"
"system"
"developer"
content: Union[str, Iterable[Dict[str, object]]]

Text, or an array of content parts: input_text, input_image (image_url as an https or base64 data URL), or input_file (file_url, or filename with base64 file_data). Which parts a model accepts depends on the model; one that cannot read a part returns 400. input_file.file_id is not supported.

One of the following:
str
Iterable[Dict[str, object]]
Dict[str, object]

An item replayed from an earlier response: message, reasoning, mcp_list_tools, mcp_call, mcp_approval_request, or mcp_approval_response.

instructions: Optional[str]

System-level instructions for the model.

agentic_memory: Optional[bool]

Use agentic memory for this request: relevant memories from earlier turns with this stack are added to the model instructions, and the turn may be used to build new memories. Omitted or null uses the stack’s agentic memory setting; requests that do not name a stack default to false.

self_improvement: Optional[bool]

Enable self-improvement for this request. Omitted or null uses the stack’s setting. Only stack models accept true.

max_output_tokens: Optional[int]

Maximum number of tokens the model may generate.

minimum1
temperature: Optional[float]

Sampling temperature.

minimum0
maximum2
stream: Optional[Literal[false]]

Whether to stream semantic response events using server-sent events.

tools: Optional[Iterable[Tool]]

Responses API tools. Catalog MCP entries are hosted by Adaption; MCP entries with server_url are called by Adaption with caller-owned authorization; file_search runs over authorized adapted datasets; web_search searches the public web; code_execution runs in an owner-scoped, network-blocked sandbox. With model: stack/<slug>, omitted tools means the stack’s configured tools (none when tool_choice is “none”), and an empty array means no tools; requested hosted MCP labels must be enabled on the stack, and file_search uses the stack dataset scope when dataset_ids is omitted. connector_id MCP tools are not supported.

One of the following:
class ToolMcpRequestToolDto: …
type: Literal["mcp"]
server_label: str

Label used to identify this MCP server in tool calls. For hosted tools, use a catalog id from GET /tools.

authorization: Optional[str]

Authorization for this request. For server_url tools, this exact value is forwarded as the Authorization header. For hosted tools, it is the connector credential used instead of the stored connection. Never stored, logged or echoed back.

server_url: Optional[str]

Caller-provided public HTTPS MCP endpoint. Adaption calls it directly.

server_description: Optional[str]

Description of a caller-provided remote MCP server.

maxLength4096
allowed_tools: Optional[ToolMcpRequestToolDtoAllowedTools]

Narrow the connector’s tools: an array of tool names, or { tool_names?, read_only? }. Every name must be a tool the connector exposes.

One of the following:
Sequence[str]
class ToolMcpRequestToolDtoAllowedToolsUnionMember1: …
tool_names: Optional[Sequence[str]]
read_only: Optional[bool]
require_approval: Optional[ToolMcpRequestToolDtoRequireApproval]

Which calls wait for your approval: ‘always’, ‘never’, or { always?, never? } tool filters. Unset uses the saved tool permission, which defaults to allow without approval. A call that needs approval ends the response with an mcp_approval_request item; replay the output with an mcp_approval_response input item to continue.

One of the following:
Literal["always", "never"]
One of the following:
"always"
"never"
class ToolMcpRequestToolDtoRequireApprovalUnionMember1: …
always: Optional[ToolMcpRequestToolDtoRequireApprovalUnionMember1Always]
tool_names: Optional[Sequence[str]]
read_only: Optional[bool]
never: Optional[ToolMcpRequestToolDtoRequireApprovalUnionMember1Never]
tool_names: Optional[Sequence[str]]
read_only: Optional[bool]
class ToolFileSearchToolDto: …
type: Literal["file_search"]
dataset_ids: Optional[Sequence[str]]

Adapted dataset identifiers to search. Omit with model: stack/<slug> to use the datasets configured on that stack.

search_mode: Optional[Literal["vector", "lexical", "hybrid"]]

Retrieval strategy. Vector is the backward-compatible default; lexical uses BM25; hybrid fuses both.

One of the following:
"vector"
"lexical"
"hybrid"
class ToolWebSearchToolDto: …
type: Literal["web_search"]
filters: Optional[ToolWebSearchToolDtoFilters]
allowed_domains: Optional[Sequence[str]]

Only return results from these domains or their subdomains, e.g. openai.com. A leading https:// or *. is allowed; paths and ports are not.

search_context_size: Optional[Literal["low", "medium", "high"]]

How many search results the model gets per search: low 3, medium 5, high 10.

One of the following:
"low"
"medium"
"high"
user_location: Optional[ToolWebSearchToolDtoUserLocation]
type: Optional[Literal["approximate"]]
country: Optional[str]

Two-letter ISO country code. Results are biased towards this country.

city: Optional[str]

Accepted for compatibility; not used yet.

region: Optional[str]

Accepted for compatibility; not used yet.

timezone: Optional[str]

Accepted for compatibility; not used yet.

class ToolCodeExecutionToolDto: …
type: Literal["code_execution"]
session_id: Optional[str]

Opaque session identifier. Reuse it across responses to retain files in the same owner-scoped sandbox. Omit it for a session scoped to this response.

maxLength256
session_mode: Optional[Literal["persistent", "ephemeral"]]

Persistent retains files until the idle/lifetime limit; ephemeral destroys the sandbox after each call.

One of the following:
"persistent"
"ephemeral"
class ToolType: …

Another OpenAI-compatible Responses tool forwarded to the model provider.

type: str
max_tool_calls: Optional[int]

Maximum number of first-party and MCP tool calls to run for this response. Once reached, the model is asked to answer without calling more tools.

minimum1
maximum64
store: Optional[bool]

Whether Adaption should retain this response for later use with previous_response_id. Adaption defaults to false, unlike OpenAI, so retention requires explicitly setting store to true. A stored response is kept for 30 days from its creation, then deleted. When an ancestor was deleted, previous_response_id still works, but the replayed history starts at the oldest response still stored. To keep the full context, resend it with previous_response_id set to null.

previous_response_id: Optional[str]

A previously stored response whose input and output should precede this turn.

background: Optional[bool]

Background execution is incompatible with the hosted-tool loop. Only false is accepted.

tool_choice: Optional[ToolChoice]

How the model may use the attached tools. Omitted or auto, the model decides whether and how to call them. none forbids tools entirely. Naming a function demands that call: use { "type": "function", "name": "file_search" } when an answer must be grounded in the attached datasets, or name code_execution when execution is required. The response fails if the model omits a demanded call.

One of the following:
Literal["auto", "none"]
One of the following:
"auto"
"none"
class ToolChoiceUnionMember1: …
type: Literal["function"]
name: str
ReturnsExpand Collapse
class Response: …
id: str
object: Literal["response"]
created_at: Optional[int]

Unix timestamp (in seconds) when the response was created.

status: Literal["completed", "failed", "in_progress", 3 more]
One of the following:
"completed"
"failed"
"in_progress"
"cancelled"
"queued"
"incomplete"
model: str

Public name of the model that generated the response.

output: List[ResponseOutputItem]

Items the model generated, in order.

type: str

Item type, such as message, reasoning, function_call, mcp_call, file_search_call, web_search_call, code_execution_call, tool_search_call or tool_search_output. Fields beyond the ones listed depend on the type. On a self-improving stack, the model can search with tool_retriever for hosted MCP tools that were not loaded up front; each search is a tool_search_call followed by a tool_search_output.

id: Optional[str]

Identifier of the output item.

status: Optional[str]

Status of the item, such as completed or in_progress. A code_execution_call is completed, failed or timed_out.

role: Optional[Literal["assistant"]]

Author of a message item.

content: Optional[List[ResponseOutputContent]]

Content parts of a message item.

type: str

Content part type: output_text for reply text, refusal for a refusal.

text: Optional[str]

The reply text, on an output_text part.

refusal: Optional[str]

The refusal message, on a refusal part.

annotations: Optional[List[Dict[str, object]]]

Citations into text: file_citation for a file search source and url_citation (with url and title) for a web search source. Each covers its [S#] bracket and carries its citation_id.

name: Optional[str]

Name of the tool called, on function_call, mcp_call and mcp_approval_request items.

arguments: Optional[Union[str, Dict[str, object], null]]

JSON-encoded arguments for the tool, on function_call, mcp_call and mcp_approval_request items. On a tool_search_call item, the search as an object, e.g. {"query": "search Slack messages"}.

One of the following:
str
Dict[str, object]
call_id: Optional[str]

Identifier to answer a function_call with: send it back as the call_id of a function_call_output input item. On tool_search_call and tool_search_output items, it pairs a search with its result.

server_label: Optional[str]

Label of the MCP server, on mcp_call, mcp_approval_request and mcp_list_tools items.

execution: Optional[Literal["server", "client"]]

Where a tool search ran, on tool_search_call and tool_search_output items. Searches Adaption runs are server.

One of the following:
"server"
"client"
approval_request_id: Optional[str]

The approval request this mcp_call answers, if it needed approval.

output: Optional[str]

What the tool returned, on an mcp_call item.

error: Optional[str]

Why the tool call failed, on mcp_call and mcp_list_tools items.

tools: Optional[List[Dict[str, object]]]

Tools the server offers, on an mcp_list_tools item. On a tool_search_output item, the tools the search loaded, as function definitions.

summary: Optional[List[Dict[str, object]]]

Summary parts of a reasoning item, each with type and text.

encrypted_content: Optional[str]

Opaque reasoning state to replay in a later request, on a reasoning item.

queries: Optional[List[str]]

Search queries, on a file_search_call item.

action: Optional[Dict[str, object]]

The search on a web_search_call item: type, query, queries and sources (the result URLs).

results: Optional[List[Dict[str, object]]]

Matched chunks on a file_search_call item, or search results on a web_search_call item (citation_id, title, url, and when available summary, highlights, published_date, author). Send the item back unchanged to replay it without a new search.

session_id: Optional[str]

Sandbox session of a code_execution_call item. Send it as the session_id of a code_execution tool to keep its files.

execution_id: Optional[str]

Identifier of the run, on a code_execution_call item.

language: Optional[Literal["python", "javascript", "typescript", "bash"]]

Language of the code, on a code_execution_call item.

One of the following:
"python"
"javascript"
"typescript"
"bash"
code: Optional[str]

Code the model ran, on a code_execution_call item.

exit_code: Optional[int]

Exit code of the program, on a code_execution_call item. Null when the program did not run.

stdout: Optional[str]

Standard output, on a code_execution_call item.

stderr: Optional[str]

Standard error, on a code_execution_call item, or why the run failed.

stdout_truncated: Optional[bool]

Whether stdout was cut to the output limit.

stderr_truncated: Optional[bool]

Whether stderr was cut to the output limit.

sandbox_reused: Optional[bool]

Whether the run reused a sandbox from an earlier run in the session.

timing: Optional[Dict[str, object]]

Run timing in milliseconds, on a code_execution_call item: sandbox_ms, execution_ms and total_ms.

output_text: str

The text of every output_text part in output, joined. Reasoning and tool calls are excluded.

error: Optional[ResponseError]
code: str
message: str
incomplete_details: Optional[ResponseIncompleteDetails]
reason: Optional[str]

Why the response is incomplete.

usage: Optional[ResponseUsage]
input_tokens: int
output_tokens: int
total_tokens: int
input_tokens_details: Optional[Dict[str, object]]
output_tokens_details: Optional[Dict[str, object]]
cost: Optional[float]

Cost of the request in US dollars. Missing when a model call did not report its cost.

previous_response_id: Optional[str]

The response this one continues, if any.

store: Optional[bool]

Whether the response is stored for later retrieval.

metadata: Optional[Dict[str, str]]

Generate a model response

import os
from adaption import Adaption

client = Adaption(
    api_key=os.environ.get("ADAPTION_API_KEY"),  # This is the default and can be omitted
)
for response in client.responses.create(
    model="qwen3.5-397b",
):
  print(response)
{
  "id": "resp_123",
  "object": "response",
  "created_at": 1750000000,
  "status": "completed",
  "model": "qwen3.5-397b",
  "output": [
    {
      "type": "message",
      "id": "id",
      "status": "completed",
      "role": "assistant",
      "content": [
        {
          "type": "output_text",
          "text": "Once upon a time, a unicorn drifted to sleep on a cloud.",
          "refusal": "refusal",
          "annotations": [
            {
              "foo": "bar"
            }
          ]
        }
      ],
      "name": "get_weather",
      "arguments": "{\"city\":\"Paris\"}",
      "call_id": "call_123",
      "server_label": "docs",
      "execution": "server",
      "approval_request_id": "approval_request_id",
      "output": "output",
      "error": "error",
      "tools": [
        {
          "foo": "bar"
        }
      ],
      "summary": [
        {
          "foo": "bar"
        }
      ],
      "encrypted_content": "encrypted_content",
      "queries": [
        "string"
      ],
      "action": {
        "foo": "bar"
      },
      "results": [
        {
          "foo": "bar"
        }
      ],
      "session_id": "session_id",
      "execution_id": "execution_id",
      "language": "python",
      "code": "code",
      "exit_code": 0,
      "stdout": "stdout",
      "stderr": "stderr",
      "stdout_truncated": true,
      "stderr_truncated": true,
      "sandbox_reused": true,
      "timing": {
        "foo": "bar"
      }
    }
  ],
  "output_text": "Once upon a time, a unicorn drifted to sleep on a cloud.",
  "error": {
    "code": "server_error",
    "message": "The model provider could not complete the request."
  },
  "incomplete_details": {
    "reason": "max_output_tokens"
  },
  "usage": {
    "input_tokens": 36,
    "output_tokens": 87,
    "total_tokens": 123,
    "input_tokens_details": {
      "cached_tokens": "bar"
    },
    "output_tokens_details": {
      "reasoning_tokens": "bar"
    },
    "cost": 0.0012
  },
  "previous_response_id": "previous_response_id",
  "store": true,
  "metadata": {
    "foo": "string"
  }
}
Returns Examples
{
  "id": "resp_123",
  "object": "response",
  "created_at": 1750000000,
  "status": "completed",
  "model": "qwen3.5-397b",
  "output": [
    {
      "type": "message",
      "id": "id",
      "status": "completed",
      "role": "assistant",
      "content": [
        {
          "type": "output_text",
          "text": "Once upon a time, a unicorn drifted to sleep on a cloud.",
          "refusal": "refusal",
          "annotations": [
            {
              "foo": "bar"
            }
          ]
        }
      ],
      "name": "get_weather",
      "arguments": "{\"city\":\"Paris\"}",
      "call_id": "call_123",
      "server_label": "docs",
      "execution": "server",
      "approval_request_id": "approval_request_id",
      "output": "output",
      "error": "error",
      "tools": [
        {
          "foo": "bar"
        }
      ],
      "summary": [
        {
          "foo": "bar"
        }
      ],
      "encrypted_content": "encrypted_content",
      "queries": [
        "string"
      ],
      "action": {
        "foo": "bar"
      },
      "results": [
        {
          "foo": "bar"
        }
      ],
      "session_id": "session_id",
      "execution_id": "execution_id",
      "language": "python",
      "code": "code",
      "exit_code": 0,
      "stdout": "stdout",
      "stderr": "stderr",
      "stdout_truncated": true,
      "stderr_truncated": true,
      "sandbox_reused": true,
      "timing": {
        "foo": "bar"
      }
    }
  ],
  "output_text": "Once upon a time, a unicorn drifted to sleep on a cloud.",
  "error": {
    "code": "server_error",
    "message": "The model provider could not complete the request."
  },
  "incomplete_details": {
    "reason": "max_output_tokens"
  },
  "usage": {
    "input_tokens": 36,
    "output_tokens": 87,
    "total_tokens": 123,
    "input_tokens_details": {
      "cached_tokens": "bar"
    },
    "output_tokens_details": {
      "reasoning_tokens": "bar"
    },
    "cost": 0.0012
  },
  "previous_response_id": "previous_response_id",
  "store": true,
  "metadata": {
    "foo": "string"
  }
}