Install
npm install ai @ai-sdk/openai-compatibleExample
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
import { generateText } from "ai";
const luv13 = createOpenAICompatible({
name: "luv13",
baseURL: "https://api.luv13.ai/v1",
apiKey: process.env.LUV13_API_KEY,
});
const { text } = await generateText({
model: luv13("luv13/glm-5.3-flash"),
prompt: "Give me three names for a hiking app.",
});
console.log(text);Options worth knowing
From the SDK's docs for the OpenAI Compatible provider:
includeUsage: trueasks for token usage in streamed responses. Whether luv13 returns it while streaming is covered on Streaming on luv13.headersadds custom headers to every request.supportsStructuredOutputsshould only be turned on if the provider supports JSON schema output. See Structured Outputs.
Notes
- Run this on the server, such as in an API route. Don't ship your key to the browser. See API Key Best Practices.
- Only chat models apply to luv13. Its embeddings and other non-chat endpoints return 404. See Endpoints.
