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

Vercel AI SDK

The Vercel AI SDK reaches MartLLM through its official @ai-sdk/openai-compatible provider. Every chat model in the catalog works with generateText and streamText, and image models work with generateImage.

The examples below were run against the live API with ai 7.0 and @ai-sdk/openai-compatible 3.0.

Install

npm i ai @ai-sdk/openai-compatible zod

Create an API key in Dashboard → Keys and put it in UBERLLM_API_KEY. Accounts start at $0, so add credit before the first call.

Set up the provider

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

export const uberllm = createOpenAICompatible({
  name: "uberllm",
  apiKey: process.env.UBERLLM_API_KEY,
  baseURL: "https://api.martllm.com/v1",
  includeUsage: true, // token usage on streamed responses too
  supportsStructuredOutputs: true, // needed for typed output (Output.object): sends your JSON schema to the model
});

A complete Next.js chat app with this provider, a tool and typed output is in the Starter kits.

apiKey is sent as Authorization: Bearer <key>. Model ids are the ids on martllm.com/models, for example deepseek/deepseek-v4-flash, anthropic/claude-sonnet-5.5 or openai/gpt-5.5.

Generate text

import { generateText } from "ai";

const { text, usage } = await generateText({
  model: uberllm("deepseek/deepseek-v4-flash"),
  prompt: "Say hello in one short sentence.",
});
console.log(text, usage);

usage.raw.cost_usd is what the call cost, in US dollars.

Stream

import { streamText } from "ai";

const result = streamText({
  model: uberllm("deepseek/deepseek-v4-flash"),
  prompt: "Count from 1 to 5.",
});
for await (const delta of result.textStream) {
  process.stdout.write(delta);
}
console.log(await result.usage);

Tool calls

import { generateText, tool, stepCountIs } from "ai";
import { z } from "zod";

const { text, steps } = await generateText({
  model: uberllm("deepseek/deepseek-v4-flash"),
  tools: {
    weather: tool({
      description: "Get the current temperature in a city, in Celsius",
      inputSchema: z.object({ city: z.string() }),
      execute: async ({ city }) => ({ city, celsius: 21 }),
    }),
  },
  stopWhen: stepCountIs(3), // call the tool, then answer
  prompt: "What is the temperature in Paris right now?",
});
console.log(text);

Most chat models take tools. A model page on martllm.com says when one does not.

Images

Image models use uberllm.imageModel(...) with generateImage. The SDK asks for b64_json, so the picture comes back in the answer.

import { generateImage } from "ai";

const { image } = await generateImage({
  model: uberllm.imageModel("black-forest-labs/flux.2-klein-4b"),
  prompt: "A red bicycle on a white background",
  size: "1024x1024",
});
// image.uint8Array holds the PNG

Image ids are listed under Images on martllm.com/models. Editing models (ids ending in -edit) take POST /v1/images/edits, which @ai-sdk/openai-compatible does not call. Use the REST call in Make a video or image for those.

Video and music

@ai-sdk/openai-compatible has no video or music model. Video and music are jobs: start one with POST /v1/videos (or /v1/music), then poll it or get a callback. See Make a video or image, or let an agent do it through the MCP server.

Prices

Each call costs what its provider charged for it. No MartLLM fee on requests. Adding credit by card costs 5.5% + $0.50. To cap what a chat call can cost, pass provider.max_price in the request body through providerOptions:

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

See Pricing and Models & routing.