openrouter

package
v0.40.2 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func New

func New(apiKey string) *Client

func NewFull added in v0.21.0

func NewFull(name, apiKey string) *Client

NewFull creates a named client.

func NewWithHTTPClient

func NewWithHTTPClient(apiKey, baseURL string, httpClient *http.Client) *Client

NewWithHTTPClient creates a client with a custom HTTP client (for testing).

func (*Client) ChatCompletion

func (c *Client) ChatCompletion(ctx context.Context, req llm.ChatRequest) (*llm.ChatResponse, error)

func (*Client) HealthCheck

func (c *Client) HealthCheck(ctx context.Context) error

func (*Client) ListModelDetails added in v0.16.11

func (c *Client) ListModelDetails(ctx context.Context) ([]llm.ModelInfo, error)

ListModelDetails returns enriched model metadata from the OpenRouter API, including pricing, tool support, and weekly usage for popularity sorting. Results are cached for 5 minutes to avoid repeated heavy API calls.

func (*Client) ListModels added in v0.15.1

func (c *Client) ListModels(ctx context.Context) ([]string, error)

ListModels returns available model IDs from the OpenRouter API.

func (*Client) Name

func (c *Client) Name() string

func (*Client) SetProviderRouting added in v0.38.0

func (c *Client) SetProviderRouting(order []string, allowFallbacks *bool, stickyTTL time.Duration)

SetProviderRouting configures OpenRouter upstream provider routing. order is an explicit preference list of provider slugs/names (e.g. "moonshotai") that always wins when set; allowFallbacks (when non-nil) controls whether OpenRouter may fall back to providers outside that list. stickyTTL (> 0) enables sticky routing: after a success the served provider is preferred for that duration so the upstream's automatic prompt caching keeps hitting instead of being scattered across providers. Errors reset the preference.

func (*Client) SetReasoning added in v0.27.1

func (c *Client) SetReasoning(enabled *bool, effort string, maxTokens int, exclude *bool)

SetReasoning configures the reasoning parameter for OpenRouter requests.

func (*Client) SupportsStreaming added in v0.16.9

func (c *Client) SupportsStreaming() bool

SupportsStreaming implements llm.StreamingProvider.

Jump to

Keyboard shortcuts

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