Vercel
Vercel AI SDK
TypeScript toolkit for building AI features. One factory for any OpenAI-compatible endpoint.
Step by step
01
Install
npm i ai @ai-sdk/openai-compatible
02
Create the provider
createOpenAICompatible with baseURL and apiKey below.
03
Call a model
generateText with any /models id.
Copy this
vercel-ai-sdk
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
import { generateText } from "ai";
const luxechain = createOpenAICompatible({
name: "luxechain",
baseURL: "https://api.luxechain.si/v1",
apiKey: "lxc_live_YOUR_KEY",
});
const { text } = await generateText({
model: luxechain("YOUR_MODEL_ID"), // any model id from the /models page
prompt: "Hello",
});
console.log(text);
createOpenAICompatible is the provider for endpoints that are not OpenAI itself; it speaks the chat-completions API.