Connect Vercel AI SDK to OpenLux
The Vercel AI SDK supports custom OpenAI-compatible providers through createOpenAICompatible. Point it at OpenLux once, then build TypeScript chat, generation and tool workflows with any catalogue model without changing your application architecture.

Set it up in four steps
Install the SDK packages
Add ai and @ai-sdk/openai-compatible to the application. The first package provides generateText and streamText; the second creates the provider.
Create an OpenLux key
Create a server-side key in the OpenLux console and store it as OPENLUX_API_KEY in the application environment.
Create the provider
Call createOpenAICompatible with the OpenLux base URL, key and includeUsage enabled so streamed responses can expose token usage where the model returns it.
Generate and test
Select an OpenLux model ID, run a generateText or streamText request, and test tool calling and structured output against the model capabilities you need.
Configuration
Copy these blocks, replace the placeholder key and you are done.
Install
pnpm add ai @ai-sdk/openai-compatibleTypeScript
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
import { generateText } from 'ai';
const openlux = createOpenAICompatible({
name: 'openlux',
baseURL: 'https://openlux.lol/v1',
apiKey: process.env.OPENLUX_API_KEY,
includeUsage: true,
});
const { text, usage } = await generateText({
model: openlux('gpt-6-astra'),
prompt: 'Write a short release note for an API gateway.',
});
console.log(text);
console.log(usage);Models that fit Vercel AI SDK
GPT-6 Astra
OpenAI · $0.3677 / 1M tokens
Claude Sonnet 4.5
Anthropic · $0.2647 / 1M tokens
Gemini 3.8 Flash
Google · $0.0551 / 1M tokens
DeepSeek V4
DeepSeek · $0.0613 / 1M tokens
The full list is in the model catalogue and the use-case collections.
Vercel AI SDK + OpenLux questions
Does OpenLux work with the Vercel AI SDK?
Yes. Use @ai-sdk/openai-compatible to create a provider for https://openlux.lol/v1, then pass an OpenLux model ID to generateText, streamText or other AI SDK functions.
Do streaming and tool calling work?
The AI SDK supports streaming and tool calling for OpenAI-compatible chat models. Test the exact model you select because tool calling and structured-output support vary by model.
Where should OPENLUX_API_KEY be stored?
Keep the key in a server-side environment variable or secret manager. Only initialize the OpenLux provider in server code, route handlers or other trusted contexts.
How do I compare models in a TypeScript app?
Pass different OpenLux model IDs to the same provider instance. Run a representative prompt and tool set, then compare quality, latency and request cost before choosing a default.
How much will this cost?
Estimate Vercel AI SDK usage
Estimate model calls, input and output tokens, retries and monthly cost.
Open the cost guideOther integration guides
LangChain
LangChain's OpenAI integrations accept a base_url, which makes OpenLux a drop-in upgrade: keep ChatOpenAI, swap the model name to change provider, and run every chain, tool and embedding on one key and one bill..
n8n
n8n automates pipelines with a visual editor, and its OpenAI node accepts a custom base URL.
OpenCode
OpenCode accepts custom providers through opencode.json.
Connect Vercel AI SDK to OpenLux today
One key covers every model in this guide and the rest of the catalogue, metered in USD with free trial credit to start.