All Products
Search
Document Center

Alibaba Cloud Model Studio:Install the SDK

Last Updated:Oct 15, 2025

Model Studio provides SDKs for Python and Java (also called DashScope SDK), and invocation methods compatible with OpenAI SDKs for Python, Node.js, Java, and Go. This topic describes how to install Open AI SDK and DashScope SDK.

Environment preparation

If you are familiar with and have already configured a local developer environment for Python, Java, Node.js, or Go, you can skip this section and proceed to install the SDK.

Detailed environment preparation configurations

Python

Step 1: Check Python version

Run the following command in the terminal to check if Python and pip are installed in your current environment:

Your Python version must be 3.8 or later. For more information, see Install Python.

python -V
pip --version

The following figure shows an example in Windows Command Prompt:

image

FAQ

Q: An error is reported when I run the python -V or pip --version command:

  • 'python' is not recognized as an internal or external command, operable program or batch file.

  • 'pip' is not recognized as an internal or external command, operable program or batch file.

  • -bash: python: command not found

  • -bash: pip: command not found

A: To resolve this issue, perform the following steps:

Windows
  1. Make sure that you have installed Python in your environment and added python.exe to the PATH environment variable. For more information, see Install Python.image

  2. If you have installed Python and added the environment variable but the error persists, close the current terminal, open a new one, and try again.

Linux and macOS
  1. Make sure that you have installed Python in your environment. For more information, see Install Python.

  2. If the error persists after you install Python, run the which python pip command to check if python and pip exist in the system.

    • If the following result is returned, close the current terminal, open a new one, and try again.

      /usr/bin/python
      /usr/bin/pip
    • If the following result is returned, run the which python3 pip3 command to check again.

      /usr/bin/which: no python in (/root/.local/bin:/root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin)
      /usr/bin/which: no pip in (/root/.local/bin:/root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin)

      If the following result is returned, use python3 -V and pip3 --version to check the versions.

      /usr/bin/python3
      /usr/bin/pip3

Step 2: Configure virtual environment (optional)

After you install Python, you can create a virtual environment to install the OpenAI Python SDK or DashScope Python SDK. This helps you avoid dependency conflicts with other projects.

  1. Create a virtual environment

    Run the following command to 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
  2. Activate the virtual environment

    On Windows, run the following command to activate the virtual environment:

    .venv\Scripts\activate

    If you use macOS or Linux, run the following command to activate the virtual environment: source .venv/bin/activate

    source .venv/bin/activate

Java

Check your Java version

Run the following command in the terminal:

java -version
# (Optional) If you use Maven to manage and build Java projects, make sure that Maven is installed in your development environment
mvn --version

Take Windows CMD as an example:

image

DashScope Java SDK requires Java 8 or higher. The first line of the output shows your Java version. For example, openjdk version "16.0.1" 2021-04-20 indicates Java 16 is installed. If Java is not installed or the installed version is earlier than Java 8, go to Java Downloads to download and install the appropriate version.

Node.js

Check the Node.js installation status

Run the following command in the terminal to check if Node.js and npm are installed in your current environment:

node -v
npm -v

The following figure shows an example in Windows Command Prompt:

image

This command displays your current Node.js version. If Node.js is not installed in your environment, go to the Node.js official website to download it.

Go

Step 1: Check your Go version

You can run the following command in the terminal:

go version

The following example shows the output in the CMD window on a Windows operating system:

image

The command prints your current Go version. If Go is not installed in your environment, visit the official Go website to download and install it.

Step 2: Create a project and initialize a module

Run the following commands in the terminal:

# Create a project. Modify the folder name and path based on your actual needs.
# The following commands are for Windows. Assume that you create a project folder on drive D and enter the folder. For other operating systems, adapt the commands for switching paths.
mkdir D:\your_project_folder && cd /d D:\your_project_folder

# Initialize the module. example.com is an example. The domain name does not need to be real, but must conform to the format.
go mod init example.com/your_project_folder

The following example shows the output in the CMD window on a Windows operating system:

image

Install the SDK

Python

You can call models on the Alibaba Cloud Model Studio platform using the OpenAI Python SDK or the DashScope Python SDK.

Install the OpenAI Python SDK

Run the following command to 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

When the Successfully installed ... openai-x.x.x message appears in the terminal, the OpenAI Python SDK has been installed.

Install the DashScope Python SDK

Run the following command to 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

When the Successfully installed ... dashscope-x.x.x message appears in the terminal, the DashScope Python SDK has been installed.

Note

If the WARNING: You are using pip version xxx; however, version xxx is available. message appears during the SDK installation, it is a notification to update your pip tool and does not affect the SDK installation. You can ignore this message.

Java

Install the DashScope Java SDK

You can use the following instructions to install the DashScope Java SDK. Add the Java SDK dependency and replace the-latest-version with the latest version number.

XML

  1. Open the pom.xml file of your Maven project.

  2. Add the following dependency information within the <dependencies> tag:

    <dependency>
        <groupId>com.alibaba</groupId>
        <artifactId>dashscope-sdk-java</artifactId>
        <!-- Replace 'the-latest-version' with the latest version number: https://mvnrepository.com/artifact/com.alibaba/dashscope-sdk-java -->
        <version>the-latest-version</version>
    </dependency>
  3. Save the pom.xml file.

  4. Use Maven commands, such as mvn compile or mvn clean install, to update the project dependencies. Maven automatically downloads and adds the DashScope Java SDK to your project.

The following example shows the configuration in an integrated development environment (IDE) for Java on a Windows operating system:

image

Gradle

  1. Open the build.gradle file of your Gradle project.

  2. Add the following dependency information to the dependencies block:

    dependencies {
        // Replace 'the-latest-version' with the latest version number: https://mvnrepository.com/artifact/com.alibaba/dashscope-sdk-java
        implementation group: 'com.alibaba', name: 'dashscope-sdk-java', version: 'the-latest-version'
    }
  3. Save the build.gradle file.

  4. In the command line, switch to the root directory of your project and execute the following Gradle command to update the project dependencies. Gradle automatically downloads and adds the DashScope Java SDK to your project.

    ./gradlew build --refresh-dependencies

The following example shows the configuration in an IDE for Java on a Windows operating system:

image

Install the OpenAI Java SDK

You can use the following instructions to add the OpenAI Java SDK dependency.

XML

  1. Open the pom.xml file of your Maven project.

  2. Install OpenAI SDK 0.32.0 or a later version. Add or update the following dependency information within the <dependencies> tag. You can use version 0.32.0 or a later version.

    <dependency>
        <groupId>com.openai</groupId>
        <artifactId>openai-java</artifactId>
        <version>0.32.0</version>
    </dependency>
  3. Save the pom.xml file.

  4. Use Maven commands, such as mvn compile or mvn clean install, to update the project dependencies. Maven automatically downloads and adds the OpenAI Java SDK to your project.

Node.js

Run the following command in the terminal:

npm install --save openai
# or
yarn add openai
Note

If the installation fails, you can configure a traffic mirror source to complete the installation. For example:

npm config set registry https://registry.npmmirror.com/

After you configure the traffic mirror source, run the SDK installation command again.

image

When the added xx package in xxs message appears in the terminal, the OpenAI SDK has been installed. You can use npm list openai to check the specific version information.

Go

OpenAI provides an SDK for the Go language. You can run the following command in the project folder to install it:

go get github.com/openai/openai-go@v0.1.0-alpha.62

image

When the terminal displays a message similar to go: added github.com/openai/openai-go v0.1.0-a1pha.62, the OpenAI SDK is successfully installed.

Note
  • Version v0.1.0-alpha.62 has been tested and is relatively stable.

  • This SDK is currently in the testing phase.

  • If a timeout occurs when you access the server, you can set an Alibaba Cloud image proxy:

    # Set the Alibaba Cloud image proxy
    go env -w GOPROXY=https://mirrors.aliyun.com/goproxy/,direct

What to do next

Explore sample codes to call models with the OpenAI SDK or DashScope SDK.

References

For a list of models that support the OpenAI SDK, see Compatibility with OpenAI.