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.
Install the SDK
Python
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
Open the
pom.xmlfile of your Maven project.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>Save the
pom.xmlfile.Use Maven commands, such as
mvn compileormvn 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:

Gradle
Open the
build.gradlefile of your Gradle project.Add the following dependency information to the
dependenciesblock: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' }Save the
build.gradlefile.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:

Install the OpenAI Java SDK
You can use the following instructions to add the OpenAI Java SDK dependency.
XML
Open the
pom.xmlfile of your Maven project.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>Save the
pom.xmlfile.Use Maven commands, such as
mvn compileormvn clean install, to update the project dependencies. Maven automatically downloads and adds the OpenAI Java SDK to your project.
Node.js
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
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.
Version
v0.1.0-alpha.62has 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.








