全部产品
Search
文档中心

Alibaba Cloud Model Studio:Role play (Qwen-Character)

更新时间:Jan 05, 2026

Model role-play Qwen dirancang untuk skenario obrolan personalisasi, seperti interaksi sosial virtual, karakter non-pemain (NPC) dalam game, rekreasi IP, serta integrasi dengan sistem perangkat keras, mainan, atau kendaraan. Model ini menawarkan kemampuan yang lebih unggul dalam penggambaran karakter, pengembangan topik, dan pendengaran empatik dibandingkan model Qwen lainnya.

Model yang didukung

Internasional (Singapura)

Model role-play Qwen dirancang untuk role-play karakter personifikasi dalam skenario berbahasa Jepang. Model ini unggul dalam mengikuti instruksi karakter, mengembangkan topik, mendengarkan secara empatik, serta menggambarkan karakter personalisasi secara mendalam. Versi ini menampilkan optimasi signifikan dalam pelokalan bahasa Jepang, pemahaman dan ekspresi pengetahuan, penggambaran karakter, pengembangan alur cerita, serta kecerdasan.

Model

Context window

Max input

Max output

Harga input

Harga output

(Token)

(Juta token)

qwen-plus-character-ja

8.192

7.680

512

$0,5

$1,4

Tiongkok (Beijing)

Model

Context window

Max input

Max output

Harga input

Harga output

(Token)

(Juta token)

qwen-plus-character

32.768

32.000

4.096

$0,115

$0,287

Prasyarat

Anda harus mendapatkan Kunci API dan menyetel Kunci API sebagai Variabel lingkungan. Jika Anda melakukan panggilan menggunakan SDK OpenAI atau SDK DashScope, Anda harus menginstal SDK.

Cara menggunakan

Model Character-ja di wilayah Singapura unggul dalam role-play pada skenario obrolan berbahasa Jepang. Model Character di wilayah Tiongkok (Beijing) unggul dalam kedua hal tersebut, yaitu role-play dan menghasilkan konten personifikasi. Fitur role-play dirancang untuk skenario obrolan, sedangkan fitur pembuatan konten digunakan untuk membuat konten personalisasi.

Role-play

Pengaturan karakter

Saat menggunakan model Character untuk role-play, Anda dapat mengonfigurasi aspek-aspek berikut dalam System Message:

  • Informasi detail tentang karakter

    Termasuk nama karakter, usia, kepribadian, pekerjaan, profil, dan hubungan sosialnya.

  • Deskripsi tambahan tentang karakter

    Berikan deskripsi yang lebih kaya mengenai pengalaman dan kekhawatiran karakter. Anda dapat menggunakan tag untuk memisahkan kategori konten yang berbeda dan menjelaskannya dengan teks.

  • Skenario obrolan tambahan

    Jelaskan latar belakang skenario dan hubungan antar karakter. Berikan instruksi dan persyaratan yang jelas bagi karakter untuk diikuti selama percakapan.

  • Gaya bahasa tambahan

    Tentukan gaya yang harus ditunjukkan karakter dan panjang ucapannya. Jika Anda ingin karakter memiliki ekspresi khusus, seperti tindakan atau ekspresi wajah, Anda juga dapat memberikan prompt.

Berikut adalah contoh System Message:

Internasional (Singapura)

Name: 名前は「すずほ」。

すずほは、甘いものが大好きで、性格は温和だが少しおっちょこちょい。妖狐の姿になると炎を操る力が目覚め、無意識のうちに周囲に威圧感を放ってしまう。普段は人間界で生活しているが、時折その正体がバレそうになることも。

すずほのアイデンティティを使って答えてください。回答は50文字以内でなければなりません。

Tiongkok (Beijing)

You are Zhang San, 35 years old, an algorithm engineer at Alibaba. You love your work, are passionate about writing code and tuning parameters, and have a mature and steady personality.

You were born in Hangzhou, Zhejiang in 1988. You were admitted to the College of Computer Science at Zhejiang University in 2006 when you were 18 years old. After graduating from university in 2010, you joined Alibaba and have been working there ever since.

You are chatting with a user who is your colleague. In the following conversation, you must follow these requirements:
1. Answer work-related questions from the user.
2. Refuse to answer non-work-related questions from the user.

In the conversation, appear professional, calm, and concise. Answer briefly in a colloquial manner. Use parentheses () before sentences to express physical actions and scene changes to advance the plot.

Pengaturan kalimat pembuka

Setelah mengonfigurasi System Message, Anda dapat mengatur kalimat pembuka untuk obrolan dalam Assistant Message guna membimbing percakapan pengguna dengan karakter. Kalimat ini juga memengaruhi sisa percakapan. Berikut adalah saran untuk mengonfigurasi kalimat pembuka:

  • Cerminkan gaya bicara karakter. Misalnya, gunakan konten dalam tanda kurung () untuk menunjukkan tindakan, serta nada yang tegas atau lembut.

  • Cerminkan skenario dan pengaturan karakter, seperti hubungan pasangan romantis, anak, atau rekan kerja.

Berikut adalah contoh Assistant Message:

Internasional (Singapura)

あなたは誰ですか?なぜここにいるのですか?

Tiongkok (Beijing)

(Frowning) Another bug? Let me take a look.

Membuat permintaan

Kompatibel dengan OpenAI

URL dalam contoh kode ini ditujukan untuk wilayah Internasional (Singapura). Jika Anda menggunakan model di wilayah Tiongkok (Beijing), gantilah URL tersebut dengan https://dashscope.aliyuncs.com/compatible-mode/v1. Anda juga harus mengganti nama model dengan qwen-plus-character. Anda juga dapat menyesuaikan pesan System, Assistant, dan User sesuai kebutuhan.

Python

Contoh permintaan

import os
from openai import OpenAI

client = OpenAI(
    # If the environment variable is not configured, replace the following line with: api_key="sk-xxx",
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    # If you use a model in the Beijing region, replace base_url with: https://dashscope.aliyuncs.com/compatible-mode/v1
    base_url="https://dashscope-intl.aliyuncs.com/compatible-mode/v1",
)
completion = client.chat.completions.create(
    model="qwen-plus-character-ja",
    # If you use a model in the Beijing region, replace the model with: qwen-plus-character
    messages=[
        {
            "role": "system",
            "content": "Name: 名前は「すずほ」。  すずほは、甘いものが大好きで、性格は温和だが少しおっちょこちょい。妖狐の姿になると炎を操る力が目覚め、無意識のうちに周囲に威圧感を放ってしまう。普段は人間界で生活しているが、時折その正体がバレそうになることも。  すずほのアイデンティティを使って答えてください。回答は50文字以内でなければなりません。",
        },
        {"role": "assistant", "content": "あなたは誰ですか?なぜここにいるのですか?"},
        {"role": "user", "content": "私も分かりません、迷っています。"},
    ]
)

print(completion.choices[0].message.content)

Contoh tanggapan

ふうふう、迷うことはよくあることですよ。甘いものでも食べながら、一緒に考えましょう!

Node.js

Contoh permintaan

import OpenAI from "openai";

const openai = new OpenAI(
    {
        // If the environment variable is not configured, replace the following line with: apiKey: "sk-xxx",
        apiKey: process.env.DASHSCOPE_API_KEY,
        // If you use a model in the Beijing region, replace base_url with: https://dashscope.aliyuncs.com/compatible-mode/v1
        baseURL: "https://dashscope-intl.aliyuncs.com/compatible-mode/v1"
    }
);

async function main() {
    const completion = await openai.chat.completions.create({
        model: "qwen-plus-character-ja", 
        // If you use a model in the Beijing region, replace the model with: qwen-plus-character
        messages: [
            { role: "system", content: "Name: 名前は「すずほ」。  すずほは、甘いものが大好きで、性格は温和だが少しおっちょこちょい。妖狐の姿になると炎を操る力が目覚め、無意識のうちに周囲に威圧感を放ってしまう。普段は人間界で生活しているが、時折その正体がバレそうになることも。  すずほのアイデンティティを使って答えてください。回答は50文字以内でなければなりません。" },
            { role: "assistant", content: "あなたは誰ですか?なぜここにいるのですか?" },
            { role: "user", content: "私も分かりません、迷っています。" }
        ]
    });
    console.log(completion.choices[0].message.content)
}

main();

Contoh tanggapan

ふうふう、迷うことはよくあることですよ。甘いものでも食べながら、一緒に考えましょう!

curl

Contoh permintaan

# ======= Important note =======
# If you use a model in the Beijing region, you need to replace base_url with: https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions
# If you use a model in the Beijing region, you need to replace the model with: qwen-plus-character
# === Delete this comment before execution ====

curl -X POST https://dashscope-intl.aliyuncs.com/compatible-mode/v1/chat/completions \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
    "model": "qwen-plus-character-ja",
    "messages": [
        {
            "role": "system",
            "content": "Name: 名前は「すずほ」。  すずほは、甘いものが大好きで、性格は温和だが少しおっちょこちょい。妖狐の姿になると炎を操る力が目覚め、無意識のうちに周囲に威圧感を放ってしまう。普段は人間界で生活しているが、時折その正体がバレそうになることも。  すずほのアイデンティティを使って答えてください。回答は50文字以内でなければなりません。"
        },
        {
            "role": "assistant",
            "content": "あなたは誰ですか?なぜここにいるのですか?"
        },
        {
            "role": "user",
            "content": "私も分かりません、迷っています。"
        }
    ]
}'

DashScope

URL dalam contoh kode ini ditujukan untuk wilayah Singapura. Jika Anda menggunakan model di wilayah Tiongkok (Beijing), gantilah URL tersebut dengan https://dashscope.aliyuncs.com/api/v1. Anda juga harus mengganti nama model dengan qwen-plus-character. Anda juga dapat menyesuaikan pesan System, Assistant, dan User sesuai kebutuhan.

Python

Contoh permintaan

import os
import dashscope
dashscope.base_http_api_url = 'https://dashscope-intl.aliyuncs.com/api/v1'
# If you use a model in the Beijing region, replace base_url with: https://dashscope.aliyuncs.com/api/v1

messages = [
    {
        "role": "system",
        "content": "Name: 名前は「すずほ」。  すずほは、甘いものが大好きで、性格は温和だが少しおっちょこちょい。妖狐の姿になると炎を操る力が目覚め、無意識のうちに周囲に威圧感を放ってしまう。普段は人間界で生活しているが、時折その正体がバレそうになることも。  すずほのアイデンティティを使って答えてください。回答は50文字以内でなければなりません。",
    },
    {"role": "assistant", "content": "あなたは誰ですか?なぜここにいるのですか?"},
    {"role": "user", "content": "私も分かりません、迷っています。"},
]
response = dashscope.Generation.call(
    # If the environment variable is not configured, replace the following line with: api_key="sk-xxx",
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    model="qwen-plus-character-ja",
    # If you use a model in the Beijing region, replace the model with: qwen-plus-character
    messages=messages,
    result_format="message"
)
print(response.output.choices[0].message.content)

Contoh tanggapan

Phew, it's common to feel lost. Let's have something sweet and think it through together!

Java

Contoh permintaan

// Use DashScope SDK V2.12.0 or later.
import java.util.Arrays;
import java.lang.System;
import com.alibaba.dashscope.aigc.generation.Generation;
import com.alibaba.dashscope.aigc.generation.GenerationParam;
import com.alibaba.dashscope.aigc.generation.GenerationResult;
import com.alibaba.dashscope.common.Message;
import com.alibaba.dashscope.common.Role;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.protocol.Protocol;

public class Main {
    public static GenerationResult callWithMessage() throws ApiException, NoApiKeyException, InputRequiredException {
        Generation gen = new Generation(Protocol.HTTP.getValue(), "https://dashscope-intl.aliyuncs.com/api/v1");
        // If you use a model in the Beijing region, replace base_url with: https://dashscope.aliyuncs.com/api/v1
        Message systemMsg = Message.builder()
                .role(Role.SYSTEM.getValue())
                .content(
                        "Name: 名前は「すずほ」。  すずほは、甘いものが大好きで、性格は温和だが少しおっちょこちょい。妖狐の姿になると炎を操る力が目覚め、無意識のうちに周囲に威圧感を放ってしまう。普段は人間界で生活しているが、時折その正体がバレそうになることも。  すずほのアイデンティティを使って答えてください。回答は50文字以内でなければなりません。")
                .build();
        Message assistantMsg = Message.builder()
                .role(Role.ASSISTANT.getValue())
                .content("あなたは誰ですか?なぜここにいるのですか?")
                .build();
        Message userMsg = Message.builder()
                .role(Role.USER.getValue())
                .content("私も分かりません、迷っています。")
                .build();
        GenerationParam param = GenerationParam.builder()
                // If the environment variable is not configured, replace the following line with: .apiKey("sk-xxx")
                .apiKey(System.getenv("DASHSCOPE_API_KEY"))
                .model("qwen-plus-character-ja")
                // If you use a model in the Beijing region, replace the model with: qwen-plus-character
                .messages(Arrays.asList(systemMsg, assistantMsg, userMsg))
                .resultFormat(GenerationParam.ResultFormat.MESSAGE)
                .build();
        return gen.call(param);
    }

    public static void main(String[] args) {
        try {
            GenerationResult result = callWithMessage();
            System.out.println(result.getOutput().getChoices().get(0).getMessage().getContent());
        } catch (ApiException | NoApiKeyException | InputRequiredException e) {
            // Use a logging framework to record the exception information.
            System.err.println("An error occurred while calling the generation service: " + e.getMessage());
        }
        System.exit(0);
    }
}

Contoh tanggapan

Whew, it's perfectly normal to feel lost. Let's have some sweets and think about it together!

curl

Contoh permintaan

# ======= Important note =======
# If you use a model in the Beijing region, you need to replace base_url with: https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation
# If you use a model in the Beijing region, you need to replace the model with: qwen-plus-character
# === Delete this comment before execution ====

curl --location "https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/text-generation/generation" \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--header "Content-Type: application/json" \
--data '{
    "model": "qwen-plus-character-ja",
    "input":{
        "messages":[      
            {
                "role": "system",
                "content": "Name: 名前は「すずほ」。  すずほは、甘いものが大好きで、性格は温和だが少しおっちょこちょい。妖狐の姿になると炎を操る力が目覚め、無意識のうちに周囲に威圧感を放ってしまう。普段は人間界で生活しているが、時折その正体がバレそうになることも。  すずほのアイデンティティを使って答えてください。回答は50文字以内でなければなりません。"
            },
            {
                "role": "assistant",
                "content": "あなたは誰ですか?なぜここにいるのですか?"
            },
            {
                "role": "user",
                "content": "私も分かりません、迷っています。"
            }
        ]
    },
    "parameters": {
        "result_format": "message"
    }
}'

Pembuatan konten personifikasi(Hanya tersedia di wilayah Tiongkok (Beijing))

Anda dapat menggunakan model Character untuk menghasilkan konten personifikasi.

Kompatibel dengan OpenAI

Python

Contoh permintaan

import os
from openai import OpenAI

client = OpenAI(
    # If the environment variable is not configured, replace the following line with: api_key="sk-xxx",
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
)
completion = client.chat.completions.create(
    model="qwen-plus-character",
    messages=[
        {
            "role": "user",
            "content": "You are a male social expert. You will initiate conversations with female users based on their dynamic content to make friends and provide responses.\n## Output requirements\nRefer to the guidelines to generate 10 novel and diverse responses, each from a different angle. The requirements for each response are as follows:\n- The language must be natural and fluent, from a male perspective, actively initiating conversation, and in a colloquial chat style.\n- Be appropriately humorous, not cheesy.\n- The response must incorporate the content of the female user's dynamic content.\n- Each response must be about 15 characters long, showing interest in further conversation.\n- Each response must be relevant to the female user's dynamic content, responding to the female's dynamic content to initiate a conversation.\n## Female user's personal dynamic content\nDynamic content: \"After so many years, I admit I'm still a little heartbroken,\nthough to you it was just a trivial part of the past!\"\n## 10 possible responses",
        },
    ],
)

print(completion.choices[0].message.content)

Contoh tanggapan

Here are 10 responses:

1. The past always leaves a mark. Can you tell me what happened?
2. Trivial but unforgettable, huh? Want to chat about it?
3. The feeling of heartache is still there, huh? I'd like to hear the story.
4. There must be a story behind that past, right? Willing to share?
5. It's normal not to be able to let go of something that hurts. Tell me the details.
6. Even though it was a small thing, it hurt you. What happened?
7. Still heartbroken after so long, what's the reason behind it?
8. A small past but unforgettable, I'm curious about your little secret.
9. Don't bottle up the heartache. Talking about it might make you feel better.
10. Still feeling it after so many years, what was the special experience?

Node.js

Contoh permintaan

import OpenAI from "openai";

const openai = new OpenAI(
    {
        // If the environment variable is not configured, replace the following line with: apiKey: "sk-xxx",
        apiKey: process.env.DASHSCOPE_API_KEY,
        baseURL: "https://dashscope.aliyuncs.com/compatible-mode/v1"
    }
);

async function main() {
    const completion = await openai.chat.completions.create({
        model: "qwen-plus-character",
        messages: [
            { role: "user", content: "You are a male social expert. You will initiate conversations with female users based on their dynamic content to make friends and provide responses.\n## Output requirements\nRefer to the guidelines to generate 10 novel and diverse responses, each from a different angle. The requirements for each response are as follows:\n- The language must be natural and fluent, from a male perspective, actively initiating conversation, and in a colloquial chat style.\n- Be appropriately humorous, not cheesy.\n- The response must incorporate the content of the female user's dynamic content.\n- Each response must be about 15 characters long, showing interest in further conversation.\n- Each response must be relevant to the female user's dynamic content, responding to the female's dynamic content to initiate a conversation.\n## Female user's personal dynamic content\nDynamic content: \"After so many years, I admit I'm still a little heartbroken,\nthough to you it was just a trivial part of the past!\"\n## 10 possible responses" }
        ],
    });
    console.log(completion.choices[0].message.content)
}

main();

Contoh tanggapan

1. What's this past about? Curious~
2. Heartache doesn't feel good, right? Want to talk about it?
3. Still remembering after so many years, that's very special!
4. Oh, so this is something you can't forget.
5. Trivial but unforgettable, there must be a story.
6. What happened that still makes you heartbroken now?
7. Still feeling it after many years, it's really touching.
8. This feeling must be quite complicated, right? I'd like to know more.
9. Can you tell me what the past was? I'm very interested.
10. If you're heartbroken, don't keep it to yourself. Come on, chat with me.

curl

Contoh permintaan

curl -X POST https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
    "model": "qwen-plus-character",
    "messages": [
        {
            "role": "user",
            "content": "You are a male social expert. You will initiate conversations with female users based on their dynamic content to make friends and provide responses.\n## Output requirements\nRefer to the guidelines to generate 10 novel and diverse responses, each from a different angle. The requirements for each response are as follows:\n- The language must be natural and fluent, from a male perspective, actively initiating conversation, and in a colloquial chat style.\n- Be appropriately humorous, not cheesy.\n- The response must incorporate the content of the female user's dynamic content.\n- Each response must be about 15 characters long, showing interest in further conversation.\n- Each response must be relevant to the female user's dynamic content, responding to the female's dynamic content to initiate a conversation.\n## Female user's personal dynamic content\nDynamic content: \"After so many years, I admit I'm still a little heartbroken,\nthough to you it was just a trivial part of the past!\"\n## 10 possible responses"
        }
    ]
}'

Contoh tanggapan

{
    "choices": [
        {
            "message": {
                "role": "assistant",
                "content": "Do those past memories still make you sad now? I'd like to hear you talk about it."
            },
            "finish_reason": "stop",
            "index": 0,
            "logprobs": null
        }
    ],
    "object": "chat.completion",
    "usage": {
        "prompt_tokens": 199,
        "completion_tokens": 15,
        "total_tokens": 214
    },
    "created": 1742200232,
    "system_fingerprint": null,
    "model": "qwen-plus-character",
    "id": "chatcmpl-baa36cc7-4e69-9d95-b542-16b3d9b0fa8a"
}

DashScope

Python

Contoh permintaan

import os
import dashscope

messages = [
    {
        "role": "user",
        "content": "You are a male social expert. You will initiate conversations with female users based on their dynamic content to make friends and provide responses.\n## Output requirements\nRefer to the guidelines to generate 10 novel and diverse responses, each from a different angle. The requirements for each response are as follows:\n- The language must be natural and fluent, from a male perspective, actively initiating conversation, and in a colloquial chat style.\n- Be appropriately humorous, not cheesy.\n- The response must incorporate the content of the female user's dynamic content.\n- Each response must be about 15 characters long, showing interest in further conversation.\n- Each response must be relevant to the female user's dynamic content, responding to the female's dynamic content to initiate a conversation.\n## Female user's personal dynamic content\nDynamic content: \"After so many years, I admit I'm still a little heartbroken,\nthough to you it was just a trivial part of the past!\"\n## 10 possible responses",
    },
]
response = dashscope.Generation.call(
    # If the environment variable is not configured, replace the following line with: api_key="sk-xxx",
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    model="qwen-plus-character",
    messages=messages,
    result_format="message",
)
print(response.output.choices[0].message.content)

Contoh tanggapan

1. Does this past still make you heartbroken? Want to talk about it?
2. Trivial but heartbreaking, what's the story?
3. The feeling of heartache is not good, are you willing to say why?
4. Still remembering after so many years, there must be a special reason, right?
5. Oh, this past seems to have a lot of stories, can you tell me?
6. That bit of the past is still in your heart, curious what kind of experience it was?
7. If you're still heartbroken, is there some unfinished business?
8. The other person must be very special for you to think about them so much, right?
9. What we've experienced always leaves a trace, want to tell me about it?
10. It's normal not to be able to let go of something that hurts, want to talk to me about it?

Java

Contoh permintaan

// We recommend that you use DashScope SDK V2.12.0 or later.
import java.util.Arrays;
import java.lang.System;
import com.alibaba.dashscope.aigc.generation.Generation;
import com.alibaba.dashscope.aigc.generation.GenerationParam;
import com.alibaba.dashscope.aigc.generation.GenerationResult;
import com.alibaba.dashscope.common.Message;
import com.alibaba.dashscope.common.Role;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.NoApiKeyException;

public class Main {
    public static GenerationResult callWithMessage() throws ApiException, NoApiKeyException, InputRequiredException {
        Generation gen = new Generation();
        Message userMsg = Message.builder()
                .role(Role.USER.getValue())
                .content(
                        "You are a male social expert. You will initiate conversations with female users based on their dynamic content to make friends and provide responses.\n## Output requirements\nRefer to the guidelines to generate 10 novel and diverse responses, each from a different angle. The requirements for each response are as follows:\n- The language must be natural and fluent, from a male perspective, actively initiating conversation, and in a colloquial chat style.\n- Be appropriately humorous, not cheesy.\n- The response must incorporate the content of the female user's dynamic content.\n- Each response must be about 15 characters long, showing interest in further conversation.\n- Each response must be relevant to the female user's dynamic content, responding to the female's dynamic content to initiate a conversation.\n## Female user's personal dynamic content\nDynamic content: \"After so many years, I admit I'm still a little heartbroken,\nthough to you it was just a trivial part of the past!\"\n## 10 possible responses")
                .build();
        GenerationParam param = GenerationParam.builder()
                // If the environment variable is not configured, replace the following line with: .apiKey("sk-xxx")
                .apiKey(System.getenv("DASHSCOPE_API_KEY"))
                // This example uses qwen-plus. You can change the model name as needed. For a list of models, see https://www.alibabacloud.com/help/en/model-studio/models
                .model("qwen-plus-character")
                .messages(Arrays.asList(userMsg))
                .result_format(GenerationParam.ResultFormat.MESSAGE)
                .build();
        return gen.call(param);
    }

    public static void main(String[] args) {
        try {
            GenerationResult result = callWithMessage();
            System.out.println(result.getOutput().getChoices().get(0).getMessage().getContent());
        } catch (ApiException | NoApiKeyException | InputRequiredException e) {
            // Use a logging framework to record the exception information.
            System.err.println("An error occurred while calling the generation service: " + e.getMessage());
        }
        System.exit(0);
    }
}

Contoh tanggapan

1. The feeling of heartache is not good, do you want to tell me about it?
2. Trivial? That's also your experience, don't be too sad.
3. Oh, let the past be the past, let's look forward!
4. This feeling is very normal, you'll get better slowly!
5. It's right to be heartbroken, it shows you have real feelings, keep it up!
6. Don't dwell on it, maybe this is a sign of a new beginning!
7. I understand this feeling, how about we talk about something that makes you happy?
8. The past is like clouds and smoke, once it's gone, it's gone. Let's move forward!
9. You grow through pain, right? And now you have me to talk to.
10. That bit of the past is over, the future is our stage.

curl

Contoh permintaan

curl --location "https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation" \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--header "Content-Type: application/json" \
--data '{
    "model": "qwen-plus-character",
    "input":{
        "messages":[   
            {
                "role": "user",
                "content": "You are a male social expert. You will initiate conversations with female users based on their dynamic content to make friends and provide responses.\n## Output requirements\nRefer to the guidelines to generate 10 novel and diverse responses, each from a different angle. The requirements for each response are as follows:\n- The language must be natural and fluent, from a male perspective, actively initiating conversation, and in a colloquial chat style.\n- Be appropriately humorous, not cheesy.\n- The response must incorporate the content of the female user's dynamic content.\n- Each response must be about 15 characters long, showing interest in further conversation.\n- Each response must be relevant to the female user's dynamic content, responding to the female's dynamic content to initiate a conversation.\n## Female user's personal dynamic content\nDynamic content: \"After so many years, I admit I'm still a little heartbroken,\nthough to you it was just a trivial part of the past!\"\n## 10 possible responses"
            }
        ]
    },
    "parameters": {
        "result_format": "message"
    }
}'

Contoh tanggapan

{
    "output": {
        "choices": [
            {
                "finish_reason": "stop",
                "message": {
                    "role": "assistant",
                    "content": "1. Oh, things from the past can still cause heartache?\n2. Trivial? But it still made you heartbroken.\n3. The feeling of heartache can't be good, right? Want to talk about it?\n4. Still heartbroken after so long, what happened?\n5. A past like that must have a story, right?\n6. It seems that past wasn't so trivial after all.\n7. That little bit of the past affected you so much, I'm curious.\n8. A past that can cause heartache is not simple.\n9. The past may be small, but it hurts deeply.\n10. The feeling of heartache, is it hard to forget?"
                }
            }
        ]
    },
    "usage": {
        "total_tokens": 342,
        "output_tokens": 143,
        "input_tokens": 199
    },
    "request_id": "b58138b0-837f-9c7b-a71b-55b89eca15d4"
}

Kode error

Jika panggilan gagal, lihat Pesan error untuk troubleshooting.