Versions in this module Expand all Collapse all v0 v0.0.1 Sep 4, 2026 Changes in this version + const ChatProtocolCompletions + const ChatProtocolMessages + const GuardrailBlock + const GuardrailCustom + const GuardrailHarmfulContent + const GuardrailPII + const GuardrailPromptInjection + const GuardrailRedact + const GuardrailSecretLeak + const GuardrailWarn + const ProviderTypeAnthropic + const ProviderTypeAzure + const ProviderTypeBedrock + const ProviderTypeOpenAI + const ProviderTypeOpenAICompatible + const ProviderTypeVertex + const ResponseEmpty + const ResponseErrorOnlyReasoning + const ResponseMalformedStream + const ResponseOK + const RoleEditor + const RolePrimary + const RoleWeak + const SeverityCritical + const SeverityHigh + const SeverityLow + const SeverityMedium + const ThinkingFormatAgnes + const ThinkingFormatDeepSeek + const ThinkingFormatKimi + const ThinkingFormatLongCat + const ThinkingFormatMiniMax + const ThinkingFormatNone + const ThinkingFormatOpenRouter + const ThinkingFormatQwen + const ThinkingFormatXiaomi + const ThinkingFormatZAI + var AgnesCompat = adapters.AgnesCompat + var AzureCompat = adapters.AzureCompat + var BedrockCompat = adapters.BedrockCompat + var CanopyWaveCompat = adapters.CanopyWaveCompat + var ClinePassCompat = adapters.ClinePassCompat + var CoreProviders = adapters.CoreProviders + var DeepSeekCompat = adapters.DeepSeekCompat + var ErrBudgetExceeded = errors.New("graycode-router: virtual key budget exceeded") + var ErrResultNotVisible = errors.New("graycode-router: batch result row not yet visible") + var ErrUnknownVirtualKey = errors.New("graycode-router: unknown virtual key") + var GeminiCompat = adapters.GeminiCompat + var GrokCompat = adapters.GrokCompat + var GroqCompat = adapters.GroqCompat + var KimiCompat = adapters.KimiCompat + var LongCatCompat = adapters.LongCatCompat + var MiniMaxCompat = adapters.MiniMaxCompat + var OllamaCompat = adapters.OllamaCompat + var OpenAICompat = adapters.OpenAICompat + var OpenAICompatibleProviders = adapters.OpenAICompatibleProviders + var OpenCodeGoCompat = adapters.OpenCodeGoCompat + var OpenGatewayCompat = adapters.OpenGatewayCompat + var OpenRouterCompat = adapters.OpenRouterCompat + var PoolsideCompat = adapters.PoolsideCompat + var StepFunCompat = adapters.StepFunCompat + var Version = "dev" + var VertexCompat = adapters.VertexCompat + var XiaomiCompat = adapters.XiaomiCompat + var ZAICompat = adapters.ZAICompat + func ActualCostUSD(model string, usage *GraycodeRouterUsage) float64 + func AnthropicBaseFromOpenAIV1(openAIBase string) string + func ApplyRedactions(response string, violations []GuardrailViolation) string + func CloseIdleConnections() + func DetectProvider() string + func EffectiveThinkingEnabled(opts core.ChatOptions) *bool + func FormatUsageBar(pct float64, width int) string + func FreezeRegistry() + func IsContextOverflow(err error) bool + func NewPooledHTTPClient(timeout time.Duration) *http.Client + func NormalizeThinkingOptions(opts core.ChatOptions) core.ChatOptions + func ParseCustomHeaders() map[string]string + func ProviderSupportsThinkingToggle(provider string) bool + func RegisterDynamicProvider(name, baseURL, envKey string) error + func ResolveDefaultModel(provider string) string + func ResolveProviderModelEnvOverride(provider string) string + func ResolveRole(roles ModelRoles, role string) string + func ResponseHasContent(resp *GraycodeRouterResponse) bool + func RoleFromContext(ctx context.Context) string + func SaveCassette(c *Cassette, path string) error + func SetVersion(v string) + func ValidateStructuredOutput(response string, schema map[string]interface{}) error + func VirtualKeyFromContext(ctx context.Context) string + func WithRole(ctx context.Context, role string) context.Context + func WithVirtualKey(ctx context.Context, id string) context.Context + type AdaptiveRateLimitConfig struct + HeaderExtractor HeaderExtractor + MaxDelay time.Duration + RPMLimit int + TPMLimit int + ThresholdPercent int + type AdaptiveRateLimitProvider struct + func NewAdaptiveRateLimitProvider(inner Provider, config AdaptiveRateLimitConfig) (*AdaptiveRateLimitProvider, error) + func (a *AdaptiveRateLimitProvider) Chat(ctx context.Context, messages []GraycodeRouterMessage, opts ChatOptions) (*GraycodeRouterResponse, error) + func (a *AdaptiveRateLimitProvider) Name() string + func (a *AdaptiveRateLimitProvider) Ping(ctx context.Context) error + func (a *AdaptiveRateLimitProvider) Status() RateLimitState + func (a *AdaptiveRateLimitProvider) StreamChat(ctx context.Context, messages []GraycodeRouterMessage, opts ChatOptions) (*StreamResult, error) + func (a *AdaptiveRateLimitProvider) UpdateFromHeaders(h http.Header) + type AgnesClient = adapters.AgnesClient + func NewAgnesClient(apiKey, openAIBase string, compat *OpenAICompatConfig, opts ...ClientOption) *AgnesClient + type Alert struct + Level string + Message string + Threshold float64 + Timestamp time.Time + type AnthropicCachedMessage struct + CacheControl interface{} + Content interface{} + Role string + func AddCacheBreakpoints(messages []GraycodeRouterMessage) []AnthropicCachedMessage + type AnthropicClient = adapters.AnthropicClient + func NewAnthropicClient(apiKey, baseURL string, opts ...ClientOption) *AnthropicClient + type AnthropicClientConfig struct + APIKey string + BaseURL string + DefaultHeaders map[string]string + MaxRetries int + Provider string + Timeout int + type AudioClient struct + func NewAudioClient(apiKey, baseURL string) *AudioClient + func (c *AudioClient) Transcribe(ctx context.Context, r TranscriptionRequest) (string, error) + type AzureClient = adapters.AzureClient + func NewAzureClient(apiKey, endpoint, apiVersion string) *AzureClient + type BatchClient struct + func NewBatchClient(apiKey, baseURL string) *BatchClient + func (bc *BatchClient) Poll(ctx context.Context, batchID string) (*BatchResult, error) + func (bc *BatchClient) PollRequestResult(ctx context.Context, batchID, customID string, opts PollOptions) (*BatchRequestResult, error) + func (bc *BatchClient) RequestResults(ctx context.Context, batchID string) ([]BatchRequestResult, error) + func (bc *BatchClient) Submit(ctx context.Context, requests []BatchRequest) (string, error) + func (bc *BatchClient) WaitUntilDone(ctx context.Context, batchID string, opts PollOptions) (*BatchResult, error) + type BatchRequest struct + CustomID string + Messages []GraycodeRouterMessage + Options ChatOptions + type BatchRequestResult struct + CustomID string + Error json.RawMessage + Result json.RawMessage + type BatchResponse struct + CustomID string + Error string + Response *GraycodeRouterResponse + type BatchResult struct + CreatedAt time.Time + ID string + Responses []BatchResponse + Status string + type BedrockClient = adapters.BedrockClient + func NewBedrockClient(accessKeyID, secretAccessKey, sessionToken, region string) *BedrockClient + type BudgetProvider struct + func NewBudgetProvider(inner Provider, store BudgetStore) *BudgetProvider + func (bp *BudgetProvider) Chat(ctx context.Context, messages []GraycodeRouterMessage, opts ChatOptions) (*GraycodeRouterResponse, error) + func (bp *BudgetProvider) Name() string + func (bp *BudgetProvider) Ping(ctx context.Context) error + func (bp *BudgetProvider) StreamChat(ctx context.Context, messages []GraycodeRouterMessage, opts ChatOptions) (*StreamResult, error) + type BudgetStore interface + CheckBudget func(ctx context.Context, virtualKey string, estCostUSD float64) error + RecordUsage func(ctx context.Context, virtualKey string, costUSD float64, ...) error + type CacheAnalytics struct + func NewCacheAnalytics() *CacheAnalytics + func (ca *CacheAnalytics) FormatSummary() string + func (ca *CacheAnalytics) RecordCall(m CallMetrics) + func (ca *CacheAnalytics) Report() CacheReport + type CacheConfig struct + Enabled bool + MaxAge time.Duration + MaxSize int + TemperatureThreshold float64 + func DefaultCacheConfig() CacheConfig + type CacheControlType string + const CacheControlEphemeral + type CacheReport struct + CacheHits int + CacheMisses int + CostSaved float64 + HitRate float64 + LatencySaved time.Duration + TokensSaved int + TotalCalls int + type CacheStatsResult struct + Enabled bool + MaxSize int + Size int + type CachedContent struct + CacheControl interface{} + Text string + Type string + type CachedProvider struct + func NewCachedProvider(inner Provider, cfg CacheConfig) *CachedProvider + func (cp *CachedProvider) CacheStats() CacheStatsResult + func (cp *CachedProvider) Chat(ctx context.Context, messages []GraycodeRouterMessage, opts ChatOptions) (*GraycodeRouterResponse, error) + func (cp *CachedProvider) ClearCache() + func (cp *CachedProvider) Name() string + func (cp *CachedProvider) Ping(ctx context.Context) error + func (cp *CachedProvider) SetEnabled(enabled bool) + func (cp *CachedProvider) StreamChat(ctx context.Context, messages []GraycodeRouterMessage, opts ChatOptions) (*StreamResult, error) + type CallMetrics struct + CacheCreationTokens int + CacheReadTokens int + InputTokens int + LatencyMs int64 + Model string + OutputTokens int + Provider string + Timestamp time.Time + type CallbackProvider struct + func NewCallbackProvider(inner Provider) (*CallbackProvider, error) + func (cp *CallbackProvider) AddCallback(cb ProviderCallback) + func (cp *CallbackProvider) Callbacks() []ProviderCallback + func (cp *CallbackProvider) Chat(ctx context.Context, messages []GraycodeRouterMessage, opts ChatOptions) (*GraycodeRouterResponse, error) + func (cp *CallbackProvider) Inner() Provider + func (cp *CallbackProvider) Name() string + func (cp *CallbackProvider) Ping(ctx context.Context) error + func (cp *CallbackProvider) RemoveCallback(cb ProviderCallback) bool + func (cp *CallbackProvider) SetLogger(l *slog.Logger) + func (cp *CallbackProvider) StreamChat(ctx context.Context, messages []GraycodeRouterMessage, opts ChatOptions) (*StreamResult, error) + type CanopyWaveClient = adapters.CanopyWaveClient + func NewCanopyWaveClient(apiKey, openAIBase string, compat *OpenAICompatConfig, opts ...ClientOption) *CanopyWaveClient + type Cassette struct + Interactions []Interaction + Name string + Provider string + RecordedAt time.Time + func LoadCassette(path string) (*Cassette, error) + type ChatOptions = core.ChatOptions + func ApplyProviderChatDefaults(provider string, opts ChatOptions) ChatOptions + type ClientOption = core.ClientOption + func WithAPIKey(key string) ClientOption + func WithBaseURL(url string) ClientOption + func WithCoalescing(ttl time.Duration) ClientOption + func WithGuardrailType(types ...GuardrailType) ClientOption + func WithGuardrails(rules ...GuardrailRule) ClientOption + func WithHTTPClient(hc *http.Client) ClientOption + func WithLogger(l *slog.Logger) ClientOption + func WithMaxTokens(n int) ClientOption + func WithMimoAuth() ClientOption + func WithModel(model string) ClientOption + func WithProviderName(name string) ClientOption + func WithRetry(rc RetryConfig) ClientOption + func WithStructuredOutput(schema map[string]interface{}, maxRetries int) ClientOption + func WithTemperature(t float64) ClientOption + func WithTimeout(d time.Duration) ClientOption + type ClinePassClient = adapters.ClinePassClient + func NewClinePassClient(apiKey, openAIBase string, compat *OpenAICompatConfig, opts ...ClientOption) *ClinePassClient + type CoalesceKey struct + MaxTokens int + Messages []GraycodeRouterMessage + Model string + Provider string + Temperature *float64 + func (k CoalesceKey) String() string + type Coalescer struct + func NewCoalescer(ttl time.Duration) *Coalescer + func (c *Coalescer) Coalesce(ctx context.Context, key CoalesceKey, ...) (*GraycodeRouterResponse, error) + func (c *Coalescer) Stats() InflightStats + type ConcentrateResponsesClient = adapters.ConcentrateResponsesClient + func NewConcentrateResponsesClient(apiKey, baseURL string, opts ...ClientOption) *ConcentrateResponsesClient + type CondenseOptions struct + KeepFirst int + MaxSize int + type CondenserOption func(*LLMSummarizingCondenser) + func WithCondenserMaxTokens(n int) CondenserOption + func WithCondenserPrompt(prompt string) CondenserOption + func WithCondenserRoles(roles ModelRoles) CondenserOption + type CondensingProvider struct + func NewCondensingProvider(inner Provider, condenser ConversationCondenser, opts CondenseOptions) *CondensingProvider + func (p *CondensingProvider) Chat(ctx context.Context, messages []GraycodeRouterMessage, opts ChatOptions) (*GraycodeRouterResponse, error) + func (p *CondensingProvider) Name() string + func (p *CondensingProvider) Ping(ctx context.Context) error + func (p *CondensingProvider) StreamChat(ctx context.Context, messages []GraycodeRouterMessage, opts ChatOptions) (*StreamResult, error) + type ContentPart = core.ContentPart + type ContinuationConfig = core.ContinuationConfig + func DefaultContinuationConfig() ContinuationConfig + type ConversationCondenser interface + Condense func(ctx context.Context, messages []GraycodeRouterMessage, opts CondenseOptions) ([]GraycodeRouterMessage, error) + type CostEstimate struct + CacheDiscount float64 + InputCostUSD float64 + InputTokens int + Model string + OutputCostUSD float64 + OutputTokens int + TotalCostUSD float64 + type CostEstimator struct + func NewCostEstimator() *CostEstimator + func (ce *CostEstimator) Estimate(messages []GraycodeRouterMessage, model string, maxOutputTokens int) CostEstimate + func (ce *CostEstimator) FormatEstimate(est CostEstimate) string + func (ce *CostEstimator) IsExpensive(est CostEstimate, threshold float64) bool + type DeepSeekClient = adapters.DeepSeekClient + func NewDeepSeekClient(apiKey, openAIBase string, compat *OpenAICompatConfig, opts ...ClientOption) *DeepSeekClient + type DeprecationChecker struct + func NewDeprecationChecker() *DeprecationChecker + func (dc *DeprecationChecker) Check(model string) *DeprecationInfo + func (dc *DeprecationChecker) Warn(model string) + type DeprecationInfo struct + Deprecated bool + Message string + Model string + Replacement string + RetireDate time.Time + type Embedder = embeddings.Embedder + type EmbeddingCachedProvider = embeddings.EmbeddingCachedProvider + func NewEmbeddingCachedProvider(inner Provider, embedder Embedder, cfg SemanticCacheConfig) *EmbeddingCachedProvider + type EmbeddingParams = embeddings.EmbeddingParams + func DefaultEmbeddingParams(model string) EmbeddingParams + type EmbeddingRequest = embeddings.EmbeddingRequest + type EmbeddingResponse = embeddings.EmbeddingResponse + type ExtractOptions struct + AllowedPredicates []string + Chat ChatOptions + Instruction string + MaxRetries int + type FeatureSet struct + AdaptiveThinking bool + Caching bool + Citations bool + CodeExecution bool + Effort bool + Embeddings bool + Images bool + JSON bool + MaxContext int + MaxOutput int + PDFInput bool + Streaming bool + StructuredOutput bool + Thinking bool + ToolUse bool + type GeminiClient = adapters.GeminiClient + func NewGeminiClient(apiKey, baseURL string) *GeminiClient + type GeminiOpenAIClient = adapters.GeminiOpenAIClient + func NewGeminiOpenAIClient(apiKey, openAIBase string, compat *OpenAICompatConfig, opts ...ClientOption) *GeminiOpenAIClient + type GraycodeRouterClient struct + func Client(cfg *GraycodeRouterConfig, opts ...ClientOption) *GraycodeRouterClient + func (c *GraycodeRouterClient) Chat(ctx context.Context, messages []GraycodeRouterMessage, opts ChatOptions) (*GraycodeRouterResponse, error) + func (c *GraycodeRouterClient) ChatWithStructuredOutput(ctx context.Context, messages []GraycodeRouterMessage, opts ChatOptions, ...) (*GraycodeRouterResponse, error) + func (c *GraycodeRouterClient) CreateEmbedding(ctx context.Context, req EmbeddingRequest, provider string) (*EmbeddingResponse, error) + func (c *GraycodeRouterClient) ExtractRelationships(ctx context.Context, text string, opts ExtractOptions) ([]Relationship, error) + func (c *GraycodeRouterClient) GetProviderInfo(provider string) *ProviderRegistryConfig + func (c *GraycodeRouterClient) GetProviders() []string + func (c *GraycodeRouterClient) Ping(ctx context.Context, provider string) error + func (c *GraycodeRouterClient) SetAPIKey(provider, apiKey string) + func (c *GraycodeRouterClient) SetCoalescingTTL(ttl time.Duration) + func (c *GraycodeRouterClient) StreamChat(ctx context.Context, messages []GraycodeRouterMessage, opts ChatOptions) (*StreamResult, error) + func (c *GraycodeRouterClient) StreamChatContinue(ctx context.Context, messages []GraycodeRouterMessage, opts ChatOptions, ...) (*StreamResult, error) + type GraycodeRouterConfig = core.GraycodeRouterConfig + type GraycodeRouterError = core.GraycodeRouterError + type GraycodeRouterMessage = core.GraycodeRouterMessage + func BuildStructuredPrompt(messages []GraycodeRouterMessage, schema map[string]interface{}) []GraycodeRouterMessage + func MergeConsecutiveRoles(messages []GraycodeRouterMessage) []GraycodeRouterMessage + func NewAudioMessage(base64Data, format string) GraycodeRouterMessage + func NewAudioMessageWithText(text, base64Data, format string) GraycodeRouterMessage + func NewBase64ImageMessage(data, mediaType string) GraycodeRouterMessage + func NewBase64ImageMessageWithText(text, data, mediaType string) GraycodeRouterMessage + func NewImageMessage(url string) GraycodeRouterMessage + func NewImageMessageWithText(text, url string) GraycodeRouterMessage + func SanitizeMessages(messages []GraycodeRouterMessage) []GraycodeRouterMessage + type GraycodeRouterResponse = core.GraycodeRouterResponse + func ChatWithContinuation(ctx context.Context, p Provider, messages []GraycodeRouterMessage, ...) (*GraycodeRouterResponse, error) + type GraycodeRouterStreamEvent = core.GraycodeRouterStreamEvent + type GraycodeRouterTool = core.GraycodeRouterTool + type GraycodeRouterUsage = core.GraycodeRouterUsage + type GrokClient = adapters.GrokClient + func NewGrokClient(apiKey, openAIBase string, compat *OpenAICompatConfig, opts ...ClientOption) *GrokClient + type GroqClient = adapters.GroqClient + func NewGroqClient(apiKey, openAIBase string, compat *OpenAICompatConfig, opts ...ClientOption) *GroqClient + type GuardrailAction = core.GuardrailAction + type GuardrailError = core.GuardrailError + type GuardrailProvider struct + func NewGuardrailProvider(inner Provider, g *Guardrails) *GuardrailProvider + func (gp *GuardrailProvider) Chat(ctx context.Context, messages []GraycodeRouterMessage, opts ChatOptions) (*GraycodeRouterResponse, error) + func (gp *GuardrailProvider) Inner() Provider + func (gp *GuardrailProvider) Name() string + func (gp *GuardrailProvider) Ping(ctx context.Context) error + func (gp *GuardrailProvider) StreamChat(ctx context.Context, messages []GraycodeRouterMessage, opts ChatOptions) (*StreamResult, error) + type GuardrailRule = core.GuardrailRule + func AllDefaultRules() []GuardrailRule + func DefaultHarmfulContentRules() []GuardrailRule + func DefaultPIIRules() []GuardrailRule + func DefaultPromptInjectionRules() []GuardrailRule + func DefaultSecretLeakRules() []GuardrailRule + func RulesForType(t GuardrailType) []GuardrailRule + type GuardrailSeverity = core.GuardrailSeverity + type GuardrailType = core.GuardrailType + type GuardrailViolation = core.GuardrailViolation + type Guardrails = core.Guardrails + func NewGuardrails(rules ...GuardrailRule) *Guardrails + func NewGuardrailsSafe(rules ...GuardrailRule) (*Guardrails, error) + type HeaderExtractor func(h http.Header) *RateLimitHeaders + type ImageClient struct + func NewImageClient(apiKey, baseURL string) *ImageClient + func (c *ImageClient) Generate(ctx context.Context, prompt, model, size string, n int) ([][]byte, []string, error) + type ImageGenRequest struct + Model string + N int + Prompt string + ResponseFormat string + Size string + type ImageGenResponse struct + Created int64 + Data []ImageGenResult + type ImageGenResult struct + B64JSON string + RevisedPrompt string + URL string + type ImageURLPart = core.ImageURLPart + type InflightRequest struct + type InflightStats struct + InflightRequests int + TotalWaiters int + type InputAudioPart = core.InputAudioPart + type Interaction struct + Request RecordedRequest + Response RecordedResponse + type KimiClient = adapters.KimiClient + func NewKimiClient(apiKey, openAIBase string, compat *OpenAICompatConfig, opts ...ClientOption) *KimiClient + type LLMSummarizingCondenser struct + func NewLLMSummarizingCondenser(provider Provider, opts ...CondenserOption) *LLMSummarizingCondenser + func (c *LLMSummarizingCondenser) Condense(ctx context.Context, messages []GraycodeRouterMessage, opts CondenseOptions) ([]GraycodeRouterMessage, error) + type LazyProvider struct + func NewLazyProvider(cfg *GraycodeRouterConfig) *LazyProvider + func (p *LazyProvider) Chat(ctx context.Context, messages []GraycodeRouterMessage, opts ChatOptions) (*GraycodeRouterResponse, error) + func (p *LazyProvider) Name() string + func (p *LazyProvider) Ping(ctx context.Context) error + func (p *LazyProvider) SetAPIKey(provider, apiKey string) + func (p *LazyProvider) StreamChat(ctx context.Context, messages []GraycodeRouterMessage, opts ChatOptions) (*StreamResult, error) + type LongCatClient = adapters.LongCatClient + func NewLongCatClient(apiKey, openAIBase, anthropicBase string, compat *OpenAICompatConfig, ...) *LongCatClient + type MemoryBudgetStore struct + func NewMemoryBudgetStore() *MemoryBudgetStore + func (s *MemoryBudgetStore) CheckBudget(_ context.Context, virtualKey string, estCostUSD float64) error + func (s *MemoryBudgetStore) RecordUsage(_ context.Context, virtualKey string, costUSD float64, tokensIn, tokensOut int) error + func (s *MemoryBudgetStore) SetBudget(virtualKey string, limitUSD float64) + func (s *MemoryBudgetStore) Usage(virtualKey string) (usedUSD float64, tokensIn, tokensOut int, ok bool) + type MetricsCollector struct + func NewMetricsCollector() *MetricsCollector + func (mc *MetricsCollector) Recent(n int) []CallMetrics + func (mc *MetricsCollector) Record(m CallMetrics) + func (mc *MetricsCollector) TotalCost() float64 + type MiMoClient = adapters.MiMoClient + func NewMiMoClient(apiKey, openAIBase string, compat *OpenAICompatConfig, providerID string, ...) *MiMoClient + type MiniMaxClient = adapters.MiniMaxClient + func NewMiniMaxClient(apiKey, openAIBase string, compat *OpenAICompatConfig, opts ...ClientOption) *MiniMaxClient + type MockCall struct + Messages []GraycodeRouterMessage + Options ChatOptions + type MockMode string + const MockModeEcho + const MockModeError + const MockModeFixed + const MockModeMaxTokens + const MockModeToolUse + type MockProvider struct + Calls []MockCall + Delay time.Duration + Mode MockMode + Response string + ToolArgs map[string]interface{} + ToolName string + func NewMockProvider(mode MockMode) *MockProvider + func (m *MockProvider) CallCount() int + func (m *MockProvider) Chat(ctx context.Context, messages []GraycodeRouterMessage, opts ChatOptions) (*GraycodeRouterResponse, error) + func (m *MockProvider) LastCall() *MockCall + func (m *MockProvider) MarshalCalls() string + func (m *MockProvider) Name() string + func (m *MockProvider) Ping(_ context.Context) error + func (m *MockProvider) Reset() + func (m *MockProvider) StreamChat(ctx context.Context, messages []GraycodeRouterMessage, opts ChatOptions) (*StreamResult, error) + type ModelRoles struct + Editor string + Primary string + Weak string + type ModerationOption func(*ModerationProvider) + func WithBlockedPatterns(patterns []string) ModerationOption + func WithCustomChecker(fn func(string) error) ModerationOption + func WithModerationMaxTokens(n int) ModerationOption + type ModerationProvider struct + func NewModerationProvider(inner Provider, opts ...ModerationOption) *ModerationProvider + func (mp *ModerationProvider) Chat(ctx context.Context, messages []GraycodeRouterMessage, opts ChatOptions) (*GraycodeRouterResponse, error) + func (mp *ModerationProvider) Name() string + func (mp *ModerationProvider) Ping(ctx context.Context) error + func (mp *ModerationProvider) StreamChat(ctx context.Context, messages []GraycodeRouterMessage, opts ChatOptions) (*StreamResult, error) + type OllamaClient = adapters.OllamaClient + func NewOllamaClient(apiKey, openAIBase string, compat *OpenAICompatConfig, opts ...ClientOption) *OllamaClient + type OpenAIClient = adapters.OpenAIClient + func NewOpenAIClient(apiKey, baseURL string, compat *OpenAICompatConfig, opts ...ClientOption) *OpenAIClient + type OpenAICompatConfig = adapters.OpenAICompatConfig + type OpenCodeGoClient = adapters.OpenCodeGoClient + func NewOpenCodeGoClient(apiKey, baseURL string, opts ...ClientOption) *OpenCodeGoClient + type OpenGatewayClient = adapters.OpenGatewayClient + func NewOpenGatewayClient(apiKey, openAIBase string, compat *OpenAICompatConfig, opts ...ClientOption) *OpenGatewayClient + type OpenRouterClient = adapters.OpenRouterClient + func NewOpenRouterClient(apiKey, openAIBase string, compat *OpenAICompatConfig, opts ...ClientOption) *OpenRouterClient + type PollOptions struct + InitialInterval time.Duration + JitterFraction float64 + MaxInterval time.Duration + Timeout time.Duration + type PoolsideClient = adapters.PoolsideClient + func NewPoolsideClient(apiKey, baseURL string, opts ...ClientOption) *PoolsideClient + type PromptOptimizer struct + func NewPromptOptimizer(maxInputTokens int) *PromptOptimizer + func (po *PromptOptimizer) Optimize(messages []GraycodeRouterMessage) []GraycodeRouterMessage + type ProtocolRouter = adapters.ProtocolRouter + type ProtocolStreamConfig = adapters.ProtocolStreamConfig + type Provider = core.Provider + func WithRateLimit(p Provider, limiter *RateLimiter) Provider + type ProviderCallback interface + OnError func(ctx context.Context, provider string, model string, err error, ...) + OnRequest func(ctx context.Context, provider string, model string, ...) + OnResponse func(ctx context.Context, provider string, model string, ...) + OnStreamEvent func(ctx context.Context, provider string, model string, ...) + type ProviderFeatures struct + func NewProviderFeatures() *ProviderFeatures + func (pf *ProviderFeatures) Get(provider string) FeatureSet + func (pf *ProviderFeatures) Supports(provider, feature string) bool + type ProviderHealth struct + func NewProviderHealth() *ProviderHealth + func (ph *ProviderHealth) AllScores() []ProviderScore + func (ph *ProviderHealth) Healthiest(candidates []string) string + func (ph *ProviderHealth) RecordFailure(provider string, latency time.Duration) + func (ph *ProviderHealth) RecordSuccess(provider string, latency time.Duration) + func (ph *ProviderHealth) Score(provider string) float64 + type ProviderRegistryConfig = adapters.ProviderRegistryConfig + type ProviderScore struct + AvgLatencyMs int64 + ErrorRate float64 + IsHealthy bool + Name string + Score float64 + type ProviderType = adapters.ProviderType + type RateLimitConfig struct + BurstSize int + MinInterval time.Duration + RequestsPerMinute int + type RateLimitHeaders struct + RequestsLimit int + RequestsRemaining int + ResetTime time.Time + TokensLimit int + TokensRemaining int + func CommonHeaderExtractor(h http.Header) *RateLimitHeaders + type RateLimitState struct + LastUpdated time.Time + RPMLimit int + RPMRemaining int + RPMResetAt time.Time + RPMUsed int + TPMLimit int + TPMRemaining int + TPMResetAt time.Time + TPMUsed int + ThrottleCount int64 + TotalRequests int64 + TotalTokens int64 + type RateLimitedProvider struct + func (r *RateLimitedProvider) Chat(ctx context.Context, messages []GraycodeRouterMessage, opts ChatOptions) (*GraycodeRouterResponse, error) + func (r *RateLimitedProvider) Name() string + func (r *RateLimitedProvider) Ping(ctx context.Context) error + func (r *RateLimitedProvider) StreamChat(ctx context.Context, messages []GraycodeRouterMessage, opts ChatOptions) (*StreamResult, error) + type RateLimiter struct + func NewRateLimiter(defaults RateLimitConfig) *RateLimiter + func (rl *RateLimiter) SetProviderLimit(provider string, cfg RateLimitConfig) + func (rl *RateLimiter) Wait(ctx context.Context, provider string) error + type RecordedRequest struct + Hash string + Messages []GraycodeRouterMessage + Model string + System string + type RecordedResponse struct + Content string + Error string + FinishReason string + ToolCalls []ToolCall + Usage *GraycodeRouterUsage + type RecorderMode string + const RecordModeAuto + const RecordModeRecord + const RecordModeReplay + type RecorderProvider struct + func NewRecorderProvider(inner Provider, cassettePath string, mode RecorderMode) (*RecorderProvider, error) + func (r *RecorderProvider) Chat(ctx context.Context, messages []GraycodeRouterMessage, opts ChatOptions) (*GraycodeRouterResponse, error) + func (r *RecorderProvider) Name() string + func (r *RecorderProvider) Ping(ctx context.Context) error + func (r *RecorderProvider) Save() error + func (r *RecorderProvider) SetRedactor(fn func(string) string) + func (r *RecorderProvider) StreamChat(ctx context.Context, messages []GraycodeRouterMessage, opts ChatOptions) (*StreamResult, error) + type Relationship struct + Object string + Predicate string + Subject string + type RepeatDetector = core.RepeatDetector + func DefaultRepeatDetector() *RepeatDetector + type RequestLogEntry struct + CacheHit bool + Error string + InputTokens int + LatencyMs int64 + Model string + OutputTokens int + Provider string + Status string + Timestamp time.Time + type RequestLogger struct + func NewRequestLogger(enabled bool) *RequestLogger + func (rl *RequestLogger) Log(entry RequestLogEntry) + func (rl *RequestLogger) Recent(n int) []RequestLogEntry + func (rl *RequestLogger) Summary() string + type ResponseFormat = core.ResponseFormat + type ResponseHealth = core.ResponseHealth + func DetectResponseHealth(sig ResponseSignals) ResponseHealth + type ResponseSignals = core.ResponseSignals + type RetryConfig = core.RetryConfig + func DefaultRetryConfig() RetryConfig + func NewRetryConfig(maxRetries int, baseDelay, maxDelay time.Duration, retryOn ...int) RetryConfig + type RoleRouter struct + func NewRoleRouter(inner Provider, roles ModelRoles) (*RoleRouter, error) + func (r *RoleRouter) Chat(ctx context.Context, messages []GraycodeRouterMessage, opts ChatOptions) (*GraycodeRouterResponse, error) + func (r *RoleRouter) Name() string + func (r *RoleRouter) Ping(ctx context.Context) error + func (r *RoleRouter) StreamChat(ctx context.Context, messages []GraycodeRouterMessage, opts ChatOptions) (*StreamResult, error) + type SSEEvent = core.SSEEvent + type SchemaValidation struct + MaxRetries int + Schema map[string]interface{} + StrictMode bool + type SemanticCacheConfig = embeddings.SemanticCacheConfig + func DefaultSemanticCacheConfig() SemanticCacheConfig + type SemanticCacheStats = embeddings.SemanticCacheStats + type StepFunClient = adapters.StepFunClient + func NewStepFunClient(apiKey, openAIBase string, compat *OpenAICompatConfig, opts ...ClientOption) *StepFunClient + type StreamGuardrailConfig = core.StreamGuardrailConfig + type StreamGuardrailResult = core.StreamGuardrailResult + type StreamGuardrails = core.StreamGuardrails + func NewStreamGuardrails(g *Guardrails, config StreamGuardrailConfig) *StreamGuardrails + type StreamMerger struct + IndexFields []string + StreamFields []string + func DefaultStreamMerger() *StreamMerger + func NewStreamMerger(streamFields, indexFields []string) *StreamMerger + func (m *StreamMerger) Merge(delta map[string]interface{}) map[string]interface{} + func (m *StreamMerger) Result() map[string]interface{} + type StreamResult = core.StreamResult + func NewStreamResult(events <-chan GraycodeRouterStreamEvent, cancel context.CancelFunc) *StreamResult + func NewStreamResultWithRequestID(events <-chan GraycodeRouterStreamEvent, requestID string, ...) *StreamResult + func StreamChatWithContinuation(ctx context.Context, p Provider, messages []GraycodeRouterMessage, ...) (*StreamResult, error) + type StreamingTokenCounter struct + func NewStreamingTokenCounter(model string, inputTokens int) *StreamingTokenCounter + func (stc *StreamingTokenCounter) AddCached(tokens int) + func (stc *StreamingTokenCounter) AddOutput(text string) + func (stc *StreamingTokenCounter) CurrentCost() float64 + func (stc *StreamingTokenCounter) Summary() string + type StructuredOutputError struct + Attempt int + Response string + ValidationErr error + func (e *StructuredOutputError) Error() string + type TokenCountResult = adapters.TokenCountResult + type ToolCall = core.ToolCall + func ParseInlineToolCalls(text string) (string, []ToolCall) + type ToolChoiceOption = core.ToolChoiceOption + type ToolResult = core.ToolResult + type TracingProvider struct + func NewTracingProvider(inner Provider) *TracingProvider + func (tp *TracingProvider) Chat(ctx context.Context, messages []GraycodeRouterMessage, opts ChatOptions) (*GraycodeRouterResponse, error) + func (tp *TracingProvider) Name() string + func (tp *TracingProvider) Ping(ctx context.Context) error + func (tp *TracingProvider) StreamChat(ctx context.Context, messages []GraycodeRouterMessage, opts ChatOptions) (*StreamResult, error) + type Transcript struct + Text string + type TranscriptionRequest struct + File []byte + FileName string + Language string + Model string + Prompt string + type UsageEntry struct + CostUSD float64 + Model string + Provider string + Timestamp time.Time + Tokens int + type UsageLimitProvider struct + func NewUsageLimitProvider(inner Provider, tracker *UsageTracker) (*UsageLimitProvider, error) + func (u *UsageLimitProvider) Chat(ctx context.Context, messages []GraycodeRouterMessage, opts ChatOptions) (*GraycodeRouterResponse, error) + func (u *UsageLimitProvider) Name() string + func (u *UsageLimitProvider) Ping(ctx context.Context) error + func (u *UsageLimitProvider) StreamChat(ctx context.Context, messages []GraycodeRouterMessage, opts ChatOptions) (*StreamResult, error) + func (u *UsageLimitProvider) Tracker() *UsageTracker + type UsageSummary struct + CostRemaining float64 + DailyCostUSD float64 + DailyPct float64 + DailyRemaining int + DailyTokens int + HourlyPct float64 + HourlyRemaining int + HourlyTokens int + SessionRemaining int + SessionTokens int + type UsageTracker struct + Alerts []Alert + CostLimitUSD float64 + DailyLimit int + HourlyLimit int + SessionLimit int + func NewUsageTracker() *UsageTracker + func (u *UsageTracker) CanProceed() (bool, string) + func (u *UsageTracker) CheckThresholds() + func (u *UsageTracker) EstimateRemaining(tokensPerRequest int) int + func (u *UsageTracker) FormatSummary() string + func (u *UsageTracker) GetUsage() UsageSummary + func (u *UsageTracker) PruneOld() + func (u *UsageTracker) Record(tokens int, costUSD float64, provider, model string) + func (u *UsageTracker) Reset() + type VertexClient = adapters.VertexClient + func NewVertexClient(projectID, region, token string) *VertexClient + type ZAIClient = adapters.ZAIClient + func NewZAIClient(apiKey, openAIBase, anthropicBase string, compat *OpenAICompatConfig, ...) *ZAIClient