Skip to content

Commit 995b00c

Browse files
committed
Use ChatCompletionAnthropicSchema for anthropic provider override
Fixes negative prompt_tokens when Anthropic models are proxied through ChatCompletion format with additive cache token semantics.
1 parent 6da7f3e commit 995b00c

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/OpenRouterCLIProxyAPI.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module OpenRouterCLIProxyAPI
22

33
using OpenRouter
4-
using OpenRouter: add_provider, set_provider!, ChatCompletionSchema, AnthropicSchema, ProviderEndpoint,
5-
get_global_cache, Pricing, ZERO_PRICING
4+
using OpenRouter: add_provider, set_provider!, ChatCompletionSchema, ChatCompletionAnthropicSchema,
5+
AnthropicSchema, ProviderEndpoint, get_global_cache, Pricing, ZERO_PRICING
66

77
export inject_cli_proxy_endpoints!, cli_proxy_model_transform, setup_cli_proxy!
88
export MODEL_MAP, MODEL_MAP_REVERSE
@@ -108,6 +108,7 @@ end
108108
Override anthropic and openai providers to route through cli_proxy_api.
109109
"""
110110
function override_providers!(base_url::String, api_key_env_var::String)
111+
schemas = Dict("anthropic" => ChatCompletionAnthropicSchema(), "openai" => ChatCompletionSchema())
111112
for name in ("anthropic", "openai")
112113
set_provider!(
113114
name,
@@ -116,7 +117,7 @@ function override_providers!(base_url::String, api_key_env_var::String)
116117
api_key_env_var,
117118
Dict{String,String}(),
118119
cli_proxy_model_transform,
119-
ChatCompletionSchema(),
120+
schemas[name],
120121
"$name (overridden to cli_proxy_api)"
121122
)
122123
end

0 commit comments

Comments
 (0)