@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 athttps://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
aipackage - Wallet balance for paid inference
NEXLLM_API_KEY server-side. Do not expose it in public Next.js NEXT_PUBLIC_* vars or browser bundles.
Install
Chat only
Chat + images (recommended)
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
Chat with the AI SDK
Create an explicit OpenAI provider pointed at NexLLM, then use.chat(modelId) for Chat Completions.
Streaming
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
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.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 yourai 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:How billing works
There is no separate “Vercel AI” price list. See Pricing overview and Wallet.
Troubleshooting
Requests still go to Vercel AI Gateway
Requests still go to Vercel AI Gateway
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.The AI SDK hits /responses unexpectedly
The AI SDK hits /responses unexpectedly
Use
model: nexllmChat.chat(modelId) for Chat Completions. The default OpenAI provider factory may select Responses.Model not found
Model not found
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.Authentication fails
Authentication fails
Send a NexLLM key in
NEXLLM_API_KEY, not a Vercel gateway key or OIDC token. Check expiration, IP allowlist, and whitespace. See Authentication.generateImage fails or package not found
generateImage fails or package not found
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.Related
- Migrate from Vercel AI Gateway — full cutover checklist
- Compatible APIs — OpenAI-compatible gateway overview
- MCP integration — agents instead of app code
- Skills — outcome recipes on top of MCP
- API Reference — all gateway endpoints
- Getting your API keys