Open Responses
Learn how to use the Open Responses provider for the AI SDK.
The Open Responses provider connects AI SDK
Core to language model servers that implement an Open Responses-compatible
POST endpoint. Open Responses is an open specification based on the OpenAI
Responses API.
Use @ai-sdk/open-responses for third-party or self-hosted endpoints that
implement this protocol, such as LM Studio. If you call OpenAI directly and
need OpenAI-specific provider options or built-in tools, use the
@ai-sdk/openai provider instead.
Setup
The Open Responses provider is available in the @ai-sdk/open-responses module. You can install it with
$ pnpm add @ai-sdk/open-responses
$ npm install @ai-sdk/open-responses
$ yarn add @ai-sdk/open-responses
$ bun add @ai-sdk/open-responses
Provider Instance
Create an Open Responses provider instance using createOpenResponses:
The name and url options are required:
-
name string
Provider name. Used in the model's provider identifier and as the key for provider options.
-
url string
Full URL for the Open Responses API
POSTendpoint. Pass the endpoint URL, such ashttp://localhost:1234/v1/responses, not only its base URL.
You can use the following optional settings to customize the Open Responses provider instance:
-
apiKey string
API key that is sent as a bearer token in the
Authorizationheader. -
headers Record<string,string> | () => Record<string,string>
Custom headers to include in requests. Pass a function when headers must be resolved lazily for each request.
-
fetch (input: RequestInfo, init?: RequestInit) => Promise<Response>
Custom fetch implementation. Defaults to the global
fetchfunction. -
failedResponseHandler ResponseHandler<APICallError>
Custom handler for non-successful HTTP responses. Use this when an endpoint returns an error envelope that differs from the default OpenAI-compatible
{ error: { message, type, param, code } }shape. -
getResponseErrorMetadata function
Extracts optional
statusCodeandisRetryablemetadata from a response error object, including endpoint-specific fields. Applies to generation failures and streamingresponse.failedanderrorevents. The standard Open Responses error fields arecodeandmessage; endpoint-specific status fields require this callback. When only a status code is supplied, the SDK derives retryability from it. HTTP failures are handled separately byfailedResponseHandler. -
strictResponseInput boolean
Serializes assistant history using strict OpenAI Responses input schemas. Assistant messages without an item ID are sent as easy input messages, while messages with a genuine provider item ID are sent as complete output items. Defaults to
false. -
customToolId
${string}.${string}Provider-tool ID used by
provider.tools.customTool. Defaults toopen-responses.custom. -
structuredOutputs boolean
Whether JSON response formats are sent to the endpoint. When
false, structured-output requests are omitted with an unsupported warning. Defaults totrue. -
userAgentSuffix string
Overrides the default
ai-sdk-open-responses/<version>user-agent suffix.
Endpoint Examples
For a local LM Studio server that does not require authentication:
For the OpenAI Responses API:
You can use the same setup with another compatible service by changing the
name, url, authentication, and model ID.
Language Models
The Open Responses provider instance is a function that you can invoke to create a language model:
The model ID is passed to the endpoint unchanged.
You can use Open Responses models with the generateText and streamText functions,
and they support structured data generation with Output
(see AI SDK Core).
Generate Text
Stream Text
Reasoning and Provider Options
Use the top-level reasoning setting to control
reasoning effort. The provider maps supported values to the Open Responses
reasoning.effort field.
The provider also supports reasoningEffort and reasoningSummary through
providerOptions. The provider option key must match the name passed to
createOpenResponses:
reasoningEffort accepts any string and is passed through unchanged to the
endpoint's reasoning.effort field. Use it for endpoint-native values that are
not part of the top-level reasoning setting, such as 'max'. When both are
set, providerOptions reasoningEffort takes precedence over the top-level
reasoning value.
reasoningSummary accepts 'auto', 'concise', or 'detailed' and can be
combined with either reasoning effort setting. Reasoning support and accepted
effort values depend on the endpoint and model; unsupported values may be
rejected or ignored by the endpoint.
Custom Tools
Endpoints with OpenAI-compatible custom-tool support can call tools with raw string inputs, optionally constrained by a regex or Lark grammar. These tools execute in your application:
The endpoint must support the OpenAI-compatible custom tool,
custom_tool_call, and custom_tool_call_output wire types, as OpenAI and
QuiverAI do. These are compatibility extensions, not part of the Open Responses
2026-04-24 specification. Custom-tool results can include text, images, and files
when supported by the endpoint.
File Inputs
The provider supports image and non-image file inputs in user messages. Images
are sent as input_image parts, while other media types, such as PDFs, are
sent as input_file parts.
You can provide a file as inline data:
You can also set data to a URL. The endpoint and model must support the
file's media type. Provider file references, such as OpenAI file IDs, and
file data in { type: 'text', text: '...' } format are not supported by this
provider.
Experimental Extensions
Open Responses implementations can add namespaced tools, items, and streaming
events. Use Experimental_OpenResponsesExtension to encode and decode an
implementation's extension wire formats. Unregistered provider tools are
omitted from requests with an unsupported warning.
This API is experimental and may change in a future release.
The AI SDK provider-tool ID uses dot notation (acme.document_search), while
Open Responses wire types use colon notation (acme:document_search). The
namespace in id must match the namespace in every registered wire type.
Some Responses-compatible implementations document non-namespaced extension
discriminators, such as web_search, web_search_call, or
response.custom_tool_call_input.delta. These are not portable Open Responses
types. Register each exact value through the dedicated bare fields to opt in:
Set allowBareTypes: true when using bareToolType, bareItemTypes, or
bareEventTypes. These fields accept only non-namespaced values. They do not
enable unknown JSON passthrough: a bare discriminator is handled only when it
exactly matches a registered value. Core Open Responses discriminators and
duplicate registrations are rejected.
Use the normal namespaced fields whenever the implementation supports them.
Experimental_OpenResponsesExtension remains the namespaced interface;
use Experimental_OpenResponsesBareExtension only for this compatibility
mode.
Set providerExecuted on each decoded tool-call or tool-input-start part.
It can vary by item or event.
An extension codec can define:
encodeTool: Encodes a provider tool. Returningundefinedomits the tool with anunsupportedwarning. AtoolChoicethat selects the omitted tool is also omitted.encodeToolChoice: Encodes a specifictoolChoice. The default is an object containing the registeredtoolTypeorbareToolType.decodeItem: Maps a completed item to AI SDK content parts.modeis either'generate'or'stream'.encodeInputItem: Encodes tool-call or tool-result history when the original wire item is unavailable. Returned items must includeid,status, and atyperegistered throughitemTypesorbareItemTypes.decodeEvent: Maps a streaming event to AI SDK stream parts. Itsstatemap lasts for one response stream.
Tool, item, and event capabilities are independent. An item-only extension, for
example, defines itemTypes (or bareItemTypes) and decodeItem without a
tool type or encodeTool. Capability fields must be provided in pairs.
Each decoded item adds an open-responses.extension-replay custom part that
stores the original JSON in provider metadata. Other decoded parts reference
that custom part instead of copying the item. Passing result.response.messages
to a later call replays the original item once, including opaque fields. This
also preserves items that decode only to response-only source parts.
The adapter validates only the extension discriminator fields. Validate other item and event fields in the codec before returning AI SDK parts. The original item is stored in provider metadata and may appear in persisted messages, telemetry, logs, or UI payloads.
Extension callbacks cannot be serialized across workflow step boundaries.
Create the provider inside the workflow step. Serializing a model configured
with extensions throws a SerializationError.
Limitations
- Stop sequences,
topK, andseedare not supported and are ignored with warnings. - The provider supports language models only. It does not provide embedding or image generation models.
- AI SDK function tools and registered Open Responses extensions are supported. Other provider-specific tools and options require a dedicated provider implementation.