Back to Mastra

Fireworks AI | Models

docs/src/content/en/models/providers/fireworks-ai.mdx

2025-12-185.7 KB
Original Source

Fireworks AI

Access 13 Fireworks AI models through Mastra's model router. Authentication is handled automatically using the FIREWORKS_API_KEY environment variable.

Learn more in the Fireworks AI documentation.

bash
FIREWORKS_API_KEY=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: "fireworks-ai/accounts/fireworks/models/deepseek-v3p1"
});

// 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 Fireworks AI documentation for details.

:::

Models

<ProviderModelsTable models={[ { "model": "fireworks-ai/accounts/fireworks/models/deepseek-v3p1", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 163840, "maxOutput": 163840, "inputCost": 0.56, "outputCost": 1.68 }, { "model": "fireworks-ai/accounts/fireworks/models/deepseek-v3p2", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 160000, "maxOutput": 160000, "inputCost": 0.56, "outputCost": 1.68 }, { "model": "fireworks-ai/accounts/fireworks/models/glm-4p5", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 131072, "maxOutput": 131072, "inputCost": 0.55, "outputCost": 2.19 }, { "model": "fireworks-ai/accounts/fireworks/models/glm-4p5-air", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 131072, "maxOutput": 131072, "inputCost": 0.22, "outputCost": 0.88 }, { "model": "fireworks-ai/accounts/fireworks/models/glm-4p7", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 198000, "maxOutput": 198000, "inputCost": 0.6, "outputCost": 2.2 }, { "model": "fireworks-ai/accounts/fireworks/models/glm-5", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 202752, "maxOutput": 131072, "inputCost": 1, "outputCost": 3.2 }, { "model": "fireworks-ai/accounts/fireworks/models/gpt-oss-120b", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 131072, "maxOutput": 32768, "inputCost": 0.15, "outputCost": 0.6 }, { "model": "fireworks-ai/accounts/fireworks/models/gpt-oss-20b", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 131072, "maxOutput": 32768, "inputCost": 0.05, "outputCost": 0.2 }, { "model": "fireworks-ai/accounts/fireworks/models/kimi-k2-instruct", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": false, "contextWindow": 128000, "maxOutput": 16384, "inputCost": 1, "outputCost": 3 }, { "model": "fireworks-ai/accounts/fireworks/models/kimi-k2-thinking", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 256000, "maxOutput": 256000, "inputCost": 0.6, "outputCost": 2.5 }, { "model": "fireworks-ai/accounts/fireworks/models/kimi-k2p5", "imageInput": true, "audioInput": false, "videoInput": true, "toolUsage": true, "reasoning": true, "contextWindow": 256000, "maxOutput": 256000, "inputCost": 0.6, "outputCost": 3 }, { "model": "fireworks-ai/accounts/fireworks/models/minimax-m2p1", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 200000, "maxOutput": 200000, "inputCost": 0.3, "outputCost": 1.2 }, { "model": "fireworks-ai/accounts/fireworks/models/minimax-m2p5", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 196608, "maxOutput": 196608, "inputCost": 0.3, "outputCost": 1.2 } ]} />

Advanced configuration

Custom headers

typescript
const agent = new Agent({
  id: "custom-agent",
  name: "custom-agent",
  model: {
    url: "https://api.fireworks.ai/inference/v1/",
    id: "fireworks-ai/accounts/fireworks/models/deepseek-v3p1",
    apiKey: process.env.FIREWORKS_API_KEY,
    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
      ? "fireworks-ai/accounts/fireworks/models/minimax-m2p5"
      : "fireworks-ai/accounts/fireworks/models/deepseek-v3p1";
  }
});