Documentation
¶
Overview ¶
Package blackforestlabs wraps Black Forest Labs' FLUX image generation API.
NewImageModel targets the official asynchronous /v1/{model} endpoints, follows each response's polling_url, and downloads the short-lived signed output before returning it. Downloads admit the official BFL HTTPS namespace and its Azure delivery origin. ImageModelConfig.OutputOrigins authorizes additional delivery origins; configuring an API endpoint does not grant that endpoint delivery authority. Delivery requests never carry the API key, authorization headers, or cookies. Output metadata blackforestlabs/duration preserves the provider's native numeric value without assuming a duration unit.
Set the output encoding through image.Options.OutputFormat. FLUX-specific knobs (steps, guidance, raw, safety_tolerance, prompt_upsampling, and image_prompt for editing) use Options.Extensions under ImageRequestExtensionKey. An explicit prompt_upsampling=false is preserved because endpoint defaults differ; omission leaves that choice to the selected model.
See https://docs.bfl.ai/ for the full reference.
Index ¶
Examples ¶
Constants ¶
const ( ImageRequestExtensionKey = Provider + "/image_request" DefaultBaseURL = "https://api.bfl.ai/v1" DefaultPollInterval = time.Second DefaultPollTimeout = 2 * time.Minute )
const ( ModelFlux2Max = "flux-2-max" ModelFlux2ProPreview = "flux-2-pro-preview" ModelFlux2Pro = "flux-2-pro" ModelFlux2Flex = "flux-2-flex" ModelFlux2Klein4B = "flux-2-klein-4b" ModelFlux2Klein9BPreview = "flux-2-klein-9b-preview" ModelFlux2Klein9B = "flux-2-klein-9b" ModelFluxKontextMax = "flux-kontext-max" ModelFluxKontextPro = "flux-kontext-pro" ModelFlux11ProUltra = "flux-pro-1.1-ultra" ModelFlux11Pro = "flux-pro-1.1" ModelFluxPro = "flux-pro" ModelFluxDev = "flux-dev" )
const (
Provider = "blackforestlabs"
)
Provider is the stable backend name for host-side attribution.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ImageModel ¶
type ImageModel struct {
// contains filtered or unexported fields
}
ImageModel wraps Black Forest Labs' Flux image-generation endpoints. Model id picks the engine ("flux-pro-1.1", "flux-pro-1.1-ultra", "flux-dev", "flux-kontext-pro", "flux-kontext-max"). BFL is async only — Call submits + polls until ready.
func NewImageModel ¶
func NewImageModel(ctx context.Context, config ImageModelConfig) (*ImageModel, error)
type ImageModelConfig ¶
type ImageModelConfig struct {
APIKey string
DefaultOptions image.Options
BaseURL string
HTTPClient *http.Client
OutputOrigins []string
// PollInterval / PollTimeout configure the synchronous wrapper
// around BFL's async generation. Zero values fall back to the
// package defaults.
PollInterval time.Duration
PollTimeout time.Duration
}
Example ¶
package main
import (
"context"
"fmt"
"github.com/Tangerg/scope/core/image"
"github.com/Tangerg/scope/models/blackforestlabs"
)
func main() {
options := image.Options{Model: blackforestlabs.ModelFlux11Pro, OutputFormat: "image/png"}
_, err := blackforestlabs.NewImageModel(context.Background(), blackforestlabs.ImageModelConfig{
APIKey: "example-key", DefaultOptions: options,
})
fmt.Println(options.Model, options.OutputFormat, err)
}
Output: flux-pro-1.1 image/png <nil>
func (ImageModelConfig) Validate ¶
func (i ImageModelConfig) Validate() error