# <img src="https://models.dev/logos/submodel.svg" alt="submodel logo" className="inline w-8 h-8 mr-2 align-middle dark:invert dark:brightness-0 dark:contrast-200" />submodel
[EN] Source: https://mastra.ai/models/providers/submodel

Access 9 submodel models through Mastra's model router. Authentication is handled automatically using the `SUBMODEL_INSTAGEN_ACCESS_KEY` environment variable.

Learn more in the [submodel documentation](https://submodel.gitbook.io).

```bash
SUBMODEL_INSTAGEN_ACCESS_KEY=your-api-key
```

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

const agent = new Agent({
  name: "my-agent",
  instructions: "You are a helpful assistant",
  model: "submodel/Qwen/Qwen3-235B-A22B-Instruct-2507"
});

// 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);
}
```

:::info

Mastra uses the OpenAI-compatible `/chat/completions` endpoint. Some provider-specific features may not be available. Check the [submodel documentation](https://submodel.gitbook.io) for details.

:::

## Models

<ProviderModelsTable
  models={[
  {
    "model": "submodel/deepseek-ai/DeepSeek-R1-0528",
    "imageInput": false,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": true,
    "contextWindow": 75000,
    "maxOutput": 163840,
    "inputCost": 0.5,
    "outputCost": 2.15
  },
  {
    "model": "submodel/deepseek-ai/DeepSeek-V3-0324",
    "imageInput": false,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": false,
    "contextWindow": 75000,
    "maxOutput": 163840,
    "inputCost": 0.2,
    "outputCost": 0.8
  },
  {
    "model": "submodel/deepseek-ai/DeepSeek-V3.1",
    "imageInput": false,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": true,
    "contextWindow": 75000,
    "maxOutput": 163840,
    "inputCost": 0.2,
    "outputCost": 0.8
  },
  {
    "model": "submodel/openai/gpt-oss-120b",
    "imageInput": false,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": true,
    "contextWindow": 131072,
    "maxOutput": 32768,
    "inputCost": 0.1,
    "outputCost": 0.5
  },
  {
    "model": "submodel/Qwen/Qwen3-235B-A22B-Instruct-2507",
    "imageInput": false,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": false,
    "contextWindow": 262144,
    "maxOutput": 131072,
    "inputCost": 0.2,
    "outputCost": 0.3
  },
  {
    "model": "submodel/Qwen/Qwen3-235B-A22B-Thinking-2507",
    "imageInput": false,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": true,
    "contextWindow": 262144,
    "maxOutput": 131072,
    "inputCost": 0.2,
    "outputCost": 0.6
  },
  {
    "model": "submodel/Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8",
    "imageInput": false,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": false,
    "contextWindow": 262144,
    "maxOutput": 262144,
    "inputCost": 0.2,
    "outputCost": 0.8
  },
  {
    "model": "submodel/zai-org/GLM-4.5-Air",
    "imageInput": false,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": false,
    "contextWindow": 131072,
    "maxOutput": 131072,
    "inputCost": 0.1,
    "outputCost": 0.5
  },
  {
    "model": "submodel/zai-org/GLM-4.5-FP8",
    "imageInput": false,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": true,
    "contextWindow": 131072,
    "maxOutput": 131072,
    "inputCost": 0.2,
    "outputCost": 0.8
  }
]}
/>

## Advanced Configuration

### Custom Headers

```typescript
const agent = new Agent({
  name: "custom-agent",
  model: {
    url: "https://llm.submodel.ai/v1",
    id: "submodel/Qwen/Qwen3-235B-A22B-Instruct-2507",
    apiKey: process.env.SUBMODEL_INSTAGEN_ACCESS_KEY,
    headers: {
      "X-Custom-Header": "value"
    }
  }
});
```

### Dynamic Model Selection

```typescript
const agent = new Agent({
  name: "dynamic-agent",
  model: ({ runtimeContext }) => {
    const useAdvanced = runtimeContext.task === "complex";
    return useAdvanced
      ? "submodel/zai-org/GLM-4.5-FP8"
      : "submodel/Qwen/Qwen3-235B-A22B-Instruct-2507";
  }
});
```




---
title: "Synthetic | Models | Mastra"
description: "Use Synthetic models with Mastra. 22 models available."
---

{/* This file is auto-generated by generate-model-docs.ts - DO NOT EDIT MANUALLY */}