Documentation
¶
Index ¶
- Variables
- func ApplyAnthropicModelTransform(req interface{}, model string) interface{}
- func ApplyCodexResponsesTransform(req *responses.ResponseNewParams, originalRequest interface{}) *responses.ResponseNewParams
- func ApplyCodexTransform(anthropicReq *anthropic.BetaMessageNewParams, ...) *responses.ResponseNewParams
- func ApplyProviderTransforms(req *openai.ChatCompletionNewParams, providerURL, model string, ...) *openai.ChatCompletionNewParams
- func ApplyResponseTransforms(resp map[string]interface{}, providerURL, model string) map[string]interface{}
- func MessageToMap(msg openai.ChatCompletionMessageParamUnion) (map[string]interface{}, error)
- type ProviderTransform
- type ResponseTransform
Constants ¶
This section is empty.
Variables ¶
var ProviderConfigs = []providerConfig{
{
APIBasePattern: "api.deepseek.com",
ModelPattern: "*",
Transform: applyDeepSeekTransform,
},
{
APIBasePattern: "api.moonshot.cn",
ModelPattern: "*",
Transform: applyDeepSeekTransform,
},
{
APIBasePattern: "api.moonshot.ai",
ModelPattern: "*",
Transform: applyDeepSeekTransform,
},
{
APIBasePattern: "generativelanguage.googleapis.com",
ModelPattern: "gemini",
Transform: applyGeminiTransform,
},
{
APIBasePattern: "poe.com",
ModelPattern: "gemini",
Transform: applyGeminiPoeTransform,
},
}
ProviderConfigs holds all registered provider configurations Add new providers here with their APIBase domain patterns
var ResponseConfigs = []responseConfig{
{"api.deepseek.com", applyDeepSeekResponseTransform},
}
ResponseConfigs holds all registered provider response configurations
Functions ¶
func ApplyAnthropicModelTransform ¶ added in v0.260324.0
func ApplyAnthropicModelTransform(req interface{}, model string) interface{}
ApplyAnthropicModelTransform applies Anthropic API provider-specific model filtering. This handles model-specific limitations such as adaptive thinking only being supported by Claude Opus 4.6 (claude-opus-4-6) and Claude Sonnet 4.6 (claude-sonnet-4-6).
Parameters:
- req: The request to transform (can be *anthropic.MessageNewParams or *anthropic.BetaMessageNewParams)
- model: The target model name
Returns the transformed request (same type as input).
Note: This applies to ALL Anthropic API requests, regardless of authentication method (API key or OAuth token). The limitation is in the Anthropic API itself, not the auth method.
func ApplyCodexResponsesTransform ¶
func ApplyCodexResponsesTransform(req *responses.ResponseNewParams, originalRequest interface{}) *responses.ResponseNewParams
ApplyCodexResponsesTransform applies Codex-specific transformations to a Responses API request. This is called from VendorTransform for Codex backend providers.
It handles:
- Stream configuration (always enabled for Codex)
- Reasoning config (converts Anthropic "thinking" to Codex "reasoning")
- Tool name shortening (64 char limit)
- Tool parameter normalization
- Special tool mappings (web_search_20250305 -> web_search)
Reference: ref/anthropic2codex.go.ref
func ApplyCodexTransform ¶
func ApplyCodexTransform(anthropicReq *anthropic.BetaMessageNewParams, responsesReq *responses.ResponseNewParams) *responses.ResponseNewParams
ApplyCodexTransform applies Codex-specific transformations to a Responses API request. This is a backward-compatible wrapper for the server-level call. Deprecated: Use ApplyCodexResponsesTransform with TransformContext instead.
func ApplyProviderTransforms ¶
func ApplyProviderTransforms(req *openai.ChatCompletionNewParams, providerURL, model string, config *protocol.OpenAIConfig) *openai.ChatCompletionNewParams
ApplyProviderTransforms applies provider-specific transformations Falls back to default handling if no specific transform found
func ApplyResponseTransforms ¶
func ApplyResponseTransforms(resp map[string]interface{}, providerURL, model string) map[string]interface{}
ApplyResponseTransforms applies provider-specific transformations to responses
func MessageToMap ¶
func MessageToMap(msg openai.ChatCompletionMessageParamUnion) (map[string]interface{}, error)
MessageToMap converts a ChatCompletionMessageParamUnion to a map for modification
Types ¶
type ProviderTransform ¶
type ProviderTransform func(*openai.ChatCompletionNewParams, string, string, *protocol.OpenAIConfig) *openai.ChatCompletionNewParams
ProviderTransform applies provider-specific transformations to OpenAI requests
func GetProviderTransform ¶
func GetProviderTransform(providerURL, model string) ProviderTransform
GetProviderTransform identifies provider by APIBase URL string and returns its transform Returns nil if no specific transform is needed (fallback to default)
type ResponseTransform ¶
ResponseTransform applies provider-specific transformations to OpenAI responses
func GetResponseTransform ¶
func GetResponseTransform(providerURL string) ResponseTransform
GetResponseTransform identifies provider by APIBase URL and returns its response transform