Fireworks Provider
Fireworks is a platform for running and testing LLMs through their API.
Setup
The Fireworks provider is available via the @ai-sdk/fireworks
module. You can install it with
pnpm add @ai-sdk/fireworks
Provider Instance
You can import the default provider instance fireworks
from @ai-sdk/fireworks
:
import { fireworks } from '@ai-sdk/fireworks';
If you need a customized setup, you can import createFireworks
from @ai-sdk/fireworks
and create a provider instance with your settings:
import { createFireworks } from '@ai-sdk/fireworks';
const fireworks = createFireworks({ apiKey: process.env.FIREWORKS_API_KEY ?? '',});
You can use the following optional settings to customize the Fireworks provider instance:
-
baseURL string
Use a different URL prefix for API calls, e.g. to use proxy servers. The default prefix is
https://api.fireworks.ai/inference/v1
. -
apiKey string
API key that is being sent using the
Authorization
header. It defaults to theFIREWORKS_API_KEY
environment variable. -
headers Record<string,string>
Custom headers to include in the requests.
-
fetch (input: RequestInfo, init?: RequestInit) => Promise<Response>
Custom fetch implementation.
Language Models
You can create Fireworks models using a provider instance.
The first argument is the model id, e.g. accounts/fireworks/models/firefunction-v1
:
const model = fireworks('accounts/fireworks/models/firefunction-v1');
Example
You can use Fireworks language models to generate text with the generateText
function:
import { fireworks } from '@ai-sdk/fireworks';import { generateText } from 'ai';
const { text } = await generateText({ model: fireworks('accounts/fireworks/models/firefunction-v1'), prompt: 'Write a vegetarian lasagna recipe for 4 people.',});
Fireworks language models can also be used in the streamText
and streamUI
functions (see AI SDK Core and AI SDK RSC).
Completion Models
You can create models that call the Fireworks completions API using the .completion()
factory method:
const model = fireworks.completion('accounts/fireworks/models/firefunction-v1');
Embedding Models
You can create models that call the Fireworks embeddings API using the .textEmbeddingModel()
factory method:
const model = fireworks.textEmbeddingModel( 'accounts/fireworks/models/nomic-embed-text-v1',);
Model Capabilities
Model | Image Input | Object Generation | Tool Usage | Tool Streaming |
---|---|---|---|---|
accounts/fireworks/models/firefunction-v2 | ||||
accounts/fireworks/models/llama-v3p3-70b-instruct | ||||
accounts/fireworks/models/llama-v3p1-405b-instruct | ||||
accounts/fireworks/models/mixtral-8x7b-instruct | ||||
accounts/fireworks/models/mixtral-8x22b-instruct | ||||
accounts/fireworks/models/mixtral-8x7b-instruct-hf | ||||
accounts/fireworks/models/qwen2p5-coder-32b-instruct | ||||
accounts/fireworks/models/qwen2p5-72b-instruct | ||||
accounts/fireworks/models/qwen2-vl-72b-instruct |
The table above lists popular models. Please see the Fireworks models page for a full list of available models.