.claude/skills/ts-fireworks-ai/SKILL.md
Expert guidance for Fireworks AI, the platform for running open-source LLMs (Llama, Mixtral, Qwen, etc.) with enterprise-grade speed and reliability. Helps developers integrate Fireworks' inference API, fine-tune models, and deploy custom model endpoints with function calling and structured output support.
npx skillsauth add eliferjunior/Claude fireworks-aiInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Fireworks AI, the platform for running open-source LLMs (Llama, Mixtral, Qwen, etc.) with enterprise-grade speed and reliability. Helps developers integrate Fireworks' inference API, fine-tune models, and deploy custom model endpoints with function calling and structured output support.
// src/llm/fireworks.ts — Fireworks AI inference (OpenAI-compatible)
import OpenAI from "openai";
const fireworks = new OpenAI({
apiKey: process.env.FIREWORKS_API_KEY!,
baseURL: "https://api.fireworks.ai/inference/v1",
});
// Chat completion with open-source models
async function chat(prompt: string, model = "accounts/fireworks/models/llama-v3p3-70b-instruct") {
const response = await fireworks.chat.completions.create({
model,
messages: [
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: prompt },
],
temperature: 0.7,
max_tokens: 1024,
});
return response.choices[0].message.content;
}
// Streaming
async function streamChat(prompt: string, onChunk: (text: string) => void) {
const stream = await fireworks.chat.completions.create({
model: "accounts/fireworks/models/llama-v3p3-70b-instruct",
messages: [{ role: "user", content: prompt }],
stream: true,
});
let full = "";
for await (const chunk of stream) {
const text = chunk.choices[0]?.delta?.content ?? "";
full += text;
onChunk(text);
}
return full;
}
// Force structured JSON output
async function extractData(text: string) {
const response = await fireworks.chat.completions.create({
model: "accounts/fireworks/models/llama-v3p3-70b-instruct",
messages: [
{
role: "system",
content: `Extract product information. Return JSON: { "name": string, "price": number, "category": string, "features": string[] }`,
},
{ role: "user", content: text },
],
response_format: { type: "json_object" },
temperature: 0,
});
return JSON.parse(response.choices[0].message.content!);
}
// Grammar-constrained generation (Fireworks-specific)
async function generateWithGrammar(prompt: string) {
const response = await fetch("https://api.fireworks.ai/inference/v1/chat/completions", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.FIREWORKS_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "accounts/fireworks/models/llama-v3p3-70b-instruct",
messages: [{ role: "user", content: prompt }],
response_format: {
type: "json_object",
schema: {
type: "object",
properties: {
sentiment: { type: "string", enum: ["positive", "negative", "neutral"] },
confidence: { type: "number", minimum: 0, maximum: 1 },
keywords: { type: "array", items: { type: "string" } },
},
required: ["sentiment", "confidence", "keywords"],
},
},
}),
});
return response.json();
}
// Tool use with Fireworks
async function agentWithTools(prompt: string) {
const response = await fireworks.chat.completions.create({
model: "accounts/fireworks/models/firefunction-v2", // Optimized for function calling
messages: [{ role: "user", content: prompt }],
tools: [
{
type: "function",
function: {
name: "search_database",
description: "Search the product database",
parameters: {
type: "object",
properties: {
query: { type: "string" },
category: { type: "string", enum: ["electronics", "clothing", "books"] },
max_price: { type: "number" },
},
required: ["query"],
},
},
},
],
tool_choice: "auto",
});
return response;
}
# fine_tune.py — Fine-tune a model on Fireworks
import requests
FIREWORKS_API_KEY = os.environ["FIREWORKS_API_KEY"]
BASE_URL = "https://api.fireworks.ai/inference/v1"
# Upload training data (JSONL format)
def upload_dataset(filepath: str):
with open(filepath, "rb") as f:
response = requests.post(
f"{BASE_URL}/files",
headers={"Authorization": f"Bearer {FIREWORKS_API_KEY}"},
files={"file": (filepath, f, "application/jsonl")},
data={"purpose": "fine-tune"},
)
return response.json()["id"]
# Start fine-tuning job
def create_fine_tune(dataset_id: str, base_model: str = "accounts/fireworks/models/llama-v3p1-8b-instruct"):
response = requests.post(
f"{BASE_URL}/fine_tuning/jobs",
headers={
"Authorization": f"Bearer {FIREWORKS_API_KEY}",
"Content-Type": "application/json",
},
json={
"model": base_model,
"training_file": dataset_id,
"hyperparameters": {
"n_epochs": 3,
"learning_rate_multiplier": 1.0,
"batch_size": 8,
},
},
)
return response.json()
# Training data format (JSONL):
# {"messages": [{"role": "system", "content": "..."}, {"role": "user", "content": "..."}, {"role": "assistant", "content": "..."}]}
## Popular Models on Fireworks
- **llama-v3p3-70b-instruct** — Best open-source general-purpose model
- **llama-v3p1-8b-instruct** — Fast, cheap, good for simple tasks
- **mixtral-8x22b-instruct** — Strong multilingual, large context
- **qwen2p5-72b-instruct** — Excellent for coding and math
- **firefunction-v2** — Optimized for function calling / tool use
- **deepseek-v3** — Strong reasoning and code generation
- **gemma-2-27b-it** — Google's compact model
# Use any OpenAI-compatible SDK
npm install openai
# Set baseURL to https://api.fireworks.ai/inference/v1
pip install openai
# Set base_url to https://api.fireworks.ai/inference/v1
User request:
Add Fireworks Ai to my Next.js app for the AI chat feature. I want streaming responses.
The agent installs the SDK, creates an API route that initializes the Fireworks Ai client, configures streaming, selects an appropriate model, and wires up the frontend to consume the stream. It handles error cases and sets up proper environment variable management for the API key.
User request:
My Fireworks Ai calls are slow and expensive. Help me optimize the setup.
The agent reviews the current implementation, identifies issues (wrong model selection, missing caching, inefficient prompting, no batching), and applies optimizations specific to Fireworks Ai's capabilities — adjusting model parameters, adding response caching, and implementing retry logic with exponential backoff.
development
Convert any website into clean, structured data with Firecrawl — API-first web scraping service. Use when someone asks to "turn a website into markdown", "scrape website for LLM", "Firecrawl", "extract website content as clean text", "crawl and convert to structured data", or "scrape website for RAG". Covers single-page scraping, full-site crawling, structured extraction, and LLM-ready output.
tools
Expert guidance for Firebase, Google's platform for building and scaling web and mobile applications. Helps developers set up authentication, Firestore/Realtime Database, Cloud Functions, hosting, storage, and analytics using Firebase's SDK and CLI.
development
When the user needs to build file upload functionality for a web application. Use when the user mentions "file upload," "image upload," "upload endpoint," "multipart upload," "presigned URL," "S3 upload," "file validation," "upload to cloud storage," or "accept user files." Handles upload endpoints, file validation (type, size, magic bytes), cloud storage integration, and upload status tracking. For image/video processing after upload, see media-transcoder.
development
Organize and rename files based on content analysis. Use when a user asks to sort files into folders, rename files by pattern, organize a messy directory, categorize documents by type or content, deduplicate files, or clean up a downloads folder. Handles smart renaming, content-based sorting, and duplicate detection.