← Back to PRs

#7798: feat: add ERNIE provider support

by mattheliu open 2026-02-03 06:36 View on GitHub →
docs cli commands agents stale
## Summary Add ERNIE (百度文心) as a new model provider, using Baidu's Qianfan API endpoint for inference. - Add `buildErnieProvider()` function to create provider configuration - Add ERNIE model constants and `buildErnieModelDefinition()` helper - Add `setErnieApiKey()` credential storage function - Add `applyErnieConfig()` / `applyErnieProviderConfig()` for onboarding configuration - Add `ernie-api-key` auth choice handler with interactive prompts - Support `ERNIE_API_KEY` environment variable for authentication - Add implicit provider resolution when API key is present ## Provider Details | Property | Value | |----------|-------| | Provider name | `ernie` | | Default model | `ernie-5.0-thinking-preview` | | Model reference | `ernie/ernie-5.0-thinking-preview` | | Context window | 128,000 tokens | | Max output tokens | 65,536 tokens | | API endpoint | `https://qianfan.baidubce.com/v2` | | API compatibility | OpenAI-compatible (`openai-completions`) | | Environment variable | `ERNIE_API_KEY` | ## Files Changed - `src/agents/models-config.providers.ts` - Core provider builder and implicit resolution - `src/commands/onboard-auth.models.ts` - Model constants and definition builder - `src/commands/onboard-auth.credentials.ts` - API key credential storage - `src/commands/onboard-auth.config-core.ts` - Provider/model configuration functions - `src/commands/onboard-auth.ts` - Re-export new functions - `src/commands/onboard-types.ts` - Add `ernie-api-key` auth choice type - `src/commands/auth-choice.apply.api-providers.ts` - Interactive auth handler - `src/commands/auth-choice.preferred-provider.ts` - Auth choice to provider mapping - `src/agents/model-auth.ts` - Environment variable mapping ## Usage ### Via environment variable ```bash export ERNIE_API_KEY="bce-v3/ALTAK-..." openclaw chat ``` ### Via onboarding ```bash openclaw onboard --auth-choice ernie-api-key ``` ### Via non-interactive mode ```bash openclaw onboard --non-interactive --auth-choice token --token-provider ernie --token "bce-v3/ALTAK-..." ``` ## Test Plan - [x] `pnpm build` - TypeScript compilation passes - [x] `pnpm check` - Lint and format checks pass - [x] `pnpm test` - All 5,228 tests pass 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR adds a new `ernie` model provider backed by Baidu Qianfan’s OpenAI-compatible endpoint, including: - Provider/model defaults and implicit provider resolution when an ERNIE key is present. - Onboarding support (interactive + non-interactive) with a new `ernie-api-key` auth choice. - Environment variable mapping (`ERNIE_API_KEY`) and documentation updates for the provider. The implementation follows the existing provider/onboarding patterns (provider builders in `src/agents/models-config.providers.ts`, auth-choice wiring in `src/commands/auth-choice.apply.api-providers.ts`, and non-interactive onboarding in `src/commands/onboard-non-interactive/local/auth-choice.ts`). <h3>Confidence Score: 4/5</h3> - Mostly safe to merge once ERNIE credential persistence is made consistent with other providers. - The change is largely additive (new provider + onboarding wiring + docs) and aligns with existing patterns, but there is a concrete consistency issue where ERNIE credential writes are not awaited while other providers’ writes are, which can lead to onboarding returning before credentials are persisted if the underlying store write is async. - src/commands/onboard-non-interactive/local/auth-choice.ts, src/commands/auth-choice.apply.api-providers.ts <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs