Documentation
¶
Index ¶
- func ContextWindowSuggests1M(window int) bool
- func GetAnthropicModels(baseURL, key string) (string, error)
- func GetAnthropicModelsWithAuth(baseURL, key, authStyle string) (string, error)
- func GetOpenAIModels(baseURL, apiKey string) (string, error)
- func NormalizeAnthropicBaseURLForClaude(baseURL string) string
- func NormalizeAnthropicMessagesURL(baseURL string) string
- func NormalizeAnthropicModelsURL(baseURL string) string
- func NormalizeOpenAIChatCompletionsURL(baseURL string) string
- func NormalizeOpenAIModelsURL(baseURL string) string
- func NormalizeOpenAIResponsesURL(baseURL string) string
- func ProbeOpenAIResponsesStatusContext(parent context.Context, endpoint, apiKey, model string, timeout time.Duration) (int, error)
- func ProbeOpenAIResponsesSupport(endpoint, apiKey, model string, timeout time.Duration) bool
- func ProbeOpenAIResponsesSupportContext(parent context.Context, endpoint, apiKey, model string, timeout time.Duration) bool
- type AnthropicModel
- type AnthropicModelResponse
- type ModelInfo
- type ModelResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextWindowSuggests1M ¶ added in v1.3.5
ContextWindowSuggests1M reports whether a catalog context_window looks like a 1M-class window. Values are advisory suggestions only.
func GetAnthropicModels ¶
func GetAnthropicModelsWithAuth ¶ added in v1.2.5
GetAnthropicModelsWithAuth fetches Anthropic-compatible models using either the official x-api-key header or a Bearer token used by some routers.
func GetOpenAIModels ¶
GetOpenAIModels fetches the comma-separated model IDs from an OpenAI-compatible /models endpoint.
func NormalizeAnthropicBaseURLForClaude ¶ added in v1.2.5
NormalizeAnthropicBaseURLForClaude returns the base URL shape expected by Claude Code's Anthropic client. Claude appends /v1/messages itself, so a configured endpoint ending in /v1, /v1/messages, or /v1/models would otherwise become /v1/v1/messages at runtime.
func NormalizeAnthropicMessagesURL ¶ added in v1.2.4
func NormalizeAnthropicModelsURL ¶ added in v1.2.4
func NormalizeOpenAIChatCompletionsURL ¶ added in v1.2.4
func NormalizeOpenAIModelsURL ¶ added in v1.2.4
func NormalizeOpenAIResponsesURL ¶ added in v1.2.4
func ProbeOpenAIResponsesStatusContext ¶ added in v1.5.3
func ProbeOpenAIResponsesStatusContext(parent context.Context, endpoint, apiKey, model string, timeout time.Duration) (int, error)
ProbeOpenAIResponsesStatusContext is ProbeOpenAIResponsesSupportContext but reports the upstream HTTP status code (0 on transport error) instead of a boolean. Callers that need to distinguish an auth rejection (401/403) from a valid key with a model/parameter/rate-limit problem use this variant.
func ProbeOpenAIResponsesSupport ¶ added in v1.2.4
ProbeOpenAIResponsesSupport sends a minimal, real generation request to the /v1/responses endpoint to determine whether an OpenAI-compatible gateway implements the newer Responses API ("openai(responses)") as opposed to only the legacy Chat Completions API ("openai(chat)"). Listing models alone (/v1/models) cannot distinguish these two, since both protocols commonly share the same model catalog — an actual call to /v1/responses is required. Returns true only when the upstream responds with a 2xx status.
Types ¶
type AnthropicModel ¶ added in v1.4.0
type AnthropicModel struct {
CreatedAt time.Time `json:"created_at"`
DisplayName string `json:"display_name"`
ID string `json:"id"`
Type string `json:"type"`
MaxInputTokens int `json:"max_input_tokens,omitempty"`
MaxOutputTokens int `json:"max_output_tokens,omitempty"`
RateMultiplier *float64 `json:"rate_multiplier,omitempty"`
RateUnit string `json:"rate_unit,omitempty"`
IsNew bool `json:"is_new,omitempty"`
PromotionAvailable bool `json:"promotion_available,omitempty"`
}
type AnthropicModelResponse ¶
type AnthropicModelResponse struct {
Data []AnthropicModel `json:"data"`
FirstId string `json:"firstId"`
HasMore bool `json:"hasMore"`
LastId string `json:"lastId"`
}
AnthropicModelResponse is the Anthropic-compatible /v1/models list payload.
type ModelInfo ¶ added in v1.3.5
type ModelInfo struct {
ID string
DisplayName string
ContextWindow int
MaxOutputTokens int
RateMultiplier *float64
RateUnit string
IsNew bool
PromotionAvailable bool
}
ModelInfo is one entry from an OpenAI-compatible /models response. ContextWindow is advisory only — third-party catalogs are often wrong or missing; callers must not treat a reported 1M window as a guarantee.
func GetAnthropicModelInfosWithAuth ¶ added in v1.4.0
GetAnthropicModelInfosWithAuth fetches model IDs and optional display, token-limit, rate, and catalog badge metadata from an Anthropic-compatible /v1/models endpoint. Unknown extension fields remain safely ignored.
func GetCodexClientModelInfos ¶ added in v1.3.16
GetCodexClientModelInfos reads the Codex-flavoured model catalog exposed by the upstream /v1/models?client_version=… endpoint.
This matters for subscription (OAuth) providers: the plain OpenAI list is trimmed to id/object/created/owned_by, so it never reveals a context window, while the Codex catalog reports the window the backend advertises for the account. Values remain advisory — the server may still enforce less.
func GetOpenAIModelInfos ¶ added in v1.3.5
GetOpenAIModelInfos fetches model IDs and optional context_window metadata.
type ModelResponse ¶
type ModelResponse struct {
Data []struct {
Created int `json:"created"`
Domain string `json:"domain"`
Features struct {
StructuredOutputs struct {
JsonObject bool `json:"json_object"`
JsonSchema bool `json:"json_schema"`
} `json:"structured_outputs,omitempty"`
Tools struct {
FunctionCalling bool `json:"function_calling"`
} `json:"tools,omitempty"`
Batch struct {
BatchChat bool `json:"batch_chat"`
BatchJob bool `json:"batch_job"`
} `json:"batch,omitempty"`
Cache struct {
PrefixCache bool `json:"prefix_cache"`
SessionCache bool `json:"session_cache"`
} `json:"cache,omitempty"`
} `json:"features"`
Id string `json:"id"`
Name string `json:"name"`
Object string `json:"object"`
Status string `json:"status,omitempty"`
Version string `json:"version"`
ContextWindow int `json:"context_window,omitempty"`
Modalities struct {
InputModalities []string `json:"input_modalities,omitempty"`
OutputModalities []string `json:"output_modalities,omitempty"`
} `json:"modalities,omitempty"`
TaskType []string `json:"task_type,omitempty"`
TokenLimits struct {
ContextWindow int `json:"context_window,omitempty"`
MaxInputTokenLength int `json:"max_input_token_length,omitempty"`
MaxOutputTokenLength int `json:"max_output_token_length,omitempty"`
MaxReasoningTokenLength int `json:"max_reasoning_token_length,omitempty"`
} `json:"token_limits,omitempty"`
} `json:"data"`
Object string `json:"object"`
}
ModelResponse is the OpenAI-compatible /models list payload. Context windows appear either nested under token_limits (some gateways) or as a top-level context_window (Codex / OpenAI-style catalogs).