Use Nivana in the Vercel AI SDK

The AI SDK’s OpenAI-compatible provider works with Nivana as it is. generateText and streamText then go to the best model for each request.

What you need

  • A Nivana API key: sign in, open the account menu and choose API keys. New accounts get 2,000 free credits.
  • The base URL https://nivana.one/v1 and the model name nivana/auto (or nivana/quality, nivana/speed, nivana/cost to lean the router one way).

Set up the Vercel AI SDK

import { createOpenAICompatible } from '@ai-sdk/openai-compatible'
import { streamText } from 'ai'

const nivana = createOpenAICompatible({ name: 'nivana', baseURL: 'https://nivana.one/v1', apiKey: process.env.NIVANA_API_KEY })

const result = streamText({ model: nivana('nivana/auto'), prompt: 'Explain vector clocks briefly.' })
for await (const part of result.textStream) process.stdout.write(part)

Limits

Tool calling works: the client’s tools are passed to the routed model, which can call them, and each step is routed on its own. JSON mode and sampling parameters (temperature, max tokens) are ignored, Nivana’s own web search is off when the client sends tools, and very long tool histories are not summarised, so a request larger than every model’s context window fails.

Every response’s model field names the model that actually answered. See the OpenAI-compatible endpoint and how routing works.