> Discover all available pages from the documentation index: https://mastra.ai/llms.txt

# ![Clarifai logo](https://models.dev/logos/clarifai.svg)Clarifai

Access 12 Clarifai models through Mastra's model router. Authentication is handled automatically using the `CLARIFAI_PAT` environment variable.

Learn more in the [Clarifai documentation](https://docs.clarifai.com).

```bash
CLARIFAI_PAT=your-api-key
```

```typescript
import { Agent } from "@mastra/core/agent";

const agent = new Agent({
  id: "my-agent",
  name: "My Agent",
  instructions: "You are a helpful assistant",
  model: "clarifai/arcee_ai/AFM/models/trinity-mini"
});

// Generate a response
const response = await agent.generate("Hello!");

// Stream a response
const stream = await agent.stream("Tell me a story");
for await (const chunk of stream) {
  console.log(chunk);
}
```

> **Note:** Mastra uses the OpenAI-compatible `/chat/completions` endpoint. Some provider-specific features may not be available. Check the [Clarifai documentation](https://docs.clarifai.com) for details.

## Models

| Model                                                                    | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
| ------------------------------------------------------------------------ | ------- | ----- | --------- | ----- | ----- | ----- | ---------- | ----------- |
| `clarifai/arcee_ai/AFM/models/trinity-mini`                              | 131K    |       |           |       |       |       | $0.04      | $0.15       |
| `clarifai/clarifai/main/models/mm-poly-8b`                               | 33K     |       |           |       |       |       | $0.66      | $1          |
| `clarifai/deepseek-ai/deepseek-ocr/models/DeepSeek-OCR`                  | 8K      |       |           |       |       |       | $0.20      | $0.70       |
| `clarifai/minimaxai/chat-completion/models/MiniMax-M2_5-high-throughput` | 205K    |       |           |       |       |       | $0.30      | $1          |
| `clarifai/mistralai/completion/models/Ministral-3-14B-Reasoning-2512`    | 262K    |       |           |       |       |       | $3         | $2          |
| `clarifai/mistralai/completion/models/Ministral-3-3B-Reasoning-2512`     | 262K    |       |           |       |       |       | $1         | $0.55       |
| `clarifai/moonshotai/chat-completion/models/Kimi-K2_6`                   | 262K    |       |           |       |       |       | $0.95      | $4          |
| `clarifai/openai/chat-completion/models/gpt-oss-120b-high-throughput`    | 131K    |       |           |       |       |       | $0.09      | $0.36       |
| `clarifai/openai/chat-completion/models/gpt-oss-20b`                     | 131K    |       |           |       |       |       | $0.04      | $0.18       |
| `clarifai/qwen/qwenCoder/models/Qwen3-Coder-30B-A3B-Instruct`            | 262K    |       |           |       |       |       | $0.11      | $0.75       |
| `clarifai/qwen/qwenLM/models/Qwen3-30B-A3B-Instruct-2507`                | 262K    |       |           |       |       |       | $0.30      | $0.50       |
| `clarifai/qwen/qwenLM/models/Qwen3-30B-A3B-Thinking-2507`                | 262K    |       |           |       |       |       | $0.36      | $1          |

## Advanced configuration

### Custom headers

```typescript
const agent = new Agent({
  id: "custom-agent",
  name: "custom-agent",
  model: {
    url: "https://api.clarifai.com/v2/ext/openai/v1",
    id: "clarifai/arcee_ai/AFM/models/trinity-mini",
    apiKey: process.env.CLARIFAI_PAT,
    headers: {
      "X-Custom-Header": "value"
    }
  }
});
```

### Dynamic model selection

```typescript
const agent = new Agent({
  id: "dynamic-agent",
  name: "Dynamic Agent",
  model: ({ requestContext }) => {
    const useAdvanced = requestContext.task === "complex";
    return useAdvanced
      ? "clarifai/qwen/qwenLM/models/Qwen3-30B-A3B-Thinking-2507"
      : "clarifai/arcee_ai/AFM/models/trinity-mini";
  }
});
```