Enterprise DNA

Omni by Enterprise DNA

Enterprise DNA Resources

Step-by-step how-tos. Practical AI operating-system thinking for owners, operators, and teams doing real work.

220k+

Data professionals

Omni

AI agents and apps

Audit

Map the manual work

Guide Intermediate General

Fireworks AI Tutorial: Fast Inference for Production

Ahands-on walkthrough of Fireworks AI covering setup, authentication, your first API call, and the settings that actually matter for production inference.

Sam McKay |
Fireworks AI Tutorial: Fast Inference for Production

What Fireworks AI Actually Is

Fireworks AI is an inference platform built around one specific job: running open-source large language models quickly and cheaply in production. It is not a foundation model lab. It does not train its own frontier models. What it does is take open-weight models from the usual suspects (Llama, Qwen, DeepSeek, Mistral, Mixtral, and others), optimize them heavily for inference, and serve them through an OpenAI-compatible API.

Under the hood, the platform layers several technical bets worth knowing about. Fireworks uses a custom inference stack with techniques like speculative decoding, paged attention variants, and aggressive batching across requests. The result is throughput and latency that tends to beat running the same model yourself on equivalent hardware, often by a meaningful margin. The model weights are the same as the ones you can download from Hugging Face. The differentiator is the serving layer.

The product comes in two main flavors. Serverless endpoints let you call any supported model on demand, billed per token, with no infrastructure to manage. Dedicated deployments give you an isolated instance pinned to a specific model for predictable low latency and throughput, billed by the minute. There is also a function-calling and structured-output layer, an embeddings endpoint, and a fine-tuning service for certain model families.

The reason this matters is that most teams do not need to fine-tune a frontier model. They need reliable, fast, cheap access to competent open models with an API that does not make them write a custom client. That is the entire pitch stripped of marketing.

Setup and Authentication

You need three things: an account, an API key, and a way to call the endpoint. Start at the Fireworks AI dashboard and create a workspace. The free tier gives you a small amount of credit, which is enough to validate the setup and run the examples in this guide.

Once you are in, navigate to API Keys under account settings and generate a new key. Treat it like any other secret. Do not commit it to a repo, do not paste it into a shared notebook, and rotate it if you suspect exposure. Store it in an environment variable called FIREWORKS_API_KEY for local development and in your secrets manager for anything deployed.

Install the official client. It is a thin wrapper around the OpenAI SDK pointed at the Fireworks base URL.

If you are on Python, the cleanest path is to install the OpenAI SDK and the Fireworks companion:

pip install openai fireworks-ai

If you are in Node, the openai package works directly because Fireworks mirrors the OpenAI API surface.

For curl users, the base URL pattern is https://api.fireworks.ai/inference/v1/. The /chat/completions endpoint behaves like the OpenAI equivalent, with the same request and response shape. This compatibility is the single biggest reason teams adopt Fireworks. You can usually point an existing OpenAI integration at Fireworks by swapping the base URL and the key, with minimal code change.

Verify your setup with a one-line ping:

curl https://api.fireworks.ai/inference/v1/models -H "Authorization: Bearer $FIREWORKS_API_KEY"

You should get back a JSON list of supported model identifiers. If you get a 401, the key is wrong or the environment variable is not exported in the current shell. If you get a 403, the key is valid but lacks the scope you need. If you get a connection error, check that you have outbound network access and that the base URL is correct.

First Working Example

Here is a complete, runnable chat completion call in Python using the OpenAI SDK pointed at Fireworks.

The model ID format on Fireworks is usually accounts/fireworks/models/<model-name> for hosted models, and you can find the exact string in the model catalog in the dashboard. For this example, pick any chat model that is currently listed, something like accounts/fireworks/models/llama-v3p1-8b-instruct if you want a small fast model to start.

The minimal request sends a system message, a user message, and a model name. The response contains a choices array, and the first element holds the assistant text. Streaming works by passing stream=True, after which you receive chunked delta objects you can append.

A clean first program looks like this: set the base URL to https://api.fireworks.ai/inference/v1, set the API key from the environment, build a list of messages, call client.chat.completions.create, and print the message content. The whole thing fits in under twenty lines.

For curl, the equivalent is a POST to /chat/completions with an Authorization: Bearer header and a JSON body containing model, messages, and max_tokens. The response is the same shape, so any tool that already speaks the OpenAI protocol will work.

Once this is working, you have a working surface for everything else. The API is intentionally boring, which is the point. Boring APIs compose well.

Key Settings That Matter

The default settings work for most cases, but a handful of parameters have outsized impact on output quality, cost, and latency. These are the ones to understand.

temperature controls randomness. Values near zero produce deterministic, focused completions, which is what you want for extraction, classification, and code generation. Values around 0.7 produce more varied creative text. Going above 1.0 rarely helps and usually degrades coherence. The Fireworks platform supports fine-grained decimal values, so experiment in 0.1 increments rather than coarse jumps.

top_p and top_k are alternative sampling controls. Most users should pick one and leave the other at default. If you set top_p, do not also tune temperature aggressively, and vice versa. Stacking them in non-obvious ways often produces worse output than either alone.

max_tokens caps the response length. Set it deliberately. An uncapped completion can be expensive and slow, and a model can keep generating indefinitely in adversarial inputs. For structured extraction, a tight cap like 256 is often enough. For open-ended generation, raise it to whatever you actually need.

repetition_penalty discourages the model from repeating tokens. Values between 1.0 and 1.2 are typical. Above 1.2 you start to see odd artifacts. Leave it at the default unless you have a specific problem with loops.

response_format lets you request JSON output. Setting it to {"type": "json_object"} asks the model to constrain its output to valid JSON, which dramatically reduces parse failures when combined with a system prompt that specifies a schema. This is one of the highest-value settings and most people do not know it exists.

stream toggles server-sent events for incremental output. Use it for chat interfaces where you want perceived latency under a second. Skip it for batch jobs where you need the full completion before doing anything.

presence_penalty and frequency_penalty are OpenAI-compatible knobs. They nudge the model away from repeating content. They are subtle, model-dependent, and usually unnecessary. Default is fine for most workloads.

stop is a list of strings that terminate generation early. If your system prompt contains a sentinel like ###END### and the model should stop at it, list it here. This is the cheapest way to enforce output length without re-tokenizing.

Model selection itself is the biggest dial. Smaller models (8B, 7B class) are fast and cheap, suitable for classification, extraction, summarization, and routing. Larger models (70B, 405B class) are slower and pricier but qualitatively better at reasoning, code synthesis, and multi-step planning. Run a benchmark on your actual prompts before picking. The right model is rarely the biggest one.

Where It Shines

Fireworks has a clear strength profile. It is at its best when you need to run open models at production scale without managing GPUs.

The first strong case is high-throughput batch processing. Summarizing tens of thousands of documents, classifying a support backlog, embedding a large corpus, or running a structured extraction pipeline over a data lake. The platform batches requests across tenants, which means your effective cost per token is lower than running the model on dedicated hardware for low-to-medium load.

The second case is latency-sensitive applications built on smaller open models. A customer support chat widget, a developer copilot for autocomplete, a real-time content moderation layer. The optimized inference stack delivers sub-200ms time-to-first-token for 8B-class models in the range you would expect from a well-tuned serving layer.

The third case is cost-sensitive production workloads. Teams that have outgrown the free tier of closed APIs and want to keep quality high while lowering unit economics often land here. The per-token pricing is typically a fraction of frontier closed APIs, and you can switch between models on the same endpoint to tune the quality/cost tradeoff.

The fourth case is OpenAI-compatible integration. If you already have a code path that calls chat.completions.create, you can redirect it to Fireworks by changing two values. That is a one-hour migration in most cases and an immediate cost reduction.

The fifth case is fine-tuning for specific tasks. Fireworks offers supervised fine-tuning on a curated set of base models, which lets you adapt an open model to your domain without training infrastructure.

Where It Fails

Honest limitations matter more than polished strengths. Here is where Fireworks is the wrong tool.

The first is the frontier. If you need the absolute best model on the hardest reasoning benchmarks, the open model ecosystem is still behind the leading closed labs. The best open model on a given week is good, but the best closed model from OpenAI or Anthropic is usually a step ahead. If you are building a product whose core differentiator is model intelligence, plan to evaluate the closed APIs in parallel.

The second is fine-tuning depth. The platform supports supervised fine-tuning, not RLHF or DPO. If you need preference optimization, you are doing it yourself on your own infrastructure and then hosting the resulting model through dedicated deployments, which adds operational complexity.

The third is region availability. Serverless endpoints are served from specific regions, and if your data residency requirements demand EU-only or APAC-only inference, you need to verify coverage. Dedicated deployments can be region-pinned, but they are a different cost profile.

The fourth is the tooling ecosystem. The platform covers inference well. The surrounding tooling (evaluation harnesses, observability, prompt management, vector store integrations) is thinner than what you get from the major closed providers or from dedicated MLOps tools. Plan to bring your own eval framework and your own observability stack.

The fifth is unpredictable latency under burst. Serverless endpoints can experience queueing during peak periods. If you have strict p99 latency requirements, dedicated deployments with reserved capacity are the answer, but they are priced for steady high load, not variable traffic.

Practical Workflow Pattern

Here is a workflow that uses Fireworks well in a real engineering setup. It is the pattern I have seen work across the teams I have worked with, and it generalizes to most open-model inference platforms.

Start with a model evaluation. Pick three to five candidate models from the Fireworks catalog, including one small (7B to 8B), one medium (around 70B), and one large (405B class if available). Build a representative prompt set from your real traffic or a synthetic version of it. Run all candidates with consistent settings and record quality, latency, and cost. The right model is the smallest one that meets your quality bar.

Develop against the OpenAI-compatible endpoint locally. Use the SDK you already know. Keep model name and API key in environment variables, not in code. This keeps the migration path open if you ever need to move.

For development and prototyping, stick with serverless endpoints. The cost is negligible and the operational burden is zero. For staging and load testing, evaluate whether serverless queueing is acceptable. For production, make the call between serverless and dedicated deployment based on traffic shape: variable and bursty favors serverless, steady and high favors dedicated.

Layer in caching at the application level. Identical or near-identical prompts are common in classification, extraction, and routing workloads. A simple key-value cache on a hash of the prompt and parameters can cut your inference bill dramatically.

Add observability from day one. Log every request with model, prompt length, completion length, latency, and cost. Tools like Langfuse, Helicone, or a custom OpenTelemetry integration all work because the API is OpenAI-compatible. You cannot optimize what you cannot measure.

Build a fallback path. The point of using an inference platform is operational leverage, but the platform itself is a dependency. Have a plan to switch models or providers if an endpoint degrades. The OpenAI compatibility makes this a config change rather than a code change.

Review weekly. Model catalogs change fast, prices change, and quality rankings shift. The model you picked three months ago is probably not the model you would pick today. Budget an hour a week to look at the catalog and re-evaluate the top of your usage.

That is the loop. Evaluate, develop, deploy, observe, fall back, re-evaluate. Boring, but it is the difference between a Fireworks integration that pays for itself and one that becomes a fire drill.

If this is the kind of problem agents can help with, the free Working With Claude field guide is the practical next step. Thirty-two pages, no fluff. Get the free guide.