openai

package
v0.42.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingPrompt       = errors.New("openai: prompt not found in workflow graph")
	ErrRemoteMediaDisabled = errors.New("openai: remote media fetch is disabled by configuration")
)

Functions

func ConfigSchema added in v0.9.0

func ConfigSchema() []engine.ConfigField

ConfigSchema returns the configuration fields required by the OpenAI engine.

func DefaultProvider added in v0.15.0

func DefaultProvider() engine.Provider

DefaultProvider returns preset engine configurations for openai.

func ModelInfos added in v0.16.0

func ModelInfos() []engine.ModelInfo

ModelInfos returns i18n metadata for all OpenAI image models.

func ModelsByCapability added in v0.7.0

func ModelsByCapability() map[string][]string

ModelsByCapability returns all known OpenAI models grouped by capability.

Types

type Config

type Config struct {
	APIKey  string
	BaseURL string
	Model   string
	Quality string
	Style   string
	// gpt-image-* 专属可选参数
	Background        string // transparent | opaque | auto
	OutputFormat      string // png | jpeg | webp
	Moderation        string // low | auto
	OutputCompression int    // 0-100, 仅 jpeg/webp 生效
	// AllowRemoteImageFetch 控制 image_url 是否允许 HTTP GET(默认 true)。
	DisableRemoteMediaFetch bool
	HTTPClient              *http.Client
}

Config configures the OpenAI image engine.

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

Engine compiles a workflow graph into an OpenAI image request.

func New

func New(cfg Config) *Engine

New creates an OpenAI engine instance.

func (*Engine) Capabilities

func (e *Engine) Capabilities() engine.Capability

Capabilities implements engine.Describer.

func (*Engine) Compile

func (e *Engine) Compile(graph workflow.Graph) (Request, error)

Compile extracts prompt and size from a graph into an OpenAI request.

func (*Engine) Execute

func (e *Engine) Execute(ctx context.Context, graph workflow.Graph) (engine.Result, error)

Execute compiles the workflow and calls the OpenAI images API. If the graph carries an image source (image_b64/image_path/image_url/LoadImage), it dispatches to /v1/images/edits with multipart upload; otherwise it calls /v1/images/generations with JSON.

type Request

type Request struct {
	Model   string
	Prompt  string
	Size    string
	Quality string
	Style   string
}

Request is the flattened image generation payload derived from a graph.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL