How to Use Vercel AI SDK Without OpenRouter (Drop-In Multi-Provider Setup)

Switch your Vercel AI SDK app from OpenRouter to SwitchRouter in 5 lines of TypeScript — keeping streamText, tool calling, and structured outputs while adding automatic failover and Naira billing.

Short answer: You don't need a custom provider package to route the Vercel AI SDK across DeepSeek, Claude, GPT, Qwen, and Gemini. Using @ai-sdk/openai-compatible pointed at https://api.switchrouter.dev/v1, you get a drop-in OpenRouter alternative with automatic cross-provider failover, prompt-cache-aware routing, and prepaid Naira (NGN) billing via Paystack.

Why teams look for an OpenRouter alternative with the Vercel AI SDK

If you are building a Next.js or Node.js app with ai (the Vercel AI SDK), OpenRouter is usually the first gateway people try. It works well until you hit one of three production headaches:

  1. USD card declines & FX friction: Funding a USD gateway balance from Nigeria or emerging markets often fails on local cards or eats FX fees.
  2. Manual model-hunting across providers: Switching between DeepSeek, Claude, Gemini, and Qwen still requires managing per-model quirks and provider outages yourself.
  3. No unified workspace + coding-agent billing: You end up paying separately for your production API gateway and your team's coding tools (Claude Code, Codex CLI, OpenCode).

OpenRouter vs. SwitchRouter with the Vercel AI SDK

FeatureOpenRouter + Vercel AI SDKSwitchRouter + Vercel AI SDK
SDK integration@openrouter/ai-sdk-provider or OpenAI-compatibleOfficial @ai-sdk/openai-compatible (zero lock-in)
Streaming & tool callingSupportedSupported (streamText, generateText, generateObject, tools)
Automatic failoverProvider fallbackCross-provider + cross-deployment failover (Bedrock, Direct, OpenRouter)
Smart phase routingManual model selectionOptional switchrouter/auto virtual alias
Billing currencyUSD credit card / cryptoPrepaid NGN via Paystack (exact integer-kobo ledger)
Free test routeFree tier modelsopenrouter/free available at ₦0.00 balance

5-Line Drop-In Setup (`@ai-sdk/openai-compatible`)

Install the official Vercel AI SDK packages:

pnpm add ai @ai-sdk/openai-compatible

Create a shared provider client (lib/ai.ts):

import { createOpenAICompatible } from "@ai-sdk/openai-compatible";

export const switchrouter = createOpenAICompatible({ name: "switchrouter", baseURL: "https://api.switchrouter.dev/v1", apiKey: process.env.SWITCHROUTER_API_KEY, headers: { "X-Title": "My Next.js App", }, }); ```

Now use generateText, streamText, or tool calling exactly as you already do:

import { streamText } from "ai";
import { switchrouter } from "@/lib/ai";

export async function POST(req: Request) { const { messages } = await req.json();

const result = streamText({ model: switchrouter("deepseek.v3.2"), // or "switchrouter/auto" on Connect messages, });

return result.toUIMessageStreamResponse(); } ```

Migrating an existing OpenRouter AI SDK route

If you already use @openrouter/ai-sdk-provider or @ai-sdk/openai pointed at OpenRouter, migration takes under 2 minutes:

  1. Replace your baseURL with https://api.switchrouter.dev/v1.
  2. Swap OPENROUTER_API_KEY for SWITCHROUTER_API_KEY (sk_sr_...).
  3. Keep your messages, tools, maxOutputTokens, and streaming UI hooks untouched.
  4. Test immediately at ₦0.00 using switchrouter("openrouter/free") before funding your wallet.

Production tips for lower token bills

  • Keep system prompts static at the top so upstream providers (DeepSeek Direct, Gemini, MiniMax, Anthropic) serve repeated prefix tokens from prompt cache at up to 90% off.
  • Pass `X-Title` so every route or feature shows up separately in your SwitchRouter Console under Usage → Top Apps.
  • Check live model IDs and Naira rates anytime via GET https://api.switchrouter.dev/v1/models (no auth required) or in the Model Directory.

Ready to test it? Create an API key in the SwitchRouter Console, run your first free request with openrouter/free, or explore SwitchRouter Connect for your coding agents.

Frequently asked questions

Does SwitchRouter work with the Vercel AI SDK streamText and tool calling?

Using @ai-sdk/openai-compatible with baseURL set to https://api.switchrouter.dev/v1, SwitchRouter supports streamText, generateText, structured outputs, and multi-step tool calling across 70+ models.

Do I need to install a custom SwitchRouter SDK to replace OpenRouter?

No. SwitchRouter speaks standard OpenAI Chat Completions, Anthropic Messages, and OpenAI Responses natively, so you only change baseURL and apiKey in @ai-sdk/openai-compatible.

Can I test SwitchRouter with the Vercel AI SDK before adding credits?

Yes. Every new Standard workspace can send test requests using the openrouter/free model ID at ₦0.00 balance before funding with Naira.

Continue reading

All articles

Start building with SwitchRouter.

Connect your app or coding agent in seconds. Route across frontier models through one endpoint — then launch your app and start building what's next.

Start building