Vercel AI SDK
Use the AI SDK with its OpenAI-compatible provider to generate and stream text from Aurora. This connects directly to Aurora; a Vercel AI Gateway account is not required.
Install and prepare
In a Node.js project:
npm install ai @ai-sdk/openai-compatible
export AURORA_API_TOKEN="<your-token>"
Create the token using Getting started. Use a Node.js version supported by your installed packages. Keep this provider in server-side code so the token is not exposed to the browser.
Generate text
Save as aurora-ai.mjs:
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
import { generateText } from 'ai';
const apiKey = process.env.AURORA_API_TOKEN;
if (!apiKey) throw new Error('Set AURORA_API_TOKEN before running this script');
const aurora = createOpenAICompatible({
name: 'aurora',
baseURL: '',
apiKey,
includeUsage: true,
});
const result = await generateText({
model: aurora.chatModel('deepseek/deepseek-v4-flash'),
prompt: 'Say hello in one sentence.',
});
console.log(result.text);
console.log(result.usage);
node aurora-ai.mjs
Expect a greeting and usage metadata. chatModel explicitly selects Chat
Completions. The name labels the local provider; the model ID has no aurora/
or openai/ prefix. The base URL includes /v1.
Stream text
Change the ai import to import { streamText } from 'ai';, then replace the
generateText call and output statements with:
const result = streamText({
model: aurora.chatModel('deepseek/deepseek-v4-flash'),
prompt: 'Explain streaming in three sentences.',
});
for await (const text of result.textStream) {
process.stdout.write(text);
}
console.log();
console.log(await result.usage);
includeUsage: true requests token usage in streamed responses. For a server
route, use the AI SDK response helper appropriate to your frontend protocol;
plain text streams and AI SDK UI message streams are different formats.
Troubleshooting
- Unexpected
/responsesrequest: Use@ai-sdk/openai-compatibleandchatModelas shown. Do not rely on another adapter's default API selection. - Tools or structured output fail: Check the selected model's capabilities
before enabling tools or
supportsStructuredOutputs. The provider package's feature list is broader than Aurora's documented endpoint set. - Dependency type errors: Install compatible versions of
aiand its provider package together and check their peer dependency requirements. - Missing usage: Keep
includeUsage: trueand consume the stream to completion.
See shared troubleshooting and the AI SDK OpenAI-compatible reference.