Fireworks AI Python SDK
Python SDK and OpenAI-compatible API for running open-source and proprietary LLMs on Fireworks AI infrastructure.
Warnings
- breaking v1.0.0 alpha SDK (pip install fireworks-ai==1.0.0a*) is NOT stable. It has breaking changes vs v0.x and is still in pre-release as of Jan 2026. pip install fireworks-ai installs v0.19.20 (stable).
- breaking Model IDs use full path format: accounts/fireworks/models/<model-name>. Short names like 'llama-3-8b' will fail with 404.
- gotcha When using OpenAI SDK compatibility, set FIREWORKS_API_KEY env var but pass it explicitly as api_key= — the OpenAI SDK reads OPENAI_API_KEY by default and will silently use the wrong key.
- gotcha usage field is not exposed in OpenAI SDK streaming responses against Fireworks. Cast chunk to Any in TypeScript; in Python, usage will be None on stream chunks.
- gotcha LiteLLM uses FIREWORKS_AI_API_KEY (with _AI_). Native SDK and OpenAI-compat use FIREWORKS_API_KEY. Different env var depending on integration.
- deprecated Build SDK (native fireworks.client) is marked deprecated in official docs. Fireworks now recommends OpenAI-compatible approach for new projects.
Install
-
pip install fireworks-ai -
pip install fireworks-ai==1.0.0a20 -
pip install openai
Imports
- Fireworks
from fireworks.client import Fireworks
- OpenAI (Fireworks compat)
from openai import OpenAI client = OpenAI(base_url='https://api.fireworks.ai/inference/v1', api_key=os.environ['FIREWORKS_API_KEY'])
Quickstart
from openai import OpenAI
client = OpenAI(
base_url='https://api.fireworks.ai/inference/v1',
api_key='YOUR_FIREWORKS_API_KEY'
)
response = client.chat.completions.create(
model='accounts/fireworks/models/llama-v3p1-8b-instruct',
messages=[{'role': 'user', 'content': 'Hello'}]
)
print(response.choices[0].message.content)