protocol

package
v1.3.9 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

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 GetAnthropicModels

func GetAnthropicModels(baseURL, key string) (string, error)

func GetAnthropicModelsWithAuth added in v1.2.5

func GetAnthropicModelsWithAuth(baseURL, key, authStyle string) (string, error)

GetAnthropicModelsWithAuth fetches Anthropic-compatible models using either the official x-api-key header or a Bearer token used by some routers.

func GetOpenAIModels

func GetOpenAIModels(baseURL, apiKey string) (string, error)

GetOpenAIModels fetches the comma-separated model IDs from an OpenAI-compatible /models endpoint.

func InvalidCodexV1EndpointSuggestion added in v1.3.1

func InvalidCodexV1EndpointSuggestion(endpoint string) (string, bool)

InvalidCodexV1EndpointSuggestion identifies a user-supplied Codex generation endpoint ending in /codex/v1 and returns the base endpoint the user should enter instead. ccl reports this suggestion but never rewrites the setting.

func IsCodexBaseEndpoint added in v1.3.1

func IsCodexBaseEndpoint(baseURL string) bool

IsCodexBaseEndpoint reports whether baseURL points at a dedicated Codex base path such as https://example.com/codex. Model discovery is performed at the corresponding /codex/models endpoint without rewriting the configured base.

func NormalizeAnthropicBaseURLForClaude added in v1.2.5

func NormalizeAnthropicBaseURLForClaude(baseURL string) string

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 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 ProbeOpenAIResponsesSupport added in v1.2.4

func ProbeOpenAIResponsesSupport(endpoint, apiKey, model string, timeout time.Duration) bool

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.

func ProbeOpenAIResponsesSupportContext added in v1.3.0

func ProbeOpenAIResponsesSupportContext(parent context.Context, endpoint, apiKey, model string, timeout time.Duration) bool

ProbeOpenAIResponsesSupportContext is ProbeOpenAIResponsesSupport with caller-controlled cancellation.

Types

type AnthropicModelResponse

type AnthropicModelResponse struct {
	Data []struct {
		CreatedAt   time.Time `json:"created_at"`
		DisplayName string    `json:"display_name"`
		Id          string    `json:"id"`
		Type        string    `json:"type"`
	} `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
	ContextWindow int
}

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 GetOpenAIModelInfos added in v1.3.5

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

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 (CLIProxyAPI / OpenAI-style catalogs).

Jump to

Keyboard shortcuts

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