live

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultOpenRouterBaseURL = "https://openrouter.ai/api/v1"
	DefaultCanopyWaveBaseURL = "https://inference.canopywave.io/v1"
	DefaultZAIBaseURL        = "https://api.z.ai/api/paas/v4"
	DefaultZAICodingBaseURL  = "https://api.z.ai/api/coding/paas/v4"
	DefaultOpenAIBaseURL     = "https://api.openai.com/v1"
	DefaultGrokBaseURL       = "https://api.x.ai/v1"
	DefaultOpenCodeGoBaseURL = opencodego.DefaultBaseURL
	DefaultKimiBaseURL       = "https://api.moonshot.ai/v1"
	DefaultXiaomiBaseURL     = "https://api.xiaomimimo.com/v1"
	DefaultMiniMaxBaseURL    = "https://api.minimax.io/v1"
)
View Source
const DefaultDeepSeekBaseURL = "https://api.deepseek.com/v1"

Variables

View Source
var Registry = map[string]FetchFunc{
	"anthropic":              FetchAnthropic,
	"openai":                 FetchOpenAI,
	"azure":                  FetchAzure,
	"gemini":                 FetchGemini,
	"bedrock":                FetchBedrock,
	"vertex":                 FetchVertex,
	"openrouter":             FetchOpenRouter,
	"grok":                   FetchGrok,
	"zai_payg":               FetchZAI,
	"zai_coding":             FetchZAICoding,
	"canopywave":             FetchCanopyWave,
	"opencodego":             FetchOpenCodeGo,
	"kimi":                   FetchKimi,
	"xiaomi_mimo_payg":       FetchXiaomiPayg,
	"xiaomi_mimo_token_plan": FetchXiaomiTokenPlan,
	"minimax_token_plan":     FetchMiniMaxTokenPlan,
	"minimax_payg":           FetchMiniMaxPayg,
	"ollama":                 FetchOllama,
	"deepseek":               FetchDeepSeek,
}

Registry maps fetcher keys to implementations.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	ID               string
	DisplayName      string
	Description      string
	OwnedBy          string
	ContextWindow    int
	MaxOutput        int
	InputPricePer1M  float64
	OutputPricePer1M float64
	// CachedReadPricePer1M is the price per 1M tokens for cached reads (prompt caching).
	CachedReadPricePer1M float64
	// CachedWritePricePer1M is the price per 1M tokens for cached writes (cache creation).
	CachedWritePricePer1M float64
	// Tiered pricing: when input tokens exceed TierThreshold, TieredInputPricePer1M applies.
	// Same for output. 0 means no tiering.
	TierThreshold          int     `json:"tier_threshold,omitempty"`
	TieredInputPricePer1M  float64 `json:"tiered_input_price_per_1m,omitempty"`
	TieredOutputPricePer1M float64 `json:"tiered_output_price_per_1m,omitempty"`
	TieredCachedReadPer1M  float64 `json:"tiered_cached_read_per_1m,omitempty"`
	TieredCachedWritePer1M float64 `json:"tiered_cached_write_per_1m,omitempty"`
	Features               []string
	// Protocol indicates which API protocol the model uses ("openai" or "anthropic").
	// Populated from live API metadata when available; empty means unknown/heuristic.
	Protocol string
	// RawJSON is the provider's full model object from the list API (preserved verbatim).
	RawJSON json.RawMessage

	// Capability fields (populated from live API responses that include capabilities).
	MaxInputTokens     int    `json:"max_input_tokens,omitempty"`
	ThinkingEnabled    bool   `json:"thinking_enabled,omitempty"`    // model supports thinking with explicit budget
	ThinkingAdaptive   bool   `json:"thinking_adaptive,omitempty"`   // model supports adaptive thinking
	EffortSupported    bool   `json:"effort_supported,omitempty"`    // model supports effort parameter
	EffortLevels       string `json:"effort_levels,omitempty"`       // comma-separated: "low,medium,high,xhigh,max"
	StructuredOutput   bool   `json:"structured_output,omitempty"`   // model supports native JSON schema output
	CodeExecution      bool   `json:"code_execution,omitempty"`      // model supports server-side code execution
	CitationsSupported bool   `json:"citations_supported,omitempty"` // model supports citations
	PDFInput           bool   `json:"pdf_input,omitempty"`           // model supports PDF input
	ImageInput         bool   `json:"image_input,omitempty"`         // model supports image input
}

Entry is one model row from a live provider list API.

func Fetch

func Fetch(key string, env map[string]string) ([]Entry, error)

Fetch runs a registered live fetcher.

func FetchAnthropic

func FetchAnthropic(env map[string]string) ([]Entry, error)

func FetchAzure

func FetchAzure(env map[string]string) ([]Entry, error)

func FetchBedrock

func FetchBedrock(env map[string]string) ([]Entry, error)

func FetchCanopyWave

func FetchCanopyWave(env map[string]string) ([]Entry, error)

func FetchDeepSeek

func FetchDeepSeek(env map[string]string) ([]Entry, error)

FetchDeepSeek lists models from the DeepSeek OpenAI-compatible API.

func FetchGemini

func FetchGemini(env map[string]string) ([]Entry, error)

func FetchGrok

func FetchGrok(env map[string]string) ([]Entry, error)

Per-provider fetchers (Grok, ZAI, CanopyWave, OpenCodeGo, Kimi, Xiaomi, MiMo, OpenRouter, Anthropic, Gemini, Ollama, DeepSeek). Split out of fetchers.go for clarity.

func FetchKimi

func FetchKimi(env map[string]string) ([]Entry, error)

func FetchMiniMaxPayg

func FetchMiniMaxPayg(env map[string]string) ([]Entry, error)

func FetchMiniMaxTokenPlan

func FetchMiniMaxTokenPlan(env map[string]string) ([]Entry, error)

func FetchOllama

func FetchOllama(env map[string]string) ([]Entry, error)

func FetchOpenAI

func FetchOpenAI(env map[string]string) ([]Entry, error)

OpenAI/OpenRouter enrichment and cloud-provider (Azure, Bedrock, Vertex, MiniMax) fetchers. Split out of fetchers.go for clarity.

func FetchOpenCodeGo

func FetchOpenCodeGo(env map[string]string) ([]Entry, error)

func FetchOpenRouter

func FetchOpenRouter(env map[string]string) ([]Entry, error)

func FetchVertex

func FetchVertex(env map[string]string) ([]Entry, error)

func FetchXiaomiPayg

func FetchXiaomiPayg(env map[string]string) ([]Entry, error)

func FetchXiaomiTokenPlan

func FetchXiaomiTokenPlan(env map[string]string) ([]Entry, error)

func FetchZAI

func FetchZAI(env map[string]string) ([]Entry, error)

func FetchZAICoding

func FetchZAICoding(env map[string]string) ([]Entry, error)

FetchZAICoding lists models using the GLM Coding Plan dedicated endpoint. It expects ZAI_CODING_API_KEY (and optional ZAI_CODING_BASE_URL) in the env map. This ensures proper quota/billing separation from the general pay-as-you-go path.

type FetchFunc

type FetchFunc func(env map[string]string) ([]Entry, error)

FetchFunc lists models from a live provider API.

Jump to

Keyboard shortcuts

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