@ai-sdk/open-responses 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/LICENSE +13 -0
- package/README.md +57 -0
- package/dist/index.d.mts +34 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +629 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +613 -0
- package/dist/index.mjs.map +1 -0
- package/docs/06-open-responses.mdx +98 -0
- package/package.json +77 -0
- package/src/index.ts +2 -0
- package/src/open-responses-provider.ts +100 -0
- package/src/responses/convert-to-open-responses-input.ts +206 -0
- package/src/responses/map-open-responses-finish-reason.ts +21 -0
- package/src/responses/open-responses-api.ts +1239 -0
- package/src/responses/open-responses-config.ts +9 -0
- package/src/responses/open-responses-language-model.ts +500 -0
- package/src/version.ts +6 -0
package/CHANGELOG.md
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2023 Vercel, Inc.
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# AI SDK - Open Responses Provider
|
|
2
|
+
|
|
3
|
+
The **[Open Responses provider](https://ai-sdk.dev/providers/ai-sdk-providers/open-responses)** for the [AI SDK](https://ai-sdk.dev/docs)
|
|
4
|
+
contains language model support for [Open Responses](https://www.openresponses.org/) compatible APIs.
|
|
5
|
+
|
|
6
|
+
## Setup
|
|
7
|
+
|
|
8
|
+
The Open Responses provider is available in the `@ai-sdk/open-responses` module. You can install it with
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm i @ai-sdk/open-responses
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Skill for Coding Agents
|
|
15
|
+
|
|
16
|
+
If you use coding agents such as Claude Code or Cursor, we highly recommend adding the AI SDK skill to your repository:
|
|
17
|
+
|
|
18
|
+
```shell
|
|
19
|
+
npx skills add vercel/ai
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Provider Instance
|
|
23
|
+
|
|
24
|
+
Create an Open Responses provider instance using `createOpenResponses`:
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import { createOpenResponses } from '@ai-sdk/open-responses';
|
|
28
|
+
|
|
29
|
+
const openResponses = createOpenResponses({
|
|
30
|
+
name: 'aProvider',
|
|
31
|
+
url: 'http://localhost:1234/v1/responses',
|
|
32
|
+
});
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
You can use this instance to access models served by any Open Responses compatible endpoint.
|
|
36
|
+
|
|
37
|
+
## Example
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
import { createOpenResponses } from '@ai-sdk/open-responses';
|
|
41
|
+
import { generateText } from 'ai';
|
|
42
|
+
|
|
43
|
+
const openResponses = createOpenResponses({
|
|
44
|
+
name: 'aProvider',
|
|
45
|
+
url: 'http://localhost:1234/v1/responses',
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const { text } = await generateText({
|
|
49
|
+
model: openResponses('mistralai/ministral-3-14b-reasoning'),
|
|
50
|
+
prompt: 'Invent a new holiday and describe its traditions.',
|
|
51
|
+
maxOutputTokens: 100,
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Documentation
|
|
56
|
+
|
|
57
|
+
Please check out the **[Open Responses provider documentation](https://ai-sdk.dev/providers/ai-sdk-providers/open-responses)** for more information.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ProviderV3, LanguageModelV3 } from '@ai-sdk/provider';
|
|
2
|
+
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
3
|
+
|
|
4
|
+
declare const VERSION: string;
|
|
5
|
+
|
|
6
|
+
interface OpenResponsesProvider extends ProviderV3 {
|
|
7
|
+
(modelId: string): LanguageModelV3;
|
|
8
|
+
}
|
|
9
|
+
interface OpenResponsesProviderSettings {
|
|
10
|
+
/**
|
|
11
|
+
* URL for the Open Responses API POST endpoint.
|
|
12
|
+
*/
|
|
13
|
+
url: string;
|
|
14
|
+
/**
|
|
15
|
+
* Provider name. Used as key for provider options and metadata.
|
|
16
|
+
*/
|
|
17
|
+
name: string;
|
|
18
|
+
/**
|
|
19
|
+
* API key for authenticating requests.
|
|
20
|
+
*/
|
|
21
|
+
apiKey?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Custom headers to include in the requests.
|
|
24
|
+
*/
|
|
25
|
+
headers?: Record<string, string>;
|
|
26
|
+
/**
|
|
27
|
+
* Custom fetch implementation. You can use it as a middleware to intercept requests,
|
|
28
|
+
* or to provide a custom fetch implementation for e.g. testing.
|
|
29
|
+
*/
|
|
30
|
+
fetch?: FetchFunction;
|
|
31
|
+
}
|
|
32
|
+
declare function createOpenResponses(options: OpenResponsesProviderSettings): OpenResponsesProvider;
|
|
33
|
+
|
|
34
|
+
export { VERSION, createOpenResponses };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ProviderV3, LanguageModelV3 } from '@ai-sdk/provider';
|
|
2
|
+
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
3
|
+
|
|
4
|
+
declare const VERSION: string;
|
|
5
|
+
|
|
6
|
+
interface OpenResponsesProvider extends ProviderV3 {
|
|
7
|
+
(modelId: string): LanguageModelV3;
|
|
8
|
+
}
|
|
9
|
+
interface OpenResponsesProviderSettings {
|
|
10
|
+
/**
|
|
11
|
+
* URL for the Open Responses API POST endpoint.
|
|
12
|
+
*/
|
|
13
|
+
url: string;
|
|
14
|
+
/**
|
|
15
|
+
* Provider name. Used as key for provider options and metadata.
|
|
16
|
+
*/
|
|
17
|
+
name: string;
|
|
18
|
+
/**
|
|
19
|
+
* API key for authenticating requests.
|
|
20
|
+
*/
|
|
21
|
+
apiKey?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Custom headers to include in the requests.
|
|
24
|
+
*/
|
|
25
|
+
headers?: Record<string, string>;
|
|
26
|
+
/**
|
|
27
|
+
* Custom fetch implementation. You can use it as a middleware to intercept requests,
|
|
28
|
+
* or to provide a custom fetch implementation for e.g. testing.
|
|
29
|
+
*/
|
|
30
|
+
fetch?: FetchFunction;
|
|
31
|
+
}
|
|
32
|
+
declare function createOpenResponses(options: OpenResponsesProviderSettings): OpenResponsesProvider;
|
|
33
|
+
|
|
34
|
+
export { VERSION, createOpenResponses };
|