UNPKG

@ai-sdk/open-responses

Version:

The **[Open Responses provider](https://ai-sdk.dev/providers/ai-sdk-providers/open-responses)** for the [AI SDK](https://ai-sdk.dev/docs) contains language model support for [Open Responses](https://www.openresponses.org/) compatible APIs.

100 lines (68 loc) 2.73 kB
--- title: Open Responses description: Learn how to use the Open Responses provider for the AI SDK. --- # Open Responses Provider The [Open Responses](https://www.openresponses.org/) provider contains language model support for Open Responses compatible APIs. ## Setup The Open Responses provider is available in the `@ai-sdk/open-responses` module. You can install it with <Tabs items={['pnpm', 'npm', 'yarn', 'bun']}> <Tab> <Snippet text="pnpm add @ai-sdk/open-responses" dark /> </Tab> <Tab> <Snippet text="npm install @ai-sdk/open-responses" dark /> </Tab> <Tab> <Snippet text="yarn add @ai-sdk/open-responses" dark /> </Tab> <Tab> <Snippet text="bun add @ai-sdk/open-responses" dark /> </Tab> </Tabs> ## Provider Instance Create an Open Responses provider instance using `createOpenResponses`: ```ts import { createOpenResponses } from '@ai-sdk/open-responses'; const openResponses = createOpenResponses({ name: 'aProvider', url: 'http://localhost:1234/v1/responses', }); ``` The `name` and `url` options are required: - **name** _string_ Provider name. Used as the key for provider options and metadata. - **url** _string_ URL for the Open Responses API POST endpoint. You can use the following optional settings to customize the Open Responses provider instance: - **apiKey** _string_ API key that is being sent using the `Authorization` header. - **headers** _Record&lt;string,string&gt;_ Custom headers to include in the requests. - **fetch** _(input: RequestInfo, init?: RequestInit) => Promise&lt;Response&gt;_ Custom [fetch](https://developer.mozilla.org/en-US/docs/Web/API/fetch) implementation. Defaults to the global `fetch` function. ## Language Models The Open Responses provider instance is a function that you can invoke to create a language model: ```ts const model = openResponses('mistralai/ministral-3-14b-reasoning'); ``` You can use Open Responses models with the `generateText` and `streamText` functions, and they support structured data generation with [`Output`](/docs/reference/ai-sdk-core/output) (see [AI SDK Core](/docs/ai-sdk-core)). ### Example ```ts import { createOpenResponses } from '@ai-sdk/open-responses'; import { generateText } from 'ai'; const openResponses = createOpenResponses({ name: 'aProvider', url: 'http://localhost:1234/v1/responses', }); const { text } = await generateText({ model: openResponses('mistralai/ministral-3-14b-reasoning'), prompt: 'Invent a new holiday and describe its traditions.', }); ``` ## Notes - Stop sequences, `topK`, and `seed` are not supported and are ignored with warnings. - Image inputs are supported for user messages with `file` parts using image media types.