skillfed

qianfan

文心千帆大模型平台 Python SDK

qianfan v0.4.12.3 234.1K downloads/30d#9,028 on PyPI383
Permissive license Apache-2.0 AGING released

What it is and what it does

Qianfan is Baidu's official Python SDK for accessing the Qianfan large language model platform. It wraps HTTP and async HTTP calls to Baidu's inference, training, and model management services, handling authentication, request formatting, and response parsing. The SDK supports multiple authentication modes (Access Key/Secret Key or legacy API Key/Secret Key) and exposes high-level interfaces for chat, text completion, embeddings, image generation, and model lifecycle operations.

The package is designed for developers integrating Baidu's LLM capabilities into Python applications. It manages 16 runtime dependencies including requests, aiohttp, pydantic for validation, tenacity for retry logic, and rich for CLI output. Configuration is flexible—credentials can be set via environment variables, .env files, or code. The SDK also provides tokenization utilities, rate limiting, and prompt management, making it a comprehensive client for the Qianfan ecosystem.

Use it for:

  • Build chatbot or conversational AI applications using ERNIE models via the ChatCompletion interface.
  • Generate text embeddings for semantic search, clustering, or retrieval-augmented generation workflows.
  • Fine-tune Baidu's large language models on custom datasets using the model training API.
  • Generate images from text prompts using the Text2Image capability within the Qianfan platform.
  • Manage datasets, models, and deployments programmatically through the model management and service APIs.
  • Integrate Qianfan's plugin ecosystem and external tools into Python applications via the plugin interface.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Python SDK for Baidu Qianfan large language model platform, enabling chat, text completion, embeddings, image generation, model training, and dataset management through a unified API.

Yes, with conditions. Install if you are building on Baidu's Qianfan platform and need a Python client—the SDK is officially maintained, permissively licensed, and has low install friction. However, note that maintenance is aging (553 days since last release), so verify that the current version supports your target models and features before committing to production. No known security vulnerabilities as of the last OSV check.

Install

qianfan on PyPI

pip

pip install qianfan

uv

uv add qianfan

poetry

poetry add qianfan

Installing qianfan

Before you install

Low install friction with a pure-Python wheel distribution. Maintenance status is aging—last commit was 2025-12-12 and the package has not received a release in 553 days, though the repository remains active and not archived.

License in practice

Licensed under Apache-2.0 (permissive), allowing commercial use, modification, and distribution with minimal restrictions—suitable for most production and proprietary projects.

Quickstart

pip install qianfan

import os
import qianfan

os.environ["QIANFAN_ACCESS_KEY"] = "..."
os.environ["QIANFAN_SECRET_KEY"] = "..."

chat_comp = qianfan.ChatCompletion(model="ERNIE-4.0-8K")
resp = chat_comp.do(messages=[{"role": "user", "content": "hello"}])
print(resp["result"])

Requires Python 3.7 or higher; Baidu Qianfan platform credentials (Access Key and Secret Key) must be obtained from Baidu Cloud console and set as environment variables.

Verify before relying

  • Whether the aging maintenance status (553 days since last release) affects stability or feature parity with the Baidu platform.
  • Performance characteristics and rate-limiting behavior under high-concurrency workloads given the aiolimiter dependency.
  • Whether all 16 runtime dependencies are actively maintained and free of known vulnerabilities beyond the OSV check.

Package facts

License Apache-2.0 (permissive)
Python support supports the current Python release (<4,>=3.7)
Install friction low — pure-Python wheel
Runtime dependencies 16 — requests, aiohttp, aiolimiter, importlib-metadata, bce-python-sdk, typing-extensions, pydantic, python-dotenv, tenacity, multiprocess, rich, typer, pyyaml, prompt-toolkit, diskcache, cachetools
Maintenance aging — 553 days since the last release
Last repo commit
First released
Downloads 234,138/month — #9,028 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: qianfan-0.4.12.3-py3-none-any.whl

Keywords: baidu, qianfan

License :: OSI Approved :: Apache Software LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

Tags

baidu qianfan sdkllm api client baiduchat completion embeddingmodel training managementtext to image generationlarge language model platformqianfan python client
baidu-cloudllm-clientasync-http

More Artificial Intelligence packages