|
| 1 | +# FireworksAI |
| 2 | + |
| 3 | +{{ community_contribution_banner }} |
| 4 | + |
| 5 | +[Fireworks AI](https://fireworks.ai) provides blazing fast inference for open-source language models. Fireworks AI is accessible through OpenAI's SDK via full API compatibility, allowing easy and portable integration with the Strands Agents SDK using the familiar OpenAI interface. |
| 6 | + |
| 7 | +## Installation |
| 8 | + |
| 9 | +The Strands Agents SDK provides access to Fireworks AI models through the OpenAI compatibility layer, configured as an optional dependency. To install, run: |
| 10 | + |
| 11 | +```bash |
| 12 | +pip install 'strands-agents[openai]' strands-agents-tools |
| 13 | +``` |
| 14 | + |
| 15 | +## Usage |
| 16 | + |
| 17 | +After installing the `openai` package, you can import and initialize the Strands Agents' OpenAI-compatible provider for Fireworks AI models as follows: |
| 18 | + |
| 19 | +```python |
| 20 | +from strands import Agent |
| 21 | +from strands.models.openai import OpenAIModel |
| 22 | +from strands_tools import calculator |
| 23 | + |
| 24 | +model = OpenAIModel( |
| 25 | + client_args={ |
| 26 | + "api_key": "<FIREWORKS_API_KEY>", |
| 27 | + "base_url": "https://api.fireworks.ai/inference/v1", |
| 28 | + }, |
| 29 | + model_id="accounts/fireworks/models/deepseek-v3p1-terminus", # or see https://fireworks.ai/models |
| 30 | + params={ |
| 31 | + "max_tokens": 5000, |
| 32 | + "temperature": 0.1 |
| 33 | + } |
| 34 | +) |
| 35 | + |
| 36 | +agent = Agent(model=model, tools=[calculator]) |
| 37 | +agent("What is 2+2?") |
| 38 | +``` |
| 39 | + |
| 40 | +## Configuration |
| 41 | + |
| 42 | +### Client Configuration |
| 43 | + |
| 44 | +The `client_args` configure the underlying OpenAI-compatible client. When using Fireworks AI, you must set: |
| 45 | + |
| 46 | +* `api_key`: Your Fireworks AI API key. Get one from the [Fireworks AI Console](https://app.fireworks.ai/settings/users/api-keys). |
| 47 | +* `base_url`: `https://api.fireworks.ai/inference/v1` |
| 48 | + |
| 49 | +Refer to [OpenAI Python SDK GitHub](https://github.com/openai/openai-python) for full client options. |
| 50 | + |
| 51 | +### Model Configuration |
| 52 | + |
| 53 | +The `model_config` specifies which Fireworks AI model to use and any additional parameters. |
| 54 | + |
| 55 | +| Parameter | Description | Example | Options | |
| 56 | +| ---------- | ------------------------- | ----------------------------------------------------------------- | ------------------------------------------------------------------ | |
| 57 | +| `model_id` | Model name | `accounts/fireworks/models/deepseek-v3p1-terminus` | See [Fireworks Models](https://fireworks.ai/models) | |
| 58 | +| `params` | Model-specific parameters | `{"max_tokens": 5000, "temperature": 0.7, "top_p": 0.9}` | [API reference](https://docs.fireworks.ai/api-reference) | |
| 59 | + |
| 60 | +## Troubleshooting |
| 61 | + |
| 62 | +### `ModuleNotFoundError: No module named 'openai'` |
| 63 | + |
| 64 | +You must install the `openai` dependency to use this provider: |
| 65 | + |
| 66 | +```bash |
| 67 | +pip install 'strands-agents[openai]' |
| 68 | +``` |
| 69 | + |
| 70 | +### Unexpected model behavior? |
| 71 | + |
| 72 | +Ensure you're using a model ID compatible with Fireworks AI (e.g., `accounts/fireworks/models/deepseek-v3p1-terminus`, `accounts/fireworks/models/kimi-k2-instruct-0905`), and your `base_url` is set to `https://api.fireworks.ai/inference/v1`. |
| 73 | + |
| 74 | +## References |
| 75 | + |
| 76 | +* [Fireworks AI OpenAI Compatibility Guide](https://fireworks.ai/docs/tools-sdks/openai-compatibility#openai-compatibility) |
| 77 | +* [Fireworks AI API Reference](https://docs.fireworks.ai/api-reference) |
| 78 | +* [Fireworks AI Models](https://fireworks.ai/models) |
| 79 | +* [OpenAI Python SDK](https://github.com/openai/openai-python) |
| 80 | +* [Strands Agents API](../../api-reference/models.md) |
0 commit comments