11module OpenRouterCLIProxyAPI
22
3+ using Dates: now
34using OpenRouter
45using OpenRouter: add_provider, set_provider!, ChatCompletionSchema, ChatCompletionAnthropicSchema,
5- AnthropicSchema, ProviderEndpoint, get_global_cache, Pricing, ZERO_PRICING
6+ AnthropicSchema, ProviderEndpoint, get_global_cache, Pricing, ZERO_PRICING,
7+ OpenRouterModel, CachedModel, ModelProviders
68
79export inject_cli_proxy_endpoints!, cli_proxy_model_transform, setup_cli_proxy!
810export MODEL_MAP, MODEL_MAP_REVERSE
@@ -33,12 +35,29 @@ const MODEL_MAP_OPENAI = Dict{String,String}(
3335 " gpt-5.2" => " openai/gpt-5.2" ,
3436 " gpt-5.2-codex" => " openai/gpt-5.2-codex" ,
3537 " gpt-5.3-codex" => " openai/gpt-5.3-codex" ,
38+ " gpt-5.3-codex-spark" => " openai/gpt-5.3-codex-spark" ,
3639)
3740
38- # Models only on CLI proxy (not on OpenRouter) — usable via cli_proxy_api provider directly
39- const PROXY_ONLY_MODELS = [
40- " gpt-5.3-codex-spark" ,
41- ]
41+ # Pricing matching gpt-5.3-codex (best estimate — no public pricing for spark yet)
42+ const CODEX_SPARK_PRICING = Pricing (
43+ prompt = " 0.00000175" ,
44+ completion = " 0.000014" ,
45+ request = nothing ,
46+ image = nothing ,
47+ web_search = nothing ,
48+ internal_reasoning = nothing ,
49+ image_output = nothing ,
50+ audio = nothing ,
51+ input_audio_cache = nothing ,
52+ input_cache_read = " 0.000000175" ,
53+ input_cache_write = nothing ,
54+ discount = nothing ,
55+ )
56+
57+ # Models only on CLI proxy (not on OpenRouter) — need synthetic cache entries
58+ const PROXY_ONLY_MODELS = Dict {String,@NamedTuple{name::String, context_length::Int, pricing::Pricing}} (
59+ " openai/gpt-5.3-codex-spark" => (name = " GPT 5.3 Codex Spark" , context_length = 128000 , pricing = CODEX_SPARK_PRICING),
60+ )
4261
4362const MODEL_MAP = merge (MODEL_MAP_ANTHROPIC, MODEL_MAP_OPENAI)
4463const MODEL_MAP_REVERSE = Dict (v => k for (k, v) in MODEL_MAP)
@@ -64,6 +83,31 @@ function inject_cli_proxy_endpoints!(provider_name::String="cli_proxy_api")
6483 cache = get_global_cache ()
6584 count = 0
6685
86+ # Register proxy-only models as synthetic cache entries
87+ for (or_model_id, meta) in PROXY_ONLY_MODELS
88+ haskey (cache. models, or_model_id) && continue
89+ native_id = get (MODEL_MAP_REVERSE, or_model_id, or_model_id)
90+ endpoint = ProviderEndpoint (;
91+ name = native_id,
92+ model_name = native_id,
93+ context_length = meta. context_length,
94+ pricing = meta. pricing,
95+ provider_name = provider_name,
96+ tag = provider_name,
97+ quantization = nothing ,
98+ max_completion_tokens = meta. context_length,
99+ max_prompt_tokens = nothing ,
100+ supported_parameters = nothing ,
101+ uptime_last_30m = nothing ,
102+ supports_implicit_caching = nothing ,
103+ status = nothing
104+ )
105+ model = OpenRouterModel (or_model_id, meta. name, " CLI proxy only model" , meta. context_length, meta. pricing, nothing , nothing )
106+ providers = ModelProviders (or_model_id, meta. name, nothing , nothing , nothing , [endpoint])
107+ cache. models[or_model_id] = CachedModel (model, providers, now (), true )
108+ count += 1
109+ end
110+
67111 for (native_id, or_model_id) in MODEL_MAP
68112 cached = get (cache. models, or_model_id, nothing )
69113
0 commit comments