Akses API untuk model teks, visual, ucapan, omni, dan embedding, dengan dukungan pemanggilan online, penjadwalan inferensi, dan pelatihan model.
Copy
curl "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1/responses" \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen4-max",
"input": "Who are you?"
}'
Copy
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["DASHSCOPE_API_KEY"],
base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
)
response = client.responses.create(
model="qwen4-max",
input="Who are you?",
)
print(response.output_text)
Copy
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.DASHSCOPE_API_KEY,
baseURL: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
});
const response = await client.responses.create({
model: "qwen4-max",
input: "Who are you?",
});
console.log(response.output_text);
Copy
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.responses.Response;
import com.openai.models.responses.ResponseCreateParams;
public class Main {
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.builder()
.apiKey(System.getenv("DASHSCOPE_API_KEY"))
.baseUrl("https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1")
.build();
ResponseCreateParams params = ResponseCreateParams.builder()
.model("qwen4-max")
.input("Who are you?")
.build();
Response response = client.responses().create(params);
response.output().stream()
.flatMap(item -> item.message().stream())
.flatMap(message -> message.content().stream())
.flatMap(content -> content.outputText().stream())
.forEach(text -> System.out.println(text.text()));
}
}
Copy
package main
import (
"context"
"fmt"
"os"
"github.com/openai/openai-go/v3"
"github.com/openai/openai-go/v3/option"
"github.com/openai/openai-go/v3/responses"
)
func main() {
client := openai.NewClient(
option.WithAPIKey(os.Getenv("DASHSCOPE_API_KEY")),
option.WithBaseURL("https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1"),
)
response, err := client.Responses.New(context.Background(), responses.ResponseNewParams{
Model: "qwen4-max",
Input: responses.ResponseNewParamsInputUnion{OfString: openai.String("Who are you?")},
})
if err != nil {
panic(err)
}
fmt.Println(response.OutputText())
}
Copy
#pragma warning disable OPENAI001
using System;
using System.ClientModel;
using OpenAI.Responses;
ResponsesClient client = new(
new ApiKeyCredential(Environment.GetEnvironmentVariable("DASHSCOPE_API_KEY")!),
new ResponsesClientOptions
{
Endpoint = new Uri("https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1")
});
ResponseResult response = client.CreateResponse(new CreateResponseOptions
{
Model = "qwen4-max",
InputItems = { ResponseItem.CreateUserMessageItem("Who are you?") }
});
Console.WriteLine(response.GetOutputText());
Copy
require "openai"
client = OpenAI::Client.new(
api_key: ENV.fetch("DASHSCOPE_API_KEY"),
base_url: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1"
)
response = client.responses.create(
model: "qwen4-max",
input: "Who are you?"
)
puts response.output_text
Copy
curl "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1/chat/completions" \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen4-max",
"messages": [{"role": "user", "content": "Who are you?"}]
}'
Copy
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["DASHSCOPE_API_KEY"],
base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
)
response = client.chat.completions.create(
model="qwen4-max",
messages=[{"role": "user", "content": "Who are you?"}]
)
print(response.choices[0].message.content)
Copy
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.DASHSCOPE_API_KEY,
baseURL: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",
});
const response = await client.chat.completions.create({
model: "qwen4-max",
messages: [{ role: "user", content: "Who are you?" }]
});
console.log(response.choices[0].message.content);
Copy
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.chat.completions.ChatCompletion;
import com.openai.models.chat.completions.ChatCompletionCreateParams;
public class Main {
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.builder()
.apiKey(System.getenv("DASHSCOPE_API_KEY"))
.baseUrl("https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1")
.build();
ChatCompletionCreateParams params = ChatCompletionCreateParams.builder()
.model("qwen4-max")
.addUserMessage("Who are you?")
.build();
ChatCompletion response = client.chat().completions().create(params);
System.out.println(response.choices().get(0).message().content().orElse(""));
}
}
Copy
package main
import (
"context"
"fmt"
"os"
"github.com/openai/openai-go/v3"
"github.com/openai/openai-go/v3/option"
)
func main() {
client := openai.NewClient(
option.WithAPIKey(os.Getenv("DASHSCOPE_API_KEY")),
option.WithBaseURL("https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1"),
)
response, err := client.Chat.Completions.New(context.Background(), openai.ChatCompletionNewParams{
Model: "qwen4-max",
Messages: []openai.ChatCompletionMessageParamUnion{
openai.UserMessage("Who are you?"),
},
})
if err != nil {
panic(err)
}
fmt.Println(response.Choices[0].Message.Content)
}
Copy
using System;
using System.ClientModel;
using OpenAI;
using OpenAI.Chat;
ChatClient client = new(
model: "qwen4-max",
credential: new ApiKeyCredential(Environment.GetEnvironmentVariable("DASHSCOPE_API_KEY")!),
options: new OpenAIClientOptions
{
Endpoint = new Uri("https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1")
});
ChatCompletion response = client.CompleteChat("Who are you?");
Console.WriteLine(response.Content[0].Text);
Copy
require "openai"
client = OpenAI::Client.new(
api_key: ENV.fetch("DASHSCOPE_API_KEY"),
base_url: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1"
)
response = client.chat.completions.create(
model: "qwen4-max",
messages: [{role: "user", content: "Who are you?"}]
)
puts response.choices.first.message.content
Copy
curl "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic/v1/messages" \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen4-max",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Who are you?"}]
}'
Copy
import os
from anthropic import Anthropic
client = Anthropic(
api_key=os.environ["DASHSCOPE_API_KEY"],
base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic",
)
response = client.messages.create(
model="qwen4-max",
max_tokens=1024,
messages=[{"role": "user", "content": "Who are you?"}]
)
for block in response.content:
if block.type == "text":
print(block.text)
Copy
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
apiKey: process.env.DASHSCOPE_API_KEY,
baseURL: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic",
});
const response = await client.messages.create({
model: "qwen4-max",
max_tokens: 1024,
messages: [{ role: "user", content: "Who are you?" }]
});
for (const block of response.content) {
if (block.type === "text") console.log(block.text);
}
Copy
import com.anthropic.client.AnthropicClient;
import com.anthropic.client.okhttp.AnthropicOkHttpClient;
import com.anthropic.models.messages.Message;
import com.anthropic.models.messages.MessageCreateParams;
public class Main {
public static void main(String[] args) {
AnthropicClient client = AnthropicOkHttpClient.builder()
.apiKey(System.getenv("DASHSCOPE_API_KEY"))
.baseUrl("https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic")
.build();
MessageCreateParams params = MessageCreateParams.builder()
.model("qwen4-max")
.maxTokens(1024L)
.addUserMessage("Who are you?")
.build();
Message response = client.messages().create(params);
response.content().stream()
.flatMap(block -> block.text().stream())
.forEach(text -> System.out.println(text.text()));
}
}
Copy
package main
import (
"context"
"fmt"
"os"
"github.com/anthropics/anthropic-sdk-go/v2"
"github.com/anthropics/anthropic-sdk-go/v2/option"
)
func main() {
client := anthropic.NewClient(
option.WithAPIKey(os.Getenv("DASHSCOPE_API_KEY")),
option.WithBaseURL("https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic"),
)
response, err := client.Messages.New(context.Background(), anthropic.MessageNewParams{
Model: "qwen4-max",
MaxTokens: 1024,
Messages: []anthropic.MessageParam{
anthropic.NewUserMessage(anthropic.NewTextBlock("Who are you?")),
},
})
if err != nil {
panic(err)
}
for _, block := range response.Content {
if block.Type == "text" {
fmt.Println(block.Text)
}
}
}
Copy
using System;
using Anthropic;
using Anthropic.Models.Messages;
AnthropicClient client = new()
{
ApiKey = Environment.GetEnvironmentVariable("DASHSCOPE_API_KEY"),
BaseUrl = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic"
};
MessageCreateParams parameters = new()
{
Model = "qwen4-max",
MaxTokens = 1024,
Messages = [new UserMessageParam("Who are you?")]
};
var response = await client.Messages.Create(parameters);
foreach (var block in response.Content)
{
if (block.TryPickText(out var text)) Console.WriteLine(text.Text);
}
Copy
require "anthropic"
client = Anthropic::Client.new(
api_key: ENV.fetch("DASHSCOPE_API_KEY"),
base_url: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic"
)
response = client.messages.create(
model: "qwen4-max",
max_tokens: 1024,
messages: [{role: "user", content: "Who are you?"}]
)
response.content.each do |block|
puts block.text if block.type == :text
end
Copy
<?php
require __DIR__ . "/vendor/autoload.php";
use Anthropic\Client;
$client = new Client(
apiKey: getenv("DASHSCOPE_API_KEY"),
baseUrl: "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic"
);
$response = $client->messages->create(
model: "qwen4-max",
maxTokens: 1024,
messages: [["role" => "user", "content" => "Who are you?"]]
);
foreach ($response->content as $block) {
if ($block->type === "text") echo $block->text . PHP_EOL;
}
Model
Lihat semua modelMulai membangun
Generasi teks dan pemahaman visual
Hasilkan teks dan pahami gambar serta video
Generasi gambar
Buat gambar dari teks
Generasi video
Buat video dari teks atau gambar
Ucapan dan audio
Kenali ucapan, sintesis suara, dan lakukan percakapan real-time
Omni-modal
Berinteraksi melalui teks, input visual, dan audio
Embedding dan pencarian
Tingkatkan pencarian dengan embedding dan reranking
Inferensi model
Mode Prime
Gunakan inferensi berkecepatan tinggi untuk skenario yang sensitif terhadap kecepatan output
Reservasi throughput
Cadangkan kapasitas inferensi model untuk mendukung trafik puncak
Inferensi batch
Proses banyak permintaan secara asinkron tanpa memerlukan respons real-time
Deployment khusus
Konfigurasikan layanan inferensi khusus untuk konkurensi tinggi dan latensi rendah
Perutean model
Pilih model yang sesuai secara otomatis berdasarkan isi permintaan
Pelatihan model
Siapkan data pelatihan
Pelajari format dan persyaratan persiapan dataset pelatihan dan evaluasi
Fine-tuning model
Latih model dengan data bisnis Anda untuk meningkatkan performa pada tugas tertentu
Evaluasi model
Evaluasi performa model untuk pemilihan model dan validasi fine-tuning
Kompresi model
Kuantisasi model hasil fine-tuning untuk mengurangi biaya deployment inferensi