Skip to content

Commit b1acfa3

Browse files
committed
Add gpt-5.3-codex-spark as proxy-only model with synthetic cache entry
- Add to MODEL_MAP_OPENAI for native ID mapping - Register synthetic CachedModel in inject_cli_proxy_endpoints! so OpenRouter.jl's get_model() finds it (fixes 'Model not found' error) - Use gpt-5.3-codex pricing as best estimate (no public pricing yet) - PROXY_ONLY_MODELS now holds metadata (name, context_length, pricing) instead of bare model ID list
1 parent a932ed1 commit b1acfa3

2 files changed

Lines changed: 52 additions & 6 deletions

File tree

Project.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
name = "OpenRouterCLIProxyAPI"
22
uuid = "d0aa8731-5480-4640-9779-77688f8e2236"
3-
authors = ["SixZero <havliktomi@hotmail.com> and contributors"]
43
version = "0.3.0"
4+
authors = ["SixZero <havliktomi@hotmail.com> and contributors"]
55

66
[deps]
7+
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
78
OpenRouter = "b1229eab-bc7b-489c-92b5-04baf87d8d0b"
89

910
[compat]
11+
Dates = "1"
1012
OpenRouter = "1.2"
1113
julia = "1.11"
1214

src/OpenRouterCLIProxyAPI.jl

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

3+
using Dates: now
34
using OpenRouter
45
using 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

79
export inject_cli_proxy_endpoints!, cli_proxy_model_transform, setup_cli_proxy!
810
export 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

4362
const MODEL_MAP = merge(MODEL_MAP_ANTHROPIC, MODEL_MAP_OPENAI)
4463
const 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

Comments
 (0)