Documentation
¶
Index ¶
- type CacheControl
- type ChatClient
- type ChatRequest
- type Client
- func (c *Client) Chat(ctx context.Context, req ChatRequest) (<-chan StreamEvent, error)
- func (c *Client) ContextWindow() int
- func (c *Client) Model() string
- func (c *Client) Pricing() (float64, float64, float64)
- func (c *Client) SetDebug(enabled bool)
- func (c *Client) SetExtraHeaders(headers map[string]string)
- type CompletionTokensDetails
- type ModelProfile
- type PromptTokensDetails
- type ProviderError
- type ProviderPreferences
- type ReasoningConfig
- type StreamEvent
- type StreamOptions
- type StreamToolCall
- type ThinkingConfig
- type Usage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CacheControl ¶ added in v0.1.5
type ChatClient ¶
type ChatClient interface {
Chat(ctx context.Context, req ChatRequest) (<-chan StreamEvent, error)
Model() string
ContextWindow() int
Pricing() (float64, float64, float64)
}
type ChatRequest ¶
type ChatRequest struct {
Model string `json:"model"`
Messages []message.Message `json:"messages"`
Tools []message.ToolDef `json:"tools,omitempty"`
Stream bool `json:"stream"`
MaxTokens int `json:"max_tokens,omitempty"`
StreamOptions *StreamOptions `json:"stream_options,omitempty"`
Thinking *ThinkingConfig `json:"thinking,omitempty"`
ReasoningEffort string `json:"reasoning_effort,omitempty"`
Reasoning *ReasoningConfig `json:"reasoning,omitempty"`
Models []string `json:"models,omitempty"`
Route string `json:"route,omitempty"`
ProviderPrefs *ProviderPreferences `json:"provider,omitempty"`
CacheControl *CacheControl `json:"cache_control,omitempty"`
SessionID string `json:"session_id,omitempty"`
}
type Client ¶
type Client struct {
Profile ModelProfile
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(baseURL, model, apiKey string, profile ModelProfile) *Client
func (*Client) Chat ¶
func (c *Client) Chat(ctx context.Context, req ChatRequest) (<-chan StreamEvent, error)
func (*Client) ContextWindow ¶
func (*Client) SetExtraHeaders ¶ added in v0.1.5
type CompletionTokensDetails ¶ added in v0.1.5
type CompletionTokensDetails struct {
ReasoningTokens int `json:"reasoning_tokens,omitempty"`
}
type ModelProfile ¶
type ModelProfile struct {
ContextWindow int
MaxOutputTokens int
ThinkingType string
ReasoningEffort string
ReasoningMaxTokens int
OpenRouter bool
InputPrice float64
CachedInputPrice float64
OutputPrice float64
FallbackModels []string
Route string
ProviderPrefs *ProviderPreferences
PromptCache bool
PromptCacheTTL string
}
type PromptTokensDetails ¶ added in v0.1.1
type ProviderError ¶ added in v0.1.1
func (*ProviderError) Error ¶ added in v0.1.1
func (e *ProviderError) Error() string
func (*ProviderError) Retryable ¶ added in v0.1.1
func (e *ProviderError) Retryable() bool
type ProviderPreferences ¶ added in v0.1.5
type ProviderPreferences struct {
Order []string `json:"order,omitempty"`
AllowFallbacks *bool `json:"allow_fallbacks,omitempty"`
RequireParameters *bool `json:"require_parameters,omitempty"`
DataCollection string `json:"data_collection,omitempty"`
Only []string `json:"only,omitempty"`
Ignore []string `json:"ignore,omitempty"`
Quantizations []string `json:"quantizations,omitempty"`
Sort string `json:"sort,omitempty"`
}
type ReasoningConfig ¶ added in v0.1.5
type StreamEvent ¶
type StreamEvent struct {
Type string `json:"type"`
Delta string `json:"delta,omitempty"`
ReasoningDelta string `json:"reasoningDelta,omitempty"`
ReasoningDetails []message.ReasoningDetail `json:"reasoningDetails,omitempty"`
ToolCall *StreamToolCall `json:"toolCall,omitempty"`
Usage *Usage `json:"usage,omitempty"`
FinishReason string `json:"finishReason,omitempty"`
Error error `json:"-"`
}
type StreamOptions ¶
type StreamOptions struct {
IncludeUsage bool `json:"include_usage"`
}
type StreamToolCall ¶
type ThinkingConfig ¶
type ThinkingConfig struct {
Type string `json:"type"`
}
type Usage ¶
type Usage struct {
PromptTokens int `json:"prompt_tokens"`
CompletionTokens int `json:"completion_tokens"`
TotalTokens int `json:"total_tokens"`
PromptCacheHitTokens int `json:"prompt_cache_hit_tokens"`
PromptTokensDetails *PromptTokensDetails `json:"prompt_tokens_details"`
CompletionTokensDetails *CompletionTokensDetails `json:"completion_tokens_details,omitempty"`
Cost float64 `json:"cost,omitempty"`
}
Click to show internal directories.
Click to hide internal directories.