Skip to content

Install the SDK

Model Studio provides official DashScope SDKs (Python, Java) and supports OpenAI SDKs (Python, Node.js, Java, Go) for OpenAI-compatible API calls.

Install the SDK

Python

The SDK requires Python >= 3.8. You can call models on Model Studio using the OpenAI Python SDK or the DashScope Python SDK.

Install the OpenAI Python SDK

Install or upgrade the OpenAI Python SDK:

HELPCODEESCAPE-bash

pip install -U openai

Look for Successfully installed ... openai-x.x.x to confirm installation.

Install the DashScope Python SDK

Install or upgrade the DashScope Python SDK:

HELPCODEESCAPE-bash
# If this fails, replace pip with pip3
pip install -U dashscope

Look for Successfully installed ... dashscope-x.x.x to confirm installation.

Java

DashScope

Add the DashScope Java SDK dependency. Replace the-latest-version with the latest version number from the Maven repository.

Gradle

HELPCODEESCAPE-gradle
dependencies {
    implementation group: 'com.alibaba', name: 'dashscope-sdk-java', version: 'the-latest-version'
}

Maven

HELPCODEESCAPE-xml
<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>dashscope-sdk-java</artifactId>
    <version>the-latest-version</version>
</dependency>

OpenAI

Add the OpenAI Java SDK dependency (replace the-latest-version with the latest version number; recommended: 3.5.0). The SDK requires Java 8 or later.

Gradle

HELPCODEESCAPE-gradle
dependencies {
    implementation("com.openai:openai-java:the-latest-version")
}

Maven

HELPCODEESCAPE-xml
<dependency>
  <groupId>com.openai</groupId>
  <artifactId>openai-java</artifactId>
  <version>the-latest-version</version>
</dependency>

Node.js

OpenAI

Run this command in your terminal:

HELPCODEESCAPE-shell
npm install --save openai
# Or
yarn add openai

Note

If installation fails, configure a registry mirror:

HELPCODEESCAPE-shell
npm config set registry https://registry.npmmirror.com/

After configuring the mirror, rerun the SDK installation command.

Look for added xx package in xxs to confirm installation. Check version: npm list openai.

Go

OpenAI

Install the OpenAI Go SDK (which requires Go 1.22+) in your project folder:

HELPCODEESCAPE-go
go get 'github.com/openai/openai-go/v3'

Or install a specific version:

HELPCODEESCAPE-go
go get -u 'github.com/openai/openai-go/v3@v3.8.1'

If the installation times out, set an Alibaba Cloud mirror: go env -w GOPROXY=https://mirrors.aliyun.com/goproxy/,direct

Import the SDK:

HELPCODEESCAPE-go
import (
"github.com/openai/openai-go/v3" // imported as openai
)

What to do next

After installing the SDK:

  • Select a model that fits your scenario from the Model Studio console.

  • Start building your application using models for text generation, image generation, video generation, speech synthesis, speech recognition, embedding, or reranking.

  • Learn about the compatibility details with the OpenAI API.

Mirror of Alibaba Cloud Model Studio docs for reference and RAG. Not affiliated with Alibaba Cloud.