ZuploZuplo
LoginStart for Free
  • Documentation
  • API Reference
Introduction
Getting Started
    Develop in the portal
      1 - Setup Your Gateway2 - Rate Limiting3 - API Key Auth4 - Deploy5 - Dynamic Rate LimitingDynamic MCP Server - Quickstart
    Develop locally with the CLI
      1 - Setup Your Gateway2 - Rate Limiting3 - API Key Auth4 - Deploy5 - Dynamic Rate LimitingDynamic MCP Server - Quickstart
Concepts
Development
Policies
Handlers
API Keys
Rate Limiting
Caching
MCP Server
MCP Gateway
AI Gateway
    IntroductionGetting StartedSource ControlUniversal API
    Providers
    Teams
    Apps
    Policies
    Cookbooks
    Integrations
      AI SDKClaude CodeCodexGooseLangChain SDKOpenAI SDK
Developer Portal
Monetization
GraphQL
Deploying & Source Control
Analytics
Observability
Networking & Infrastructure
Account Management
Programming API
Build with AI
Zuplo CLI
Migration Guides
Platform LimitsVersion Support PolicySecuritySupportTrust & ComplianceChangelog
powered by Zudoku
Integrations

AI SDK

The AI SDK is a free open-source library that gives you the tools you need to build AI-powered products. It's compatible with a large selection of providers and models, and has a large selection of additional community supported providers being added regularly.

Prerequisites

In order to use the AI Gateway with any AI SDK powered app you will need to complete these steps first:

  1. Create a new provider in the AI Gateway for the provider you want to use with AI SDK

  2. Set up a new team

  3. Create a new app to use specifically with AI SDK and assign it to the team you created

  4. Copy the API URL and API Key shown at the top of the app page

Configure the AI SDK

To route all AI SDK requests through Zuplo instead of directly to the API of the chosen provider, you must set baseURL in the SDK configuration to point to your app's API URL with /v1 appended. The app page in the Zuplo Portal shows the URL, which ends in the app's ID.

Additionally, you will need to change the value of apiKey to the API key of the app you have configured in Zuplo.

Models are referenced as providerName/model, where providerName is the provider name configured in your gateway. By default an app can reach any model offered by the providers configured for the Zuplo project. To limit it to a curated set, add the Model Filtering policy to the app—it applies separate rules to completions (generateText, streamText) and embeddings (embed), and rejects a capability it doesn't configure.

Each provider package appends its own operation path to baseURL, so pick the model factory that targets an endpoint the gateway serves: /v1/chat/completions for OpenAI-compatible requests, /v1/messages for Anthropic, /v1/embeddings, and /v1/responses for OpenAI only. The examples below use the right factory for each provider.

OpenAI

Code
import { createOpenAI } from "@ai-sdk/openai"; import { generateText } from "ai"; const openai = createOpenAI({ apiKey: process.env.ZUPLO_AI_GATEWAY_API_KEY, baseURL: "https://my-gateway-main-2e18f50.zuplo.app/config_fe0a04972d2848e0a94ae4b8bcd1497e/v1", }); const { text } = await generateText({ model: openai.chat("openai/gpt-5-mini"), prompt: "Write a one-sentence bedtime story about a unicorn.", });

Anthropic

Pass the app's API key as authToken, not apiKey. The provider sends apiKey as the x-api-key header, which the gateway doesn't read, while authToken is sent as Authorization: Bearer. Setting both throws an InvalidArgumentError.

Code
import { createAnthropic } from "@ai-sdk/anthropic"; import { generateText } from "ai"; const anthropic = createAnthropic({ authToken: process.env.ZUPLO_AI_GATEWAY_API_KEY, baseURL: "https://my-gateway-main-2e18f50.zuplo.app/config_fe0a04972d2848e0a94ae4b8bcd1497e/v1", }); const { text } = await generateText({ model: anthropic("anthropic/claude-sonnet-4-5-20250929"), prompt: "Write a one-sentence bedtime story about a unicorn.", });

Google

The @ai-sdk/google provider speaks Gemini's native protocol: it posts to a {model}:generateContent path and authenticates with the x-goog-api-key header, neither of which the AI Gateway serves. Use the OpenAI-compatible provider instead—the AI Gateway translates OpenAI-format requests to Google upstream.

Code
import { createOpenAICompatible } from "@ai-sdk/openai-compatible"; import { generateText } from "ai"; const gateway = createOpenAICompatible({ name: "zuplo-ai-gateway", apiKey: process.env.ZUPLO_AI_GATEWAY_API_KEY, baseURL: "https://my-gateway-main-2e18f50.zuplo.app/config_fe0a04972d2848e0a94ae4b8bcd1497e/v1", }); const { text } = await generateText({ model: gateway("google/gemini-2.5-flash"), prompt: "Write a one-sentence bedtime story about a unicorn.", });

Mistral

Code
import { createMistral } from "@ai-sdk/mistral"; import { generateText } from "ai"; const mistral = createMistral({ apiKey: process.env.ZUPLO_AI_GATEWAY_API_KEY, baseURL: "https://my-gateway-main-2e18f50.zuplo.app/config_fe0a04972d2848e0a94ae4b8bcd1497e/v1", }); const { text } = await generateText({ model: mistral("mistral/mistral-large-latest"), prompt: "Write a one-sentence bedtime story about a unicorn.", });

xAI

Call xai.chat(...) rather than xai(...). The bare callable targets xAI's Responses API, and the gateway serves /v1/responses for the OpenAI provider only—an xAI model sent there returns a 400.

Code
import { createXai } from "@ai-sdk/xai"; import { generateText } from "ai"; const xai = createXai({ apiKey: process.env.ZUPLO_AI_GATEWAY_API_KEY, baseURL: "https://my-gateway-main-2e18f50.zuplo.app/config_fe0a04972d2848e0a94ae4b8bcd1497e/v1", }); const { text } = await generateText({ model: xai.chat("xai/grok-4"), prompt: "Write a one-sentence bedtime story about a unicorn.", });

Provider options the gateway doesn't forward

On the OpenAI-shaped endpoints (/v1/chat/completions, /v1/embeddings, and /v1/responses) the gateway rebuilds the upstream request from a per-provider parameter list instead of forwarding your body as-is. Standard AI SDK settings— messages, temperature, topP, maxOutputTokens, stopSequences, tools, toolChoice, responseFormat, presencePenalty, and frequencyPenalty—are forwarded. Options outside that list are dropped without a warning. For example, seed and providerOptions.mistral.safePrompt don't reach Mistral, and temperature is capped at Mistral's maximum of 1.

Anthropic is different: /v1/messages is a native passthrough, so @ai-sdk/anthropic requests reach Anthropic unchanged apart from the model and credential, which the gateway sets from your app configuration.

Edit this page
Last modified on August 18, 2026
Custom fallback logicClaude Code
On this page
  • Prerequisites
  • Configure the AI SDK
    • OpenAI
    • Anthropic
    • Google
    • Mistral
    • xAI
  • Provider options the gateway doesn't forward
TypeScript
TypeScript
TypeScript
TypeScript
TypeScript