### Clone Quickstart Repository Source: https://docs.fireworks.ai/fine-tuning/quickstart-svg-agent Clone the necessary repository to get started with the quickstart project. ```bash git clone git@github.com:eval-protocol/quickstart.git cd quickstart ``` -------------------------------- ### Quickstart SFT Training Example Source: https://docs.fireworks.ai/fine-tuning/training-api/cookbook/overview A basic example demonstrating how to perform Supervised Fine-Tuning (SFT) using the Fireworks AI Training API. It shows the necessary imports, configuration setup, and the call to the main training function. ```python from training.recipes.sft_loop import Config, main from training.utils import TrainerConfig cfg = Config( log_path="./sft_quickstart", base_model="accounts/fireworks/models/qwen3-8b", dataset="/path/to/training_data.jsonl", tokenizer_model="Qwen/Qwen3-8B", max_seq_len=4096, epochs=1, batch_size=4, trainer=TrainerConfig( training_shape_id="accounts/fireworks/trainingShapes/qwen3-8b-128k-h200", ), ) main(cfg) ``` -------------------------------- ### System Prompt Example Source: https://docs.fireworks.ai/merged.openapi.yaml Example of how to include a system prompt to guide the model's behavior. ```json [ {"type": "text", "text": "Today's date is 2024-06-01."} ] ``` -------------------------------- ### Run OpenClaw Onboarding Wizard Source: https://docs.fireworks.ai/firepass Initiates the OpenClaw onboarding process, including setting up the background daemon. It guides users through configuration, allowing them to skip model and authentication setup if already configured. ```bash openclaw onboard --install-daemon ``` -------------------------------- ### Get User Information by Full Path Source: https://docs.fireworks.ai/tools-sdks/firectl/commands/user-get Example of retrieving user information using the full account and user path. ```bash firectl user get accounts/my-account/users/my-user ``` -------------------------------- ### Copy Environment Example Source: https://docs.fireworks.ai/fine-tuning/quickstart-svg-agent Create the .env file by copying the example configuration file in the evaluator directory. ```bash cp evaluator/env.example evaluator/.env ``` -------------------------------- ### Set Example Monthly Spend Limit Source: https://docs.fireworks.ai/guides/quotas_usage/account-quotas Example command to set a monthly budget of $200 USD. ```bash firectl quota update monthly-spend-usd --value 200 ``` -------------------------------- ### Example: Uploading a Model Source: https://docs.fireworks.ai/tools-sdks/firectl/commands/model-upload An example demonstrating how to upload a model named 'my-model' from a local checkpoint directory. ```bash firectl model upload my-model /path/to/checkpoint/ ``` -------------------------------- ### Start Local Server Source: https://docs.fireworks.ai/fine-tuning/connect-environments Use uvicorn to start your local development server on a specified port. ```bash uvicorn main:app --reload --port 8080 ``` -------------------------------- ### Incorrect Usage: Including Base Model with Warm Start Source: https://docs.fireworks.ai/fine-tuning/warm-start This example shows an incorrect usage pattern where both `--base-model` and `--warm-start-from` are specified. This will result in an error because the base model is automatically determined from the warm-start LoRA adapter. ```bash # Wrong, includes --base-model eval-protocol create rft \ --base-model accounts/fireworks/models/llama-v3p1-8b-instruct \ --warm-start-from accounts/your-account/models/ ``` -------------------------------- ### DPO Fine-tuning Dataset Example Source: https://docs.fireworks.ai/fine-tuning/dpo-fine-tuning Example of a single training example for DPO fine-tuning in JSONL format. Ensure the dataset adheres to the specified schema, including 'input' with a 'messages' array and 'preferred_output'/'non_preferred_output' fields. ```json { "input": { "messages": [ { "role": "user", "content": "What is Einstein famous for?" } ], "tools": [] }, "preferred_output": [ { "role": "assistant", "content": "Einstein is renowned for his theory of relativity, especially the equation E=mc²." } ], "non_preferred_output": [ { "role": "assistant", "content": "He was a famous scientist." } ] } ``` -------------------------------- ### Install Dependencies Source: https://docs.fireworks.ai/faq-new/billing-pricing/how-many-tokens-per-image Install the necessary Python libraries for tokenizing images: torch, torchvision, transformers, and pillow. ```bash pip install torch torchvision transformers pillow ``` -------------------------------- ### Install firectl CLI (Linux x86_64) Source: https://docs.fireworks.ai/getting-started/ondemand-quickstart Download and install the firectl CLI for Linux with x86_64 architecture. ```bash wget -O firectl.gz https://storage.googleapis.com/fireworks-public/firectl/stable/linux-amd64.gz gunzip firectl.gz sudo install -o root -g root -m 0755 firectl /usr/local/bin/firectl ``` -------------------------------- ### Resume DPO Job Examples Source: https://docs.fireworks.ai/tools-sdks/firectl/commands/dpo-job-resume Examples of how to resume a DPO job using its ID or full path. ```bash firectl dpo-job resume my-dpo-job ``` ```bash firectl dpo-job resume accounts/my-account/dpoJobs/my-dpo-job ``` -------------------------------- ### Install FireConnect CLI Source: https://docs.fireworks.ai/ecosystem/fireconnect/overview Installs the FireConnect CLI script. It clones the CLI to ~/.fireconnect/cli and adds a launcher to ~/.local/bin. ```bash curl -fsSL https://raw.githubusercontent.com/fw-ai/fireconnect/main/install.sh | bash ``` -------------------------------- ### Clone Repository and Install Dependencies Source: https://docs.fireworks.ai/fine-tuning/quickstart-math Clone the quickstart-gsm8k repository and install its dependencies using pip. This is the recommended approach for setting up the project. ```bash git clone https://github.com/eval-protocol/quickstart-gsm8k.git cd quickstart-gsm8k pip install -r requirements.txt ``` ```bash mkdir -p gsm8k_artifacts/{tests/pytest/gsm8k,development} cp evaluation.py gsm8k_artifacts/tests/pytest/gsm8k/test_pytest_math_example.py cp gsm8k_sample.jsonl gsm8k_artifacts/development/gsm8k_sample.jsonl ``` -------------------------------- ### Examples of Getting Training Shape Source: https://docs.fireworks.ai/tools-sdks/firectl/commands/training-shape-get These examples demonstrate how to use the `firectl training-shape get` command with different training shape identifiers. The first example uses a simple name, while the second uses a fully qualified path. ```bash firectl training-shape get my-shape ``` ```bash firectl training-shape get accounts/my-account/trainingShapes/my-shape ``` -------------------------------- ### Get Weather Tool Example Source: https://docs.fireworks.ai/api-reference/anthropic-messages An example of another tool definition for 'get_weather', specifying its input parameters for location and unit. ```APIDOC ## Example Tool: Get Weather ### Name `get_weather` ### Description Get the current weather in a given location ### Input Schema ```json { "properties": { "location": { "description": "The city and state, e.g. San Francisco, CA", "type": "string" }, "unit": { "description": "Unit for the output - one of (celsius, fahrenheit)", "type": "string" } }, "required": [ "location" ], "type": "object" } ``` ``` -------------------------------- ### Example Evaluator Revision Retrieval Source: https://docs.fireworks.ai/tools-sdks/firectl/commands/evaluator-revision-get Example of how to get the latest revision of a specific evaluator. Ensure the account, evaluator, and version identifiers are correct. ```bash firectl evaluator-revision get accounts/my-account/evaluators/my-evaluator/versions/latest ``` -------------------------------- ### Create a Deployment for Video/Audio Models Source: https://docs.fireworks.ai/guides/video-audio-inputs Use the `firectl` command-line tool to create a new deployment. Ensure you use the specified minimal deployment shape for video and audio models to function correctly. ```bash firectl deployment create qwen3-omni-30b-a3b-instruct \ --account-id \ --min-replica-count 1 \ --max-replica-count 1 \ --deployment-shape qwen3-omni-30b-a3b-instruct-minimal ``` -------------------------------- ### Example Dockerfile for RFT Evaluators Source: https://docs.fireworks.ai/fine-tuning/quickstart-svg-agent This is an example Dockerfile that adheres to the constraints for RFT evaluators. It specifies a Debian-based image, installs system and Python dependencies, and copies the evaluator code. ```dockerfile FROM python:3.11-slim WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y \ chromium \ && rm -rf /var/lib/apt/lists/* # Install Python dependencies COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy evaluator code COPY . . CMD ["pytest", "-vs"] ``` -------------------------------- ### Prepare a model with account and model path Source: https://docs.fireworks.ai/tools-sdks/firectl/commands/model-prepare Example of preparing a model by specifying the account and full model path. This is useful when working with models in different accounts. ```bash firectl model prepare accounts/my-account/models/my-model ``` -------------------------------- ### Get Specific Training Shape Version Source: https://docs.fireworks.ai/tools-sdks/firectl/commands/training-shape-version-get Example of how to get information for a specific training shape version by providing its full path. This is useful for retrieving details of a known version. ```bash firectl training-shape-version get accounts/my-account/trainingShapes/my-shape/versions/my-version ``` -------------------------------- ### Start Local Development Server Source: https://docs.fireworks.ai/fine-tuning/quickstart-svg-agent Navigate to the vercel_svg_server_ts directory and start the local development server using Vercel CLI. ```bash cd vercel_svg_server_ts vercel dev ``` -------------------------------- ### Get User Information by Username Source: https://docs.fireworks.ai/tools-sdks/firectl/commands/user-get Example of retrieving user information using the user's username. ```bash firectl user get my-user ``` -------------------------------- ### Get Identity Provider with Output Format Flag Source: https://docs.fireworks.ai/tools-sdks/firectl/commands/identity-provider-get This example demonstrates how to specify the output format for the identity provider information. Supported formats are 'text', 'json', or 'flag'. ```bash firectl identity-provider get my-provider -o json ``` -------------------------------- ### firectl api-key get Command with Flags Source: https://docs.fireworks.ai/tools-sdks/firectl/commands/api-key-get This example shows the command structure with available flags. The `--output` flag can be used to specify the desired output format. ```bash firectl api-key get [flags] ``` -------------------------------- ### Create Deployment Sampler Source: https://docs.fireworks.ai/fine-tuning/training-api/training-and-sampling Instantiate a deployment sampler to interact with a serving deployment. This can be used for initial setup or refreshing with new weights. ```python sampler = service.create_deployment_sampler( model_name="meta-llama/Llama-2-7b-chat-hf", model_path="meta-llama/Llama-2-7b-chat-hf" ) ``` -------------------------------- ### Basic firectl user list command Source: https://docs.fireworks.ai/tools-sdks/firectl/commands/user-list Use this command to list all users in your Fireworks account. No special setup is required beyond having the firectl CLI installed and authenticated. ```bash firectl user list ``` -------------------------------- ### Training with Automatic Checkpointing and Promotion Source: https://docs.fireworks.ai/fine-tuning/training-api/cookbook/checkpoints This snippet demonstrates how to configure and run a training job using the SFT loop recipe. It sets up automatic saving of checkpoints every 10 steps and promotes the final checkpoint to a deployable model named 'qwen3-8b-finetuned'. Rerunning the script with the same configuration will automatically resume training from the last saved checkpoint. ```python from training.recipes.sft_loop import Config, main from training.utils import TrainerConfig cfg = Config( log_path="./my_training", base_model="accounts/fireworks/models/qwen3-8b", dataset="data.jsonl", tokenizer_model="Qwen/Qwen3-8B", output_model_id="qwen3-8b-finetuned", dcp_save_interval=10, trainer=TrainerConfig( training_shape_id="accounts/fireworks/trainingShapes/qwen3-8b-128k-h200", ), ) main(cfg) # Interrupted? Run again with the same config — it picks up automatically. main(cfg) ``` -------------------------------- ### Prepare a model by name Source: https://docs.fireworks.ai/tools-sdks/firectl/commands/model-prepare Example of preparing a model using its name. This command assumes the model is in your default account. ```bash firectl model prepare my-model ``` -------------------------------- ### Get Latest Training Shape Version Source: https://docs.fireworks.ai/tools-sdks/firectl/commands/training-shape-version-get Example of how to retrieve information for the latest training shape version using the 'latest' keyword. This is convenient for accessing the most recent version without knowing its exact identifier. ```bash firectl training-shape-version get accounts/my-account/trainingShapes/my-shape/versions/latest ``` -------------------------------- ### Deployment Creation with Configuration File Source: https://docs.fireworks.ai/tools-sdks/firectl/commands/deployment-create Creates a new deployment using a configuration file to define deployment parameters. ```bash firectl deployment create falcon-7b --file=/path/to/deployment-config.json ``` -------------------------------- ### Get Dedicated Deployment Usage by Deployment and GPU Type Source: https://docs.fireworks.ai/accounts/exporting-usage-and-costs Use this command to retrieve detailed usage data for dedicated deployments, grouped by deployment name and accelerator type. Ensure you have the firectl CLI installed and configured. ```bash firectl billing get-usage \ --start-time 2026-05-01 --end-time 2026-06-01 \ --usage-type dedicated-deployment \ --group-by deployment_name \ --group-by accelerator_type ``` -------------------------------- ### Create RFT Model with Warm Start Source: https://docs.fireworks.ai/fine-tuning/warm-start Use this command to initiate RFT training, starting from a previously fine-tuned SFT model. Ensure you do not include the `--base-model` flag as it is inferred from the warm-start model. ```bash eval-protocol create rft \ --warm-start-from accounts/your-account/models/ \ --output-model ``` -------------------------------- ### Create Training Client from Service Source: https://docs.fireworks.ai/fine-tuning/training-api/reference/service-client Obtain a training client from the initialized service client. This client is used for actual training operations. ```python training_client = service.create_training_client( base_model="accounts/fireworks/models/qwen3-8b", lora_rank=0, ) ``` -------------------------------- ### Rerank Documents using /embeddings Endpoint (Python) Source: https://docs.fireworks.ai/guides/querying-embeddings-models Use the /embeddings endpoint with return_logits to rerank documents. This example shows how to format prompts, specify token IDs for 'yes' and 'no', and process the response to get relevance scores. Requires the 'requests' library. ```python import requests url = "https://api.fireworks.ai/inference/v1/embeddings" query = "What is the capital of France?" documents = [ "Paris is the capital and largest city of France, home to the Eiffel Tower and the Louvre Museum.", "France is a country in Western Europe known for its wine, cuisine, and rich history.", "The weather in Europe varies significantly between northern and southern regions.", "Python is a popular programming language used for web development and data science." ] # Format prompts as query-document pairs using the Qwen3 Reranker format instruction = "Given a web search query, retrieve relevant passages that answer the query" prompts = [ f": {instruction}\n: {query}\n: {doc}" for doc in documents ] # Token IDs for "no" and "yes" in Qwen3 reranker models token_false_id = 2753 # "no" token_true_id = 9454 # "yes" payload = { "model": "fireworks/qwen3-reranker-8b", "input": prompts, "return_logits": [token_false_id, token_true_id], "normalize": True # Applies softmax to the selected logits } headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers).json() # Extract relevance scores (probability of "yes" token) results = [] for i, item in enumerate(response["data"]): probs = item["embedding"] # [no_prob, yes_prob] relevance_score = probs[1] # "yes" probability is the relevance score results.append({ "index": i, "relevance_score": relevance_score, "document": documents[i] }) # Sort by relevance score (highest first) results.sort(key=lambda x: x["relevance_score"], reverse=True) for result in results: print(f"Score: {result['relevance_score']:.4f} - {result['document'][:80]}...") ``` -------------------------------- ### Install OpenClaw on macOS / Linux Source: https://docs.fireworks.ai/firepass Installs the OpenClaw tool on macOS or Linux systems using a provided installation script. ```bash curl -fsSL https://openclaw.ai/install.sh | bash ``` -------------------------------- ### Initialize WeightSyncer Source: https://docs.fireworks.ai/fine-tuning/training-api/reference/weight-syncer Instantiate the WeightSyncer with specified training client, deployment manager, and configuration parameters. Use this to set up automatic weight synchronization for deployments. ```python tracker = WeightSyncer( policy_client=training_client, deploy_mgr=deploy_mgr, deployment_id="my-deployment", base_model="accounts/fireworks/models/qwen3-8b", hotload_timeout=600, first_checkpoint_type="base", warmup_after_hotload=True, reset_prompt_cache=True, lora_rank=0, # >0 for LoRA adapters (disables delta chain) ) ``` -------------------------------- ### Install firectl CLI on Linux Source: https://docs.fireworks.ai/fine-tuning/agent/use-with-coding-agents Installs the `firectl` command-line tool on a Linux system. Ensure you have `curl` and `gunzip` installed. ```bash curl -sL -o /tmp/firectl.gz https://storage.googleapis.com/fireworks-public/firectl/stable/linux-amd64.gz gunzip -f /tmp/firectl.gz sudo install -m 0755 /tmp/firectl /usr/local/bin/firectl ``` -------------------------------- ### View All Options for RFT Create Source: https://docs.fireworks.ai/fine-tuning/cli-reference Execute this command to display all available options for creating an RFT job. ```bash eval-protocol create rft --help ``` -------------------------------- ### Install Eval Protocol CLI Source: https://docs.fireworks.ai/fine-tuning/cli-reference Install the Eval Protocol CLI using pip. Verify the installation by checking the version. ```bash pip install eval-protocol ``` ```bash eval-protocol --version ``` -------------------------------- ### Python Example for Interleaved Thinking Source: https://docs.fireworks.ai/guides/reasoning This Python script demonstrates how to use the Fireworks client to enable interleaved thinking. It makes two chat completion calls: the first to get a response and capture reasoning content, and the second to include the previous assistant message (with reasoning content) in a new request. It then verifies that the reasoning content is present in the raw prompt sent to the model. ```python import os from fireworks import Fireworks from dotenv import load_dotenv load_dotenv() client = Fireworks() MODEL = "accounts/fireworks/models/kimi-k2-thinking" # MODEL = "accounts/fireworks/models/minimax-m2" # Define tools to enable interleaved thinking tools = [ { "type": "function", "function": { "name": "calculator", "description": "Perform basic arithmetic operations", "parameters": { "type": "object", "properties": { "operation": { "type": "string", "enum": ["add", "subtract", "multiply", "divide"], }, "a": {"type": "number"}, "b": {"type": "number"}, }, "required": ["operation", "a", "b"], }, }, } ] def print_header(title: str, char: str = "═", width: int = 60): """Print a formatted section header.""" print(f"\n{char * width}") print(f" {title}") print(f"{char * width}") def print_field(label: str, value: str, indent: int = 2): """Print a labeled field with optional indentation.""" prefix = " " * indent print(f"{prefix}{label}: {value}") def print_multiline(label: str, content: str, max_preview: int = 200, indent: int = 2): """Print multiline content with a label and optional truncation.""" prefix = " " * indent print(f"{prefix}{label}:") preview = content[:max_preview] + "..." if len(content) > max_preview else content for line in preview.split("\n"): print(f"{prefix} │ {line}") # First turn - get a response with reasoning_content print_header("FIRST TURN", "═") first_response = client.chat.completions.create( messages=[ { "role": "user", "content": "What is 15 + 27?", } ], model=MODEL, tools=tools, ) print_field("📝 Content", first_response.choices[0].message.content or "(none)") reasoning = first_response.choices[0].message.reasoning_content print_multiline("💭 Reasoning", reasoning) # Print tool call (verified) from the first response tool_calls = first_response.choices[0].message.tool_calls assert tool_calls, "No tool calls in first response!" print(f"\n 🔧 Tool Calls ({len(tool_calls)}):") for i, tc in enumerate(tool_calls, 1): print(f" [{i}] id={tc.id}") print(f" function={tc.function.name}") print(f" arguments={tc.function.arguments}") tool_call_id = first_response.choices[0].message.tool_calls[0].id # Verify we got reasoning_content assert reasoning and len(reasoning) > 0, "No reasoning_content in first response!" print("\n ✓ First response has reasoning_content") # Second turn - include the first assistant message print_header("SECOND TURN", "═") second_response = client.chat.completions.create( messages=[ { "role": "user", "content": "What is 15 + 27?", }, first_response.choices[0].message, # Includes reasoning_content {"role": "tool", "content": "42", "tool_call_id": tool_call_id}, ], model=MODEL, tools=tools, raw_output=True, ) print_field("📝 Answer", second_response.choices[0].message.content or "(none)") # Extract and display the raw prompt that was sent to the model raw_prompt = second_response.choices[0].raw_output.prompt_fragments[0] print_header("RAW PROMPT SENT TO MODEL", "─") print(raw_prompt) # Check if reasoning_content from first turn is in the raw prompt has_reasoning_content = reasoning[:50] in raw_prompt print_header("RESULT", "═") if has_reasoning_content: print(" ✅ SUCCESS: reasoning_content IS included in subsequent requests!") else: print(" ❌ FAILED: reasoning_content not found in raw prompt") print() ``` -------------------------------- ### Start RFT from SFT Model with Custom Parameters Source: https://docs.fireworks.ai/fine-tuning/warm-start This command initiates RFT training from an existing SFT model, allowing you to specify additional RFT parameters such as epochs, learning rate, and temperature for further fine-tuning. ```bash eval-protocol create rft \ --warm-start-from accounts/your-account/models/ \ --output-model \ --epochs 2 \ --learning-rate 5e-5 \ --temperature 0.8 ``` -------------------------------- ### Install Anthropic JavaScript SDK Source: https://docs.fireworks.ai/getting-started/quickstart Install the Anthropic JavaScript/TypeScript SDK to interact with Fireworks AI's compatible endpoint. Ensure you have the SDK installed. ```bash npm install @anthropic-ai/sdk ``` -------------------------------- ### Deployment Creation Response Source: https://docs.fireworks.ai/getting-started/ondemand-quickstart This is an example of the response received after a deployment is created. It includes details like the deployment name, creation time, state, and autoscaling configuration. ```bash Name: accounts//deployments/ Create Time: Expire Time: Created By: State: CREATING Status: OK Min Replica Count: 0 Max Replica Count: 1 Desired Replica Count: 0 Replica Count: 0 Autoscaling Policy: Scale Up Window: 30s Scale Down Window: 5m0s Scale To Zero Window: 5m0s Base Model: accounts/fireworks/models/gpt-oss-120b ...other fields... ``` -------------------------------- ### Install OpenAI JavaScript SDK Source: https://docs.fireworks.ai/getting-started/quickstart Install the OpenAI JavaScript/TypeScript SDK to interact with Fireworks AI's compatible endpoint. Ensure you have the SDK installed. ```bash npm install openai ``` -------------------------------- ### Install SDK and Download Files Source: https://docs.fireworks.ai/fine-tuning/quickstart-math Install the necessary Python packages, including the eval-protocol SDK, pytest, and requests. This method is for manually downloading the evaluator and dataset files. ```bash python -m pip install --upgrade pip python -m pip install pytest requests git+https://github.com/eval-protocol/python-sdk.git ``` -------------------------------- ### Install Anthropic Python SDK Source: https://docs.fireworks.ai/getting-started/quickstart Install the Anthropic Python SDK to interact with Fireworks AI's compatible endpoint. Ensure you have the SDK installed. ```bash pip install anthropic ```