Community Maintainedv1.2.0-alpha.76SDK • Go • Fireworks AI

Fireworks SDK Go

An unofficial Go port of the official Fireworks AI Python SDK. It targets Python SDK 1.2.0-alpha.76 and keeps the Go package version aligned exactly, giving Go teams typed and generic access to Fireworks inference, management, datasets, and training workflows.

Python SDK parity focus: generated resource coverage, generated type exports, request serialization, retries, errors, SSE streaming, file uploads, account resolution, FireTitan training lifecycle helpers, and opt-in live contract tests.

⚠️ Disclaimer: This is an unofficial SDK and is not affiliated with, endorsed by, or supported by Fireworks AI. For official support, use the Fireworks AI documentation and support channels.

Why Fireworks SDK Go?

Fireworks AI exposes high-performance inference, fine-tuning, deployments, datasets, and training infrastructure. This SDK brings that workflow into idiomatic Go while preserving behavior parity with the official Python client.

Use typed APIs when you want compile-time structure, generic APIs when you need flexibility, and raw request helpers for endpoints that are not yet represented by generated resource methods.

Key Features

Typed and Generic APIs

Most resources expose generated typed methods plus flexible map[string]any methods for fast iteration.

Chat Completions

Create Fireworks chat completions with Python-compatible JSON fields and generated Go structs.

SSE Streaming

Streaming uses Server-Sent Events and exposes an idiomatic stream iterator for incremental responses.

Dataset Uploads

Upload small dataset files directly or use signed upload endpoints for larger training datasets.

Pagination Helpers

List responses include helper methods for checking and requesting subsequent result pages.

Retries and Timeouts

Mirrors Python SDK behavior for status errors, retry headers, request metadata, timeouts, and connection errors.

Account Resolution

Supports per-request account IDs, client-level defaults, and FIREWORKS_ACCOUNT_ID environment fallback.

FireTitan Training

Includes trainer jobs, deployments, hotload, sampler clients, managed provisioning, and checkpoint promotion helpers.

Quick Start

Installation

Use Go 1.22 or newer.

go get github.com/ZaguanLabs/fireworks-sdk-go

Authentication

The client reads FIREWORKS_API_KEY by default.

export FIREWORKS_API_KEY="fw_..."

Chat Completion

package main

import (
    "context"
    "fmt"

    fireworks "github.com/ZaguanLabs/fireworks-sdk-go"
    "github.com/ZaguanLabs/fireworks-sdk-go/types"
)

func main() {
    ctx := context.Background()

    client, err := fireworks.NewClient()
    if err != nil {
        panic(err)
    }

    resp, err := client.Chat.Completions.CreateTyped(ctx, types.ChatCompletionCreateParams{
        Model: "accounts/fireworks/models/kimi-k2-instruct-0905",
        Messages: []types.SharedParamsChatMessage{
            {Role: "user", Content: "How do LLMs work?"},
        },
    })
    if err != nil {
        panic(err)
    }

    fmt.Println(resp.Choices[0].Message.Content)
}

Streaming

stream, err := client.Chat.Completions.CreateTypedStream(ctx, types.ChatCompletionCreateParams{
    Model: "accounts/fireworks/models/kimi-k2-instruct-0905",
    Messages: []types.SharedParamsChatMessage{
        {Role: "user", Content: "How do LLMs work?"},
    },
})
if err != nil {
    return err
}
defer stream.Close()

for stream.Next() {
    chunk := stream.Current()
    if len(chunk.Choices) > 0 {
        fmt.Print(chunk.Choices[0].Delta.Content)
    }
}
if err := stream.Err(); err != nil {
    return err
}

API Surface

Generic and Typed Resources

Choose raw maps for rapid prototyping or generated typed structs for safer production integrations.

raw, err := client.Models.Get(ctx, "my-model")
model, err := client.Models.GetTyped(ctx, "my-model", types.ModelGetParams{})

Raw Requests

Use raw helpers for custom or undocumented endpoints without waiting for generated resource coverage.

resp, err := client.Raw(ctx, "POST", "/v1/custom/path", map[string]any{
    "my_param": true,
})

Training and Contract Tests

The FireTitan training layer ports the Fireworks Python training SDK into Go, including trainer jobs, deployments, hotload flows, sampler clients, managed provisioning, checkpoint promotion, and setup helpers.

Live tests are opt-in through FIREWORKS_SDK_GO_LIVE and can run read-only account smoke checks with only FIREWORKS_API_KEY. Resource-specific trainer, deployment, and checkpoint tests require additional environment variables.

go run ./cmd/fireworks-training setup-trainer   --display-name ablation-eager   --extra-args "--forward-only --no-compile"   --custom-image-tag your-image-tag

Build Fireworks AI Apps in Go

Install the SDK, set FIREWORKS_API_KEY, and start with typed chat completions, streaming, datasets, raw requests, or FireTitan training helpers.