All Products
Search
Document Center

Alibaba Cloud Model Studio:Kimi

Last Updated:Jun 30, 2026

Dokumen ini menjelaskan cara memanggil layanan inferensi model Kimi yang diimplementasikan di Alibaba Cloud Model Studio.

Penting

Moonshot-Kimi-K2-Instruct dan kimi-k2-thinking akan dihentikan pada 9 Juli 2026. Kami merekomendasikan migrasi ke qwen3.7-plus, qwen3.7-max, atau qwen3.6-flash.

Wilayah yang didukung: China (Beijing), Singapura, Jepang (Tokyo), China (Hong Kong), Jerman (Frankfurt), dan AS (Virginia).

Pengalaman model: Anda dapat mencoba model Kimi di pusat uji coba model.

Titik akhir layanan bersifat spesifik per wilayah. Konfigurasikan URL dasar yang sesuai untuk wilayah Anda.

Kompatibel dengan OpenAI

AS (Virginia)

base_url untuk pemanggilan SDK adalah: https://dashscope-us.aliyuncs.com/compatible-mode/v1

URL permintaan HTTP: POST https://dashscope-us.aliyuncs.com/compatible-mode/v1/chat/completions

Jerman (Frankfurt)

base_url untuk pemanggilan SDK adalah: https://{WorkspaceId}.eu-central-1.maas.aliyuncs.com/compatible-mode/v1

URL permintaan HTTP: POST https://{WorkspaceId}.eu-central-1.maas.aliyuncs.com/compatible-mode/v1/chat/completions

Singapura

base_url untuk pemanggilan SDK adalah: https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1

URL permintaan HTTP: POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1/chat/completions

Jepang (Tokyo)

base_url untuk pemanggilan SDK adalah: https://{WorkspaceId}.ap-northeast-1.maas.aliyuncs.com/compatible-mode/v1

URL permintaan HTTP: POST https://{WorkspaceId}.ap-northeast-1.maas.aliyuncs.com/compatible-mode/v1/chat/completions

China (Beijing)

base_url untuk pemanggilan SDK adalah: https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1

URL permintaan HTTP: POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1/chat/completions

China (Hong Kong)

base_url untuk pemanggilan SDK adalah: https://{WorkspaceId}.cn-hongkong.maas.aliyuncs.com/compatible-mode/v1

URL permintaan HTTP: POST https://{WorkspaceId}.cn-hongkong.maas.aliyuncs.com/compatible-mode/v1/chat/completions

DashScope

AS (Virginia)

URL permintaan HTTP untuk model teks, seperti kimi-k2-thinking, adalah POST https://dashscope-us.aliyuncs.com/api/v1/services/aigc/text-generation/generation

URL permintaan HTTP untuk model multimodal, seperti kimi-k2.6 dan kimi-k2.5, adalah POST https://dashscope-us.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation

base_url untuk pemanggilan SDK adalah:

Kode Python

dashscope.base_http_api_url = 'https://dashscope-us.aliyuncs.com/api/v1'

Kode Java

  • Metode 1:

    import com.alibaba.dashscope.protocol.Protocol;
    Generation gen = new Generation(Protocol.HTTP.getValue(), “https://dashscope-us.aliyuncs.com/api/v1");
  • Metode 2:

    import com.alibaba.dashscope.utils.Constants;
    Constants.baseHttpApiUrl="https://dashscope-us.aliyuncs.com/api/v1";

Jerman (Frankfurt)

URL permintaan HTTP untuk model teks, seperti kimi-k2-thinking, adalah POST https://{WorkspaceId}.eu-central-1.maas.aliyuncs.com/api/v1/services/aigc/text-generation/generation

URL permintaan HTTP untuk model multimodal, seperti kimi-k2.7-code, kimi-k2.6, dan kimi-k2.5, adalah POST https://{WorkspaceId}.eu-central-1.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation

base_url untuk pemanggilan SDK adalah:

Kode Python

dashscope.base_http_api_url = 'https://{WorkspaceId}.eu-central-1.maas.aliyuncs.com/api/v1'

Kode Java

  • Metode 1:

    import com.alibaba.dashscope.protocol.Protocol;
    Generation gen = new Generation(Protocol.HTTP.getValue(), “https://{WorkspaceId}.eu-central-1.maas.aliyuncs.com/api/v1");
  • Metode 2:

    import com.alibaba.dashscope.utils.Constants;
    Constants.baseHttpApiUrl="https://{WorkspaceId}.eu-central-1.maas.aliyuncs.com/api/v1";

Singapura

URL permintaan HTTP untuk model teks, seperti kimi-k2-thinking, adalah POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/text-generation/generation

URL permintaan HTTP untuk model multimodal, seperti kimi-k2.7-code, kimi-k2.6, dan kimi-k2.5, adalah POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation

base_url untuk pemanggilan SDK adalah:

Kode Python

dashscope.base_http_api_url = 'https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1'

Kode Java

  • Opsi 1:

    import com.alibaba.dashscope.protocol.Protocol;
    Generation gen = new Generation(Protocol.HTTP.getValue(), "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1");
  • Opsi 2:

    import com.alibaba.dashscope.utils.Constants;
    Constants.baseHttpApiUrl="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1";

Jepang (Tokyo)

URL permintaan HTTP untuk model teks, seperti kimi-k2-thinking, adalah POST https://{WorkspaceId}.ap-northeast-1.maas.aliyuncs.com/api/v1/services/aigc/text-generation/generation

URL permintaan HTTP untuk model multimodal, seperti kimi-k2.7-code, kimi-k2.6, dan kimi-k2.5, adalah POST https://{WorkspaceId}.ap-northeast-1.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation

base_url untuk pemanggilan SDK adalah:

Kode Python

dashscope.base_http_api_url = 'https://{WorkspaceId}.ap-northeast-1.maas.aliyuncs.com/api/v1'

Kode Java

  • Opsi 1:

    import com.alibaba.dashscope.protocol.Protocol;
    Generation gen = new Generation(Protocol.HTTP.getValue(), "https://{WorkspaceId}.ap-northeast-1.maas.aliyuncs.com/api/v1");
  • Opsi 2:

    import com.alibaba.dashscope.utils.Constants;
    Constants.baseHttpApiUrl="https://{WorkspaceId}.ap-northeast-1.maas.aliyuncs.com/api/v1";

China (Hong Kong)

URL permintaan HTTP untuk model teks, seperti kimi-k2-thinking, adalah POST https://{WorkspaceId}.cn-hongkong.maas.aliyuncs.com/api/v1/services/aigc/text-generation/generation

URL permintaan HTTP untuk model multimodal, seperti kimi-k2.7-code, kimi-k2.6, dan kimi-k2.5, adalah POST https://{WorkspaceId}.cn-hongkong.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation

base_url untuk pemanggilan SDK adalah:

Kode Python

dashscope.base_http_api_url = 'https://{WorkspaceId}.cn-hongkong.maas.aliyuncs.com/api/v1'

Kode Java

  • Metode 1:

    import com.alibaba.dashscope.protocol.Protocol;
    Generation gen = new Generation(Protocol.HTTP.getValue(), “https://{WorkspaceId}.cn-hongkong.maas.aliyuncs.com/api/v1");
  • Metode 2:

    import com.alibaba.dashscope.utils.Constants;
    Constants.baseHttpApiUrl="https://{WorkspaceId}.cn-hongkong.maas.aliyuncs.com/api/v1";

China (Beijing)

URL permintaan HTTP untuk model teks, seperti kimi-k2-thinking, adalah POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/text-generation/generation

URL permintaan HTTP untuk model multimodal, seperti kimi-k2.7-code, kimi-k2.6, dan kimi-k2.5, adalah POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation

base_url untuk pemanggilan SDK adalah:

Kode Python

dashscope.base_http_api_url = 'https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1'

Kode Java

  • Opsi 1:

    import com.alibaba.dashscope.protocol.Protocol;
    Generation gen = new Generation(Protocol.HTTP.getValue(), "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1");
  • Opsi 2:

    import com.alibaba.dashscope.utils.Constants;
    Constants.baseHttpApiUrl="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1";

Ganti {WorkspaceId} dengan ID ruang kerja aktual Anda.

Prasyarat: Anda harus mendapatkan Kunci API dan menetapkannya sebagai variabel lingkungan. Jika menggunakan SDK, Anda harus menginstal SDK.

Mulai

Contoh berikut menggunakan input teks saja. Untuk contoh multimodal, lihat pemanggilan multimodal.

Kompatibel dengan OpenAI

Python

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    base_url="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
)

completion = client.chat.completions.create(
    model="kimi-k2.6",
    messages=[{"role": "user", "content": "Who are you?"}],
    stream=True,
    extra_body={"enable_thinking": True},  # Aktifkan mode berpikir untuk mendapatkan reasoning_content
)

reasoning_content = ""  # Proses berpikir lengkap
answer_content = ""     # Respons lengkap
is_answering = False    # Melacak apakah respons utama telah dimulai.

print("\n" + "=" * 20 + "Thinking Process" + "=" * 20 + "\n")

for chunk in completion:
    if chunk.choices:
        delta = chunk.choices[0].delta
        # Simpan konten dari proses berpikir.
        if hasattr(delta, "reasoning_content") and delta.reasoning_content is not None:
            if not is_answering:
                print(delta.reasoning_content, end="", flush=True)
            reasoning_content += delta.reasoning_content
        # Mulai mencetak respons utama setelah kontennya tiba.
        if hasattr(delta, "content") and delta.content:
            if not is_answering:
                print("\n" + "=" * 20 + "Complete Response" + "=" * 20 + "\n")
                is_answering = True
            print(delta.content, end="", flush=True)
            answer_content += delta.content

Respons

====================Thinking Process====================

The user asks "Who are you?", which is a direct question about my identity. I need to answer truthfully based on my actual identity.

I am Kimi, an AI assistant developed by Moonshot AI. I should introduce myself clearly and concisely, including:
1. My identity: AI assistant
2. My developer: Moonshot AI
3. My name: Kimi
4. My core capabilities: long-text processing, intelligent conversation, file processing, search, etc.

I should maintain a friendly and professional tone, avoiding overly technical terms for clarity. I should also emphasize that I am an AI without personal consciousness, emotions, or experiences to prevent misunderstandings.

Response structure:
- Directly state my identity
- Mention my developer
- Briefly introduce core capabilities
- Keep it clear and concise
====================Complete Response====================

I am Kimi, an AI assistant developed by Moonshot AI. I am based on a Mixture-of-Experts (MoE) architecture and have capabilities such as ultra-long context understanding, intelligent conversation, file processing, code generation, and complex task reasoning. How can I help you?

Node.js

import OpenAI from "openai";
import process from 'process';

// Inisialisasi klien OpenAI
const openai = new OpenAI({
    // Jika tidak menggunakan variabel lingkungan, ganti `process.env.DASHSCOPE_API_KEY` dengan string kunci API Anda (misalnya, "sk-xxx").
    apiKey: process.env.DASHSCOPE_API_KEY,
    baseURL: 'https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1'
});

let reasoningContent = ''; // Proses berpikir lengkap
let answerContent = ''; // Tanggapan lengkap
let isAnswering = false; // Melacak apakah tanggapan utama telah dimulai.

async function main() {
    const messages = [{ role: 'user', content: 'Who are you?' }];

    const stream = await openai.chat.completions.create({
        model: 'kimi-k2.6',
        messages,
        stream: true,
        enable_thinking: true,  // Aktifkan mode berpikir untuk mendapatkan reasoning_content
    });

    console.log('\n' + '='.repeat(20) + 'Thinking Process' + '='.repeat(20) + '\n');

    for await (const chunk of stream) {
        if (chunk.choices?.length) {
            const delta = chunk.choices[0].delta;
            // Simpan konten dari proses berpikir.
            if (delta.reasoning_content !== undefined && delta.reasoning_content !== null) {
                if (!isAnswering) {
                    process.stdout.write(delta.reasoning_content);
                }
                reasoningContent += delta.reasoning_content;
            }

            // Mulai mencetak tanggapan utama setelah kontennya tiba.
            if (delta.content !== undefined && delta.content) {
                if (!isAnswering) {
                    console.log('\n' + '='.repeat(20) + 'Complete Response' + '='.repeat(20) + '\n');
                    isAnswering = true;
                }
                process.stdout.write(delta.content);
                answerContent += delta.content;
            }
        }
    }
}

main();

Respons

====================Thinking Process====================

The user asks "Who are you?", which is a direct question about my identity. I need to answer truthfully based on my actual identity.

I am Kimi, an AI assistant developed by Moonshot AI. I should introduce myself clearly and concisely, including:
1. My identity: AI assistant
2. My developer: Moonshot AI
3. My name: Kimi
4. My core capabilities: long-text processing, intelligent conversation, file processing, search, etc.

I should maintain a friendly and professional tone and avoid overly technical terms for clarity. I should also emphasize that I am an AI without personal consciousness, emotions, or experiences to prevent misunderstandings.

Response structure:
- Directly state my identity
- Mention my developer
- Briefly introduce core capabilities
- Keep it clear and concise
====================Complete Response====================

I am Kimi, an AI assistant developed by Moonshot AI.

I am skilled in:
- Long-text understanding and generation
- Intelligent conversation and question answering
- File processing and analysis
- Information retrieval and integration

As an AI assistant, I do not have personal consciousness, emotions, or experiences, but I am designed to provide accurate and helpful assistance. How can I help you?

HTTP

curl

curl -X POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1/chat/completions \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
    "model": "kimi-k2.6",
    "messages": [
        {
            "role": "user",
            "content": "Who are you?"
        }
    ],
    "enable_thinking": true
}'

Respons

{
    "choices": [
        {
            "message": {
                "content": "I am Kimi, an AI assistant developed by Moonshot AI. I am skilled in long-text processing, intelligent conversation, file analysis, programming assistance, and complex task reasoning. I can help you answer questions, create content, and analyze documents. How can I assist you?",
                "reasoning_content": "The user asks \"Who are you?\", which is a direct question about my identity. I must answer truthfully based on my actual identity.\n\nI am Kimi, an AI assistant developed by Moonshot AI. I should introduce myself clearly and concisely, including:\n1. My identity: AI assistant\n2. My developer: Moonshot AI\n3. My name: Kimi\n4. My core capabilities: long-text processing, intelligent conversation, file processing, search, etc.\n\nI should maintain a friendly and professional tone while providing useful information. No need to overcomplicate; a direct answer is sufficient.",
                "role": "assistant"
            },
            "finish_reason": "stop",
            "index": 0,
            "logprobs": null
        }
    ],
    "object": "chat.completion",
    "usage": {
        "prompt_tokens": 8,
        "completion_tokens": 183,
        "total_tokens": 191
    },
    "created": 1762753998,
    "system_fingerprint": null,
    "model": "kimi-k2.6",
    "id": "chatcmpl-485ab490-90ec-48c3-85fa-1c732b683db2"
}

DashScope

Contoh DashScope berikut menggunakan titik akhir multimodal-generation untuk memanggil kimi-k2.6, yang mendukung input teks dan multimodal. Untuk contoh multimodal lainnya, lihat pemanggilan multimodal.

Python

import os
import dashscope
from dashscope import MultiModalConversation
# Konfigurasi wilayah China (Beijing). Ganti {WorkspaceId} dengan ID ruang kerja aktual Anda. Untuk wilayah lain, gunakan URL dasar yang sesuai.
dashscope.base_http_api_url = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1"

# Definisikan pesan permintaan.
messages = [{"role": "user", "content": "Who are you?"}]

completion = MultiModalConversation.call(
    api_key=os.getenv("DASHSCOPE_API_KEY"),  # Jika tidak menggunakan variabel lingkungan, berikan kunci Anda secara langsung, misalnya api_key="sk-xxx"
    model="kimi-k2.6",
    messages=messages,
    result_format="message",  # Atur format hasil menjadi message
    stream=True,              # Aktifkan streaming.
    incremental_output=True,  # Aktifkan output inkremental
    enable_thinking=True,     # Aktifkan mode berpikir untuk mendapatkan reasoning_content
)

reasoning_content = ""  # Proses berpikir lengkap
answer_content = ""     # Respons lengkap
is_answering = False    # Melacak apakah respons utama telah dimulai.

print("\n" + "=" * 20 + "Thinking Process" + "=" * 20 + "\n")

for chunk in completion:
    message = chunk.output.choices[0].message
    
    # Simpan konten dari proses berpikir.
    if message.reasoning_content:
        if not is_answering:
            print(message.reasoning_content, end="", flush=True)
        reasoning_content += message.reasoning_content

    # Mulai mencetak respons utama setelah kontennya tiba.
    if message.content:
        if not is_answering:
            print("\n" + "=" * 20 + "Complete Response" + "=" * 20 + "\n")
            is_answering = True
        print(message.content, end="", flush=True)
        answer_content += message.content

Respons

====================Thinking Process====================

The user asks "Who are you?", which is a direct question about my identity. I need to answer truthfully based on my actual identity.

I am Kimi, an AI assistant developed by Moonshot AI. I should state this clearly and concisely.

Key information to include:
1. My name: Kimi
2. My developer: Moonshot AI
3. My nature: AI assistant
4. What I can do: answer questions, assist with content creation, etc.

I should maintain a friendly and helpful tone while accurately stating my identity. I should not pretend to be human or have a personal identity.

A suitable response would be:
"I am Kimi, an AI assistant developed by Moonshot AI. I can help you with a variety of tasks such as answering questions, creating content, and analyzing documents. How can I help you?"

This response is direct, accurate, and encourages further interaction.
====================Complete Response====================

I am Kimi, an AI assistant developed by Moonshot AI. I can help you with a variety of tasks such as answering questions, creating content, and analyzing documents. How can I help you?

Java

// Versi SDK DashScope >= 2.19.4
import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversation;
import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversationParam;
import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversationResult;
import com.alibaba.dashscope.common.MultiModalMessage;
import com.alibaba.dashscope.common.Role;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.exception.UploadFileException;
import com.alibaba.dashscope.utils.Constants;
import java.util.Arrays;
import java.util.Collections;

public class Main {
    public static void main(String[] args) {
        // Konfigurasi wilayah China (Beijing). Ganti {WorkspaceId} dengan ID ruang kerja aktual Anda. Untuk wilayah lain, gunakan URL dasar yang sesuai.
        Constants.baseHttpApiUrl = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1";
        try {
            MultiModalConversation conv = new MultiModalConversation();

            MultiModalMessage userMsg = MultiModalMessage.builder()
                    .role(Role.USER.getValue())
                    .content(Arrays.asList(Collections.singletonMap("text", "Who are you?")))
                    .build();

            MultiModalConversationParam param = MultiModalConversationParam.builder()
                    // Jika tidak menggunakan variabel lingkungan, ganti baris berikut dengan Kunci API Anda, misalnya .apiKey("sk-xxx")
                    .apiKey(System.getenv("DASHSCOPE_API_KEY"))
                    .model("kimi-k2.6")
                    .messages(Arrays.asList(userMsg))
                    .build();

            MultiModalConversationResult result = conv.call(param);

            String content = (String) result.getOutput().getChoices().get(0).getMessage().getContent().get(0).get("text");
            System.out.println("Response: " + content);
        } catch (ApiException | NoApiKeyException | UploadFileException e) {
            System.err.println("An exception occurred: " + e.getMessage());
        }
        System.exit(0);
    }
}

Respons

====================Thinking Process====================
The user asks "Who are you?", which is a direct question about my identity. I need to answer truthfully based on my actual identity.

I am Kimi, an AI assistant developed by Moonshot AI. I should state this clearly and concisely.

The response should include:
1. My identity: AI assistant
2. My developer: Moonshot AI
3. My name: Kimi
4. My core capabilities: long-text processing, intelligent conversation, file processing, etc.

I should not pretend to be human or provide excessive technical details. A clear and friendly answer is sufficient.
====================Complete Response====================
I am Kimi, an AI assistant developed by Moonshot AI. My skills include long-text processing, intelligent conversation, question answering, content creation, and file analysis and processing. How can I assist you?

HTTP

curl

curl -X POST "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation" \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
    "model": "kimi-k2.6",
    "input":{
        "messages":[      
            {
                "role": "user",
                "content": "Who are you?"
            }
        ]
    },
    "parameters": {
        "result_format": "message",
        "enable_thinking": true
    }
}'

Respons

{
    "output": {
        "choices": [
            {
                "finish_reason": "stop",
                "message": {
                    "content": "I am Kimi, an AI assistant developed by Moonshot AI. I can help you answer questions, create content, analyze documents, and write code. How can I help you?",
                    "reasoning_content": "The user asks \"Who are you?\", which is a direct question about my identity. I need to answer truthfully based on my actual identity.\n\nI am Kimi, an AI assistant developed by Moonshot AI. I should state this clearly and concisely.\n\nKey information to include:\n1. My name: Kimi\n2. My developer: Moonshot AI\n3. My nature: AI assistant\n4. What I can do: answer questions, assist with content creation, etc.\n\nThe response should be friendly, direct, and easy to understand.",
                    "role": "assistant"
                }
            }
        ]
    },
    "usage": {
        "input_tokens": 9,
        "output_tokens": 156,
        "total_tokens": 165
    },
    "request_id": "709a0697-ed1f-4298-82c9-a4b878da1849"
}

Pemanggilan multimodal

Model kimi-k2.7-code, kimi-k2.6, dan kimi-k2.5 dapat memproses teks, gambar, atau video secara simultan. Gunakan parameter enable_thinking untuk mengaktifkan mode berpikir. Contoh berikut menunjukkan cara menggunakan kemampuan ini.

Aktifkan atau nonaktifkan mode berpikir

kimi-k2.6 dan kimi-k2.5 adalah model berpikir hibrida. Model ini dapat membalas setelah berpikir atau membalas secara langsung. Anda dapat menggunakan parameter enable_thinking untuk mengontrol apakah mode berpikir diaktifkan:

  • true: Aktifkan mode berpikir

  • false (default): Nonaktifkan mode berpikir

kimi-k2.7-code adalah model berpikir saja: mode berpikir selalu diaktifkan (enable_thinking default-nya true dan tidak dapat dinonaktifkan), dan preserve_thinking default-nya true.

kimi-k2.6 mendukung meneruskan proses berpikir dalam percakapan multi-putaran dengan menggunakan parameter preserve_thinking. Untuk informasi lebih lanjut, lihat Meneruskan proses berpikir.

Contoh berikut menunjukkan cara menggunakan URL gambar dan mengaktifkan mode berpikir. Contoh utama menunjukkan input gambar tunggal, sedangkan kode yang dikomentari adalah contoh input multi-gambar.

Kompatibel dengan OpenAI

Python

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    base_url="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
)

# Contoh input gambar tunggal (mode berpikir diaktifkan)
completion = client.chat.completions.create(
    model="kimi-k2.6",
    messages=[
        {
            "role": "user",
            "content": [
                {"type": "text", "text": "What scene is depicted in the image?"},
                {
                    "type": "image_url",
                    "image_url": {
                        "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241022/emyrja/dog_and_girl.jpeg"
                    }
                }
            ]
        }
    ],
    extra_body={"enable_thinking":True}  # Aktifkan mode berpikir
)

# Cetak proses berpikir
if hasattr(completion.choices[0].message, 'reasoning_content') and completion.choices[0].message.reasoning_content:
    print("\n" + "=" * 20 + "Thinking Process" + "=" * 20 + "\n")
    print(completion.choices[0].message.reasoning_content)

# Cetak respons lengkap
print("\n" + "=" * 20 + "Complete Response" + "=" * 20 + "\n")
print(completion.choices[0].message.content)

# Contoh input multi-gambar (mode berpikir diaktifkan, hapus komentar untuk digunakan)
# completion = client.chat.completions.create(
#     model="kimi-k2.6",
#     messages=[
#         {
#             "role": "user",
#             "content": [
#                 {"type": "text", "text": "What do these images depict?"},
#                 {
#                     "type": "image_url",
#                     "image_url": {"url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241022/emyrja/dog_and_girl.jpeg"}
#                 },
#                 {
#                     "type": "image_url",
#                     "image_url": {"url": "https://dashscope.oss-cn-beijing.aliyuncs.com/images/tiger.png"}
#                 }
#             ]
#         }
#     ],
#     extra_body={"enable_thinking":True}
# )
#
# # Cetak proses berpikir dan respons lengkap
# if hasattr(completion.choices[0].message, 'reasoning_content') and completion.choices[0].message.reasoning_content:
#     print("\nThinking Process:\n" + completion.choices[0].message.reasoning_content)
# print("\nComplete Response:\n" + completion.choices[0].message.content)

Node.js

import OpenAI from "openai";
import process from 'process';

const openai = new OpenAI({
    apiKey: process.env.DASHSCOPE_API_KEY,
    baseURL: 'https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1'
});

// Contoh input gambar tunggal (mode berpikir diaktifkan)
const completion = await openai.chat.completions.create({
    model: 'kimi-k2.6',
    messages: [
        {
            role: 'user',
            content: [
                { type: 'text', text: 'What scene is depicted in the image?' },
                {
                    type: 'image_url',
                    image_url: {
                        url: 'https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241022/emyrja/dog_and_girl.jpeg'
                    }
                }
            ]
        }
    ],
    enable_thinking: true  // Aktifkan mode berpikir
});

// Cetak proses berpikir
if (completion.choices[0].message.reasoning_content) {
    console.log('\n' + '='.repeat(20) + 'Thinking Process' + '='.repeat(20) + '\n');
    console.log(completion.choices[0].message.reasoning_content);
}

// Cetak respons lengkap
console.log('\n' + '='.repeat(20) + 'Complete Response' + '='.repeat(20) + '\n');
console.log(completion.choices[0].message.content);

// Contoh input multi-gambar (mode berpikir diaktifkan, hapus komentar untuk digunakan)
// const multiCompletion = await openai.chat.completions.create({
//     model: 'kimi-k2.6',
//     messages: [
//         {
//             role: 'user',
//             content: [
//                 { type: 'text', text: 'What do these images depict?' },
//                 {
//                     type: 'image_url',
//                     image_url: { url: 'https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241022/emyrja/dog_and_girl.jpeg' }
//                 },
//                 {
//                     type: 'image_url',
//                     image_url: { url: 'https://dashscope.oss-cn-beijing.aliyuncs.com/images/tiger.png' }
//                 }
//             ]
//         }
//     ],
//     enable_thinking: true
// });
//
// // Cetak proses berpikir dan respons lengkap
// if (multiCompletion.choices[0].message.reasoning_content) {
//     console.log('\nThinking Process:\n' + multiCompletion.choices[0].message.reasoning_content);
// }
// console.log('\nComplete Response:\n' + multiCompletion.choices[0].message.content);

Curl

curl -X POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1/chat/completions \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
    "model": "kimi-k2.6",
    "messages": [
        {
            "role": "user",
            "content": [
                {
                    "type": "text",
                    "text": "What scene is depicted in the image?"
                },
                {
                    "type": "image_url",
                    "image_url": {
                        "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241022/emyrja/dog_and_girl.jpeg"
                    }
                }
            ]
        }
    ],
    "enable_thinking": true
}'

# Contoh input multi-gambar (hapus komentar untuk digunakan)
# curl -X POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1/chat/completions \
# -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
# -H "Content-Type: application/json" \
# -d '{
#     "model": "kimi-k2.6",
#     "messages": [
#         {
#             "role": "user",
#             "content": [
#                 {
#                     "type": "text",
#                     "text": "What do these images depict?"
#                 },
#                 {
#                     "type": "image_url",
#                     "image_url": {
#                         "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241022/emyrja/dog_and_girl.jpeg"
#                     }
#                 },
#                 {
#                     "type": "image_url",
#                     "image_url": {
#                         "url": "https://dashscope.oss-cn-beijing.aliyuncs.com/images/tiger.png"
#                     }
#                 }
#             ]
#         }
#     ],
#     "enable_thinking": true,
#     "stream": false
# }'

DashScope

Python

import os
import dashscope
from dashscope import MultiModalConversation
# Konfigurasi wilayah China (Beijing). Ganti {WorkspaceId} dengan ID ruang kerja aktual Anda. Untuk wilayah lain, gunakan URL dasar yang sesuai.
dashscope.base_http_api_url = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1"

# Contoh input gambar tunggal (mode berpikir diaktifkan)
response = MultiModalConversation.call(
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    model="kimi-k2.6",
    messages=[
        {
            "role": "user",
            "content": [
                {"text": "What scene is depicted in the image?"},
                {"image": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241022/emyrja/dog_and_girl.jpeg"}
            ]
        }
    ],
    enable_thinking=True  # Aktifkan mode berpikir
)

# Cetak proses berpikir
if hasattr(response.output.choices[0].message, 'reasoning_content') and response.output.choices[0].message.reasoning_content:
    print("\n" + "=" * 20 + "Thinking Process" + "=" * 20 + "\n")
    print(response.output.choices[0].message.reasoning_content)

# Cetak respons lengkap
print("\n" + "=" * 20 + "Complete Response" + "=" * 20 + "\n")
print(response.output.choices[0].message.content[0]["text"])

# Contoh input multi-gambar (mode berpikir diaktifkan, hapus komentar untuk digunakan)
# response = MultiModalConversation.call(
#     api_key=os.getenv("DASHSCOPE_API_KEY"),
#     model="kimi-k2.6",
#     messages=[
#         {
#             "role": "user",
#             "content": [
#                 {"text": "What do these images depict?"},
#                 {"image": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241022/emyrja/dog_and_girl.jpeg"},
#                 {"image": "https://dashscope.oss-cn-beijing.aliyuncs.com/images/tiger.png"}
#             ]
#         }
#     ],
#     enable_thinking=True
# )
#
# # Cetak proses berpikir dan respons lengkap
# if hasattr(response.output.choices[0].message, 'reasoning_content') and response.output.choices[0].message.reasoning_content:
#     print("\nThinking Process:\n" + response.output.choices[0].message.reasoning_content)
# print("\nComplete Response:\n" + response.output.choices[0].message.content[0]["text"])

Java

// Memerlukan SDK DashScope v2.19.4 atau lebih baru.
import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversation;
import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversationParam;
import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversationResult;
import com.alibaba.dashscope.common.MultiModalMessage;
import com.alibaba.dashscope.common.Role;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.exception.UploadFileException;
import com.alibaba.dashscope.utils.JsonUtils;
import com.alibaba.dashscope.utils.Constants;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

public class KimiK26MultiModalExample {
    public static void main(String[] args) {
        // Konfigurasi wilayah China (Beijing). Ganti {WorkspaceId} dengan ID ruang kerja aktual Anda. Untuk wilayah lain, gunakan URL dasar yang sesuai.
        Constants.baseHttpApiUrl = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1";
        try {
            // Contoh input gambar tunggal (mode berpikir diaktifkan)
            MultiModalConversation conv = new MultiModalConversation();

            // Bangun konten pesan
            Map<String, Object> textContent = new HashMap<>();
            textContent.put("text", "What scene is depicted in the image?");

            Map<String, Object> imageContent = new HashMap<>();
            imageContent.put("image", "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241022/emyrja/dog_and_girl.jpeg");

            MultiModalMessage userMessage = MultiModalMessage.builder()
                    .role(Role.USER.getValue())
                    .content(Arrays.asList(textContent, imageContent))
                    .build();

            // Bangun parameter permintaan
            MultiModalConversationParam param = MultiModalConversationParam.builder()
                    // Jika variabel lingkungan tidak disetel, ganti ini dengan Kunci API Anda dari Model Studio.
                    .apiKey(System.getenv("DASHSCOPE_API_KEY"))
                    .model("kimi-k2.6")
                    .messages(Arrays.asList(userMessage))
                    .enableThinking(true)  // Aktifkan mode berpikir
                    .build();

            // Panggil model
            MultiModalConversationResult result = conv.call(param);

            // Cetak respons
            String content = (String) result.getOutput().getChoices().get(0).getMessage().getContent().get(0).get("text");
            System.out.println("Response: " + content);

            // Jika mode berpikir diaktifkan, cetak proses berpikir
            if (result.getOutput().getChoices().get(0).getMessage().getReasoningContent() != null) {
                System.out.println("\nThinking Process: " +
                    result.getOutput().getChoices().get(0).getMessage().getReasoningContent());
            }

            // Contoh input multi-gambar (hapus komentar untuk digunakan)
            // Map<String, Object> imageContent1 = new HashMap<>();
            // imageContent1.put("image", "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241022/emyrja/dog_and_girl.jpeg");
            // Map<String, Object> imageContent2 = new HashMap<>();
            // imageContent2.put("image", "https://dashscope.oss-cn-beijing.aliyuncs.com/images/tiger.png");
            //
            // Map<String, Object> textContent2 = new HashMap<>();
            // textContent2.put("text", "What do these images depict?");
            //
            // MultiModalMessage multiImageMessage = MultiModalMessage.builder()
            //         .role(Role.USER.getValue())
            //         .content(Arrays.asList(textContent2, imageContent1, imageContent2))
            //         .build();
            //
            // MultiModalConversationParam multiParam = MultiModalConversationParam.builder()
            //         .apiKey(System.getenv("DASHSCOPE_API_KEY"))
            //         .model("kimi-k2.6")
            //         .messages(Arrays.asList(multiImageMessage))
            //         .enableThinking(true)
            //         .build();
            //
            // MultiModalConversationResult multiResult = conv.call(multiParam);
            // System.out.println(multiResult.getOutput().getChoices().get(0).getMessage().getContent().get(0).get("text"));

        } catch (ApiException | NoApiKeyException | UploadFileException e) {
            System.err.println("Call failed: " + e.getMessage());
        }
    }
}

Curl

curl -X POST "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation" \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
    "model": "kimi-k2.6",
    "input": {
        "messages": [
            {
                "role": "user",
                "content": [
                    {
                        "text": "What scene is depicted in the image?"
                    },
                    {
                        "image": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241022/emyrja/dog_and_girl.jpeg"
                    }
                ]
            }
        ]
    },
    "parameters": {
        "enable_thinking": true
    }
}'

# Contoh input multi-gambar (hapus komentar untuk digunakan)
# curl -X POST "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation" \
# -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
# -H "Content-Type: application/json" \
# -d '{
#     "model": "kimi-k2.6",
#     "input": {
#         "messages": [
#             {
#                 "role": "user",
#                 "content": [
#                     {
#                         "text": "What do these images depict?"
#                     },
#                     {
#                         "image": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241022/emyrja/dog_and_girl.jpeg"
#                     },
#                     {
#                         "image": "https://dashscope.oss-cn-beijing.aliyuncs.com/images/tiger.png"
#                     }
#                 ]
#             }
#         ]
#     },
#     "parameters": {
#         "enable_thinking": true
#     }
# }'

Pemahaman video

Berkas video

Model kimi-k2.7-code, kimi-k2.6, dan kimi-k2.5 menganalisis video dengan mengekstraksi rangkaian frame. Anda dapat mengontrol strategi ekstraksi frame dengan parameter berikut:

  • fps: Mengontrol frekuensi ekstraksi frame. Interval antar frame yang diekstraksi adalah detik. Nilainya harus berada dalam rentang [0,1, 10]. Nilai default-nya adalah 2,0.

    • Untuk adegan bergerak cepat: Atur nilai fps lebih tinggi untuk menangkap lebih banyak detail.

    • Untuk video statis atau panjang: Atur nilai fps lebih rendah untuk meningkatkan efisiensi pemrosesan.

  • max_frames: Menentukan jumlah maksimum frame yang diekstraksi dari video. Nilai default dan maksimumnya adalah 2000.

    Jika jumlah frame yang dihitung dari nilai fps melebihi batas ini, sistem secara otomatis mengekstraksi frame secara seragam agar tetap dalam batas max_frames. Parameter ini hanya tersedia saat Anda menggunakan SDK DashScope.

Kompatibel dengan OpenAI

Saat meneruskan berkas video ke model menggunakan SDK OpenAI atau permintaan HTTP, atur parameter "type" dalam pesan pengguna ke "video_url".

Python

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    base_url="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
)

completion = client.chat.completions.create(
    model="kimi-k2.6",
    messages=[
        {
            "role": "user",
            "content": [
                # Saat meneruskan berkas video langsung, atur parameter "type" ke "video_url".
                {
                    "type": "video_url",
                    "video_url": {
                        "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241115/cqqkru/1.mp4"
                    },
                    "fps": 2
                },
                {
                    "type": "text",
                    "text": "What is the content of this video?"
                }
            ]
        }
    ]
)

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

Node.js

import OpenAI from "openai";

const openai = new OpenAI({
    apiKey: process.env.DASHSCOPE_API_KEY,
    baseURL: "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1"
});

async function main() {
    const response = await openai.chat.completions.create({
        model: "kimi-k2.6",
        messages: [
            {
                role: "user",
                content: [
                    // Saat meneruskan berkas video langsung, atur parameter "type" ke "video_url".
                    {
                        type: "video_url",
                        video_url: {
                            "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241115/cqqkru/1.mp4"
                        },
                        "fps": 2
                    },
                    {
                        type: "text",
                        text: "What is the content of this video?"
                    }
                ]
            }
        ]
    });

    console.log(response.choices[0].message.content);
}

main();

curl

curl -X POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1/chat/completions \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "kimi-k2.6",
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "video_url",
            "video_url": {
              "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241115/cqqkru/1.mp4"
            },
            "fps":2
          },
          {
            "type": "text",
            "text": "What is the content of this video?"
          }
        ]
      }
    ]
  }'

DashScope

Python

import dashscope
import os

dashscope.base_http_api_url = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1"

messages = [
    {"role": "user",
        "content": [
            # Parameter fps mengatur frekuensi ekstraksi frame; interval antar frame adalah 1/fps detik.
            {"video": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241115/cqqkru/1.mp4","fps":2},
            {"text": "What is the content of this video?"}
        ]
    }
]

response = dashscope.MultiModalConversation.call(
    # Jika variabel lingkungan DASHSCOPE_API_KEY tidak disetel, ganti baris ini dengan Kunci API Model Studio Anda: api_key="sk-xxx"
    api_key=os.getenv('DASHSCOPE_API_KEY'),
    model='kimi-k2.6',
    messages=messages
)

print(response.output.choices[0].message.content[0]["text"])

Java

import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversation;
import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversationParam;
import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversationResult;
import com.alibaba.dashscope.common.MultiModalMessage;
import com.alibaba.dashscope.common.Role;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.exception.UploadFileException;
import com.alibaba.dashscope.utils.JsonUtils;
import com.alibaba.dashscope.utils.Constants;

public class Main {
    public static void simpleMultiModalConversationCall()
            throws ApiException, NoApiKeyException, UploadFileException {
        MultiModalConversation conv = new MultiModalConversation();
        // Parameter fps mengatur frekuensi ekstraksi frame; interval antar frame adalah 1/fps detik.
        Map<String, Object> params = new HashMap<>();
        params.put("video", "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241115/cqqkru/1.mp4");
        params.put("fps", 2);
        MultiModalMessage userMessage = MultiModalMessage.builder().role(Role.USER.getValue())
                .content(Arrays.asList(
                        params,
                        Collections.singletonMap("text", "What is the content of this video?"))).build();
        MultiModalConversationParam param = MultiModalConversationParam.builder()
                .apiKey(System.getenv("DASHSCOPE_API_KEY"))
                .model("kimi-k2.6")
                .messages(Arrays.asList(userMessage))
                .build();
        MultiModalConversationResult result = conv.call(param);
        System.out.println(result.getOutput().getChoices().get(0).getMessage().getContent().get(0).get("text"));
    }
    public static void main(String[] args) {
        // Konfigurasi wilayah China (Beijing). Ganti {WorkspaceId} dengan ID ruang kerja aktual Anda. Untuk wilayah lain, gunakan URL dasar yang sesuai.
        Constants.baseHttpApiUrl = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1";
        try {
            simpleMultiModalConversationCall();
        } catch (ApiException | NoApiKeyException | UploadFileException e) {
            System.out.println(e.getMessage());
        }
        System.exit(0);
    }
}

curl

curl -X POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
    "model": "kimi-k2.6",
    "input":{
        "messages":[
            {"role": "user","content": [{"video": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241115/cqqkru/1.mp4","fps":2},
            {"text": "What is the content of this video?"}]}]}
}'

Daftar gambar

Saat Anda memberikan video sebagai daftar gambar (frame yang telah diekstraksi sebelumnya), gunakan parameter fps untuk menentukan laju ekstraksi frame video asli. Nilai ini menunjukkan bahwa frame diekstraksi setiap detik, sehingga model dapat lebih memahami urutan peristiwa, durasi, dan perubahan dinamis.

Kompatibel dengan OpenAI

Saat meneruskan video sebagai daftar gambar menggunakan SDK OpenAI atau permintaan HTTP, atur parameter "type" dalam pesan pengguna ke "video".

Python

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    base_url="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
)

completion = client.chat.completions.create(
    model="kimi-k2.6", 
    messages=[{"role": "user","content": [
        # Saat meneruskan daftar gambar, atur parameter "type" dalam pesan pengguna ke "video".
         {"type": "video","video": [
         "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/xzsgiz/football1.jpg",
         "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/tdescd/football2.jpg",
         "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/zefdja/football3.jpg",
         "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/aedbqh/football4.jpg"],
         "fps":2},
         {"type": "text","text": "Describe the action in this video."},
    ]}]
)

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

Node.js

import OpenAI from "openai";

const openai = new OpenAI({
    apiKey: process.env.DASHSCOPE_API_KEY,
    baseURL: "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1"
});

async function main() {
    const response = await openai.chat.completions.create({
        model: "kimi-k2.6",  
        messages: [{
            role: "user",
            content: [
                {
                    // Saat meneruskan daftar gambar, atur parameter "type" dalam pesan pengguna ke "video".
                    type: "video",
                    video: [
                        "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/xzsgiz/football1.jpg",
                        "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/tdescd/football2.jpg",
                        "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/zefdja/football3.jpg",
                        "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/aedbqh/football4.jpg"],
                        "fps":2
                },
                {
                    type: "text",
                    text: "Describe the action in this video."
                }
            ]
        }]
    });
    console.log(response.choices[0].message.content);
}

main();

curl

curl -X POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1/chat/completions \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
    "model": "kimi-k2.6",
    "messages": [{"role": "user","content": [{"type": "video","video": [
                  "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/xzsgiz/football1.jpg",
                  "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/tdescd/football2.jpg",
                  "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/zefdja/football3.jpg",
                  "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/aedbqh/football4.jpg"],
                  "fps":2},
                {"type": "text","text": "Describe the action in this video."}]}]
}'

DashScope

Python

import os
import dashscope

dashscope.base_http_api_url = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1"

messages = [{"role": "user",
             "content": [
                 {"video":["https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/xzsgiz/football1.jpg",
                           "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/tdescd/football2.jpg",
                           "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/zefdja/football3.jpg",
                           "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/aedbqh/football4.jpg"],
                   "fps":2},
                 {"text": "Describe the action in this video."}]}]
response = dashscope.MultiModalConversation.call(
    # Jika variabel lingkungan DASHSCOPE_API_KEY tidak disetel, ganti baris ini dengan Kunci API Model Studio Anda: api_key="sk-xxx"
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    model='kimi-k2.6', 
    messages=messages
)
print(response.output.choices[0].message.content[0]["text"])

Java

// Memerlukan SDK DashScope v2.21.10 atau lebih baru.
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversation;
import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversationParam;
import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversationResult;
import com.alibaba.dashscope.common.MultiModalMessage;
import com.alibaba.dashscope.common.Role;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.exception.UploadFileException;
import com.alibaba.dashscope.utils.Constants;

public class Main {
    static {Constants.baseHttpApiUrl="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1";}

    private static final String MODEL_NAME = "kimi-k2.6"; 
    public static void videoImageListSample() throws ApiException, NoApiKeyException, UploadFileException {
        MultiModalConversation conv = new MultiModalConversation();
        Map<String, Object> params = new HashMap<>();
        params.put("video", Arrays.asList("https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/xzsgiz/football1.jpg",
                "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/tdescd/football2.jpg",
                "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/zefdja/football3.jpg",
                "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/aedbqh/football4.jpg"));
        params.put("fps", 2);
        MultiModalMessage userMessage = MultiModalMessage.builder()
                .role(Role.USER.getValue())
                .content(Arrays.asList(
                        params,
                        Collections.singletonMap("text", "Describe the action in this video.")))
                .build();
        MultiModalConversationParam param = MultiModalConversationParam.builder()
                .apiKey(System.getenv("DASHSCOPE_API_KEY"))
                .model(MODEL_NAME)
                .messages(Arrays.asList(userMessage)).build();
        MultiModalConversationResult result = conv.call(param);
        System.out.print(result.getOutput().getChoices().get(0).getMessage().getContent().get(0).get("text"));
    }
    public static void main(String[] args) {
        try {
            videoImageListSample();
        } catch (ApiException | NoApiKeyException | UploadFileException e) {
            System.out.println(e.getMessage());
        }
        System.exit(0);
    }
}

curl

curl -X POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
  "model": "kimi-k2.6",
  "input": {
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "video": [
              "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/xzsgiz/football1.jpg",
              "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/tdescd/football2.jpg",
              "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/zefdja/football3.jpg",
              "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/aedbqh/football4.jpg"
            ],
            "fps":2
                 
          },
          {
            "text": "Describe the action in this video."
          }
        ]
      }
    ]
  }
}'

Melewatkan file lokal

Contoh berikut menunjukkan cara melewatkan file lokal. API yang kompatibel dengan OpenAI hanya mendukung pengkodean Base64, sedangkan DashScope mendukung pengkodean Base64 maupun jalur file.

Kompatibel dengan OpenAI

Untuk melewatkan file lokal menggunakan pengkodean Base64, buat Data URL. Untuk petunjuknya, lihat Construct a Data URL.

Python

from openai import OpenAI
import os
import base64

# Fungsi encoding: Mengonversi file lokal menjadi string terenkripsi Base64.
def encode_image(image_path):
    with open(image_path, "rb") as image_file:
        return base64.b64encode(image_file.read()).decode("utf-8")

# Ganti "xxx/eagle.png" dengan jalur mutlak ke gambar lokal Anda.
base64_image = encode_image("xxx/eagle.png")

client = OpenAI(
    api_key=os.getenv('DASHSCOPE_API_KEY'),
    base_url="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",
)
completion = client.chat.completions.create(
    model="kimi-k2.6",
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "image_url",
                    "image_url": {"url": f"data:image/png;base64,{base64_image}"}, 
                },
                {"type": "text", "text": "What scene is depicted in the image?"},
            ],
        }
    ],
)
print(completion.choices[0].message.content)


# Contoh berikut menunjukkan cara melewatkan file video lokal dan daftar gambar lokal.

# [File video lokal] Enkode video lokal sebagai Data URL dan lewatkan ke parameter video_url:
#   def encode_video_to_data_url(video_path):
#       with open(video_path, "rb") as f:
#           return "data:video/mp4;base64," + base64.b64encode(f.read()).decode("utf-8")

#   video_data_url = encode_video_to_data_url("xxx/local.mp4")
#   content = [{"type": "video_url", "video_url": {"url": video_data_url}, "fps": 2}, {"type": "text", "text": "What is the content of this video?"}]

# [Daftar gambar lokal] Enkode beberapa gambar lokal dengan Base64 dan lewatkan sebagai daftar ke parameter video:
#   image_data_urls = [f"data:image/jpeg;base64,{encode_image(p)}" for p in ["xxx/f1.jpg", "xxx/f2.jpg", "xxx/f3.jpg", "xxx/f4.jpg"]]
#   content = [{"type": "video", "video": image_data_urls, "fps": 2}, {"type": "text", "text": "Describe the sequence of events in this video."}]

Node.js

import OpenAI from "openai";
import { readFileSync } from 'fs';

const openai = new OpenAI(
    {
        apiKey: process.env.DASHSCOPE_API_KEY,
        baseURL: "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1"
    }
);

const encodeImage = (imagePath) => {
    const imageFile = readFileSync(imagePath);
    return imageFile.toString('base64');
  };
// Ganti "xxx/eagle.png" dengan jalur mutlak ke gambar lokal Anda.
const base64Image = encodeImage("xxx/eagle.png")
async function main() {
    const completion = await openai.chat.completions.create({
        model: "kimi-k2.6", 
        messages: [
            {"role": "user",
             "content": [{"type": "image_url",
                        "image_url": {"url": `data:image/png;base64,${base64Image}`},},
                        {"type": "text", "text": "What scene is depicted in the image?"}]}]
    });
    console.log(completion.choices[0].message.content);
}

main();

// Contoh berikut menunjukkan cara melewatkan file video lokal dan daftar gambar lokal.

// [File video lokal] Enkode video lokal sebagai Data URL dan lewatkan ke parameter video_url:
//   const encodeVideoToDataUrl = (videoPath) => "data:video/mp4;base64," + readFileSync(videoPath).toString("base64");
//   const videoDataUrl = encodeVideoToDataUrl("xxx/local.mp4");
//   content: [{ type: "video_url", video_url: { url: videoDataUrl }, fps: 2 }, { type: "text", text: "What is the content of this video?" }]

// [Daftar gambar lokal] Enkode beberapa gambar lokal dengan Base64 dan lewatkan sebagai daftar ke parameter video:
//   const imageDataUrls = ["xxx/f1.jpg","xxx/f2.jpg","xxx/f3.jpg","xxx/f4.jpg"].map(p => `data:image/jpeg;base64,${encodeImage(p)}`);
//   content: [{ type: "video", video: imageDataUrls, fps: 2 }, { type: "text", text: "Describe the sequence of events in this video." }]

//   messages: [{"role": "user", "content": content}] 
//   Lalu panggil openai.chat.completions.create({model: "kimi-k2.6", messages: messages})

DashScope

Pengkodean Base64

Untuk melewatkan file lokal menggunakan pengkodean Base64, buat Data URL. Untuk petunjuknya, lihat Construct a Data URL.

Python

import base64
import os
import dashscope 
from dashscope import MultiModalConversation

dashscope.base_http_api_url = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1"

# Fungsi encoding: Mengonversi file lokal menjadi string terenkripsi Base64.
def encode_image(image_path):
    with open(image_path, "rb") as image_file:
        return base64.b64encode(image_file.read()).decode("utf-8")


# Ganti "xxx/eagle.png" dengan jalur mutlak ke gambar lokal Anda.
base64_image = encode_image("xxx/eagle.png")

messages = [
    {
        "role": "user",
        "content": [
            {"image": f"data:image/png;base64,{base64_image}"},
            {"text": "What scene is depicted in the image?"},
        ],
    },
]
response = MultiModalConversation.call(
    # Jika variabel lingkungan DASHSCOPE_API_KEY tidak diatur, masukkan langsung kunci API Model Studio Anda, contohnya: api_key="sk-xxx"
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    model="kimi-k2.6", 
    messages=messages,
)
print(response.output.choices[0].message.content[0]["text"])

# Contoh berikut menunjukkan cara melewatkan file video lokal dan daftar gambar lokal.

# [File video lokal]
#   video_data_url = "data:video/mp4;base64," + base64.b64encode(open("xxx/local.mp4","rb").read()).decode("utf-8")
#   content: [{"video": video_data_url, "fps": 2}, {"text": "What is the content of this video?"}]

# [Daftar gambar lokal]
#   image_data_urls = [f"data:image/jpeg;base64,{encode_image(p)}" for p in ["xxx/f1.jpg","xxx/f2.jpg","xxx/f3.jpg","xxx/f4.jpg"]]
#   content: [{"video": image_data_urls, "fps": 2}, {"text": "Describe the sequence of events in this video."}]

Java

import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Base64;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

import com.alibaba.dashscope.aigc.multimodalconversation.*;
import com.alibaba.dashscope.common.MultiModalMessage;
import com.alibaba.dashscope.common.Role;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.exception.UploadFileException;
import com.alibaba.dashscope.utils.Constants;

public class Main {

   static {Constants.baseHttpApiUrl="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1";}

    private static String encodeToBase64(String imagePath) throws IOException {
        Path path = Paths.get(imagePath);
        byte[] imageBytes = Files.readAllBytes(path);
        return Base64.getEncoder().encodeToString(imageBytes);
    }
    

    public static void callWithLocalFile(String localPath) throws ApiException, NoApiKeyException, UploadFileException, IOException {

        String base64Image = encodeToBase64(localPath);

        MultiModalConversation conv = new MultiModalConversation();
        MultiModalMessage userMessage = MultiModalMessage.builder().role(Role.USER.getValue())
                .content(Arrays.asList(
                        new HashMap<String, Object>() {{ put("image", "data:image/png;base64," + base64Image); }},
                        new HashMap<String, Object>() {{ put("text", "What scene is depicted in the image?"); }}
                )).build();

        MultiModalConversationParam param = MultiModalConversationParam.builder()
                .apiKey(System.getenv("DASHSCOPE_API_KEY"))
                .model("kimi-k2.6")
                .messages(Arrays.asList(userMessage))
                .build();

        MultiModalConversationResult result = conv.call(param);
        System.out.println(result.getOutput().getChoices().get(0).getMessage().getContent().get(0).get("text"));
    }

    public static void main(String[] args) {
        try {
            // Ganti "xxx/eagle.png" dengan jalur mutlak ke gambar lokal Anda.
            callWithLocalFile("xxx/eagle.png");
        } catch (ApiException | NoApiKeyException | UploadFileException | IOException e) {
            System.out.println(e.getMessage());
        }
        System.exit(0);
    }
    
    // Contoh berikut menunjukkan cara melewatkan file video lokal dan daftar gambar lokal.
    // [File video lokal]
    // String base64Video = encodeToBase64(localPath);
    // MultiModalConversation conv = new MultiModalConversation();
   //  MultiModalMessage userMessage = MultiModalMessage.builder().role(Role.USER.getValue())
   //             .content(Arrays.asList(
   //                     new HashMap<String, Object>() {{ put("video", "data:video/mp4;base64," + base64Video); }},
   //                     new HashMap<String, Object>() {{ put("text", "What scene is depicted in this video?"); }}
   //             )).build();

    // [Daftar gambar lokal]
    // List<String> urls = Arrays.asList(
    //                                   "data:image/jpeg;base64,"+encodeToBase64("path/f1.jpg"),
    //                                   "data:image/jpeg;base64,"+encodeToBase64("path/f2.jpg"),
    //                                   "data:image/jpeg;base64,"+encodeToBase64("path/f3.jpg"),
    //                                   "data:image/jpeg;base64,"+encodeToBase64("path/f4.jpg"));
   //  MultiModalConversation conv = new MultiModalConversation();
   //  MultiModalMessage userMessage = MultiModalMessage.builder().role(Role.USER.getValue())
   //             .content(Arrays.asList(
   //                     new HashMap<String, Object>() {{ put("video", urls); }},
   //                     new HashMap<String, Object>() {{ put("text", "What scene is depicted in this video?"); }}
   //             )).build();

}

Jalur file

Anda dapat melewatkan jalur file lokal secara langsung ke model. Metode ini hanya didukung oleh SDK Python dan Java DashScope; tidak tersedia untuk HTTP DashScope maupun API yang kompatibel dengan OpenAI. Tabel berikut menunjukkan format jalur file yang diperlukan untuk setiap bahasa pemrograman dan sistem operasi.

Tentukan jalur file (contoh gambar)

Sistem

SDK

Format jalur

Contoh

Linux atau macOS

Python SDK

file://{jalur mutlak file}

file:///home/images/test.png

Java SDK

Windows

Python SDK

file://{jalur mutlak file}

file://D:/images/test.png

Java SDK

file:///{jalur mutlak file}

file:///D:/images/test.png

Python

import os
from dashscope import MultiModalConversation
import dashscope 

dashscope.base_http_api_url = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1"

# Ganti "xxx/eagle.png" dengan jalur mutlak ke gambar lokal Anda.
local_path = "xxx/eagle.png"
image_path = f"file://{local_path}"
messages = [
                {'role':'user',
                'content': [{'image': image_path},
                            {'text': 'What scene is depicted in the image?'}]}]
response = MultiModalConversation.call(
    api_key=os.getenv('DASHSCOPE_API_KEY'),
    model='kimi-k2.6',  
    messages=messages)
print(response.output.choices[0].message.content[0]["text"])

# Contoh berikut menunjukkan cara melewatkan video lokal dan daftar gambar lokal menggunakan jalur file.
# [File video lokal]
#  video_path = "file:///path/to/local.mp4"
#  content: [{"video": video_path, "fps": 2}, {"text": "What is the content of this video?"}]

# [Daftar gambar lokal]
# image_paths = ["file:///path/f1.jpg", "file:///path/f2.jpg", "file:///path/f3.jpg", "file:///path/f4.jpg"]
# content: [{"video": image_paths, "fps": 2}, {"text": "Describe the sequence of events in this video."}]

Java

import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;

import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversation;
import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversationParam;
import com.alibaba.dashscope.aigc.multimodalconversation.MultiModalConversationResult;
import com.alibaba.dashscope.common.MultiModalMessage;
import com.alibaba.dashscope.common.Role;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.exception.UploadFileException;
import com.alibaba.dashscope.utils.Constants;

public class Main {
    public static void callWithLocalFile(String localPath)
            throws ApiException, NoApiKeyException, UploadFileException {
        String filePath = "file://"+localPath;
        MultiModalConversation conv = new MultiModalConversation();
        MultiModalMessage userMessage = MultiModalMessage.builder().role(Role.USER.getValue())
                .content(Arrays.asList(new HashMap<String, Object>(){{put("image", filePath);}},
                        new HashMap<String, Object>(){{put("text", "What scene is depicted in the image?");}})).build();
        MultiModalConversationParam param = MultiModalConversationParam.builder()
                .apiKey(System.getenv("DASHSCOPE_API_KEY"))
                .model("kimi-k2.6")  
                .messages(Arrays.asList(userMessage))
                .build();
        MultiModalConversationResult result = conv.call(param);
        System.out.println(result.getOutput().getChoices().get(0).getMessage().getContent().get(0).get("text"));}

    public static void main(String[] args) {
        // Konfigurasi wilayah China (Beijing). Ganti {WorkspaceId} dengan ID ruang kerja aktual Anda. Untuk wilayah lain, gunakan URL dasar yang sesuai.
        Constants.baseHttpApiUrl = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1";
        try {
            // Ganti "xxx/eagle.png" dengan jalur mutlak ke gambar lokal Anda.
            callWithLocalFile("xxx/eagle.png");
        } catch (ApiException | NoApiKeyException | UploadFileException e) {
            System.out.println(e.getMessage());
        }
        System.exit(0);
    }
    
    // Contoh berikut menunjukkan cara melewatkan video lokal dan daftar gambar lokal menggunakan jalur file.
    
    // [File video lokal]
    //  String filePath = "file://"+localPath;
    //    MultiModalConversation conv = new MultiModalConversation();
    //    MultiModalMessage userMessage = MultiModalMessage.builder().role(Role.USER.getValue())
    //            .content(Arrays.asList(new HashMap<String, Object>(){{put("video", filePath);}},
    //                    new HashMap<String, Object>(){{put("text", "What scene is depicted in the video?");}})).build();

    // [Daftar gambar lokal]
    
    //    MultiModalConversation conv = new MultiModalConversation();
    //    List<String> filePath = Arrays.asList("file:///path/f1.jpg", "file:///path/f2.jpg", "file:///path/f3.jpg", "file:///path/f4.jpg")
    //    MultiModalMessage userMessage = MultiModalMessage.builder().role(Role.USER.getValue())
    //            .content(Arrays.asList(new HashMap<String, Object>(){{put("video", filePath);}},
    //                    new HashMap<String, Object>(){{put("text", "What scene is depicted in the video?");}})).build();
}

Batasan file

Batasan gambar

  • Resolusi gambar:

    • Ukuran minimum: Lebar dan tinggi masing-masing harus melebihi 10 piksel.

    • Rasio aspek: Rasio sisi terpanjang terhadap sisi terpendek tidak boleh melebihi 200:1.

    • Resolusi maksimum: Disarankan maksimal 8K(7680x4320). Resolusi yang lebih tinggi dapat menyebabkan timeout panggilan API akibat ukuran file yang besar atau transfer jaringan yang lambat.

  • Format gambar yang didukung

    • Format berikut didukung untuk resolusi di bawah 4K(3840x2160):

      Format gambar

      Ekstensi file

      Jenis MIME

      BMP

      .bmp

      image/bmp

      JPEG

      .jpe, .jpeg, .jpg

      image/jpeg

      PNG

      .png

      image/png

      TIFF

      .tif, .tiff

      image/tiff

      WEBP

      .webp

      image/webp

      HEIC

      .heic

      image/heic

    • Untuk resolusi antara 4K(3840x2160) dan 8K(7680x4320), hanya JPEG, JPG, dan PNG yang didukung.

  • Ukuran gambar:

    • Jika menyediakan gambar melalui URL publik atau path lokal, ukurannya tidak boleh melebihi 10 MB.

    • Jika menggunakan encoding Base64, string terenkripsi tidak boleh melebihi 10 MB.

    Untuk mengompresi file, lihat Cara mengompresi gambar atau video agar memenuhi batas ukuran.
  • Jumlah gambar yang didukung: Saat menyediakan beberapa gambar, jumlah total token untuk semua gambar dan teks tidak boleh melebihi batas input maksimum model.

Batasan video

  • Sebagai daftar gambar: 4 hingga 2.000 gambar.

  • Sebagai file video:

    • Ukuran video:

      • Melalui URL publik: Maksimal 2 GB.

      • Melalui encoding Base64: string terenkripsi harus kurang dari 10 MB.

      • Melalui path file lokal: Maksimal 100 MB.

    • Durasi video: 2 detik hingga 1 jam.

  • Format video: Format yang didukung mencakup MP4, AVI, MKV, MOV, FLV, dan WMV.

  • Resolusi video: Meskipun tidak ada batasan resolusi ketat, gunakan 2K atau lebih rendah untuk hasil terbaik. Resolusi yang lebih tinggi meningkatkan waktu pemrosesan tanpa meningkatkan pemahaman model.

  • Pemahaman audio: Model tidak memproses track audio dalam file video.

Fitur lainnya

Model

Multi-turn conversation

Deep thinking

Function calling

Structured output

Web search

Prefix completion

Context cache

kimi-k2.7-code

Supported

Supported

Supported

Not supported

Not supported

Not supported

Supported

kimi-k2.6

Supported

Supported

Supported

Not supported

Not supported

Not supported

Supported

kimi-k2.5

Supported

Supported

Supported

Not supported

Not supported

Not supported

Supported

kimi-k2-thinking

Supported

Supported

Supported

Supported

Not supported

Not supported

Supported

Moonshot-Kimi-K2-Instruct

Supported

Not supported

Supported

Not supported

Supported

Not supported

Supported

Parameter default

Model

enable_thinking

temperature

top_p

presence_penalty

fps

max_frames

kimi-k2.7-code

true (hanya mode thinking)

1.0

0.95

0.0

2

2000

kimi-k2.6

false

mode thinking: 1.0

mode non-thinking: 0.6

Kedua mode: 0.95

Kedua mode: 0.0

2

2000

kimi-k2.5

false

mode thinking: 1.0

mode non-thinking: 0.6

Kedua mode: 0.95

Kedua mode: 0.0

2

2000

kimi-k2-thinking

-

1.0

-

-

-

-

Moonshot-Kimi-K2-Instruct

-

0.6

1.0

0

-

-

Tanda hubung (-) menunjukkan bahwa parameter tersebut tidak berlaku.

Models and billing

Seri Kimi adalah model bahasa besar dari Moonshot AI.

  • kimi-k2.7-code: Model Kimi paling andal untuk pemrograman. Model ini lebih andal dalam mengikuti instruksi konteks panjang dan mencapai tingkat keberhasilan lebih tinggi pada tugas pemrograman. Mendukung input teks, gambar, dan video, mode berpikir, percakapan, serta tugas Agen.

  • kimi-k2.6: Model terbaru dan paling andal dalam seri Kimi. Menawarkan peningkatan performa dalam pemrograman jangka panjang, pengikutan instruksi, dan koreksi mandiri. Mendukung input teks, gambar, dan video, mode berpikir dan non-berpikir, percakapan, serta tugas Agen.

  • kimi-k2.5: Mencapai performa state-of-the-art (SOTA) pada benchmark open-source untuk tugas Agen, pembuatan kode, pemahaman visual, dan tugas kecerdasan umum lainnya. Mendukung input gambar, video, dan teks, mode berpikir dan non-berpikir, percakapan, serta tugas Agen.

  • kimi-k2-thinking: Hanya mendukung mode deep thinking. Menampilkan proses penalaran melalui bidang reasoning_content. Unggul dalam pemrograman dan Pemanggilan alat, serta cocok untuk kasus penggunaan yang memerlukan analisis logis, perencanaan, atau pemahaman mendalam.

  • Moonshot-Kimi-K2-Instruct: Tidak mendukung deep thinking. Menghasilkan tanggapan dengan latensi lebih rendah, serta cocok untuk kasus penggunaan yang membutuhkan jawaban cepat dan langsung.

Untuk harga kimi-k2.7-code, lihat penagihan pemanggilan model.

Untuk informasi harga dan detail jendela konteks, lihat Konsol Model Studio.

Penagihan didasarkan pada jumlah token input dan output.

Dalam mode berpikir, rantai pemikiran dihitung sebagai token output.

Error codes

Jika pemanggilan model gagal dan mengembalikan pesan error, lihat Error codes.