NewHow we catch a seller listing the wrong model, and refund you if one does.

Use the Vercel AI SDK with MartLLM (cheaper models, same code)

Install @ai-sdk/openai-compatible, create a provider with baseURL https://api.martllm.com/v1 and your MartLLM key, and pass uberllm("<model id>") wherever your app passes a model today. Nothing else in the app changes.

Steps

  1. Make a key on your keys page and add a little credit (accounts start at $0).
  2. Install the provider:
npm i ai @ai-sdk/openai-compatible
  1. Put the key in .env.local (Next.js) or your server's environment:
UBERLLM_API_KEY=ull_your_key
  1. Create the provider once, for example in lib/uberllm.ts:
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";

export const uberllm = createOpenAICompatible({
  name: "uberllm",
  baseURL: "https://api.martllm.com/v1",
  apiKey: process.env.UBERLLM_API_KEY, // sent as Authorization: Bearer <key>
  includeUsage: true, // token counts on streamed answers too
});
  1. Use it where you used a model before:
import { generateText } from "ai";
import { uberllm } from "@/lib/uberllm";

const { text } = await generateText({
  model: uberllm("deepseek/deepseek-v4.1-flash"),
  prompt: "Write a one-line welcome message.",
});

Moving an app that already uses @ai-sdk/openai

Swap the model argument and keep everything else:

// before
import { openai } from "@ai-sdk/openai";
const model = openai("gpt-4o");

// after
import { uberllm } from "@/lib/uberllm";
const model = uberllm("deepseek/deepseek-v4.1-flash");

Model ids are the ids on martllm.com/models and always have a maker in front (openai/…, anthropic/…, deepseek/…). That is how you can run GPT, Claude, Gemini and open models from one key and compare them by changing one string.

A Next.js chat route for useChat

useChat from @ai-sdk/react posts to /api/chat by default. This route answers it:

// app/api/chat/route.ts
import { streamText, convertToModelMessages, type UIMessage } from "ai";
import { uberllm } from "@/lib/uberllm";

export async function POST(req: Request) {
  const { messages }: { messages: UIMessage[] } = await req.json();
  const result = streamText({
    model: uberllm("deepseek/deepseek-v4.1-flash"),
    messages: await convertToModelMessages(messages),
  });
  return result.toUIMessageStreamResponse();
}

Keep the key on the server. Never put it in a NEXT_PUBLIC_ variable: anyone could read it from the page and spend your balance.

Cap what one call can cost

Chat requests accept provider.max_price (dollars per million tokens). Pass it through providerOptions under the provider name you chose:

await generateText({
  model: uberllm("deepseek/deepseek-v4.1-flash"),
  prompt: "Hi",
  providerOptions: { uberllm: { provider: { max_price: { prompt: 0.2, completion: 0.4 } } } },
});

If nobody sells the model under that price right now the call is refused with max_price_exceeded and nothing is charged.

Troubleshooting

  • 401 invalid_api_key: the key did not reach the server. Restart next dev after editing .env.local, and check process.env.UBERLLM_API_KEY is set where the code runs (server, not the browser).
  • 402 insufficient_credits: add credit on the credits page.
  • 404 model_not_found: the id is wrong or missing its maker. Copy it from the model's page.
  • 400 wrong_endpoint: you passed an image or video model to streamText. Image models go through uberllm.imageModel(…) with generateImage; video is a job, see Make a video or image.
  • Usage is empty on streams: set includeUsage: true on the provider, as above.

Keep reading

Good models for an app

All of these take tool calls. The first one is in the code below.

ModelModel id (paste this)Price now
DeepSeek V4.1 Flashdeepseek/deepseek-v4.1-flash$0.0075 in · $0.0282 out / 1M
Gemini 3.5 Flashgoogle/gemini-3.5-flash$0.0075 in · $0.0450 out / 1M
Claude Sonnet 5.5anthropic/claude-sonnet-5.5$0.3600 in · $1.80 out / 1M
GPT-5.5openai/gpt-5.5$1.25 in · $7.50 out / 1M
Kimi K3moonshotai/kimi-k3$0.0384 in · $0.2021 out / 1M
GLM 5.3z-ai/glm-5.3$0.0029 in · $0.0100 out / 1M
Gemma 3 27Bgoogle/gemma-3-27b-it$0.00079 in · $0.0020 out / 1M
Qwen3 VL 235B A22Bqwen/qwen3-vl-235b-a22b-instruct$0.0021 in · $0.0188 out / 1M

Prices at the last hourly build, no fee added · every model →

FAQ

Does the Vercel AI SDK work with MartLLM?

Yes. Use the official @ai-sdk/openai-compatible provider with baseURL https://api.martllm.com/v1 and your MartLLM key. generateText, streamText, useChat, tool calls and generateImage work.

Do I need @ai-sdk/openai or @ai-sdk/anthropic as well?

No. One @ai-sdk/openai-compatible provider reaches every chat model on MartLLM, including Claude, GPT and Gemini, by model id.

Can I make videos with the AI SDK?

Not through @ai-sdk/openai-compatible, which has no video model. Videos are jobs on MartLLM: start one with POST /v1/video/generations and check on it, as shown in the media docs.