Integrations

Vercel AI SDK

Vercel AI SDK is an open-source TypeScript toolkit for building AI-powered applications. It provides a unified API for working with LLMs, including streaming, tool calling, and structured outputs. Since it supports OpenAI-compatible endpoints, you can configure it to use MARA Cloud models.

Prerequisites

Setup

Install the AI SDK and the OpenAI-compatible provider:
bash
npm install ai @ai-sdk/openai-compatible

Configuration

Create a custom provider pointing to MARA Cloud:
typescript
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
import { generateText } from "ai";

const mara = createOpenAICompatible({
  name: "mara",
  baseURL: "https://api.cloud.mara.com/v1",
  headers: {
    Authorization: `Bearer your-mara-api-key`,
  },
});

const { text } = await generateText({
  model: mara("MiniMax-M2.5"),
  prompt: "Explain what the Vercel AI SDK does in two sentences.",
});

console.log(text);

Streaming responses

typescript
import { streamText } from "ai";

const result = streamText({
  model: mara("MiniMax-M2.5"),
  prompt: "Write a short poem about cloud computing.",
});

for await (const chunk of result.textStream) {
  process.stdout.write(chunk);
}

Learn more