Documentation
¶
Index ¶
- Variables
- func CopyToClipboard(imagePath string, imageData []byte) error
- func DisplayImage(imagePath string) error
- func ExpandPath(path string) string
- func ReadFromClipboard() ([]byte, error)
- func RenderImageToWriter(w io.Writer, path string) error
- func SaveImage(data []byte, outputDir, prompt string) (string, error)
- func ValidateSize(size string) error
- type ChatGPTProvider
- func (p *ChatGPTProvider) Edit(ctx context.Context, req EditRequest) (*ImageResult, error)
- func (p *ChatGPTProvider) Generate(ctx context.Context, req GenerateRequest) (*ImageResult, error)
- func (p *ChatGPTProvider) Name() string
- func (p *ChatGPTProvider) SupportsEdit() bool
- func (p *ChatGPTProvider) SupportsMultiImage() bool
- type DebugProvider
- func (p *DebugProvider) Edit(ctx context.Context, req EditRequest) (*ImageResult, error)
- func (p *DebugProvider) Generate(ctx context.Context, req GenerateRequest) (*ImageResult, error)
- func (p *DebugProvider) Name() string
- func (p *DebugProvider) SupportsEdit() bool
- func (p *DebugProvider) SupportsMultiImage() bool
- type EditRequest
- type FluxProvider
- func (p *FluxProvider) Edit(ctx context.Context, req EditRequest) (*ImageResult, error)
- func (p *FluxProvider) Generate(ctx context.Context, req GenerateRequest) (*ImageResult, error)
- func (p *FluxProvider) Name() string
- func (p *FluxProvider) SupportsEdit() bool
- func (p *FluxProvider) SupportsMultiImage() bool
- type GeminiProvider
- func (p *GeminiProvider) Edit(ctx context.Context, req EditRequest) (*ImageResult, error)
- func (p *GeminiProvider) Generate(ctx context.Context, req GenerateRequest) (*ImageResult, error)
- func (p *GeminiProvider) Name() string
- func (p *GeminiProvider) SupportsEdit() bool
- func (p *GeminiProvider) SupportsMultiImage() bool
- type GenerateRequest
- type ImageProvider
- type ImageResult
- type InputImage
- type OpenAIProvider
- func (p *OpenAIProvider) Edit(ctx context.Context, req EditRequest) (*ImageResult, error)
- func (p *OpenAIProvider) Generate(ctx context.Context, req GenerateRequest) (*ImageResult, error)
- func (p *OpenAIProvider) Name() string
- func (p *OpenAIProvider) SupportsEdit() bool
- func (p *OpenAIProvider) SupportsMultiImage() bool
- type OpenRouterProvider
- func (p *OpenRouterProvider) Edit(ctx context.Context, req EditRequest) (*ImageResult, error)
- func (p *OpenRouterProvider) Generate(ctx context.Context, req GenerateRequest) (*ImageResult, error)
- func (p *OpenRouterProvider) Name() string
- func (p *OpenRouterProvider) SupportsEdit() bool
- func (p *OpenRouterProvider) SupportsMultiImage() bool
- type RenderImageResult
- type TerminalImageCapability
- type VeniceProvider
- func (p *VeniceProvider) Edit(ctx context.Context, req EditRequest) (*ImageResult, error)
- func (p *VeniceProvider) Generate(ctx context.Context, req GenerateRequest) (*ImageResult, error)
- func (p *VeniceProvider) Name() string
- func (p *VeniceProvider) SupportsEdit() bool
- func (p *VeniceProvider) SupportsMultiImage() bool
- type XAIProvider
- func (p *XAIProvider) Edit(ctx context.Context, req EditRequest) (*ImageResult, error)
- func (p *XAIProvider) Generate(ctx context.Context, req GenerateRequest) (*ImageResult, error)
- func (p *XAIProvider) Name() string
- func (p *XAIProvider) SupportsEdit() bool
- func (p *XAIProvider) SupportsMultiImage() bool
Constants ¶
This section is empty.
Variables ¶
var ValidSizes = []string{"1K", "2K", "4K"}
ValidSizes are the normalized image size values accepted by the system.
Functions ¶
func CopyToClipboard ¶
CopyToClipboard copies image to clipboard (platform-aware) Attempts to copy actual image data, not just the path
func DisplayImage ¶
DisplayImage displays the image in terminal using rasterm Returns nil if terminal doesn't support images (graceful degradation)
func ExpandPath ¶ added in v0.0.111
ExpandPath expands ~ and ~username to the appropriate home directory. It delegates to pathutil.Expand and returns the original path on error. Deprecated: prefer pathutil.Expand or pathutil.MustExpand directly.
func ReadFromClipboard ¶
ReadFromClipboard reads image data from the system clipboard Returns the image data and an error if clipboard doesn't contain an image
func RenderImageToWriter ¶ added in v0.0.39
RenderImageToWriter renders an image to a writer using the detected capability This is for one-shot display (e.g., DisplayImage) - uses rasterm directly
func SaveImage ¶
SaveImage saves image data to the configured output directory Returns the path where the image was saved
func ValidateSize ¶ added in v0.0.99
ValidateSize checks that size is a recognized normalized value. Returns nil for empty string (no size requested). Returns an error for invalid values.
Types ¶
type ChatGPTProvider ¶ added in v0.0.176
type ChatGPTProvider struct {
// contains filtered or unexported fields
}
ChatGPTProvider implements ImageProvider using the chatgpt.com backend's built-in image_generation tool, authenticated via the user's existing ChatGPT OAuth login (same as the chatgpt LLM provider).
func NewChatGPTProvider ¶ added in v0.0.176
func NewChatGPTProvider(model string) (*ChatGPTProvider, error)
NewChatGPTProvider builds a ChatGPT image provider. The user must already be logged in via `term-llm ask --provider chatgpt`; this constructor does not prompt for interactive auth because the image command runs without a full TTY lifecycle.
func (*ChatGPTProvider) Edit ¶ added in v0.0.176
func (p *ChatGPTProvider) Edit(ctx context.Context, req EditRequest) (*ImageResult, error)
func (*ChatGPTProvider) Generate ¶ added in v0.0.176
func (p *ChatGPTProvider) Generate(ctx context.Context, req GenerateRequest) (*ImageResult, error)
func (*ChatGPTProvider) Name ¶ added in v0.0.176
func (p *ChatGPTProvider) Name() string
func (*ChatGPTProvider) SupportsEdit ¶ added in v0.0.176
func (p *ChatGPTProvider) SupportsEdit() bool
func (*ChatGPTProvider) SupportsMultiImage ¶ added in v0.0.176
func (p *ChatGPTProvider) SupportsMultiImage() bool
type DebugProvider ¶ added in v0.0.39
type DebugProvider struct {
// contains filtered or unexported fields
}
DebugProvider implements ImageProvider for local development without API costs
func NewDebugProvider ¶ added in v0.0.39
func NewDebugProvider(delaySeconds float64) *DebugProvider
NewDebugProvider creates a debug provider with an optional delay (in seconds)
func (*DebugProvider) Edit ¶ added in v0.0.39
func (p *DebugProvider) Edit(ctx context.Context, req EditRequest) (*ImageResult, error)
func (*DebugProvider) Generate ¶ added in v0.0.39
func (p *DebugProvider) Generate(ctx context.Context, req GenerateRequest) (*ImageResult, error)
func (*DebugProvider) Name ¶ added in v0.0.39
func (p *DebugProvider) Name() string
func (*DebugProvider) SupportsEdit ¶ added in v0.0.39
func (p *DebugProvider) SupportsEdit() bool
func (*DebugProvider) SupportsMultiImage ¶ added in v0.0.39
func (p *DebugProvider) SupportsMultiImage() bool
type EditRequest ¶
type EditRequest struct {
Prompt string
InputImages []InputImage // Input images for editing (supports multiple for some providers)
Size string // Normalized resolution: "1K", "2K", "4K"; providers translate or ignore
AspectRatio string // e.g. "1:1", "16:9", "9:16"; providers translate or ignore
Debug bool
DebugRaw bool
}
EditRequest contains parameters for image editing
type FluxProvider ¶
type FluxProvider struct {
// contains filtered or unexported fields
}
FluxProvider implements ImageProvider using Black Forest Labs' Flux API
func NewFluxProvider ¶
func NewFluxProvider(apiKey, model string) *FluxProvider
func (*FluxProvider) Edit ¶
func (p *FluxProvider) Edit(ctx context.Context, req EditRequest) (*ImageResult, error)
func (*FluxProvider) Generate ¶
func (p *FluxProvider) Generate(ctx context.Context, req GenerateRequest) (*ImageResult, error)
func (*FluxProvider) Name ¶
func (p *FluxProvider) Name() string
func (*FluxProvider) SupportsEdit ¶
func (p *FluxProvider) SupportsEdit() bool
func (*FluxProvider) SupportsMultiImage ¶ added in v0.0.33
func (p *FluxProvider) SupportsMultiImage() bool
type GeminiProvider ¶
type GeminiProvider struct {
// contains filtered or unexported fields
}
GeminiProvider implements ImageProvider using Google's Gemini API
func NewGeminiProvider ¶
func NewGeminiProvider(apiKey, model, defaultSize string) *GeminiProvider
func (*GeminiProvider) Edit ¶
func (p *GeminiProvider) Edit(ctx context.Context, req EditRequest) (*ImageResult, error)
func (*GeminiProvider) Generate ¶
func (p *GeminiProvider) Generate(ctx context.Context, req GenerateRequest) (*ImageResult, error)
func (*GeminiProvider) Name ¶
func (p *GeminiProvider) Name() string
func (*GeminiProvider) SupportsEdit ¶
func (p *GeminiProvider) SupportsEdit() bool
func (*GeminiProvider) SupportsMultiImage ¶ added in v0.0.33
func (p *GeminiProvider) SupportsMultiImage() bool
type GenerateRequest ¶
type GenerateRequest struct {
Prompt string
Size string // Normalized resolution: "1K", "2K", "4K"; providers translate or ignore
AspectRatio string // e.g. "1:1", "16:9", "9:16"; providers translate or ignore
Debug bool
DebugRaw bool
}
GenerateRequest contains parameters for image generation
type ImageProvider ¶
type ImageProvider interface {
// Name returns the provider name for logging
Name() string
// Generate creates a new image from a text prompt
Generate(ctx context.Context, req GenerateRequest) (*ImageResult, error)
// Edit modifies an existing image based on a prompt
Edit(ctx context.Context, req EditRequest) (*ImageResult, error)
// SupportsEdit returns true if the provider supports image editing
SupportsEdit() bool
// SupportsMultiImage returns true if the provider supports multiple input images
SupportsMultiImage() bool
}
ImageProvider is the interface for image generation providers
func NewImageProvider ¶
func NewImageProvider(cfg *config.Config, providerOverride string) (ImageProvider, error)
NewImageProvider creates an image provider based on config
type ImageResult ¶
type ImageResult struct {
Data []byte // Image data (PNG/JPEG)
MimeType string // "image/png", "image/jpeg", etc.
}
ImageResult contains the generated image and metadata
type InputImage ¶ added in v0.0.33
InputImage represents a single input image for editing
type OpenAIProvider ¶
type OpenAIProvider struct {
// contains filtered or unexported fields
}
OpenAIProvider implements ImageProvider using OpenAI's Image API.
GPT Image 2 supports both /v1/images/generations and /v1/images/edits, accepts multiple reference images on edits, and allows flexible resolutions as long as they satisfy OpenAI's documented constraints (multiples of 16, max 3840px edge, max 3:1 aspect ratio, pixel count between 655,360 and 8,294,400). Older GPT Image models keep the legacy 3-size behavior.
func NewOpenAIProvider ¶
func NewOpenAIProvider(apiKey, model string) *OpenAIProvider
func (*OpenAIProvider) Edit ¶
func (p *OpenAIProvider) Edit(ctx context.Context, req EditRequest) (*ImageResult, error)
func (*OpenAIProvider) Generate ¶
func (p *OpenAIProvider) Generate(ctx context.Context, req GenerateRequest) (*ImageResult, error)
func (*OpenAIProvider) Name ¶
func (p *OpenAIProvider) Name() string
func (*OpenAIProvider) SupportsEdit ¶
func (p *OpenAIProvider) SupportsEdit() bool
func (*OpenAIProvider) SupportsMultiImage ¶ added in v0.0.33
func (p *OpenAIProvider) SupportsMultiImage() bool
type OpenRouterProvider ¶ added in v0.0.24
type OpenRouterProvider struct {
// contains filtered or unexported fields
}
OpenRouterProvider implements ImageProvider using OpenRouter's API
func NewOpenRouterProvider ¶ added in v0.0.24
func NewOpenRouterProvider(apiKey, model string) *OpenRouterProvider
func (*OpenRouterProvider) Edit ¶ added in v0.0.24
func (p *OpenRouterProvider) Edit(ctx context.Context, req EditRequest) (*ImageResult, error)
func (*OpenRouterProvider) Generate ¶ added in v0.0.24
func (p *OpenRouterProvider) Generate(ctx context.Context, req GenerateRequest) (*ImageResult, error)
func (*OpenRouterProvider) Name ¶ added in v0.0.24
func (p *OpenRouterProvider) Name() string
func (*OpenRouterProvider) SupportsEdit ¶ added in v0.0.24
func (p *OpenRouterProvider) SupportsEdit() bool
func (*OpenRouterProvider) SupportsMultiImage ¶ added in v0.0.33
func (p *OpenRouterProvider) SupportsMultiImage() bool
type RenderImageResult ¶ added in v0.0.39
type RenderImageResult struct {
// Upload contains the upload/placement commands that must go directly to terminal
// For Kitty: delete + transmit + placement commands
// For iTerm/Sixel: empty (everything is in Placeholder)
Upload string
// Placeholder contains the displayable portion
// For Kitty: Unicode placeholder characters
// For iTerm/Sixel: full escape sequence
Placeholder string
// Full is Upload + Placeholder (for convenience in non-bubbletea contexts)
Full string
}
RenderImageResult contains the result of rendering an image
func RenderImageToString ¶ added in v0.0.39
func RenderImageToString(path string) (RenderImageResult, error)
RenderImageToString renders an image and returns a string for display For Kitty: returns full upload sequence for first display, placeholder-only for cache For others: returns full escape sequence (same for both) The caller should cache result.Cached and use result.Full for first display.
type TerminalImageCapability ¶ added in v0.0.39
type TerminalImageCapability int
TerminalImageCapability represents the terminal's image rendering capability
const ( CapNone TerminalImageCapability = iota // No image support CapKitty // Kitty graphics protocol CapITerm // iTerm2 inline images CapSixel // Sixel graphics )
func DetectCapability ¶ added in v0.0.39
func DetectCapability() TerminalImageCapability
DetectCapability detects the terminal's image rendering capability Detection order: Kitty -> iTerm -> Sixel -> None
func (TerminalImageCapability) String ¶ added in v0.0.39
func (c TerminalImageCapability) String() string
String returns the capability name
type VeniceProvider ¶ added in v0.0.98
type VeniceProvider struct {
// contains filtered or unexported fields
}
VeniceProvider implements ImageProvider using Venice AI's native image API. - Text-to-image: POST /image/generate (JSON, returns base64 in JSON) - Single image edit: POST /image/edit (multipart/form-data, returns raw PNG) - Multi-image edit: POST /image/multi-edit (JSON with base64 images, returns raw PNG)
func NewVeniceProvider ¶ added in v0.0.98
func NewVeniceProvider(apiKey, model, editModel, resolution string) *VeniceProvider
func (*VeniceProvider) Edit ¶ added in v0.0.98
func (p *VeniceProvider) Edit(ctx context.Context, req EditRequest) (*ImageResult, error)
Edit dispatches to the appropriate endpoint: - 1 image → POST /image/edit (multipart/form-data) - 2-3 images → POST /image/multi-edit (JSON with base64 images array) Both return raw PNG binary.
func (*VeniceProvider) Generate ¶ added in v0.0.98
func (p *VeniceProvider) Generate(ctx context.Context, req GenerateRequest) (*ImageResult, error)
Generate calls POST /image/generate — text-to-image. Response: JSON { "images": ["<base64>"] }
func (*VeniceProvider) Name ¶ added in v0.0.98
func (p *VeniceProvider) Name() string
func (*VeniceProvider) SupportsEdit ¶ added in v0.0.98
func (p *VeniceProvider) SupportsEdit() bool
func (*VeniceProvider) SupportsMultiImage ¶ added in v0.0.98
func (p *VeniceProvider) SupportsMultiImage() bool
type XAIProvider ¶ added in v0.0.31
type XAIProvider struct {
// contains filtered or unexported fields
}
XAIProvider implements ImageProvider using xAI's Grok image API
func NewXAIProvider ¶ added in v0.0.31
func NewXAIProvider(apiKey, model string) *XAIProvider
func (*XAIProvider) Edit ¶ added in v0.0.31
func (p *XAIProvider) Edit(ctx context.Context, req EditRequest) (*ImageResult, error)
func (*XAIProvider) Generate ¶ added in v0.0.31
func (p *XAIProvider) Generate(ctx context.Context, req GenerateRequest) (*ImageResult, error)
func (*XAIProvider) Name ¶ added in v0.0.31
func (p *XAIProvider) Name() string
func (*XAIProvider) SupportsEdit ¶ added in v0.0.31
func (p *XAIProvider) SupportsEdit() bool
func (*XAIProvider) SupportsMultiImage ¶ added in v0.0.33
func (p *XAIProvider) SupportsMultiImage() bool