responses_create
Generate a completion from an OpenAI Responses-shaped request, returning the Responses API response object. The completion is produced by the host agent's own model: direct MCP sampling on pre-2026-07-28 connections, an MRTR…
Instructions
Generate a completion from an OpenAI Responses-shaped request, returning the Responses API response object. The completion is produced by the host agent's own model: direct MCP sampling on pre-2026-07-28 connections, an MRTR InputRequiredResult carrying the request payload on 2026-07-28+. input is a string or a list of input items; each item is {role, content} with role user, assistant, system, or developer, and content a string or a list of text parts ({type: 'input_text'|'text', input_text: '...'}). A string input becomes one user message. System and developer items fold into the system prompt alongside instructions, which leads. Non-text parts are rejected. max_tokens is named for uniformity with the other tools (the Responses API calls it max_output_tokens); same meaning. When output_schema is given, the request carries exactly one required tool whose input schema is that schema, and the validated structured completion is returned as JSON text inside the output_text. When tools is given, the tool definitions are forwarded to the host's model with tool_choice, but only if the host advertised the sampling.tools capability: otherwise the tools are dropped (a warning is logged server-side) and the call degrades to a plain-text completion. When the host answers by calling tools, the output array carries the accompanying text as a message item (omitted when empty) followed by one function_call item per call: {type: 'function_call', id: 'fc_', call_id: '', name: '...', arguments: ''}; the host's tool-call id maps to call_id, the object id is derived from it. A plain-text host answer returns a single message item. tools and output_schema cannot be combined. An optional persona {name, input_schema, output_schema} registers a per-call contract: the request arguments are validated against input_schema before anything is sent, and the host's completion text must parse as JSON validating against output_schema. The server is stateless and keeps no persona registry. persona.output_schema and output_schema cannot be combined. Session cursors: the server keeps no session state. To continue a conversation, pass the accumulated history back in input and the previous turn's response id as previous_response_id: '' starts a cursor chain (nothing verified), 'cur_<64 hex>' continues a verified chain (checked against the history passed back; mismatch fails loud naming expected vs received), 'resp_<32 hex>' (a previous response id) anchors a new chain at the passed history. The response object's id field IS the cursor: when previous_response_id is given it carries the 'cur_' tamper-evident commitment, when omitted it stays the opaque 'resp_' unique id exactly as before. The cursor is 'cur_' + sha256 over canonical JSON '{"model","tool","transcript"}' (sorted keys, compact separators), the transcript being the conversation through the assistant turn, so the caller can recompute it. Re-supply previous_response_id on the MRTR retry round on 2026-07-28+ connections, like persona. No API key is used or needed: the connected agent is the model.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| input | Yes | The Responses API input: a string, which becomes one user message, or a list of input items {role, content}. role is user, assistant, system, or developer; content is a string or a list of text parts ({type: 'input_text'|'text', input_text: '...'}). System and developer items fold into the system prompt alongside instructions. Non-text parts are rejected. | |
| model | No | Model alias; agent-default means the host's own model. | agent-default |
| tools | No | Optional tool definitions to forward to the host's model. Each is {name, description, input_schema} where input_schema is a JSON Schema object with root type 'object'. Forwarded only when the host advertised the sampling.tools capability; otherwise dropped with a server-side warning and the call degrades to plain text. | |
| persona | No | Optional persona contract for this call: {name, input_schema, output_schema}. name is required and non-empty; the server is stateless and keeps no persona registry. When input_schema is given, the request arguments (input, instructions, model, temperature, max_tokens, output_schema, tools, tool_choice, previous_response_id) are validated against it before anything is sent. When output_schema is given, the host's completion text must parse as JSON validating against it. persona.output_schema and output_schema cannot be combined. | |
| max_tokens | No | Maximum tokens to generate. Named max_tokens for uniformity with the other tools; the Responses API calls it max_output_tokens. | |
| temperature | No | Sampling temperature, if the host honors it. | |
| tool_choice | No | Optional tool-choice mode, forwarded with tools; defaults to 'auto' when tools are given. | |
| instructions | No | Optional system prompt; leads the system/developer items. | |
| output_schema | No | Optional JSON Schema (root type object). When given, the sampling request carries exactly one required tool with this input schema and the completion is validated against it before returning. | |
| previous_response_id | No | Optional session cursor for host-owned multi-turn continuations. The server keeps no session state: pass the accumulated history back in input and the previous turn's response id here. '' starts a cursor chain (nothing verified); 'cur_<64 hex>' continues a verified chain, checked against the history passed back (mismatch fails loud, naming expected vs received); 'resp_<32 hex>' (a previous response id) anchors a new chain at the passed history. When given, the response object's id field carries the 'cur_' cursor; when omitted the id stays the opaque 'resp_' unique id exactly as before. |