# Mastra

Use Boundless in Mastra agents: an OpenAI-compatible provider from the AI SDK, the version rule and common errors.


Mastra reaches Boundless through an OpenAI-compatible provider from the AI SDK, using the base URL `https://api.inference.boundless.network/v1`.

## Install

Mastra is a library, so you configure it in code. The setup command does not offer it. Install Mastra and `@ai-sdk/openai-compatible` from their own documentation, then add the provider below. Need a key? Create one in [API Keys](https://inference.boundless.network/settings/api-keys) and export it as `BOUNDLESS_API_KEY`.

## Configure

### Mastra

An OpenAI-compatible provider from the AI SDK:

```typescript
import { Agent } from "@mastra/core/agent";
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";

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

export const assistant = new Agent({
  name: "assistant",
  instructions: "You are a helpful coding assistant.",
  model: boundless("deepseek/deepseek-v4.1-flash"),
});
```

Keep `@ai-sdk/openai-compatible` on the same AI SDK major version as `@mastra/core`.

## Model ids

The examples use `deepseek/deepseek-v4.1-flash`. Use any id from `GET https://api.inference.boundless.network/v1/models`; the [models page](https://inference.boundless.network/models) lists each one with its price and limits.

## Verify

To check the base URL and key on their own, list the models the gateway serves. A list of models means both are right. A `401` means the key is missing or wrong:

```bash
curl https://api.inference.boundless.network/v1/models -H "Authorization: Bearer YOUR_API_KEY"
```

Then send a short message in a new session and check that a reply comes back.

## Common errors

| What you see | What it usually is |
| --- | --- |
| `401` on every request | `BOUNDLESS_API_KEY` is not set in the process that runs the agent. |
| Type errors or odd behaviour from the provider | Keep `@ai-sdk/openai-compatible` on the same AI SDK major version as `@mastra/core`. |
| `403` with `model_not_allowed` | Your team admin has not enabled that model for you. Ask them, or pick another. See [Model access](https://inference.boundless.network/docs/teams#model-access). |

Every status and code is on the [Errors](https://inference.boundless.network/docs/errors) page. Other harnesses are on the [Coding Agents & Harnesses](https://inference.boundless.network/docs/coding-agents-and-harnesses) page.
