Install
openclaw skills install @psyb0t/go-fireworksUnofficial Go client for the Fireworks AI REST API, generated with oapi-codegen. fireworks.NewClientWithResponses(baseURL, fireworks.WithRequestEditorFn(...)) from github.com/psyb0t/go-fireworks gives one typed method per spec operation, covering all 136 paths of the Fireworks AI Gateway REST API, the control plane (accounts, API keys, users, models, datasets, deployments, fine-tuning and batch jobs) under https://api.fireworks.ai and the inference endpoints (chat completions, completions, messages, responses) under https://api.fireworks.ai/inference. Responses decode into typed JSON200 fields. Use when Go code needs to call Fireworks AI, or already imports go-fireworks.
openclaw skills install @psyb0t/go-fireworksTyped Go client for the Fireworks AI REST API. Every operation in the spec is a method on ClientWithResponses, named after its operation ID.
For install, base URLs, method naming and error handling in detail, see references/setup.md.
FIREWORKS_API_KEY. Never hardcode it, commit it or log it, and never print request headers.NewClientWithResponses. Prompts, datasets and model files sent through the client reach Fireworks AI.github.com/psyb0t/go-fireworks.stream: true read HTTPResponse.Body from the plain Client methods yourself.import (
"context"
"fmt"
"net/http"
"os"
"github.com/psyb0t/go-fireworks"
)
auth := fireworks.WithRequestEditorFn(func(_ context.Context, req *http.Request) error {
req.Header.Set("Authorization", "Bearer "+os.Getenv("FIREWORKS_API_KEY"))
return nil
})
client, err := fireworks.NewClientWithResponses("https://api.fireworks.ai", auth)
if err != nil {
return err
}
res, err := client.GatewayListModelsWithResponse(ctx, "my-account", &fireworks.GatewayListModelsParams{})
if err != nil {
return err // transport error
}
if res.JSON200 == nil {
return fmt.Errorf("list models: status %d: %s", res.StatusCode(), res.Body)
}
for _, m := range *res.JSON200.Models {
fmt.Println(*m.Name)
}
Chat completions live on the inference base URL, so they need a second client:
inference, err := fireworks.NewClientWithResponses("https://api.fireworks.ai/inference", auth)
if err != nil {
return err
}
var content fireworks.ChatMessage_Content
if err := content.FromChatMessageContent0("Say hi"); err != nil {
return err
}
res, err := inference.CreateChatCompletionV1ChatCompletionsPostWithResponse(ctx, fireworks.ChatCompletionRequest{
Model: "accounts/fireworks/models/<model-id>",
Messages: []fireworks.ChatMessage{{Role: "user", Content: &content}},
})
if err != nil {
return err
}
if res.JSON200 == nil {
return fmt.Errorf("chat: status %d: %s", res.StatusCode(), res.Body)
}
text, err := res.JSON200.Choices[0].Message.Content.AsChatMessageContent0()
Check JSON200 for nil before reading it. A non-2xx status is not a Go error; the status is in StatusCode() and the raw body in Body.