Skip to main content
Last edited: 25 Oct 2026 (Asia/Hong_Kong) Point the Vercel AI SDK at NexLLM’s OpenAI-compatible gateway. Chat and streaming use @ai-sdk/openai. Images use the published @nexllm/ai-sdk-provider package (0.1.0) with AI SDK generateImage / experimental_generateImage.
Already migrating off Vercel AI Gateway? Follow Migrate from Vercel AI Gateway for env vars, model IDs, and gateway-option cleanup. This page is the Integrations setup for new apps and for using NexLLM as your AI SDK backend.

Introduction

NexLLM is an OpenAI-compatible inference gateway at https://www.nexllm.ai/v1. Spend lands on the wallet tied to your API key. There is no Vercel-AI-specific surcharge. If your agent should call NexLLM from Claude or Cursor instead of application code, use the MCP integration.

Prerequisites

  • A NexLLM account at www.nexllm.ai
  • An API key from the dashboard (Getting your API keys)
  • Node.js and a project that uses (or will use) the ai package
  • Wallet balance for paid inference
Keep NEXLLM_API_KEY server-side. Do not expose it in public Next.js NEXT_PUBLIC_* vars or browser bundles.

Install

Chat only

Peer dependency for the image provider: ai ^6 (ImageModelV3). Use matching majors for ai and @ai-sdk/openai — do not mix unrelated major upgrades. Package: npmjs.com/package/@nexllm/ai-sdk-provider

Configure environment

Authentication for OpenAI-compatible requests:
See Authentication.

Chat with the AI SDK

Create an explicit OpenAI provider pointed at NexLLM, then use .chat(modelId) for Chat Completions.
Use nexllmChat.chat(modelId) when you want Chat Completions. The OpenAI provider’s default model factory can select the Responses API. Do not replace .chat(modelId) with nexllmChat(modelId) unless you intentionally want /v1/responses and have verified the model supports it.

Streaming

In a Next.js Route Handler or Server Action, return result.toDataStreamResponse() (or the streaming helper your AI SDK major documents) the same way you would for any other OpenAI-compatible provider.

Discover model IDs

Use the exact data[].id value in nexllmChat.chat(...) and nexllm.image(...). Do not invent a mapping from another gateway’s prefixed strings. See Models API and Channel groups.

Images with @nexllm/ai-sdk-provider

The published package wraps POST /v1/images/generations for AI SDK generateImage / experimental_generateImage. It does not replace @ai-sdk/openai for chat.

Quick start

Custom config

Optional provider options

For GPT Image model IDs (nexllm/gpt-image-*), do not pass response_format (and prefer a provider/path that omits it). The b64_json example below is for models that accept OpenAI Images response_format (for example classic DALL·E-style). Confirm with GET /v1/models plus a cheap probe.
Confirm image-capable model IDs with GET /v1/models for your key. Full gateway fields: Image Generation API. From an agent (Claude / Cursor), you can also use MCP generate_image — see MCP integration.

Images without the AI SDK provider (fallback)

If your ai major does not expose a compatible image provider interface yet, call the OpenAI SDK or HTTP against the same base URL.

OpenAI SDK

Direct HTTP

Optional: Responses API

If you deliberately need the Responses shape:
Confirm the model’s supported endpoint types first. See API Reference and the Responses notes in Migrate from Vercel AI Gateway.

How billing works

There is no separate “Vercel AI” price list. See Pricing overview and Wallet.

Troubleshooting

Search the repo for @ai-sdk/gateway, gateway(, AI_GATEWAY_API_KEY, and ai-gateway.vercel.sh. Replace migrated call sites with createOpenAI({ baseURL: "https://www.nexllm.ai/v1", ... }) and .chat(modelId). Check shared registries and background jobs, not only the main route.
Use model: nexllmChat.chat(modelId) for Chat Completions. The default OpenAI provider factory may select Responses.
Call GET /v1/models with the same key the app uses. Confirm the exact id, the key’s channel group, and any model restrictions on the key.
Send a NexLLM key in NEXLLM_API_KEY, not a Vercel gateway key or OIDC token. Check expiration, IP allowlist, and whitespace. See Authentication.
Install @nexllm/ai-sdk-provider (and ai ^6). Confirm the image model ID is available to your key. For edits (/v1/images/edits), use the OpenAI SDK — the thin provider only wraps generations.