# Vercel AI SDK

Use the Vercel AI SDK with Boundless through the OpenAI-compatible provider: install, base URL and key, streaming and a tool call.


The Vercel AI SDK reaches Boundless through `@ai-sdk/openai-compatible`, which speaks chat completions.

## Install

```bash
npm install ai @ai-sdk/openai-compatible zod
```

## Base URL and key

```bash
export BOUNDLESS_API_KEY="paste-your-key-here"
```

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

export const boundless = createOpenAICompatible({
  name: "boundless",
  baseURL: "https://api.inference.boundless.network/v1",
  apiKey: process.env.BOUNDLESS_API_KEY,
})
```

Name a model with the ID from the [models table](https://inference.boundless.network/docs/models): `boundless("deepseek/deepseek-v4.1-flash-1017")`.

## Make a request

```typescript
import { generateText } from "ai"
import { boundless } from "./boundless"

const { text, usage } = await generateText({
  model: boundless("deepseek/deepseek-v4.1-flash-1017"),
  prompt: "Say hello",
})

console.log(text)
console.log(usage)
```

## Stream the reply

```typescript
import { streamText } from "ai"

const result = streamText({
  model: boundless("deepseek/deepseek-v4.1-flash-1017"),
  prompt: "Say hello",
})

for await (const delta of result.textStream) {
  process.stdout.write(delta)
}
console.log("\n", await result.usage)
```

## Call a tool

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

const { text, toolCalls } = await generateText({
  model: boundless("deepseek/deepseek-v4.1-flash"),
  prompt: "What is 20 + 22? Use the add tool.",
  tools: {
    add: tool({
      description: "Add two integers.",
      inputSchema: z.object({ a: z.number().int(), b: z.number().int() }),
      execute: async ({ a, b }) => ({ result: a + b }),
    }),
  },
  stopWhen: stepCountIs(3),
})

console.log(toolCalls)
console.log(text)
```

The SDK runs `execute`, sends the result back and asks the model for the final answer. [Tool calling](https://inference.boundless.network/docs/tool-calling) shows the same loop on the raw API.

## Known differences

- Keep `@ai-sdk/openai-compatible` on the same AI SDK major version as `ai`. The tool example uses the `inputSchema` and `stopWhen` names of AI SDK 5 and later.
- The provider speaks chat completions. Messages and Responses are not used.
- Not every model supports tools. `GET /v1/model/info` lists the capability flags.
- Credits that run out return `402` with `budget_exceeded`. Rate limits return `429`. See [Errors](https://inference.boundless.network/docs/errors).
- A reasoning model spends `max_tokens` on thinking too. See [Reasoning](https://inference.boundless.network/docs/reasoning).
