Model providers

Using Qianfan (Baidu) with OpenClaw

3 min read

Browse more in Model providers.

All model providers guides →

This guide shows you how to wire up Baidu Qianfan as a model provider inside OpenClaw. You will configure authentication, run the OpenClaw onboarding flow, and point your agents at Qianfan’s DeepSeek and ERNIE models.

2`.

Prerequisites

  • A Baidu Cloud account with Qianfan API access enabled in the Qianfan Console.
  • A Qianfan API key in the `bce-v3/ALTAK-...` format generated from a Qianfan application.
  • The OpenClaw CLI installed and available as the `openclaw` command on your machine.

Steps

  1. 1

    Create a Baidu Cloud Qianfan account

    Start by making sure you actually have access to Qianfan; OpenClaw cannot talk to Baidu without a valid Qianfan-enabled account. Go to the Qianfan Console and confirm that the Qianfan API service is activated for your Baidu Cloud account before you touch any OpenClaw config.

    text
    Sign up or log in at the Qianfan Console (https://console.bce.baidu.com/qianfan/ais/console/apiKey) and ensure you have Qianfan API access enabled.
  2. 2

    Generate a Qianfan API key

    OpenClaw authenticates to Qianfan using a single API key, so you need to create one tied to an application in the console. Pay attention to the key format; if it does not start with `bce-v3/ALTAK-`, OpenClaw’s Qianfan provider will not authenticate correctly.

    text
    Create a new application or select an existing one, then generate an API key. The key format is `bce-v3/ALTAK-...`.
  3. 3

    Run the OpenClaw Qianfan onboarding flow

    Use the OpenClaw CLI onboarding command to register Qianfan as an auth choice and store your API key. This step wires the `QIANFAN_API_KEY` into OpenClaw’s config so later model and agent commands can talk to Baidu without extra flags.

    bash
    openclaw onboard --auth-choice qianfan-api-key
  4. 4

    Verify Qianfan models are available in OpenClaw

    Once onboarding is done, list the models that OpenClaw sees for the Qianfan provider. This confirms both your credentials and that the provider catalog (including DeepSeek and ERNIE) is wired up correctly before you point any agents at it.

    bash
    openclaw models list --provider qianfan
  5. 5

    Configure OpenClaw to use Qianfan models for your agents

    Add or update your OpenClaw config so agents default to Qianfan’s DeepSeek model and know about the ERNIE thinking preview. qianfan` if you want to control the base URL or model metadata; otherwise the bundled catalog already includes these models.

    json
    {
      env: { QIANFAN_API_KEY: "bce-v3/ALTAK-..." },
      agents: {
        defaults: {
          model: { primary: "qianfan/deepseek-v3.2" },
          models: {
            "qianfan/deepseek-v3.2": { alias: "QIANFAN" },
          },
        },
      },
      models: {
        providers: {
          qianfan: {
            baseUrl: "https://qianfan.baidubce.com/v2",
            api: "openai-completions",
            models: [
              {
                id: "deepseek-v3.2",
                name: "DEEPSEEK V3.2",
                reasoning: true,
                input: ["text"],
                cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
                contextWindow: 98304,
                maxTokens: 32768,
              },
              {
                id: "ernie-5.0-thinking-preview",
                name: "ERNIE-5.0-Thinking-Preview",
                reasoning: true,
                input: ["text", "image"],
                cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
                contextWindow: 119000,
                maxTokens: 64000,
              },
            ],
          },
        },
      },
    }

Configuration

OptionDescriptionExample
QIANFAN_API_KEYAPI key OpenClaw uses to authenticate requests to Baidu Qianfan’s unified API.bce-v3/ALTAK-...
envTop-level OpenClaw config section where you set environment variables like the Qianfan API key.{ QIANFAN_API_KEY: "bce-v3/ALTAK-..." }
agents.defaults.model.primarySets the default primary model ref for your agents, here pointing them at Qianfan’s DeepSeek model.qianfan/deepseek-v3.2
agents.defaults.models."qianfan/deepseek-v3.2".aliasDefines a short alias you can use inside OpenClaw for the Qianfan DeepSeek model.QIANFAN
models.providers.qianfan.baseUrlBase URL OpenClaw uses for Qianfan’s OpenAI-compatible API endpoint.https://qianfan.baidubce.com/v2
models.providers.qianfan.apiSpecifies the transport type OpenClaw uses for Qianfan; it runs through the OpenAI-compatible completions path.openai-completions
models.providers.qianfan.models[0].idInternal ID for the Qianfan DeepSeek model used in the provider catalog.deepseek-v3.2
models.providers.qianfan.models[1].idInternal ID for the Qianfan ERNIE thinking preview model used in the provider catalog.ernie-5.0-thinking-preview

Troubleshooting

Qianfan calls fail and your API key does not start with bce-v3/ALTAK-

` format; if your key looks different, OpenClaw’s Qianfan provider will not authenticate. Go back to the Baidu Cloud Qianfan Console, generate a new key that starts with `bce-v3/ALTAK-`, and update `QIANFAN_API_KEY` in your config.

bash
Ensure your API key starts with `bce-v3/ALTAK-` and has Qianfan API access enabled in the Baidu Cloud console.

Running `openclaw models list --provider qianfan` shows no models

If the models list is empty, your Baidu account likely does not have the Qianfan service activated yet. Activate the Qianfan service in the Baidu Cloud console, confirm API access is enabled, then rerun the models list command.

bash
If models are not listed, confirm your account has the Qianfan service activated.

Requests fail after changing the Qianfan base URL

com/v2`; changing this to a wrong URL breaks all calls. com/v2` unless you intentionally use a custom endpoint or proxy.

bash
The default base URL is `https://qianfan.baidubce.com/v2`. Only change it if you use a custom endpoint or proxy.

Frequently asked questions

Powered by Mem0

Add persistent memory to OpenClaw

Official Mem0 plugin for OpenClaw keeps context across chats and tools. Smaller prompts, lower cost, better continuity for your agents.

More in Model providers