Conversation
Adds an `openai-discount` provider mirroring the `anthropic-discount` pattern: base URL + API key come from env vars (LLM_OPENAI_DISCOUNT_BASE_URL / LLM_OPENAI_DISCOUNT_API_KEY), pricing carries a 10% discount, and request/response handling is identical to upstream OpenAI (Responses API included). Exposes GPT-5.5 via `openai-discount/gpt-5.5` (kie.ai external id `gpt-5-5`, https://docs.kie.ai/market/chat/gpt-5-5). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
WalkthroughThis PR adds a new ChangesOpenAI Discount Provider Integration
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Adds a new openai-discount provider that mirrors the upstream openai request/response handling but resolves its base URL and API key from environment variables (following the existing anthropic-discount stealth pattern).
Changes:
- New
openai-discountprovider definition inpackages/modelswith env-drivenapiKey/baseUrl, plus anopenai-discountmapping (external idgpt-5-5,discount: "0.1",supportsResponsesApi: true) added to thegpt-5.5model. - Endpoint resolution (
get-provider-endpoint.ts) readsLLM_OPENAI_DISCOUNT_BASE_URLand now keys the Responses-API capability lookup on the actualproviderrather than a hardcoded"openai"; request-body transforms inprepare-request-body.tstreatopenai-discountlikeopenaion both Responses-API and chat-completions paths. - Gateway-side OpenAI branches (streaming/non-streaming transform-to-openai, tool-call extraction, usage extraction, web-search counting) extended to also match
openai-discount;.env.exampledocuments the two new vars.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/models/src/providers.ts | Registers openai-discount provider with env-based credentials, priority 1.5, mirroring anthropic-discount. |
| packages/models/src/models/openai.ts | Adds openai-discount provider mapping for gpt-5.5 (external id gpt-5-5, 10% discount, Responses API). |
| packages/actions/src/get-provider-endpoint.ts | Resolves base URL from env for openai-discount and uses provider (not hardcoded "openai") when looking up Responses-API capability. |
| packages/actions/src/prepare-request-body.ts | Treats openai-discount identically to openai for none-effort, image-gen guard, and prompt-cache field handling on both Responses and chat-completions paths. |
| apps/gateway/src/chat/tools/transform-streaming-to-openai.ts | Routes streaming transform for openai-discount through the OpenAI/Azure branch. |
| apps/gateway/src/chat/tools/transform-response-to-openai.ts | Routes non-streaming response transform for openai-discount through the OpenAI branch. |
| apps/gateway/src/chat/tools/extract-tool-calls.ts | Extracts streaming tool-call deltas for openai-discount like openai/azure. |
| apps/gateway/src/chat/chat.ts | Includes openai-discount in Responses-API usage extraction and web_search_call.completed counting. |
| .env.example | Documents LLM_OPENAI_DISCOUNT_BASE_URL / LLM_OPENAI_DISCOUNT_API_KEY. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Adds a new
openai-discountprovider that behaves exactly like upstream OpenAI for all request/response handling, mirroring the existinganthropic-discountpattern, with two differences:LLM_OPENAI_DISCOUNT_BASE_URL/LLM_OPENAI_DISCOUNT_API_KEY), following the same stealth pattern asanthropic-discount/glacier/quartz.What changed
packages/models: newopenai-discountprovider definition (env-basedapiKey+baseUrl); the existinggpt-5.5model gains anopenai-discountprovider mapping withdiscount: "0.1"andsupportsResponsesApi: true.packages/actions: endpoint resolution readsLLM_OPENAI_DISCOUNT_BASE_URLand appends/v1/responses(or/v1/chat/completions); the request-body transform (Responses + chat completions paths) treatsopenai-discountidentically toopenai. The responses-API capability lookup now keys on the actualproviderinstead of a hardcoded"openai".apps/gateway: OpenAI-specific branches (Responses-API streaming/non-streaming transforms, tool-call extraction, usage extraction, web-search counting) now also matchopenai-discount..env.example: documents the two new env vars.Token, header (Bearer), and response parsing flow through the existing generic / OpenAI-default machinery, so no further plumbing was needed.
Testing
pnpm format✅pnpm build✅pnpm test:unit✅ (1696 passed)End-to-end verification against the real discounted endpoint is pending — the proxy will be configured separately.
🤖 Generated with Claude Code
Summary by CodeRabbit