Overview
Nia AI Gateway is a fully OpenAI-compatible and Vercel AI Gateway-compatible proxy that exposes every model from every provider behind a single endpoint. Anyone already using Vercel AI Gateway can switch to Nia by changing exactly two lines.
Base URL
https://nia.naslabs.ai/v1Providers
Quick Start
The gateway accepts any provider/model format from Vercel AI Gateway. Use it with the OpenAI SDK, Vercel AI SDK, or raw HTTP.
import OpenAI from 'openai'; // npm install openai
const nia = new OpenAI({
baseURL: 'https://nia.naslabs.ai/v1',
apiKey: 'nia_your_key_here',
});
// Works with ANY provider — not just OpenAI
const stream = await nia.chat.completions.create({
model: 'anthropic/claude-opus-4-5',
messages: [{ role: 'user', content: 'Hello from Nia!' }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? '');
}Migrate from Vercel AI Gateway
If you already use Vercel AI Gateway, migration is exactly two line changes. All model IDs, request formats, streaming, and response shapes are identical.
- const nia = new OpenAI({
- baseURL: 'https://ai-gateway.vercel.sh/v1',
- apiKey: process.env.AI_GATEWAY_API_KEY,
- });
+ const nia = new OpenAI({
+ baseURL: 'https://nia.naslabs.ai/v1',
+ apiKey: process.env.NIA_GATEWAY_API_KEY, // your nia_ key
+ });
// Everything else stays the same
const response = await nia.chat.completions.create({
model: 'anthropic/claude-opus-4-5',
messages: [{ role: 'user', content: 'Hello!' }],
});All provider/model strings are forwarded to Vercel AI Gateway unchanged, so you get the same model behaviour with Nia billing and credits.
Authentication
Every request must include your Nia API key as a Bearer token. Generate keys in Settings → Developers.
Authorization: Bearer nia_your_key_hereScopes
gateway:readAccess all gateway endpoints (chat, images, audio, video, embeddings, rerank)chat:readRead chat historychat:writeCreate and update chatsfiles:readRead uploaded filesfiles:writeUpload fileskb:readRead knowledge base / spaceskb:writeAdd or remove knowledge base documentsGateway endpoints (gateway:read) require a PLUS plan or higher. Credits are deducted per request based on token usage plus a 20% markup.
Models
The live model catalog below is fetched in real-time from GET /v1/models. All 315 models are available — search by ID or filter by type. Prices shown include Nia's 20% markup.
/v1/modelsLoading models...
You can also fetch a specific model:
/v1/models/{provider}/{model}curl https://nia.naslabs.ai/v1/models/anthropic/claude-opus-4-5 \
-H "Authorization: Bearer nia_your_key_here"Chat Completions
OpenAI-compatible chat completions. Works with any language model from any of the 34 providers using the provider/model format. Streaming is fully supported.
/v1/chat/completionscurl https://nia.naslabs.ai/v1/chat/completions \
-H "Authorization: Bearer nia_your_key_here" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic/claude-opus-4-5",
"messages": [{ "role": "user", "content": "Explain quantum entanglement" }],
"stream": true
}'Request parameters
{
"model": "provider/model", // required — use any provider/model from /v1/models
"messages": [...], // required — OpenAI messages array
"stream": true, // optional — enable SSE streaming
"temperature": 0.7, // optional
"max_tokens": 4096, // optional
"tools": [...], // optional — function calling
"top_p": 1.0 // optional
}Embeddings
Generate vector embeddings with any embedding model from OpenAI, Voyage, Cohere, Google, and more.
/v1/embeddingscurl https://nia.naslabs.ai/v1/embeddings \
-H "Authorization: Bearer nia_your_key_here" \
-H "Content-Type: application/json" \
-d '{"model":"openai/text-embedding-3-large","input":"The quick brown fox"}'Image Generation
Generate images with DALL-E, Imagen, Flux, Recraft, and more. Returns b64_json or a URL depending on the model.
/v1/images/generationscurl https://nia.naslabs.ai/v1/images/generations \
-H "Authorization: Bearer nia_your_key_here" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/dall-e-3",
"prompt": "A serene Japanese garden at dusk",
"size": "1024x1024",
"n": 1
}'Image models
openai/dall-e-3OpenAIopenai/dall-e-2OpenAIopenai/gpt-image-1OpenAIgoogle/imagen-4.0-generate-001Googlebfl/flux-pro-1.1BFLbfl/flux-pro-1.1-ultraBFLbfl/flux-devBFLrecraft/recraft-v3Recraftrecraft/recraft-20bRecraftAudio
Text-to-Speech
Convert text to audio. Returns binary audio (audio/mpeg).
/v1/audio/speechcurl https://nia.naslabs.ai/v1/audio/speech \
-H "Authorization: Bearer nia_your_key_here" \
-H "Content-Type: application/json" \
-d '{"model":"openai/tts-1","input":"Hello from Nia AI Gateway!","voice":"alloy"}' \
--output speech.mp3// Request body
{
"model": "openai/tts-1", // or "openai/tts-1-hd", "xai/grok-tts"
"input": "Text to speak", // required
"voice": "alloy", // alloy | echo | fable | onyx | nova | shimmer
"response_format": "mp3", // mp3 | opus | aac | flac | wav
"speed": 1.0 // 0.25 – 4.0
}Speech-to-Text (Transcription)
Transcribe audio files to text. Send multipart/form-data.
/v1/audio/transcriptionscurl https://nia.naslabs.ai/v1/audio/transcriptions \
-H "Authorization: Bearer nia_your_key_here" \
-F "file=@recording.mp3" \
-F "model=openai/whisper-1" \
-F "language=en"
# Response: { "text": "Hello, how are you today?" }Translation (audio → English text)
/v1/audio/translationscurl https://nia.naslabs.ai/v1/audio/translations \
-H "Authorization: Bearer nia_your_key_here" \
-F "file=@french-audio.mp3" \
-F "model=openai/whisper-1"
# Translates from any language to EnglishVideo Generation
Generate videos from text prompts using Veo, Kling, Seedance, and more. Video generation is long-running — expect 30–120 seconds.
/v1/videos/generationscurl https://nia.naslabs.ai/v1/videos/generations \
-H "Authorization: Bearer nia_your_key_here" \
-H "Content-Type: application/json" \
-d '{
"model": "google/veo-3.0-generate-001",
"prompt": "A cinematic drone shot over mountain peaks",
"duration": 8,
"aspectRatio": "16:9",
"generateAudio": true
}'Reranking
Rerank a list of documents by relevance to a query. Supported by Cohere and Voyage reranking models.
/v1/rerankcurl https://nia.naslabs.ai/v1/rerank \
-H "Authorization: Bearer nia_your_key_here" \
-H "Content-Type: application/json" \
-d '{
"model": "cohere/rerank-v3.5",
"query": "What is the capital of France?",
"documents": [
"Paris is the capital of France.",
"The Eiffel Tower is in Paris.",
"London is the capital of the UK."
],
"top_n": 2
}'// Response
{
"results": [
{ "index": 0, "relevance_score": 0.997 },
{ "index": 1, "relevance_score": 0.821 }
],
"usage": { "total_tokens": 42 }
}cohere/rerank-v3.5Coherecohere/rerank-v4-proCoherevoyage/rerank-2.5Voyagevoyage/rerank-lite-1VoyageRealtime (Voice)
Start a WebSocket voice session. Obtain an ephemeral token, then connect to OpenAI's Realtime WebSocket with it.
/v1/realtime/tokencurl -X POST https://nia.naslabs.ai/v1/realtime/token \
-H "Authorization: Bearer nia_your_key_here" \
-H "Content-Type: application/json" \
-d '{"model":"openai/gpt-4o-realtime-preview","voice":"alloy"}'// Response
{
"token": "ek_...",
"url": "wss://api.openai.com/v1/realtime",
"model": "openai/gpt-4o-realtime-preview",
"expires_at": 1756000000,
"session_id": "sess_abc123"
}// Connect WebSocket with the token
const ws = new WebSocket(
`wss://api.openai.com/v1/realtime?model=gpt-4o-realtime-preview`,
['realtime', `openai-insecure-api-key.${token}`, 'openai-beta.realtime-v1'],
);Credits & Billing
Check your gateway credit balance. Credits are deducted per request based on token usage with a 20% markup over provider cost. Top up credits in Settings → Billing.
/v1/creditscurl https://nia.naslabs.ai/v1/credits \
-H "Authorization: Bearer nia_your_key_here"
// Response
{
"object": "credits",
"balance": "45.23",
"lifetime_spend": "12.50"
}Spend Report
Get a breakdown of your gateway usage. Group by day, model, or provider.
/v1/report# Group by model
curl "https://nia.naslabs.ai/v1/report?start_date=2026-08-01&end_date=2026-08-31&group_by=model" \
-H "Authorization: Bearer nia_your_key_here"
# Group by day (default)
curl "https://nia.naslabs.ai/v1/report?start_date=2026-08-01&end_date=2026-08-07" \
-H "Authorization: Bearer nia_your_key_here"// Response
{
"object": "report",
"group_by": "model",
"data": [
{
"period": "anthropic/claude-opus-4-5",
"model": "anthropic/claude-opus-4-5",
"provider": "",
"input_tokens": 145200,
"output_tokens": 32400,
"cost_usd": 5.241,
"nia_cost_usd": 6.289,
"requests": 47
}
],
"totals": {
"input_tokens": 145200,
"output_tokens": 32400,
"cost_usd": 5.241,
"nia_cost_usd": 6.289,
"requests": 47
}
}Error Codes
All errors return an OpenAI-compatible JSON shape:
{
"error": {
"message": "Insufficient gateway credits. Purchase more at your billing page.",
"type": "insufficient_credits",
"code": 402
}
}invalid_api_key401Missing or invalid API key, or key lacks required scope.plan_restricted403Your plan does not allow access to this endpoint.insufficient_credits402Your gateway credit balance is zero. Top up at billing.invalid_request400Request body is malformed or missing required fields.upstream_error503Vercel AI Gateway upstream was unreachable.gateway_unavailable503Gateway key not configured on this server.rate_limit_exceeded429Too many requests. Back off and retry.service_unavailable503Required service (e.g. OPENAI_API_KEY) not configured.