Skip to main content
Preparation

Install the SDK

Python and Java setup

Qwen Cloud provides DashScope SDKs (Python, Java) and supports OpenAI-compatible calls. OpenAI provides SDKs for Python, Node.js, Java, and Go.

Prepare the environment

Skip this section if you already have Python, Java, Node.js, or Go configured locally.
  • Python
  • Java
  • Node.js
  • Go

Check your Python version

Check if Python and pip are installed:
python -V
pip --version
image
Python 3.8 or higher required. Install from python.org if needed.

python -V or pip --version returns "command not found"?

  • Windows
  • Linux and macOS
  1. Install Python and add it to PATH. See Install Python.
    image
  2. If the error persists after installing Python and setting PATH, restart your terminal and try again.

Configure a virtual environment (optional)

Create a virtual environment to isolate SDK dependencies (recommended).
  1. Create a virtual environment
Create a virtual environment named .venv:
# If the command fails to run, you can replace python with python3 and run it again.
python -m venv .venv
  1. Activate the virtual environment
Activate the virtual environment:
  • Windows:
.venv\Scripts\activate
  • macOS/Linux:
source .venv/bin/activate

Install the SDK

  • Python
  • Java
  • Node.js
  • Go
You can call Qwen Cloud APIs using the OpenAI Python SDK or the DashScope Python SDK.

Install the OpenAI Python SDK

Install the OpenAI Python SDK:
# If the command fails to run, you can replace pip with pip3 and run it again.
pip install -U openai
image
Success message: Successfully installed ... openai-x.x.x

Install the DashScope Python SDK

Install the DashScope Python SDK:
# If the command fails to run, you can replace pip with pip3 and run it again.
pip install -U dashscope
image
Success message: Successfully installed ... dashscope-x.x.x
Pip version warnings are safe to ignore.

Next steps

Run the code examples for the OpenAI SDK or the DashScope SDK.