0

Fireworks AI Provider

Fireworks AI Provider explains the cloud layer of MTPX with practical guidance for building inspectable, tool-using agents.

Fi
Fireworks AI Provider
Chapter 031ProvidersCloudIndex
01Orientation

Fireworks AI Provider belongs to the providers track. The page breaks the idea into responsibilities, implementation rules, failure modes, and the signals you should expose in a product UI.

Use this when

Use this when you need to understand how fireworks ai provider affects a real MTPX agent before you wire it into an application.

  • What fireworks ai provider owns in the runtime.
  • How it connects to planning, tool execution, events, providers, or storage.
  • What to log, test, and expose to users when this layer is active.
  • Common mistakes that make agent systems hard to inspect.
02 / syntax starter
from mtp import Agent
from mtp.providers import Groq

agent = Agent.MTPAgent(
    provider=Groq(model="llama-3.3-70b-versatile"),
    tools=tools,
)
03 / manual

Read the system

The complete source manual—syntax, examples, linked references, edge cases, and implementation notes.

Documentation index ↗

Fireworks AI specializes in FAST open-model inference using their FireAttention kernel — often 3-5x faster than competitors.

Install

bashpip install "mtpx[fireworksai]"

This installs the openai SDK. Alternatively, install the native Fireworks SDK:

bashpip install fireworks-ai

API Key Setup

  1. Install dotenv support:
bash   pip install python-dotenv

Or with the MTP extra:

bash   pip install "mtpx[dotenv]"
  1. Create a .env file in your project root:
text   FIREWORKS_API_KEY=fw_your_key_here
  1. Load it in your code before creating the provider:
python   from mtp import Agent

   Agent.load_dotenv_if_available()  # reads .env file

Get a free API key at fireworks.ai (free credits on signup).

Option 2: System environment variable

bash# Linux/macOS
export FIREWORKS_API_KEY="fw_..."

# Windows PowerShell
$env:FIREWORKS_API_KEY="fw_..."

Quick Start

pythonfrom mtp import Agent
from mtp.providers import FireworksAI

Agent.load_dotenv_if_available()  # loads FIREWORKS_API_KEY from .env

provider = FireworksAI(model="accounts/fireworks/models/llama-v3p3-70b-instruct")
tools = Agent.ToolRegistry()
agent = Agent(provider=provider, tools=tools)

reply = agent.run_loop("What is 25 * 4 + 10?")
print(reply)

Parameters

ParameterTypeDefaultDescription
modelstr"accounts/fireworks/models/llama-v3p3-70b-instruct"Fireworks model ID (account-qualified)
api_keystr | NoneNoneAPI key (falls back to FIREWORKS_API_KEY env var)
temperaturefloat0.0Sampling temperature
tool_choicestr | dict"auto"Tool selection strategy
parallel_tool_callsboolTrueAllow parallel tool calls
max_tokensint4096Maximum response tokens
response_formatdict | NoneNoneStructured output format (JSON schema)
clientAny | NoneNonePre-configured client instance

Capabilities

CapabilityValue
Tool callingYes
Parallel tool callsYes (configurable)
Input modalitiestext, image
StreamingFallback
Usage metricsRich
Reasoning metadataNo
Structured outputNative JSON schema (when response_format set)
Native asyncNo (uses thread fallback)
  • accounts/fireworks/models/llama-v3p3-70b-instruct — Best overall (default)
  • accounts/fireworks/models/llama-v3p1-405b-instruct — Most capable
  • accounts/fireworks/models/qwen2p5-72b-instruct — Top reasoning
  • accounts/fireworks/models/deepseek-v3 — Best reasoning
  • accounts/fireworks/models/mixtral-8x22b-instruct — Fast + smart
  • accounts/fireworks/models/firefunction-v2 — Purpose-built for tool calling

Structured Output

Fireworks supports native JSON schema output:

pythonprovider = FireworksAI(
    model="accounts/fireworks/models/llama-v3p3-70b-instruct",
    response_format={
        "type": "json_schema",
        "json_schema": {
            "name": "result",
            "schema": {
                "type": "object",
                "properties": {
                    "answer": {"type": "number"},
                    "explanation": {"type": "string"},
                },
                "required": ["answer", "explanation"],
            },
        },
    },
)

Full Example

pythonfrom mtp import Agent
from mtp.providers import FireworksAI

Agent.load_dotenv_if_available()

provider = FireworksAI(
    model="accounts/fireworks/models/llama-v3p3-70b-instruct",
    temperature=0.0,
    max_tokens=4096,
)

tools = Agent.ToolRegistry()
agent = Agent(provider=provider, tools=tools, debug_mode=True)

reply = agent.run_loop(
    "Calculate (25 * 4) + 10",
    max_rounds=3,
)
print(reply)

Notes

  • Fireworks prefers the native fireworks-ai SDK, falls back to OpenAI client at https://api.fireworks.ai/inference/v1.
  • Model IDs must be account-qualified (e.g., accounts/fireworks/models/...).
  • firefunction-v2 is purpose-built for function/tool calling and may give better results for agent workflows.
  • When response_format is set, structured_output_support reports native_json_schema capability.

Source

src/mtp/providers/fireworks_provider.py

01

Read

Understand where Fireworks AI Provider sits in the agent loop before adding abstractions.

02

Wire

Connect the smallest useful provider, registry, store, or event stream first.

03

Observe

Expose events, logs, results, and failure states while the runtime is still moving.

04

Harden

Add policy, tests, retries, and audit traces after the behavior is visible.

Next docGemini Provider