Documentation
¶
Index ¶
- type Client
- func (c *Client) ChatCompletion(ctx context.Context, req llm.ChatRequest) (*llm.ChatResponse, error)
- func (c *Client) HealthCheck(ctx context.Context) error
- func (c *Client) ListModelDetails(ctx context.Context) ([]llm.ModelInfo, error)
- func (c *Client) ListModels(ctx context.Context) ([]string, error)
- func (c *Client) Name() string
- func (c *Client) SetProviderRouting(order []string, allowFallbacks *bool, stickyTTL time.Duration)
- func (c *Client) SetReasoning(enabled *bool, effort string, maxTokens int, exclude *bool)
- func (c *Client) SupportsStreaming() bool
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 NewWithHTTPClient ¶
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) ListModelDetails ¶ added in v0.16.11
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
ListModels returns available model IDs from the OpenRouter API.
func (*Client) SetProviderRouting ¶ added in v0.38.0
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
SetReasoning configures the reasoning parameter for OpenRouter requests.
func (*Client) SupportsStreaming ¶ added in v0.16.9
SupportsStreaming implements llm.StreamingProvider.