@ai-sdk/openai-compatible 3.0.76 → 3.0.78
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 +19 -0
- package/README.md +3 -76
- package/dist/index.js +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @ai-sdk/openai-compatible
|
|
2
2
|
|
|
3
|
+
## 3.0.78
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- e729d58: chore(docs): update `README.md` for consistent format and to avoid duplication
|
|
8
|
+
- Updated dependencies [5475347]
|
|
9
|
+
- Updated dependencies [e729d58]
|
|
10
|
+
- @ai-sdk/provider@4.0.34
|
|
11
|
+
- @ai-sdk/provider-utils@5.0.68
|
|
12
|
+
|
|
13
|
+
## 3.0.77
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [8202f5b]
|
|
18
|
+
- Updated dependencies [85d84a1]
|
|
19
|
+
- @ai-sdk/provider-utils@5.0.67
|
|
20
|
+
- @ai-sdk/provider@4.0.33
|
|
21
|
+
|
|
3
22
|
## 3.0.76
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -2,16 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
This package provides a foundation for implementing providers that expose an OpenAI-compatible API.
|
|
4
4
|
|
|
5
|
-
The primary [OpenAI provider](../openai/README.md) is more feature-rich, including OpenAI-specific experimental and legacy features. This package offers a lighter-weight alternative focused on core OpenAI-compatible functionality.
|
|
6
|
-
|
|
7
5
|
> **Deploying to Vercel?** With Vercel's AI Gateway you can access hundreds of models from any provider — no additional packages, API keys, or extra cost. [Get started with AI Gateway](https://vercel.com/ai-gateway).
|
|
8
6
|
|
|
9
7
|
## Setup
|
|
10
8
|
|
|
11
|
-
The provider is available in the `@ai-sdk/openai-compatible` module. You can install it with
|
|
12
|
-
|
|
13
9
|
```bash
|
|
14
|
-
npm i @ai-sdk/openai-compatible
|
|
10
|
+
npm i ai @ai-sdk/openai-compatible
|
|
15
11
|
```
|
|
16
12
|
|
|
17
13
|
## Skill for Coding Agents
|
|
@@ -22,15 +18,7 @@ If you use coding agents such as Claude Code or Cursor, we highly recommend addi
|
|
|
22
18
|
npx skills add vercel/ai
|
|
23
19
|
```
|
|
24
20
|
|
|
25
|
-
##
|
|
26
|
-
|
|
27
|
-
You can import the provider creation method `createOpenAICompatible` from `@ai-sdk/openai-compatible`:
|
|
28
|
-
|
|
29
|
-
```ts
|
|
30
|
-
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
## Example
|
|
21
|
+
## Usage
|
|
34
22
|
|
|
35
23
|
```ts
|
|
36
24
|
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
|
|
@@ -46,65 +34,4 @@ const { text } = await generateText({
|
|
|
46
34
|
});
|
|
47
35
|
```
|
|
48
36
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
You can further customize headers if desired. For example, here is an alternate implementation to pass along api key authentication:
|
|
52
|
-
|
|
53
|
-
```ts
|
|
54
|
-
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
|
|
55
|
-
import { generateText } from 'ai';
|
|
56
|
-
|
|
57
|
-
const { text } = await generateText({
|
|
58
|
-
model: createOpenAICompatible({
|
|
59
|
-
baseURL: 'https://api.example.com/v1',
|
|
60
|
-
name: 'example',
|
|
61
|
-
headers: {
|
|
62
|
-
Authorization: `Bearer ${process.env.MY_API_KEY}`,
|
|
63
|
-
},
|
|
64
|
-
}).chatModel('meta-llama/Llama-3-70b-chat-hf'),
|
|
65
|
-
prompt: 'Write a vegetarian lasagna recipe for 4 people.',
|
|
66
|
-
});
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
### Including model ids for auto-completion
|
|
70
|
-
|
|
71
|
-
```ts
|
|
72
|
-
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
|
|
73
|
-
import { generateText } from 'ai';
|
|
74
|
-
|
|
75
|
-
type ExampleChatModelIds =
|
|
76
|
-
| 'meta-llama/Llama-3-70b-chat-hf'
|
|
77
|
-
| 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo'
|
|
78
|
-
| (string & {});
|
|
79
|
-
|
|
80
|
-
type ExampleCompletionModelIds =
|
|
81
|
-
| 'codellama/CodeLlama-34b-Instruct-hf'
|
|
82
|
-
| 'Qwen/Qwen2.5-Coder-32B-Instruct'
|
|
83
|
-
| (string & {});
|
|
84
|
-
|
|
85
|
-
type ExampleEmbeddingModelIds =
|
|
86
|
-
| 'BAAI/bge-large-en-v1.5'
|
|
87
|
-
| 'bert-base-uncased'
|
|
88
|
-
| (string & {});
|
|
89
|
-
|
|
90
|
-
const model = createOpenAICompatible<
|
|
91
|
-
ExampleChatModelIds,
|
|
92
|
-
ExampleCompletionModelIds,
|
|
93
|
-
ExampleEmbeddingModelIds
|
|
94
|
-
>({
|
|
95
|
-
baseURL: 'https://api.example.com/v1',
|
|
96
|
-
name: 'example',
|
|
97
|
-
apiKey: process.env.MY_API_KEY,
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
// Subsequent calls to e.g. `model.chatModel` will auto-complete the model id
|
|
101
|
-
// from the list of `ExampleChatModelIds` while still allowing free-form
|
|
102
|
-
// strings as well.
|
|
103
|
-
|
|
104
|
-
const { text } = await generateText({
|
|
105
|
-
model: model.chatModel('meta-llama/Llama-3-70b-chat-hf'),
|
|
106
|
-
prompt: 'Write a vegetarian lasagna recipe for 4 people.',
|
|
107
|
-
});
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
For more examples, see the [OpenAI Compatible Providers](https://ai-sdk.dev/providers/openai-compatible-providers) documentation.
|
|
37
|
+
See the [OpenAI Compatible Provider documentation](https://ai-sdk.dev/providers/openai-compatible-providers) for more information.
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/openai-compatible",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.78",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@ai-sdk/provider": "4.0.
|
|
39
|
-
"@ai-sdk/provider-utils": "5.0.
|
|
38
|
+
"@ai-sdk/provider": "4.0.34",
|
|
39
|
+
"@ai-sdk/provider-utils": "5.0.68"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@ai-sdk/test-server": "2.0.4",
|