nuroute-ai-sdk
v0.1.0
Published
Vercel AI SDK provider for NuRoute — route generateText/streamText through your NuRoute gateway
Maintainers
Readme
nuroute-ai-sdk
A Vercel AI SDK provider for NuRoute. Lets
generateText, streamText, and everything else in the AI SDK route through your NuRoute
gateway, the same way you'd use @ai-sdk/openai or @ai-sdk/anthropic.
Built on @ai-sdk/openai-compatible
since the gateway's /v1/chat/completions endpoint is OpenAI-compatible — this package just
adds NuRoute's own defaults (env var names, bare-URL normalization) and documents how NuRoute's
own options (routing to "auto", pinning a provider) flow through.
Installation
npm install nuroute-ai-sdk aiQuick start
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/baseURL default to the NUROUTE_API_KEY/NUROUTE_BASE_URL environment variables if
omitted:
const nuroute = createNuRoute(); // reads NUROUTE_API_KEY / NUROUTE_BASE_URLStreaming
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
Pin a specific upstream provider via providerOptions — combine with model: 'auto' to pick
the best model from just that provider, or with a specific model ID to pin both:
await generateText({
model: nuroute('auto'),
prompt: 'Hello!',
providerOptions: { nuroute: { provider: 'anthropic' } },
});What's not supported
Only chat completions — no embeddings, image, or completion models, since the gateway doesn't expose those today.
License
MIT
