#7798: feat: add ERNIE provider support
docs
cli
commands
agents
stale
Cluster:
Provider Support Enhancements
## 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
#8232: Nebius token factory Provider support
by KiranChilledOut · 2026-02-03
77.4%
#13295: feat: add Eternal AI provider integration
by peterparkernho · 2026-02-10
74.5%
#15991: feat: add Novita AI provider support with dynamic model discovery
by Alex-wuhu · 2026-02-14
74.3%
#15742: feat: add Edgee AI Gateway as provider
by manthis · 2026-02-13
73.7%
#2429: added cerebras as a model provider.
by kkkamur07 · 2026-01-26
73.7%
#7418: feat (amazon-nova): add Amazon Nova 1P provider
by 5herlocked · 2026-02-02
71.8%
#7051: Add io-intelligence model inference provider
by rajagurunath · 2026-02-02
70.4%
#1943: Add jan.ai provider documentation
by csa1234 · 2026-01-25
70.4%
#7113: feat(providers): add CommonStack provider support
by flhoildy · 2026-02-02
70.1%
#12059: feat(agents): Add Azure AI Foundry credential support
by lisanyambere · 2026-02-08
70.0%