protocol

package
v1.7.17 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const GPTDefaultReasoningLevel = "low"

GPTDefaultReasoningLevel is the picker default on GPT flagship models such as gpt-6.1-sol. Callers that invent a ladder use this instead of medium.

Variables

This section is empty.

Functions

func ContextWindowSuggests1M added in v1.3.5

func ContextWindowSuggests1M(window int) bool

ContextWindowSuggests1M reports whether a catalog context_window looks like a 1M-class window. Values are advisory suggestions only.

func GetOpenAIModelsContext added in v1.5.13

func GetOpenAIModelsContext(ctx context.Context, baseURL, apiKey string) (string, error)

GetOpenAIModelsContext is GetOpenAIModels with caller-controlled cancellation.

func NormalizeAnthropicBaseURLForClaude added in v1.2.5

func NormalizeAnthropicBaseURLForClaude(baseURL string) string

NormalizeAnthropicBaseURLForClaude removes the suffix Claude appends itself.

func NormalizeAnthropicMessagesURL added in v1.2.4

func NormalizeAnthropicMessagesURL(baseURL string) string

func NormalizeAnthropicModelsURL added in v1.2.4

func NormalizeAnthropicModelsURL(baseURL string) string

func NormalizeOpenAIChatCompletionsURL added in v1.2.4

func NormalizeOpenAIChatCompletionsURL(baseURL string) string

func NormalizeOpenAIModelsURL added in v1.2.4

func NormalizeOpenAIModelsURL(baseURL string) string

func NormalizeOpenAIResponsesURL added in v1.2.4

func NormalizeOpenAIResponsesURL(baseURL string) string

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.

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
	InputModalities       []string
	RateMultiplier        *float64
	RateUnit              string
	IsNew                 bool
	PromotionAvailable    bool
	ReasoningLevels       []ReasoningLevel
	DefaultReasoningLevel string
	// ReasoningKnown distinguishes an authoritative empty effort list from
	// missing metadata, so compatibility defaults do not invent controls.
	ReasoningKnown 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

func GetAnthropicModelInfosWithAuth(baseURL, key, authStyle string) ([]ModelInfo, error)

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 GetAnthropicModelInfosWithAuthContext added in v1.5.21

func GetAnthropicModelInfosWithAuthContext(ctx context.Context, baseURL, key, authStyle string) ([]ModelInfo, error)

func GetCodexClientModelInfos added in v1.3.16

func GetCodexClientModelInfos(baseURL, apiKey string) ([]ModelInfo, error)

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

func GetOpenAIModelInfos(baseURL, apiKey string) ([]ModelInfo, error)

GetOpenAIModelInfos fetches model IDs and optional context_window metadata.

func GetOpenAIModelInfosContext added in v1.5.13

func GetOpenAIModelInfosContext(ctx context.Context, baseURL, apiKey string) ([]ModelInfo, error)

GetOpenAIModelInfosContext is GetOpenAIModelInfos with caller-controlled cancellation.

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"`
		InputModalities       []string         `json:"input_modalities,omitempty"`
		SupportedInputTypes   []string         `json:"supported_input_types,omitempty"`
		ReasoningLevels       []ReasoningLevel `json:"supported_reasoning_levels,omitempty"`
		DefaultReasoningLevel string           `json:"default_reasoning_level,omitempty"`
		// Anthropic-shaped extensions some Anthropic-compatible gateways and
		// CCL runtimes publish alongside the OpenAI list fields.
		RateMultiplier     *float64 `json:"rate_multiplier,omitempty"`
		RateUnit           string   `json:"rate_unit,omitempty"`
		IsNew              bool     `json:"is_new,omitempty"`
		PromotionAvailable bool     `json:"promotion_available,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).

type ReasoningLevel added in v1.7.17

type ReasoningLevel struct {
	Effort      string `json:"effort"`
	Description string `json:"description"`
}

ReasoningLevel uses the Codex model-catalog shape so a runtime can retain upstream capability metadata without inferring it from a model's name.

func ChatReasoningLevels added in v1.7.17

func ChatReasoningLevels() []ReasoningLevel

ChatReasoningLevels are the standard Chat Completions effort controls for a backend that explicitly advertises supportsReasoning.

func GPTReasoningLevels added in v1.7.17

func GPTReasoningLevels() []ReasoningLevel

GPTReasoningLevels is the six-rung effort ladder GPT flagship models advertise, in desktop slider order. Descriptions match that catalog. Each call returns a new slice.

Jump to

Keyboard shortcuts

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