Documentation
¶
Index ¶
Constants ¶
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 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 ¶
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 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.