Vercel AI SDK connector
The Vercel AI SDK is a popular JavaScript and TypeScript toolkit for building AI features, like chatbots, in web apps. It has helpers such as generateText (get a whole answer) and streamText (get the answer piece by piece).
nuroute-ai-sdk is the official provider (the plug) that sends those helpers through your NuRoute gateway. You use it the same way you would use @ai-sdk/openai or @ai-sdk/anthropic.
Before you start
- Node.js and a JavaScript or TypeScript project.
- Your NuRoute gateway address.
- An API key that starts with
aicp-.
Step 1: Install
npm install nuroute-ai-sdk ai
Step 2: Get your first answer
import { createNuRoute } from 'nuroute-ai-sdk';
import { generateText } from 'ai';
const nuroute = createNuRoute({
apiKey: 'aicp-...',
baseURL: 'https://your-nuroute-gateway',
});
const { text } = await generateText({
model: nuroute('auto'), // NuRoute's routing engine picks the best model
prompt: 'Write a haiku about distributed systems.',
});
apiKey and baseURL are optional here. If you leave them out, they are read from the environment variables NUROUTE_API_KEY and NUROUTE_BASE_URL. So createNuRoute() with no arguments works wherever those two are set.
With nuroute('auto'), Artemis picks the model for each request.
Streaming
Streaming shows the answer as it is written:
import { streamText } from 'ai';
const { textStream } = streamText({
model: nuroute('auto'),
prompt: 'Tell me a short story.',
});
for await (const chunk of textStream) {
process.stdout.write(chunk);
}
Forcing a provider
You can pin one upstream provider with providerOptions. Pair it with a specific model ID to fix both. With model: 'auto', no router runs: the provider serves the first model it lists.
await generateText({
model: nuroute('claude-sonnet-4-6'),
prompt: 'Hello!',
providerOptions: { nuroute: { provider: 'anthropic' } },
});
Which models can I use?
- Send
auto, or an Artemis option (artemis-cost,artemis-balanced,artemis-quality), and Artemis picks the model. - Or name any model in the model catalogue.
- Named models can run on your own provider keys (BYOK).
How it works inside
nuroute-ai-sdk is built on @ai-sdk/openai-compatible. The gateway's /v1/chat/completions address already speaks OpenAI's chat format, so the package gets solid, well-tested request, response and streaming handling for free.
It adds only NuRoute's own touches:
- the
NUROUTE_API_KEYandNUROUTE_BASE_URLenvironment variables, - adding
/v1to a bare gateway address for you, - passing NuRoute-only options through the AI SDK's standard
providerOptions(see Forcing a provider).
What is not supported
Only chat. There are no embedding, image or plain-completion models, because the gateway does not offer those today.