provider

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheControl added in v0.1.5

type CacheControl struct {
	Type string `json:"type"`
	TTL  string `json:"ttl,omitempty"`
}

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 (c *Client) ContextWindow() int

func (*Client) Model

func (c *Client) Model() string

func (*Client) Pricing added in v0.1.1

func (c *Client) Pricing() (float64, float64, float64)

func (*Client) SetDebug

func (c *Client) SetDebug(enabled bool)

func (*Client) SetExtraHeaders added in v0.1.5

func (c *Client) SetExtraHeaders(headers map[string]string)

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 PromptTokensDetails struct {
	CachedTokens     int `json:"cached_tokens"`
	CacheWriteTokens int `json:"cache_write_tokens,omitempty"`
}

type ProviderError added in v0.1.1

type ProviderError struct {
	StatusCode int
	Body       string
}

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 ReasoningConfig struct {
	Effort    string `json:"effort,omitempty"`
	MaxTokens int    `json:"max_tokens,omitempty"`
	Exclude   *bool  `json:"exclude,omitempty"`
	Enabled   *bool  `json:"enabled,omitempty"`
}

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 StreamToolCall struct {
	ID        string
	Name      string
	Arguments string
}

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"`
}

Jump to

Keyboard shortcuts

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