Skip to content

Add Baidu Qianfan (ERNIE) as a supported model provider - #94

Merged
veerareddyvishal144 merged 3 commits into
mainfrom
feature/baidu-qianfan-provider
Aug 18, 2026
Merged

Add Baidu Qianfan (ERNIE) as a supported model provider#94
veerareddyvishal144 merged 3 commits into
mainfrom
feature/baidu-qianfan-provider

Conversation

@veerareddyvishal144

Copy link
Copy Markdown
Contributor

Summary

Adds baidu (Baidu Qianfan / ERNIE) as a supported model provider, wired up end-to-end the same way as openai/openrouter/moonshot/zai. Qianfan's v2 endpoint is OpenAI-Chat-Completions-compatible, so invokeBaidu is modeled closely on invokeMoonshot: request-side conversion reuses the shared openrouter-utils.js converters, and the response is converted to Anthropic shape locally so the orchestrator branch is a plain passthrough.

Changes

  • src/config/index.jsBAIDU_API_KEY/BAIDU_ENDPOINT/BAIDU_MODEL parsing, config.baidu block, added to SUPPORTED_MODEL_PROVIDERS, hot-reload sync
  • src/clients/databricks.js — new invokeBaidu, registered in PROVIDER_INVOKERS, exported
  • src/orchestrator/index.js — destination-url, tool-schema, and response-conversion branches for baidu
  • src/routing/model-tiers.jsbaidu case in _getProviderModel so TIER_*=baidu:... resolves
  • src/api/providers-handler.js, src/api/openai-router.js — discovery-listing entries
  • bin/lynkr-init.js — onboarding wizard entry, PROVIDER_ORDER, baseline .env defaults
  • .env.example, documentation/providers.md (new §12), README.md — provider docs
  • test/baidu-model-mapping.test.js (new, 14 tests) — model mapping, tool conversion, auth, response conversion, mirrors moonshot-model-mapping.test.js
  • test/dispatch-registry.test.js, test/init.test.js — updated the hardcoded anti-drift guard lists
  • package.json — wired the new test file into test:unit

Known gaps (flagged in code comments, not yet resolved)

  • Streaming: baidu is not yet in DEFAULT_OPENAI_SSE_PROVIDERS (sse-transformer.js) — requests are buffered-only until Qianfan's SSE shape is confirmed to match OpenAI's.
  • Reasoning content: not added to REASONING_CONTENT_PROVIDERS — unconfirmed whether ernie-x1.1 emits reasoning_content the same way Moonshot/OpenAI do.
  • Model roster & sampling params: the Claude→ERNIE model map (ernie-4.5-turbo-128k, ernie-x1.1, ernie-speed-8k) and default temperature/top_p are best-effort from public docs, not yet probed against a live BAIDU_API_KEY. Moonshot hit a real landmine here (kimi-k* models reject any temperature other than exactly 1) — Baidu may have similar undocumented constraints that only surface on first live call.

Testing

  • All 1267 existing unit tests pass, plus the new 14-test baidu-model-mapping.test.js suite.
  • Not tested against a live Baidu API key/quota (none provisioned yet).

🤖 Generated with Claude Code

vishal veerareddy and others added 3 commits August 18, 2026 15:40
Wires up "baidu" end-to-end alongside openai/openrouter/moonshot/zai,
modeled on invokeMoonshot since Qianfan's v2 endpoint is OpenAI-compatible:

- src/config/index.js: BAIDU_API_KEY/BAIDU_ENDPOINT/BAIDU_MODEL parsing,
  config.baidu block, SUPPORTED_MODEL_PROVIDERS entry, hot-reload sync
- src/clients/databricks.js: new invokeBaidu (request conversion via
  openrouter-utils, response converted to Anthropic shape locally),
  registered in PROVIDER_INVOKERS
- src/orchestrator/index.js: destination-url, tool-schema, and
  response-conversion branches for "baidu"
- src/routing/model-tiers.js: baidu case in _getProviderModel
- src/api/providers-handler.js, src/api/openai-router.js: discovery listing
- bin/lynkr-init.js: onboarding wizard entry + PROVIDER_ORDER + baseline env
- .env.example, documentation/providers.md: new provider docs/section
- test/baidu-model-mapping.test.js: model mapping, tool conversion, auth,
  response conversion (mirrors moonshot-model-mapping.test.js)
- test/dispatch-registry.test.js, test/init.test.js: anti-drift guard lists
- package.json: wire new test file into test:unit

Not yet done, flagged in code/docs: sampling-param quirks and the exact
ERNIE model roster are best-effort from public docs, not probed against a
live key; "baidu" is not yet in DEFAULT_OPENAI_SSE_PROVIDERS (streaming is
buffered-only until SSE shape is confirmed); not added to
REASONING_CONTENT_PROVIDERS (unconfirmed whether ERNIE reasoning models
emit reasoning_content). All 1267 existing unit tests plus the new baidu
suite pass.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Follow-up to 57959c0. Only these three rows + the cloud-provider count are
touched — README already had unrelated pending edits (OAuth/wrap-mode
policy note) in the working tree that are intentionally left unstaged,
they're not part of this branch's scope.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The "Web Tools Test Suite" check has been failing on every PR/push that
touches its trigger paths (including src/config/index.js, which this
branch's Baidu changes touch) since commit b32e988 deleted
src/tools/web.js, src/tools/web-client.js, and test/web-tools.test.js
without removing the standalone workflow that ran that test file — this
predates and is unrelated to the Baidu provider work, confirmed failing
on main itself and on PR #90/#91 too (`gh run list --workflow
web-tools-tests.yml`).

- Remove .github/workflows/web-tools-tests.yml (nothing left to test)
- Remove the same two stale file refs (test/web-tools.test.js,
  test/code-mode.test.js — deleted in the same commit) from ci.yml's
  "Tests" job. These didn't fail there since node --test silently skips
  a missing file when given alongside other real ones in one invocation,
  but a passing check that silently means "0 tests ran for this file"
  is a gap worth closing, not a reference worth keeping.
- Update workflows/README.md: drop the Web Tools Tests section,
  renumber remaining sections, drop the dead badge/example command.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@veerareddyvishal144
veerareddyvishal144 merged commit de6ea1a into main Aug 18, 2026
2 checks passed
@veerareddyvishal144
veerareddyvishal144 deleted the feature/baidu-qianfan-provider branch August 18, 2026 23:07
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