config

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultBaseURL = "https://openrouter.ai/api/v1"

DefaultBaseURL is the default OpenRouter API base URL.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatRequest

type ChatRequest struct {
	Model              string
	Models             []string
	Messages           []map[string]any
	Tools              []map[string]any
	Stream             bool
	ToolChoice         any
	MaxTokens          *int
	MaxOutputTokens    *int
	Temperature        *float64
	TopP               *float64
	TopK               *float64
	PresencePenalty    *float64
	FrequencyPenalty   *float64
	Seed               *int64
	Stop               []string
	Logprobs           *bool
	TopLogprobs        *int
	ParallelToolCalls  *bool
	ResponseFormat     map[string]any
	ResponseText       map[string]any
	Metadata           map[string]any
	Provider           map[string]any
	Plugins            []map[string]any
	Route              string
	Reasoning          map[string]any
	SessionID          string
	Trace              *bool
	Modalities         []string
	ImageConfig        map[string]any
	User               string
	Instructions       string
	PreviousResponseID string
	PromptCacheKey     string
	MaxToolCalls       *int
	ServiceTier        string
	Truncation         string
	Include            []string
	Background         *bool
	SafetyIdentifier   string
	Store              *bool
	Prompt             map[string]any
	Extra              map[string]any
}

ChatRequest is the normalized OpenRouter chat request used by transports.

type Effort

type Effort string

Effort controls thinking depth.

const (
	EffortLow    Effort = "low"
	EffortMedium Effort = "medium"
	EffortHigh   Effort = "high"
	EffortMax    Effort = "max"
)

type OpenRouterAPIMode

type OpenRouterAPIMode string

OpenRouterAPIMode selects which OpenRouter API surface to use.

const (
	// OpenRouterAPIModeChatCompletions uses /chat/completions.
	OpenRouterAPIModeChatCompletions OpenRouterAPIMode = "chat_completions"
	// OpenRouterAPIModeResponses uses /responses.
	OpenRouterAPIModeResponses OpenRouterAPIMode = "responses"
)

type Options

type Options struct {
	Logger             *slog.Logger
	SystemPrompt       string
	SystemPromptPreset *SystemPromptPreset
	Model              string
	PermissionMode     string
	MaxTurns           int
	Cwd                string
	User               string

	Hooks                  map[hook.Event][]*hook.Matcher
	Thinking               ThinkingConfig
	Effort                 *Effort
	IncludePartialMessages bool
	MaxBudgetUSD           *float64

	MCPServers map[string]mcp.ServerConfig
	MCPConfig  string

	Tools           ToolsConfig
	AllowedTools    []string
	DisallowedTools []string
	CanUseTool      permission.Callback
	OnUserInput     userinput.Callback

	Resume           string
	ForkSession      bool
	SessionStorePath string

	FallbackModel            string
	PermissionPromptToolName string
	Plugins                  []*PluginConfig
	OutputFormat             map[string]any
	EnableFileCheckpointing  bool
	Transport                Transport

	// OpenRouter specific
	APIKey            string
	BaseURL           string
	OpenRouterAPIMode OpenRouterAPIMode
	HTTPReferer       string
	XTitle            string
	RequestTimeout    *time.Duration
	MaxToolIterations int

	// OpenRouter request fields
	OpenRouterTopP               *float64
	OpenRouterTemperature        *float64
	OpenRouterMaxTokens          *int
	OpenRouterTopK               *float64
	OpenRouterPresencePenalty    *float64
	OpenRouterFrequencyPenalty   *float64
	OpenRouterSeed               *int64
	OpenRouterStop               []string
	OpenRouterLogprobs           *bool
	OpenRouterTopLogprobs        *int
	OpenRouterParallelToolCalls  *bool
	OpenRouterToolChoice         any
	OpenRouterProvider           map[string]any
	OpenRouterPlugins            []map[string]any
	OpenRouterRoute              string
	OpenRouterReasoning          map[string]any
	OpenRouterSessionID          string
	OpenRouterTrace              *bool
	OpenRouterModalities         []string
	OpenRouterImageConfig        map[string]any
	OpenRouterModels             []string
	OpenRouterMetadata           map[string]any
	OpenRouterInstructions       string
	OpenRouterPreviousResponseID string
	OpenRouterPromptCacheKey     string
	OpenRouterPrompt             map[string]any
	OpenRouterText               map[string]any
	OpenRouterMaxOutputTokens    *int
	OpenRouterMaxToolCalls       *int
	OpenRouterServiceTier        string
	OpenRouterTruncation         string
	OpenRouterInclude            []string
	OpenRouterBackground         *bool
	OpenRouterSafetyIdentifier   string
	OpenRouterStore              *bool
	OpenRouterExtra              map[string]any
}

Options contains all SDK options.

func (*Options) ApplyDefaults

func (o *Options) ApplyDefaults()

ApplyDefaults fills missing option defaults.

type PluginConfig

type PluginConfig struct {
	Type string `json:"type"` // "local"
	Path string `json:"path"`
}

PluginConfig configures a plugin to load.

type SystemPromptPreset

type SystemPromptPreset struct {
	Type   string  `json:"type"`   // "preset"
	Preset string  `json:"preset"` // backend-defined preset identifier
	Append *string `json:"append,omitempty"`
}

SystemPromptPreset defines a system prompt preset configuration.

type ThinkingConfig

type ThinkingConfig interface {
	// contains filtered or unexported methods
}

ThinkingConfig is a marker interface for thinking settings.

type ThinkingConfigAdaptive

type ThinkingConfigAdaptive struct{}

ThinkingConfigAdaptive enables adaptive thinking.

type ThinkingConfigDisabled

type ThinkingConfigDisabled struct{}

ThinkingConfigDisabled disables thinking.

type ThinkingConfigEnabled

type ThinkingConfigEnabled struct {
	BudgetTokens int
}

ThinkingConfigEnabled enables thinking with a token budget.

type ToolsConfig

type ToolsConfig interface {
	// contains filtered or unexported methods
}

ToolsConfig is an interface for configuring available tools.

type ToolsList

type ToolsList []string

ToolsList is a list of tool names to make available.

type ToolsPreset

type ToolsPreset struct {
	Type   string `json:"type"`   // "preset"
	Preset string `json:"preset"` // backend-defined preset identifier
}

ToolsPreset represents a preset configuration for available tools.

type Transport

type Transport interface {
	Start(ctx context.Context) error
	CreateStream(ctx context.Context, req *ChatRequest) (<-chan map[string]any, <-chan error)
	Close() error
}

Transport defines the runtime transport interface.

Jump to

Keyboard shortcuts

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