Skip to content

api: expose usage estimate rates in model listings - #184

Open
hhh2210 wants to merge 1 commit into
Mag1cFall:mainfrom
hhh2210:feat/model-estimate-prices
Open

hhh2210 wants to merge 1 commit into
Mag1cFall:mainfrom
hhh2210:feat/model-estimate-prices

Conversation

@hhh2210

@hhh2210 hhh2210 commented Nov 17, 2026 •

Copy link
Copy Markdown

改动 / Changes

OpenAI 模型列表与单模型响应提供 estimated_cost,客户端可以复用用量页的输入、输出、缓存输入单价和长上下文分档。搜索型号沿用基础型号的价格,未计价模型省略该字段。

数据直接来自 internal/pricing 的现有价格表。tiers[].above 使用严格大于的输入阈值,输入含缓存命中,输出含思考 token。配套适配:magpie-gemini-web #68、Magpie #6922,使用同一份价格计算账号卡与请求用量的估算费用。

验证 / Verification

  • go test ./internal/api ./internal/pricing ./internal/requestdb 通过,使用仓库 CI 固定的 Darwin ARM64 SpiderMonkey/libwebp 静态库。
  • 回归覆盖普通型号、搜索别名、200000/200001 输入分档、缓存、零输出单价和未计价型号。
  • 使用原版 openAIModelObject 运行新测试,报 has no estimated_cost;新实现通过。

Add estimated_cost to OpenAI model listings and single-model responses
from the existing usage pricing table. Search aliases share base rates;
context tiers include cached input and use a strict input-size threshold.

Validation: internal/api, internal/pricing and internal/requestdb tests
passed with the repository's pinned Darwin ARM64 static libraries.
TestModelEstimatedCost fails with the original openAIModelObject
(no estimated_cost), and passes with this change at 200000/200001 input
tokens. Unknown model prices remain omitted.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T05:38:10.939721Z 89fa750 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

BUKOWSKIREAL pushed a commit to BUKOWSKIREAL/magpie-gemini-web that referenced this pull request Nov 17, 2026
Map AIStudio2API estimated_cost into model prices, including cached input
and context tiers. Prefer those rates over public catalog estimates only
when the host advertises the complete modelCost capability. Older hosts
and backends retain the existing zero-price placeholder.

Validation: 344 Node tests and 39 Bun Studio tests pass; diff interrogation
and package dry-run pass. The new regression fails against the original
adapter's all-zero prices, and checks both capability states through the
actual plugin entrypoint. Independent read-only review found no issues.
A sanitized five-request ledger replay through the adapter and a patched
Magpie binary calculates $0.69533715 from the backend rates.

Backend protocol: Mag1cFall/AIStudio2API#184.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant