Repository navigation
Conversation
Adds Baidu as a provider backed by the Qianfan platform, whose OpenAI-compatible surface lives at /v2/chat/completions rather than /v1. Covers the eight language models Qianfan offers on the Hong Kong pay-as-you-go plan: ERNIE 5.0 as a new model definition, plus provider mappings for DeepSeek V3.2 / V4 Pro / V4 Flash, GLM-5 / 5.1 / 5.2 and Kimi K2.6. Context and output limits come from Qianfan's own /v2/models catalogue. Qianfan counts reasoning inside completion_tokens while also reporting it under completion_tokens_details, so it joins the completionIncludesReasoning set - without that, a thinking reply bills its output twice. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (4)
WalkthroughThe change adds Baidu Qianfan as a provider with API-key configuration, model mappings, endpoint routing, streaming support, cost handling, e2e wiring, and UI branding. ChangesBaidu provider support
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to This PR adds the Baidu Qianfan International provider and its model, pricing, capability, and token-accounting mappings. No actionable merge-blocking risk remains beyond normal checks and review. Sequence Diagram(s)sequenceDiagram
participant Client
participant Gateway
participant EndpointResolver
participant BaiduQianfan
Client->>Gateway: Send chat completion request
Gateway->>EndpointResolver: Resolve Baidu endpoint
EndpointResolver->>BaiduQianfan: POST /v1/chat/completions
BaiduQianfan-->>Gateway: Return streaming response
Gateway-->>Client: Return OpenAI-compatible stream
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/actions/src/get-provider-endpoint.ts (1)
956-958: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAdd Qianfan endpoint unit coverage.
Assert the default and caller-supplied Baidu base URLs both use
/v2/chat/completions.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/actions/src/get-provider-endpoint.ts` around lines 956 - 958, Add unit coverage for the Baidu branch in the provider endpoint tests, asserting both the default base URL and a caller-supplied base URL resolve to /v2/chat/completions. Reuse the existing endpoint test patterns and fixtures.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/models/src/models/baidu.ts`:
- Around line 20-28: Update the Qianfan capability mappings: in
packages/models/src/models/baidu.ts lines 20-28, set the vision flag to false;
in packages/models/src/models/moonshot.ts lines 566-582, set vision to false and
remove the supportedToolChoices restriction. Keep the remaining capability flags
unchanged until funded endpoint testing verifies these behaviors.
---
Nitpick comments:
In `@packages/actions/src/get-provider-endpoint.ts`:
- Around line 956-958: Add unit coverage for the Baidu branch in the provider
endpoint tests, asserting both the default base URL and a caller-supplied base
URL resolve to /v2/chat/completions. Reuse the existing endpoint test patterns
and fixtures.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 51702889-166f-4bc8-bd53-ac8a7a4378d7
📒 Files selected for processing (17)
.env.example.env.unified.example.github/workflows/e2e.ymlapps/gateway/src/chat/tools/transform-streaming-to-openai.tsapps/gateway/src/lib/costs.spec.tsapps/gateway/src/lib/costs.tsapps/gateway/src/models/models.spec.tsapps/ui/src/components/provider-keys/provider-logo.tsinfra/helm/llmgateway/values.yamlpackages/actions/src/get-provider-endpoint.tspackages/models/src/models.tspackages/models/src/models/baidu.tspackages/models/src/models/deepseek.tspackages/models/src/models/moonshot.tspackages/models/src/models/zai.tspackages/models/src/providers.tspackages/shared/src/components/provider-icons.tsx
# Conflicts: # packages/models/src/models/baidu.ts
Repoints the Baidu provider at Qianfan International (https://api.baiduqianfan.ai/v1) and drops the mainland surface. That endpoint publishes its catalogue in USD, so every mapping is now taken from it directly rather than from a price sheet. Corrections that fell out of it: DeepSeek V3.2 is served as `deepseek-v3.2-intl`; GLM-5 is $0.70/$0.14/$2.24, not $1.00/$0.20/$3.20; and several context and output limits were too generous. ERNIE 5.0 is not offered internationally, so its definition is removed - the file keeps only the Novita ERNIE 4.5 VL entry from main. Adds mappings for the two remaining international chat models the catalogue already carries, Hy3 and MiMo V2.5, and turns on jsonOutput now that the API declares structured_outputs on every chat model. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Qianfan's published price list and the sheet we were quoted both put GLM-5 at $1.00/$0.20/$3.20, while /v1/models reports exactly 70% of that. The API appears to serve account-effective rather than list pricing, and a negotiated discount does not belong in the catalogue, so the list price goes back in. Also drops jsonOutput on GLM-5, where Qianfan's model page contradicts the API and lists structured output as unsupported, and caps DeepSeek V4 Pro output at the lower of the two figures the two sources give. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Baidu Qianfan International serves several third-party models behind an OpenAI-compatible API, but the gateway could not route to it. This adds
baiduas an international-only provider athttps://api.baiduqianfan.ai/v1.Active models and pricing
The catalogue uses standard public pay-as-you-go prices. It does not encode promotional, off-peak, account-effective, or negotiated discounts.
deepseek-v4-prodeepseek-v4-flashglm-5glm-5.1glm-5.2kimi-k2.6Prices are USD per million tokens and follow Qianfan International's public rate card.
Qianfan rejects
deepseek-v3.2-intl,hy3, andmimo-v2.5withinvalid_model. Those mappings were introduced only on this unmerged branch, so they are removed entirely.AGENTS.mdnow clarifies that the no-removal rule applies only to definitions already present onorigin/main.Integration details
/v1/chat/completions.completion_tokens.none,minimal,low,medium,high,xhigh, andmaxreasoning efforts for all six models. Qianfan requiresthinking: { type: "disabled" }to reliably implementnone.ERNIE 5.0 is omitted because the authenticated international catalogue does not list it. The dated
deepseek-v4-flash-0731alias andqianfan-ocr-fastare also omitted rather than duplicating an existing model or guessing missing capability metadata.Verification
pnpm format— passedpnpm build— 17/17 tasks passedTEST_MODELS="baidu/deepseek-v4-pro,baidu/deepseek-v4-flash,baidu/glm-5,baidu/glm-5.1,baidu/glm-5.2,baidu/kimi-k2.6" CONCURRENT_TESTS=false FULL_MODE=true pnpm test:e2e— 29 files passed, 193 tests passed, 99 non-applicable tests skipped