Skip to main content

Fireworks AI

info

We support ALL Fireworks AI models, just set fireworks_ai/ as a prefix when sending completion requests

PropertyDetails
DescriptionThe fastest and most efficient inference engine to build production-ready, compound AI systems.
Provider Route on LiteLLMfireworks_ai/
Provider DocFireworks AI ↗
Supported OpenAI Endpoints/chat/completions, /responses, /embeddings, /completions, /audio/transcriptions, /rerank

Overview​

This guide explains how to integrate LiteLLM with Fireworks AI. You can connect to Fireworks AI in three main ways:

  1. Using Fireworks AI serverless models – Easy connection to Fireworks-managed models.
  2. Connecting to a model in your own Fireworks account – Access models that are hosted within your Fireworks account.
  3. Connecting via a direct-route deployment – A more flexible, customizable connection to a specific Fireworks instance.

API Key​

# env variable
os.environ['FIREWORKS_AI_API_KEY']

Sample Usage - Serverless Models​

from litellm import completion
import os

os.environ['FIREWORKS_AI_API_KEY'] = ""
response = completion(
model="fireworks_ai/glm-5p2",
messages=[
{"role": "user", "content": "hello from litellm"}
],
)
print(response)

A bare serverless slug like glm-5p2 is expanded to accounts/fireworks/models/glm-5p2 for you, so you can pass either the short slug or the full resource id.

Sample Usage - Serverless Models - Streaming​

from litellm import completion
import os

os.environ['FIREWORKS_AI_API_KEY'] = ""
response = completion(
model="fireworks_ai/glm-5p2",
messages=[
{"role": "user", "content": "hello from litellm"}
],
stream=True
)

for chunk in response:
print(chunk)

Sample Usage - Models in Your Own Fireworks Account​

from litellm import completion
import os

os.environ['FIREWORKS_AI_API_KEY'] = ""
response = completion(
model="fireworks_ai/accounts/fireworks/models/YOUR_MODEL_ID",
messages=[
{"role": "user", "content": "hello from litellm"}
],
)
print(response)

Sample Usage - Direct-Route Deployment​

from litellm import completion
import os

os.environ['FIREWORKS_AI_API_KEY'] = "YOUR_DIRECT_API_KEY"
response = completion(
model="fireworks_ai/accounts/fireworks/models/qwen2p5-coder-7b#accounts/gitlab/deployments/2fb7764c",
messages=[
{"role": "user", "content": "hello from litellm"}
],
api_base="https://gitlab-2fb7764c.direct.fireworks.ai/v1"
)
print(response)

Note: The above is for the chat interface, if you want to use the text completion interface it's model="text-completion-openai/accounts/fireworks/models/qwen2p5-coder-7b#accounts/gitlab/deployments/2fb7764c"

Sample Usage - Routers​

Fireworks routers are served at accounts/fireworks/routers/<router-id> rather than accounts/fireworks/models/<model-id>, so a bare slug alone cannot tell LiteLLM which one you mean. Prefix the slug with routers/ to target a router; LiteLLM expands routers/<id> to accounts/fireworks/routers/<id>. See the Fireworks routers docs for the routers available on your account.

from litellm import completion
import os

os.environ['FIREWORKS_AI_API_KEY'] = ""
response = completion(
model="fireworks_ai/routers/glm-latest",
messages=[
{"role": "user", "content": "hello from litellm"}
],
)
print(response)

The full resource id (fireworks_ai/accounts/fireworks/routers/glm-latest) is still accepted if you prefer to be explicit. Slugs ending in -fast (for example fireworks_ai/glm-5p2-fast) are treated as routers even without the routers/ prefix.

FireRouter (auto router)​

FireRouter is Fireworks' managed router. Instead of pointing at one model, the accounts/fireworks/routers/firerouter resource picks a model per request, and the response model field reports which one served it.

LiteLLM accepts three equivalent spellings:

model="fireworks_ai/firerouter"                                        # default router
model="fireworks_ai/firerouter/kimi-k3/glm-5p2" # custom slug: restrict the pool
model="fireworks_ai/accounts/fireworks/routers/firerouter" # full resource id

Bring your own key for pass-through legs​

Fireworks does not resell closed models. When FireRouter picks a Claude or GPT leg, it forwards the request to that provider under your own credentials, so the caller must supply x-anthropic-api-key or x-openai-api-key. Without it Fireworks fails closed with a 401.

Attach the header server-side on the deployment with litellm_params.extra_headers, or let each client send its own by enabling forward_client_headers_to_llm_api globally or per model group.

model_list:
- model_name: firerouter
litellm_params:
model: fireworks_ai/firerouter
api_key: os.environ/FIREWORKS_AI_API_KEY
extra_headers:
x-anthropic-api-key: os.environ/ANTHROPIC_API_KEY
general_settings:
forward_client_headers_to_llm_api: true
# or per model group:
# model_group_settings:
# forward_client_headers_to_llm_api: [firerouter]
curl -X POST http://localhost:4000/v1/chat/completions \
-H "Authorization: Bearer $LITELLM_MASTER_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "firerouter", "messages": [{"role": "user", "content": "hello"}]}'

The same headers go through the SDK on completion():

from litellm import completion

response = completion(
model="fireworks_ai/firerouter",
messages=[{"role": "user", "content": "hello"}],
extra_headers={"x-anthropic-api-key": "sk-ant-..."},
)

Routing preference​

x-routing-preference steers the router on a 1–5 scale, where 1 is cheapest and 5 is highest quality. It travels the same way as the BYOK headers: litellm_params.extra_headers server-side, client-supplied when forward_client_headers_to_llm_api is on, or extra_headers on completion().

Cost tracking​

LiteLLM prices each request off the model Fireworks reports it routed to. Fireworks-hosted legs are billed at Fireworks rates; pass-through legs (for example a Claude leg) are billed at that provider's own list price. Your invoice is split across two vendor bills, the Fireworks key covering open models and your Anthropic or OpenAI key covering pass-through, but LiteLLM spend logs and budgets sum both under the one model group.

Usage with LiteLLM Proxy​

1. Set Fireworks AI Models on config.yaml​

model_list:
- model_name: fireworks-glm-5p2
litellm_params:
model: fireworks_ai/glm-5p2
api_key: "os.environ/FIREWORKS_AI_API_KEY"

2. Start Proxy​

litellm --config config.yaml

3. Test it​

curl --location 'http://0.0.0.0:4000/chat/completions' \
--header 'Content-Type: application/json' \
--data ' {
"model": "fireworks-glm-5p2",
"messages": [
{
"role": "user",
"content": "what llm are you"
}
]
}
'

Responses API​

fireworks_ai/ models on /v1/responses go straight to Fireworks' native https://api.fireworks.ai/inference/v1/responses endpoint, so server-side features such as MCP tools ("type": "mcp"), previous_response_id, and reasoning output items work the same as they do against Fireworks directly

import os
from litellm import responses

os.environ["FIREWORKS_AI_API_KEY"] = "YOUR_API_KEY"

response = responses(
model="fireworks_ai/accounts/fireworks/models/kimi-k3",
input="Use the deepwiki MCP server to tell me in one sentence what the BerriAI/litellm repository is.",
tools=[
{
"type": "mcp",
"server_label": "deepwiki",
"server_url": "https://mcp.deepwiki.com/mcp",
"require_approval": "never",
}
],
)
print(response.output)

Multi-turn tool calling works the same way it does against Fireworks directly: send back the function_call_output items together with the previous_response_id Fireworks returned, and Fireworks continues the conversation server-side

developer input items are sent to Fireworks as system messages, since Fireworks' Responses API has no developer role on models such as kimi-k3 and qwen3.8. A model whose chat template needs the system message first (qwen3.8) still rejects a developer item placed after the first input item, the same way it does when called directly

Document Inlining​

LiteLLM supports document inlining for Fireworks AI models. This is useful for models that are not vision models, but still need to parse documents/images/etc.

LiteLLM will add #transform=inline to the url of the image_url, if the model is not a vision model.See Code

from litellm import completion
import os

os.environ["FIREWORKS_AI_API_KEY"] = "YOUR_API_KEY"
os.environ["FIREWORKS_AI_API_BASE"] = "https://audio-prod.api.fireworks.ai/v1"

completion = litellm.completion(
model="fireworks_ai/accounts/fireworks/models/llama-v3p3-70b-instruct",
messages=[
{
"role": "user",
"content": [
{
"type": "image_url",
"image_url": {
"url": "https://storage.googleapis.com/fireworks-public/test/sample_resume.pdf"
},
},
{
"type": "text",
"text": "What are the candidate's BA and MBA GPAs?",
},
],
}
],
)
print(completion)

Disable Auto-add​

If you want to disable the auto-add of #transform=inline to the url of the image_url, set disable_add_transform_inline_image_block to True

litellm.disable_add_transform_inline_image_block = True

Reasoning Effort​

The reasoning_effort parameter is supported on select Fireworks AI models. Supported models include:

from litellm import completion
import os

os.environ["FIREWORKS_AI_API_KEY"] = "YOUR_API_KEY"

response = completion(
model="fireworks_ai/accounts/fireworks/models/qwen3-8b",
messages=[
{"role": "user", "content": "What is the capital of France?"}
],
reasoning_effort="low",
)
print(response)

Supported Models - ALL Fireworks AI Models Supported!​

info

We support ALL Fireworks AI models, just set fireworks_ai/ as a prefix when sending completion requests

Model NameFunction Call
glm-5p2completion(model="fireworks_ai/glm-5p2", messages)
deepseek-v4-procompletion(model="fireworks_ai/deepseek-v4-pro", messages)
kimi-k3completion(model="fireworks_ai/kimi-k3", messages)
qwen3p8-maxcompletion(model="fireworks_ai/qwen3p8-max", messages)
minimax-m3completion(model="fireworks_ai/minimax-m3", messages)
gpt-oss-120bcompletion(model="fireworks_ai/gpt-oss-120b", messages)

The table above is a small selection of popular models. For the full, current list of models and routers, see the Fireworks model library.

Supported Embedding Models​

info

We support ALL Fireworks AI models, just set fireworks_ai/ as a prefix when sending embedding requests

Model NameFunction Call
fireworks_ai/nomic-ai/nomic-embed-text-v1.5response = litellm.embedding(model="fireworks_ai/nomic-ai/nomic-embed-text-v1.5", input=input_text)
fireworks_ai/nomic-ai/nomic-embed-text-v1response = litellm.embedding(model="fireworks_ai/nomic-ai/nomic-embed-text-v1", input=input_text)
fireworks_ai/WhereIsAI/UAE-Large-V1response = litellm.embedding(model="fireworks_ai/WhereIsAI/UAE-Large-V1", input=input_text)
fireworks_ai/thenlper/gte-largeresponse = litellm.embedding(model="fireworks_ai/thenlper/gte-large", input=input_text)
fireworks_ai/thenlper/gte-baseresponse = litellm.embedding(model="fireworks_ai/thenlper/gte-base", input=input_text)

Audio Transcription​

Quick Start​

from litellm import transcription
import os

os.environ["FIREWORKS_AI_API_KEY"] = "YOUR_API_KEY"
os.environ["FIREWORKS_AI_API_BASE"] = "https://audio-prod.api.fireworks.ai/v1"

response = transcription(
model="fireworks_ai/whisper-v3",
audio=audio_file,
)

Pass API Key/API Base in .transcription

Rerank​

Quick Start​

from litellm import rerank
import os

os.environ["FIREWORKS_AI_API_KEY"] = "YOUR_API_KEY"

query = "What is the capital of France?"
documents = [
"Paris is the capital and largest city of France, home to the Eiffel Tower and the Louvre Museum.",
"France is a country in Western Europe known for its wine, cuisine, and rich history.",
"The weather in Europe varies significantly between northern and southern regions.",
"Python is a popular programming language used for web development and data science.",
]

response = rerank(
model="fireworks_ai/fireworks/qwen3-reranker-8b",
query=query,
documents=documents,
top_n=3,
return_documents=True,
)
print(response)

Pass API Key/API Base in .rerank

Supported Models​

Model NameFunction Call
fireworks/qwen3-reranker-8brerank(model="fireworks_ai/fireworks/qwen3-reranker-8b", query=query, documents=documents)