Gathering detailed insights and metrics for @ai-sdk/openai-compatible
Gathering detailed insights and metrics for @ai-sdk/openai-compatible
Build AI-powered applications with React, Svelte, Vue, and Solid
npm install @ai-sdk/openai-compatible
Typescript
Module System
Min. Node Version
Node Version
NPM Version
89.9
Supply Chain
99.2
Quality
96
Maintenance
100
Vulnerability
99.6
License
@ai-sdk/svelte@1.1.16
Updated on Feb 14, 2025
@ai-sdk/react@1.1.15
Updated on Feb 14, 2025
@ai-sdk/vue@1.1.16
Updated on Feb 14, 2025
ai@4.1.40
Updated on Feb 14, 2025
@ai-sdk/valibot@0.0.7
Updated on Feb 14, 2025
@ai-sdk/solid@1.1.17
Updated on Feb 14, 2025
TypeScript (62.46%)
MDX (36.86%)
JavaScript (0.38%)
Vue (0.31%)
Love this project? Help keep it running — sponsor us today! 🚀
Total Downloads
281,884
Last Day
11,668
Last Week
72,089
Last Month
212,684
Last Year
281,884
NOASSERTION License
11,855 Stars
2,751 Commits
1,808 Forks
70 Watchers
101 Branches
349 Contributors
Updated on Feb 15, 2025
Minified
Minified + Gzipped
Latest Version
0.1.10
Package Id
@ai-sdk/openai-compatible@0.1.10
Unpacked Size
294.86 kB
Size
50.64 kB
File Count
16
NPM Version
10.8.2
Node Version
18.20.6
Published on
Feb 13, 2025
Cumulative downloads
Total Downloads
Last Day
26.6%
11,668
Compared to previous day
Last Week
29.3%
72,089
Compared to previous week
Last Month
392.1%
212,684
Compared to previous month
Last Year
0%
281,884
Compared to previous year
2
1
5
This package provides a foundation for implementing providers that expose an OpenAI-compatible API.
The primary OpenAI provider is more feature-rich, including OpenAI-specific experimental and legacy features. This package offers a lighter-weight alternative focused on core OpenAI-compatible functionality.
The provider is available in the @ai-sdk/openai-compatible
module. You can install it with
1npm i @ai-sdk/openai-compatible
You can import the provider creation method createOpenAICompatible
from @ai-sdk/openai-compatible
:
1import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
1import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
2import { generateText } from 'ai';
3
4const { text } = await generateText({
5 model: createOpenAICompatible({
6 baseURL: 'https://api.example.com/v1',
7 name: 'example',
8 apiKey: process.env.MY_API_KEY,
9 }).chatModel('meta-llama/Llama-3-70b-chat-hf'),
10 prompt: 'Write a vegetarian lasagna recipe for 4 people.',
11});
You can further customize headers if desired. For example, here is an alternate implementation to pass along api key authentication:
1import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
2import { generateText } from 'ai';
3
4const { text } = await generateText({
5 model: createOpenAICompatible({
6 baseURL: 'https://api.example.com/v1',
7 name: 'example',
8 headers: {
9 Authorization: `Bearer ${process.env.MY_API_KEY}`,
10 },
11 }).chatModel('meta-llama/Llama-3-70b-chat-hf'),
12 prompt: 'Write a vegetarian lasagna recipe for 4 people.',
13});
1import { createOpenAICompatible } from '@ai-sdk/openai-compatible'; 2import { generateText } from 'ai'; 3 4type ExampleChatModelIds = 5 | 'meta-llama/Llama-3-70b-chat-hf' 6 | 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo' 7 | (string & {}); 8 9type ExampleCompletionModelIds = 10 | 'codellama/CodeLlama-34b-Instruct-hf' 11 | 'Qwen/Qwen2.5-Coder-32B-Instruct' 12 | (string & {}); 13 14type ExampleEmbeddingModelIds = 15 | 'BAAI/bge-large-en-v1.5' 16 | 'bert-base-uncased' 17 | (string & {}); 18 19const model = createOpenAICompatible< 20 ExampleChatModelIds, 21 ExampleCompletionModelIds, 22 ExampleEmbeddingModelIds 23>({ 24 baseURL: 'https://api.example.com/v1', 25 name: 'example', 26 apiKey: process.env.MY_API_KEY, 27}); 28 29// Subsequent calls to e.g. `model.chatModel` will auto-complete the model id 30// from the list of `ExampleChatModelIds` while still allowing free-form 31// strings as well. 32 33const { text } = await generateText({ 34 model: model.chatModel('meta-llama/Llama-3-70b-chat-hf'), 35 prompt: 'Write a vegetarian lasagna recipe for 4 people.', 36});
For more examples, see the OpenAI Compatible Providers documentation.
No vulnerabilities found.
No security vulnerabilities found.