openrouter

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package openrouter implements an aigo engine for the OpenRouter API.

OpenRouter routes all multimodal interactions through the chat completions endpoint (/v1/chat/completions). Image generation, TTS, and ASR are handled via modality flags and multimodal content blocks — there are no dedicated /v1/images/generations or /v1/audio/* endpoints.

Index

Constants

View Source
const (
	ModelGPT5Image        = "openai/gpt-5-image"
	ModelGPT5ImageMini    = "openai/gpt-5-image-mini"
	ModelGeminiFlashImage = "google/gemini-2.5-flash-image"
	ModelGemini3ProImage  = "google/gemini-3-pro-image-preview"
	ModelGPTAudio         = "openai/gpt-audio"
	ModelGPTAudioMini     = "openai/gpt-audio-mini"
)

Model constants for known OpenRouter media models.

Variables

View Source
var (
	ErrMissingAPIKey    = errors.New("openrouter: missing API key")
	ErrMissingPrompt    = errors.New("openrouter: prompt not found in workflow graph")
	ErrMissingAudioURL  = errors.New("openrouter: audio URL not found in workflow graph")
	ErrMissingVoice     = errors.New("openrouter: TTS voice not found in workflow graph")
	ErrUnsupportedModel = errors.New("openrouter: unsupported model")
)

Sentinel errors.

Functions

func ConfigSchema

func ConfigSchema() []engine.ConfigField

ConfigSchema returns the configuration fields required by the OpenRouter engine.

func ModelsByCapability

func ModelsByCapability() map[string][]string

ModelsByCapability returns all known OpenRouter media models grouped by capability.

Types

type Config

type Config struct {
	APIKey     string
	BaseURL    string
	Model      string
	HTTPClient *http.Client
}

Config configures the OpenRouter engine.

type Engine

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

Engine implements engine.Engine for OpenRouter.

func New

func New(cfg Config) *Engine

New creates an OpenRouter engine.

func (*Engine) Capabilities

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

Capabilities implements engine.Describer.

func (*Engine) Execute

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

Execute runs a workflow graph against the OpenRouter API.

Jump to

Keyboard shortcuts

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