Nia
Developer Reference

Nia AI Gateway

Drop-in replacement for Vercel AI Gateway. 315 models, 34 providers — OpenAI, Anthropic, Google, Mistral, Meta, xAI and more. Change two lines to migrate.

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.

315Models
34Providers
7Modalities
20%Markup

Base URL

text
https://nia.naslabs.ai/v1

Providers

ProviderModelsTypes
OpenAI58Language, Image, Audio, Embedding
Alibaba37Language, Embedding, Video
Google29Language, Image, Video, Embedding
xAI19Language
Mistral16Language, Embedding
Anthropic16Language
Voyage12Embedding, Reranking
Bytedance11Language, Video
BFL10Image
DeepSeek9Language
Recraft8Image
KlingAI8Video
Meta6Language
Amazon5Language
Cohere5Language, Embedding, Reranking
20+ more56All modalities

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.

typescript
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.

diff
- 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.

http
Authorization: Bearer nia_your_key_here

Scopes

ScopePermission
gateway:readAccess all gateway endpoints (chat, images, audio, video, embeddings, rerank)
chat:readRead chat history
chat:writeCreate and update chats
files:readRead uploaded files
files:writeUpload files
kb:readRead knowledge base / spaces
kb:writeAdd or remove knowledge base documents

Gateway 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.

GET/v1/models

Loading models...

You can also fetch a specific model:

GET/v1/models/{provider}/{model}
bash
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.

POST/v1/chat/completions
bash
curl 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

json
{
  "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.

POST/v1/embeddings
bash
curl 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.

POST/v1/images/generations
bash
curl 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

ModelProvider
openai/dall-e-3OpenAI
openai/dall-e-2OpenAI
openai/gpt-image-1OpenAI
google/imagen-4.0-generate-001Google
bfl/flux-pro-1.1BFL
bfl/flux-pro-1.1-ultraBFL
bfl/flux-devBFL
recraft/recraft-v3Recraft
recraft/recraft-20bRecraft

Audio

Text-to-Speech

Convert text to audio. Returns binary audio (audio/mpeg).

POST/v1/audio/speech
bash
curl 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
json
// 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.

POST/v1/audio/transcriptions
bash
curl 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)

POST/v1/audio/translations
bash
curl 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 English

Video Generation

Generate videos from text prompts using Veo, Kling, Seedance, and more. Video generation is long-running — expect 30–120 seconds.

POST/v1/videos/generations
bash
curl 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.

POST/v1/rerank
bash
curl 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
  }'
json
// Response
{
  "results": [
    { "index": 0, "relevance_score": 0.997 },
    { "index": 1, "relevance_score": 0.821 }
  ],
  "usage": { "total_tokens": 42 }
}
ModelProvider
cohere/rerank-v3.5Cohere
cohere/rerank-v4-proCohere
voyage/rerank-2.5Voyage
voyage/rerank-lite-1Voyage

Realtime (Voice)

Start a WebSocket voice session. Obtain an ephemeral token, then connect to OpenAI's Realtime WebSocket with it.

POST/v1/realtime/token
bash
curl -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"}'
json
// Response
{
  "token":      "ek_...",
  "url":        "wss://api.openai.com/v1/realtime",
  "model":      "openai/gpt-4o-realtime-preview",
  "expires_at": 1756000000,
  "session_id": "sess_abc123"
}
typescript
// 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.

GET/v1/credits
bash
curl 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.

GET/v1/report
bash
# 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"
json
// 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:

json
{
  "error": {
    "message": "Insufficient gateway credits. Purchase more at your billing page.",
    "type":    "insufficient_credits",
    "code":    402
  }
}
TypeHTTPDescription
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.