nebius-ai-provider
v0.1.0
Published
Vercel AI SDK community provider for Nebius Token Factory (formerly Nebius AI Studio)
Maintainers
Readme
Nebius Token Factory provider for the Vercel AI SDK
A community provider for the Vercel AI SDK that gives you access to the open-source models served by Nebius Token Factory (formerly Nebius AI Studio): DeepSeek, Qwen, Llama, GLM, Kimi, gpt-oss and more, plus embedding and image models — all through the standard AI SDK interface.
Installation
npm install nebius-ai-provider aiRequires Node.js >= 22 and the AI SDK v7.
Setup
Get an API key from the Token Factory console
and expose it as NEBIUS_API_KEY:
export NEBIUS_API_KEY="your-api-key"Quickstart
import { generateText } from 'ai';
import { nebius } from 'nebius-ai-provider';
const { text } = await generateText({
model: nebius('deepseek-ai/DeepSeek-V4-Flash'),
prompt: 'Hello!',
});Model IDs are HuggingFace-style paths. Known models are typed for autocompletion, but any string is accepted, so new models on the platform work immediately. Browse the current catalog at tokenfactory.nebius.com/models/catalog.
Custom provider instance
Use createNebius to customize the API key, base URL, headers, or fetch:
import { createNebius } from 'nebius-ai-provider';
const nebius = createNebius({
apiKey: process.env.MY_NEBIUS_KEY,
// baseURL: 'https://api.tokenfactory.nebius.com/v1', // default
headers: { 'X-Team': 'research' },
});Streaming
import { streamText } from 'ai';
import { nebius } from 'nebius-ai-provider';
const result = streamText({
model: nebius('Qwen/Qwen3-235B-A22B-Instruct-2507'),
prompt: 'Write a haiku about GPUs.',
});
for await (const delta of result.textStream) {
process.stdout.write(delta);
}Tool calling
import { generateText, tool, stepCountIs } from 'ai';
import { nebius } from 'nebius-ai-provider';
import { z } from 'zod';
const { text } = await generateText({
model: nebius('Qwen/Qwen3-32B'),
tools: {
weather: tool({
description: 'Get the weather for a location',
inputSchema: z.object({ location: z.string() }),
execute: async ({ location }) => ({ location, temperature: 21 }),
}),
},
stopWhen: stepCountIs(3),
prompt: 'What is the weather in Amsterdam?',
});Reasoning models
Nebius serves reasoning models (the DeepSeek-R1 family, Qwen "Thinking"
variants) that emit their chain of thought as <think>...</think> blocks.
Use the AI SDK's extractReasoningMiddleware to surface reasoning separately
from the final text:
import {
extractReasoningMiddleware,
generateText,
wrapLanguageModel,
} from 'ai';
import { nebius } from 'nebius-ai-provider';
const model = wrapLanguageModel({
model: nebius('deepseek-ai/DeepSeek-R1-0528'),
middleware: extractReasoningMiddleware({ tagName: 'think' }),
});
const { text, reasoningText } = await generateText({
model,
prompt: 'How many primes are there below 100?',
});
console.log(reasoningText); // the model's chain of thought
console.log(text); // the final answerThis works with streamText too — reasoning arrives as reasoning-delta
stream parts, separate from text-delta.
Embeddings
import { embed } from 'ai';
import { nebius } from 'nebius-ai-provider';
const { embedding } = await embed({
model: nebius.embeddingModel('Qwen/Qwen3-Embedding-8B'),
value: 'sunny day at the beach',
});Image generation
import { experimental_generateImage as generateImage } from 'ai';
import { nebius } from 'nebius-ai-provider';
const { image } = await generateImage({
model: nebius.imageModel('black-forest-labs/flux-schnell'),
prompt: 'A watercolor painting of a lighthouse at dawn',
});Provider settings
| Option | Type | Default | Description |
| --------- | ------------------------ | ---------------------------------------- | -------------------------------------- |
| baseURL | string | https://api.tokenfactory.nebius.com/v1 | API base URL |
| apiKey | string | process.env.NEBIUS_API_KEY | Bearer API key |
| headers | Record<string, string> | — | Extra headers merged into each request |
| fetch | typeof fetch | global fetch | Custom fetch for proxies/testing |
Legacy base URLs (AI Studio → Token Factory)
Nebius AI Studio was rebranded to Nebius Token Factory. This provider defaults
to the current https://api.tokenfactory.nebius.com/v1 endpoint. If you need
one of the legacy endpoints, pass it explicitly:
const nebius = createNebius({
baseURL: 'https://api.studio.nebius.com/v1', // or https://api.studio.nebius.ai/v1
});