Acesse APIs de modelos de texto, visão, fala, omni e embeddings, com suporte a chamadas online, agendamento de inferência e treinamento de modelos.
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;
}
Modelos
Ver todos os modelosComece a criar
Geração de texto e compreensão visual
Gere texto e compreenda imagens e vídeos
Geração de imagens
Crie imagens a partir de texto
Geração de vídeos
Crie vídeos a partir de texto ou imagens
Fala e áudio
Reconheça fala, sintetize vozes e converse em tempo real
Omnimodal
Interaja por texto, entradas visuais e áudio
Embeddings e busca
Melhore a busca com embeddings e reranking
Inferência de modelos
Modo Prime
Use inferência de alta velocidade em cenários sensíveis à velocidade de saída
Reserva de throughput
Reserve capacidade de inferência de um modelo para atender ao tráfego de pico
Inferência em lote
Processe grandes lotes de solicitações que não exigem respostas em tempo real
Implantação dedicada
Configure serviços de inferência dedicados para alta simultaneidade e baixa latência
Roteamento de modelos
Selecione automaticamente modelos adequados com base no conteúdo das solicitações
Treinamento de modelos
Preparar dados de treinamento
Conheça os formatos e requisitos de preparação dos conjuntos de dados de treinamento e avaliação
Ajustar modelos
Treine modelos com dados do seu negócio para melhorar o desempenho em tarefas específicas
Avaliação de modelos
Avalie o desempenho para selecionar modelos e validar o ajuste fino
Compressão de modelos
Quantize modelos ajustados para reduzir os custos de implantação de inferência