openrouter

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package openrouter provides the OpenRouter-specific construction and request options for the OpenAI-compatible Chat Completions API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(selected model.Model, key auth.APIKey, options ...Option) (inference.Client, error)

New builds an OpenRouter inference client. The selected model must identify OpenRouter and the OpenAI API format; an empty API key is rejected before a client is constructed. An empty model base URL uses OpenRouter's canonical API root.

Types

type Option

type Option func(*config)

Option customizes an OpenRouter client at construction time.

func WithHTTPReferer

func WithHTTPReferer(value string) Option

WithHTTPReferer adds OpenRouter's optional HTTP-Referer attribution header.

func WithPromptCacheKey

func WithPromptCacheKey(value string) Option

WithPromptCacheKey sets OpenRouter's stable prompt-cache key.

func WithProviderRouting

func WithProviderRouting(options ProviderRoutingOptions) Option

WithProviderRouting adds OpenRouter provider-routing preferences.

func WithReasoning

func WithReasoning(options ReasoningOptions) Option

WithReasoning adds OpenRouter's reasoning request object.

func WithTLSRootCAs

func WithTLSRootCAs(roots *x509.CertPool) Option

WithTLSRootCAs installs a caller-owned verified certificate pool for tests and controlled clients; nil is rejected rather than silently using defaults.

func WithTitle

func WithTitle(value string) Option

WithTitle adds OpenRouter's optional X-OpenRouter-Title attribution header.

func WithUsage

func WithUsage(include bool) Option

WithUsage requests OpenRouter to include its usage metadata in the response.

type ProviderRoutingOptions

type ProviderRoutingOptions struct {
	Order             []string `json:"order,omitempty"`
	AllowFallbacks    *bool    `json:"allow_fallbacks,omitempty"`
	RequireParameters *bool    `json:"require_parameters,omitempty"`
	DataCollection    string   `json:"data_collection,omitempty"`
	ZDR               *bool    `json:"zdr,omitempty"`
}

ProviderRoutingOptions controls OpenRouter's provider-selection policy. Pointer fields preserve the difference between an omitted value and an explicitly supplied false.

type ReasoningOptions

type ReasoningOptions struct {
	Effort    string `json:"effort,omitempty"`
	MaxTokens *int   `json:"max_tokens,omitempty"`
	Exclude   *bool  `json:"exclude,omitempty"`
	Enabled   *bool  `json:"enabled,omitempty"`
	Context   string `json:"context,omitempty"`
	Mode      string `json:"mode,omitempty"`
}

ReasoningOptions controls OpenRouter's provider-specific reasoning object. Pointer fields preserve the difference between an omitted value and an explicitly supplied false or zero.

Jump to

Keyboard shortcuts

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