すべてのプロダクト
Search
ドキュメントセンター

Alibaba Cloud Model Studio:Kimi

最終更新日:Jun 30, 2026

このドキュメントでは、Alibaba Cloud Model Studio にデプロイされた Kimi モデルの推論サービスを呼び出す方法について説明します。

重要

Moonshot-Kimi-K2-Instruct と kimi-k2-thinking は 2026 年 7 月 9 日に廃止されます。qwen3.7-plusqwen3.7-max、または qwen3.6-flash への移行を推奨します。

サポートされているリージョン: 中国 (北京)、シンガポール、日本 (東京)、中国 (香港)、ドイツ (フランクフルト)、および米国 (バージニア)

モデル体験: モデル体験センターで Kimi モデルを試すことができます。

サービスエンドポイントはリージョン固有です。ご利用のリージョンに対応する正しいベース URL を設定してください。

OpenAI 互換

米国 (バージニア)

SDK 呼び出しの base_urlhttps://dashscope-us.aliyuncs.com/compatible-mode/v1 です。

HTTP リクエスト URL: POST https://dashscope-us.aliyuncs.com/compatible-mode/v1/chat/completions

ドイツ (フランクフルト)

SDK 呼び出しの base_urlhttps://{WorkspaceId}.eu-central-1.maas.aliyuncs.com/compatible-mode/v1 です。

HTTP リクエスト URL: POST https://{WorkspaceId}.eu-central-1.maas.aliyuncs.com/compatible-mode/v1/chat/completions

シンガポール

SDK 呼び出しの base_urlhttps://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1 です。

HTTP リクエスト URL: POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1/chat/completions

日本 (東京)

SDK 呼び出しの base_urlhttps://{WorkspaceId}.ap-northeast-1.maas.aliyuncs.com/compatible-mode/v1 です。

HTTP リクエスト URL: POST https://{WorkspaceId}.ap-northeast-1.maas.aliyuncs.com/compatible-mode/v1/chat/completions

中国 (北京)

SDK 呼び出しの base_urlhttps://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1 です。

HTTP リクエスト URL: POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1/chat/completions

中国 (香港)

SDK 呼び出しの base_urlhttps://{WorkspaceId}.cn-hongkong.maas.aliyuncs.com/compatible-mode/v1 です。

HTTP リクエスト URL: POST https://{WorkspaceId}.cn-hongkong.maas.aliyuncs.com/compatible-mode/v1/chat/completions

DashScope

米国 (バージニア)

kimi-k2-thinking などのテキストモデルの場合、HTTP リクエスト URL は POST https://dashscope-us.aliyuncs.com/api/v1/services/aigc/text-generation/generation です。

kimi-k2.6 や kimi-k2.5 などのマルチモーダルモデルの場合、HTTP リクエスト URL は POST https://dashscope-us.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation です。

SDK 呼び出しの base_url は次のとおりです:

Python コード

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

Java コード

  • 方法 1:

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

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

ドイツ (フランクフルト)

kimi-k2-thinking などのテキストモデルの場合、HTTP リクエスト URL は POST https://{WorkspaceId}.eu-central-1.maas.aliyuncs.com/api/v1/services/aigc/text-generation/generation です。

kimi-k2.7-code、kimi-k2.6、kimi-k2.5 などのマルチモーダルモデルの場合、HTTP リクエスト URL は POST https://{WorkspaceId}.eu-central-1.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation です。

SDK 呼び出しの base_url は次のとおりです:

Python コード

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

Java コード

  • 方法 1:

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

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

シンガポール

kimi-k2-thinking などのテキストモデルの場合、HTTP リクエスト URL は POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/text-generation/generation です。

kimi-k2.7-code、kimi-k2.6、kimi-k2.5 などのマルチモーダルモデルの場合、HTTP リクエスト URL は POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation です。

SDK 呼び出しの base_url は次のとおりです:

Python コード

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

Java コード

  • オプション 1:

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

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

日本 (東京)

kimi-k2-thinking などのテキストモデルの場合、HTTP リクエスト URL は POST https://{WorkspaceId}.ap-northeast-1.maas.aliyuncs.com/api/v1/services/aigc/text-generation/generation です。

kimi-k2.7-code、kimi-k2.6、kimi-k2.5 などのマルチモーダルモデルの場合、HTTP リクエスト URL は POST https://{WorkspaceId}.ap-northeast-1.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation です。

SDK 呼び出しの base_url は次のとおりです:

Python コード

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

Java コード

  • オプション 1:

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

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

中国 (香港)

kimi-k2-thinking などのテキストモデルの場合、HTTP リクエスト URL は POST https://{WorkspaceId}.cn-hongkong.maas.aliyuncs.com/api/v1/services/aigc/text-generation/generation です。

kimi-k2.7-code、kimi-k2.6、kimi-k2.5 などのマルチモーダルモデルの場合、HTTP リクエスト URL は POST https://{WorkspaceId}.cn-hongkong.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation です。

SDK 呼び出しの base_url は次のとおりです:

Python コード

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

Java コード

  • 方法 1:

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

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

中国 (北京)

kimi-k2-thinking などのテキストモデルの場合、HTTP リクエスト URL は POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/text-generation/generation です。

kimi-k2.7-code、kimi-k2.6、kimi-k2.5 などのマルチモーダルモデルの場合、HTTP リクエスト URL は POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation です。

SDK 呼び出しの base_url は次のとおりです:

Python コード

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

Java コード

  • オプション 1:

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

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

{WorkspaceId} を実際の ワークスペース ID に置き換えます。

前提条件: API キーを取得し、環境変数として設定する必要があります。SDK を使用する場合は、SDK をインストールする必要があります。

クイックスタート

以下の例では、テキストのみの入力を使用します。マルチモーダルの例については、マルチモーダル呼び出しをご参照ください。

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},  # 思考モードを有効にして reasoning_content を取得
)

reasoning_content = ""  # 完全な思考プロセス
answer_content = ""     # 完全な応答
is_answering = False    # メインの応答が開始されたかを追跡

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

for chunk in completion:
    if chunk.choices:
        delta = chunk.choices[0].delta
        # 思考プロセスのコンテンツを保存
        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
        # コンテンツが到着次第、メインの応答の出力を開始
        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

応答

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

ユーザーは「あなたは誰ですか?」と質問しています。これは私の ID に関する直接的な質問です。私は自身の実際の ID に基づいて、正直に答える必要があります。

私は Moonshot AI によって開発された AI アシスタント、Kimi です。以下を含め、明確かつ簡潔に自己紹介する必要があります。
1. 私の ID:AI アシスタント
2. 私の開発者:Moonshot AI
3. 私の名前:Kimi
4. 私のコア機能:ロングコンテキスト処理、インテリジェントな会話、ファイル処理、検索など。

明確さを保つため、過度に専門的な用語を避け、フレンドリーでプロフェッショナルなトーンを維持する必要があります。また、誤解を避けるため、私が個人の意識、感情、経験を持たない AI であることを強調する必要があります。

応答の構造:
- 自身の ID を直接述べる
- 開発者に言及する
- コア機能を簡潔に紹介する
- 明確かつ簡潔に保つ
====================Complete Response====================

私は Moonshot AI によって開発された AI アシスタント、Kimi です。私は Mixture-of-Experts (MoE) アーキテクチャに基づいており、超ロングコンテキスト理解、インテリジェントな会話、ファイル処理、コード生成、複雑なタスクの推論などの機能を持っています。何かお手伝いできることはありますか?

Node.js

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

// OpenAI クライアントを初期化
const openai = new OpenAI({
    // 環境変数を使用しない場合は、`process.env.DASHSCOPE_API_KEY` をご自身の API キー文字列 (例: "sk-xxx") に置き換えてください。
    apiKey: process.env.DASHSCOPE_API_KEY,
    baseURL: 'https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1'
});

let reasoningContent = ''; // 完全な思考プロセス
let answerContent = ''; // 完全な応答
let isAnswering = false; // メインの応答が開始されたかを追跡

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,  // 思考モードを有効にして 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;
            // 思考プロセスのコンテンツを保存
            if (delta.reasoning_content !== undefined && delta.reasoning_content !== null) {
                if (!isAnswering) {
                    process.stdout.write(delta.reasoning_content);
                }
                reasoningContent += delta.reasoning_content;
            }

            // コンテンツが到着次第、メインの応答の出力を開始
            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();

応答

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

ユーザーは「あなたは誰ですか?」と質問しています。これは私の ID に関する直接的な質問です。私は自身の実際の ID に基づいて、正直に答える必要があります。

私は Moonshot AI によって開発された AI アシスタント、Kimi です。以下を含め、明確かつ簡潔に自己紹介する必要があります。
1. 私の ID:AI アシスタント
2. 私の開発者:Moonshot AI
3. 私の名前:Kimi
4. 私のコア機能:ロングコンテキスト処理、インテリジェントな会話、ファイル処理、検索など。

明確さを保つため、過度に専門的な用語を避け、フレンドリーでプロフェッショナルなトーンを維持する必要があります。また、誤解を避けるため、私が個人の意識、感情、経験を持たない AI であることを強調する必要があります。

応答の構造:
- 自身の ID を直接述べる
- 開発者に言及する
- コア機能を簡潔に紹介する
- 明確かつ簡潔に保つ
====================Complete Response====================

私は Moonshot AI によって開発された AI アシスタント、Kimi です。

得意なことは以下の通りです。
- ロングコンテキストの理解と生成
- インテリジェントな会話と質疑応答
- ファイルの処理と分析
- 情報の取得と統合

AI アシスタントとして、私には個人の意識、感情、経験はありませんが、正確で役立つサポートを提供するように設計されています。何かお手伝いできることはありますか?

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
}'

応答

{
    "choices": [
        {
            "message": {
                "content": "私は Moonshot AI によって開発された AI アシスタント、Kimi です。ロングコンテキスト処理、インテリジェントな会話、ファイル分析、プログラミング支援、複雑なタスクの推論が得意です。質問に答えたり、コンテンツを作成したり、ドキュメントを分析したりするお手伝いができます。何かお手伝いできることはありますか?",
                "reasoning_content": "ユーザーは「あなたは誰ですか?」と質問しています。これは私の ID に関する直接的な質問です。私は自身の実際の ID に基づいて、正直に答える必要があります。\n\n私は Moonshot AI によって開発された AI アシスタント、Kimi です。以下を含め、明確かつ簡潔に自己紹介する必要があります。\n1. 私の ID:AI アシスタント\n2. 私の開発者:Moonshot AI\n3. 私の名前:Kimi\n4. 私のコア機能:ロングコンテキスト処理、インテリジェントな会話、ファイル処理、検索など。\n\n役立つ情報を提供しつつ、フレンドリーでプロフェッショナルなトーンを維持する必要があります。複雑にしすぎる必要はなく、直接的な回答で十分です。",
                "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

以下の DashScope の例では、multimodal-generation エンドポイントを使用して kimi-k2.6 を呼び出します。これはテキスト入力とマルチモーダル入力の両方をサポートしています。マルチモーダルの例については、マルチモーダル呼び出しをご参照ください。

Python

import os
import dashscope
from dashscope import MultiModalConversation
# 中国 (北京) リージョンの構成です。{WorkspaceId} を実際のワークスペース ID に置き換えてください。他のリージョンについては、対応するベース URL を使用してください。
dashscope.base_http_api_url = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1"

# リクエストメッセージを定義
messages = [{"role": "user", "content": "Who are you?"}]

completion = MultiModalConversation.call(
    api_key=os.getenv("DASHSCOPE_API_KEY"),  # 環境変数を使用しない場合は、api_key="sk-xxx" のようにキーを直接指定してください
    model="kimi-k2.6",
    messages=messages,
    result_format="message",  # 結果のフォーマットを message に設定
    stream=True,              # ストリーミングを有効化
    incremental_output=True,  # 増分出力を有効化
    enable_thinking=True,     # 思考モードを有効にして reasoning_content を取得
)

reasoning_content = ""  # 完全な思考プロセス
answer_content = ""     # 完全な応答
is_answering = False    # メインの応答が開始されたかを追跡

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

for chunk in completion:
    message = chunk.output.choices[0].message
    
    # 思考プロセスのコンテンツを保存
    if message.reasoning_content:
        if not is_answering:
            print(message.reasoning_content, end="", flush=True)
        reasoning_content += message.reasoning_content

    # コンテンツが到着次第、メインの応答の出力を開始
    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

応答

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

ユーザーは「あなたは誰ですか?」と質問しています。これは私の ID に関する直接的な質問です。私は自身の実際の ID に基づいて、正直に答える必要があります。

私は Moonshot AI によって開発された AI アシスタント、Kimi です。このことを明確かつ簡潔に述べる必要があります。

含めるべき主要な情報:
1. 私の名前:Kimi
2. 私の開発者:Moonshot AI
3. 私の性質:AI アシスタント
4. 私にできること:質問への回答、コンテンツ作成の支援など。

自身の ID を正確に述べつつ、フレンドリーで親切なトーンを維持する必要があります。人間であるかのように振る舞ったり、個人的な ID を持っているかのように見せかけたりしてはいけません。

適切な応答は次のようになります:
「私は Moonshot AI によって開発された AI アシスタント、Kimi です。質問への回答、コンテンツの作成、ドキュメントの分析など、さまざまなタスクでお手伝いできます。何かお手伝いできることはありますか?」

この応答は直接的で正確であり、さらなる対話を促します。
====================Complete Response====================

私は Moonshot AI によって開発された AI アシスタント、Kimi です。質問への回答、コンテンツの作成、ドキュメントの分析など、さまざまなタスクでお手伝いできます。何かお手伝いできることはありますか?

Java

// DashScope SDK バージョン >= 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) {
        // 中国 (北京) リージョンの構成です。{WorkspaceId} を実際のワークスペース ID に置き換えてください。他のリージョンについては、対応するベース URL を使用してください。
        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()
                    // 環境変数を使用しない場合は、次の行をご自身の API キー (例: .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);
    }
}

応答

====================Thinking Process====================
ユーザーは「あなたは誰ですか?」と質問しています。これは私の ID に関する直接的な質問です。私は自身の実際の ID に基づいて、正直に答える必要があります。

私は Moonshot AI によって開発された AI アシスタント、Kimi です。このことを明確かつ簡潔に述べる必要があります。

応答に含めるべき内容:
1. 私の ID:AI アシスタント
2. 私の開発者:Moonshot AI
3. 私の名前:Kimi
4. 私のコア機能:ロングコンテキスト処理、インテリジェントな会話、ファイル処理など。

人間であるかのように振る舞ったり、過度な技術的詳細を提供したりするべきではありません。明確でフレンドリーな回答で十分です。
====================Complete Response====================
私は Moonshot AI によって開発された AI アシスタント、Kimi です。私のスキルには、ロングコンテキスト処理、インテリジェントな会話、質疑応答、コンテンツ作成、ファイル分析と処理が含まれます。何かお手伝いできることはありますか?

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
    }
}'

応答

{
    "output": {
        "choices": [
            {
                "finish_reason": "stop",
                "message": {
                    "content": "私は Moonshot AI によって開発された AI アシスタント、Kimi です。質問への回答、コンテンツの作成、ドキュメントの分析、コードの作成をお手伝いできます。何かお手伝いできることはありますか?",
                    "reasoning_content": "ユーザーは「あなたは誰ですか?」と質問しています。これは私の ID に関する直接的な質問です。私は自身の実際の ID に基づいて、正直に答える必要があります。\n\n私は Moonshot AI によって開発された AI アシスタント、Kimi です。このことを明確かつ簡潔に述べる必要があります。\n\n含めるべき主要な情報:\n1. 私の名前:Kimi\n2. 私の開発者:Moonshot AI\n3. 私の性質:AI アシスタント\n4. 私にできること:質問への回答、コンテンツ作成の支援など。\n\n応答はフレンドリーで、直接的で、理解しやすいものであるべきです。",
                    "role": "assistant"
                }
            }
        ]
    },
    "usage": {
        "input_tokens": 9,
        "output_tokens": 156,
        "total_tokens": 165
    },
    "request_id": "709a0697-ed1f-4298-82c9-a4b878da1849"
}

マルチモーダル呼び出し

kimi-k2.7-code、kimi-k2.6、および kimi-k2.5 モデルは、テキスト、イメージ、またはビデオを同時に処理できます。思考モードを有効にするには、enable_thinking パラメーターを使用します。以下の例では、この機能の使用方法を示します。

思考モードの有効化/無効化

kimi-k2.6 と kimi-k2.5 はハイブリッド思考モデルです。これらのモデルは、思考後に返信するか、直接返信することができます。enable_thinking パラメーターを使用して、思考モードを有効にするかどうかをコントロールできます:

  • true:思考モードを有効にします

  • false (デフォルト):思考モードを無効にします

kimi-k2.7-code は思考専用モデルです。思考モードは常に有効であり (enable_thinking はデフォルトで true であり、無効にすることはできません)、preserve_thinking はデフォルトで true です。

kimi-k2.6 は、preserve_thinking パラメーターを使用することで、マルチターン対話において思考プロセスを渡すことをサポートします。詳細については、「思考プロセスを渡す」をご参照ください。

以下の例では、画像 URL を使用して思考モードを有効にする方法を示します。主な例は単一画像入力を示しており、コメントアウトされたコードは複数画像入力の例です。

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": [
                {"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}  # 思考モードを有効にする
)

# 思考プロセスを出力する
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)

# 完全な応答を出力する
print("\n" + "=" * 20 + "Complete Response" + "=" * 20 + "\n")
print(completion.choices[0].message.content)

# 複数イメージ入力の例 (思考モードが有効、使用するにはコメントを解除)
# 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}
# )
#
# # 思考プロセスと完全な応答を出力する
# 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'
});

// 単一画像入力の例 (思考モード有効)
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/20241022/emyrja/dog_and_girl.jpeg'
                    }
                }
            ]
        }
    ],
    enable_thinking: true  // 思考モードを有効にする
});

// 思考プロセスを出力
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);
}

// 完全な応答を出力
console.log('\n' + '='.repeat(20) + 'Complete Response' + '='.repeat(20) + '\n');
console.log(completion.choices[0].message.content);

// 複数画像入力の例 (思考モード有効、使用するにはコメントを解除)
// 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/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
// });
//
// // 思考プロセスと完全な応答を出力
// 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
}'

# 複数画像の入力例 (使用するにはコメントアウトを解除)
# 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
# 中国 (北京) リージョンの構成。{WorkspaceId} を実際のワークスペース ID に置き換えてください。他のリージョンでは、対応するベース URL を使用してください。
dashscope.base_http_api_url = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1"

# 単一イメージ入力の例 (思考モード有効)
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  # 思考モードを有効にする
)

# 思考プロセスを出力
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)

# 完全な応答を出力
print("\n" + "=" * 20 + "Complete Response" + "=" * 20 + "\n")
print(response.output.choices[0].message.content[0]["text"])

# 複数イメージ入力の例 (思考モード有効、使用する場合はコメントアウトを解除)
# 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
# )
#
# # 思考プロセスと完全な応答を出力
# 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

// DashScope SDK v2.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.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) {
        // 中国 (北京) リージョンの構成。{WorkspaceId} を実際のワークスペース ID に置き換えてください。他のリージョンの場合は、対応するベース URL を使用してください。
        Constants.baseHttpApiUrl = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1";
        try {
            // 単一画像入力の例 (思考モード有効)
            MultiModalConversation conv = new MultiModalConversation();

            // メッセージ本文を構築
            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/20241022/emyrja/dog_and_girl.jpeg");

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

            // リクエストパラメーターを構築
            MultiModalConversationParam param = MultiModalConversationParam.builder()
                    // 環境変数が設定されていない場合は、これを Model Studio の API キーに置き換えてください。
                    .apiKey(System.getenv("DASHSCOPE_API_KEY"))
                    .model("kimi-k2.6")
                    .messages(Arrays.asList(userMessage))
                    .enableThinking(true)  // 思考モードを有効にする
                    .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);

            // 思考モードが有効な場合、思考プロセスを出力
            if (result.getOutput().getChoices().get(0).getMessage().getReasoningContent() != null) {
                System.out.println("\nThinking Process: " +
                    result.getOutput().getChoices().get(0).getMessage().getReasoningContent());
            }

            // 複数画像入力の例 (使用するにはコメントを解除)
            // Map<String, Object> imageContent1 = new HashMap<>();
            // imageContent1.put("image", "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/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": "このイメージにはどのようなシーンが描かれていますか?"
                    },
                    {
                        "image": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241022/emyrja/dog_and_girl.jpeg"
                    }
                ]
            }
        ]
    },
    "parameters": {
        "enable_thinking": true
    }
}'

# 複数イメージ入力の例 (コメントを解除して使用)
# 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": "これらのイメージには何が描かれていますか?"
#                     },
#                     {
#                         "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
#     }
# }'

動画理解

動画ファイル

`kimi-k2.7-code`、`kimi-k2.6`、および `kimi-k2.5` モデルは、一連のフレームを抽出して動画を分析します。以下のパラメーターでフレーム抽出戦略を制御できます。

  • fps:フレーム抽出の周波数を制御します。抽出されるフレーム間の間隔は 秒です。値は [0.1, 10] の範囲内である必要があります。デフォルト値は 2.0 です。

    • 動きの激しいシーンの場合:より多くの詳細をキャプチャするために、より高い fps 値を設定します。

    • 静的な動画または長時間の動画の場合:処理効率を向上させるために、より低い fps 値を設定します。

  • max_frames:動画から抽出するフレームの最大数を指定します。デフォルトおよび最大値は 2000 です。

    fps 値から計算されたフレーム数がこの制限を超えた場合、システムは自動的にフレームを均等に抽出し、`max_frames` の制限内に収めます。このパラメーターは、DashScope SDK を使用する場合にのみ利用可能です。

OpenAI 互換

OpenAI SDK または HTTP リクエストを使用してモデルに動画ファイルを渡す場合、ユーザーメッセージの "type" パラメーターを "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": [
                # 動画ファイルを直接渡す場合、"type" パラメーターを "video_url" に設定します。
                {
                    "type": "video_url",
                    "video_url": {
                        "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/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: [
                    // 動画ファイルを直接渡す場合、"type" パラメーターを "video_url" に設定します。
                    {
                        type: "video_url",
                        video_url: {
                            "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/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": "この動画の内容は何ですか?"
          }
        ]
      }
    ]
  }'

DashScope

Python

import dashscope
import os

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

messages = [
    {"role": "user",
        "content": [
            # fps パラメーターはフレーム抽出の周波数を設定します。フレーム間の間隔は 1/fps 秒です。
            {"video": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/20241115/cqqkru/1.mp4","fps":2},
            {"text": "What is the content of this video?"}
        ]
    }
]

response = dashscope.MultiModalConversation.call(
    # DASHSCOPE_API_KEY 環境変数が設定されていない場合は、この行を Model Studio API キーに置き換えてください: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();
        // fps パラメーターはフレーム抽出の周波数を設定します。フレーム間の間隔は 1/fps 秒です。
        Map<String, Object> params = new HashMap<>();
        params.put("video", "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/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) {
        // 中国 (北京) リージョンの構成。{WorkspaceId} を実際のワークスペース ID に置き換えてください。他のリージョンの場合は、対応するベース URL を使用してください。
        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": "このビデオの内容は何ですか?"}]}]}
}'

画像リスト

動画を画像リスト (事前に抽出されたフレーム) として提供する場合、`fps` パラメーターを使用して元の動画のフレーム抽出レートを指定します。この値は、フレームが 秒ごとに抽出されたことを示し、モデルがイベントのシーケンス、持続時間、および動的な変化をよりよく理解できるようにします。

OpenAI 互換

OpenAI SDK または HTTP リクエストを使用して動画を画像リストとして渡す場合、ユーザーメッセージの "type" パラメーターを "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": [
        # イメージリストを渡す場合、ユーザーメッセージ内の "type" パラメーターを "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: [
                {
                    // 画像リストを渡す場合、ユーザーメッセージの "type" パラメーターを "video" に設定します。
                    type: "video",
                    video: [
                        "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/20241108/xzsgiz/football1.jpg",
                        "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/20241108/tdescd/football2.jpg",
                        "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/20241108/zefdja/football3.jpg",
                        "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/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": "このビデオでのアクションを説明してください。"}]}]
}'

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/20241108/xzsgiz/football1.jpg",
                           "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/20241108/tdescd/football2.jpg",
                           "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/20241108/zefdja/football3.jpg",
                           "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/20241108/aedbqh/football4.jpg"],
                   "fps":2},
                 {"text": "Describe the action in this video."}]}]
response = dashscope.MultiModalConversation.call(
    # DASHSCOPE_API_KEY 環境変数が設定されていない場合は、この行を Model Studio API キーに置き換えてください: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

// DashScope SDK v2.21.10 以降が必要です。
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", "この動画のアクションを説明してください。")))
                .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": "このビデオのアクションを説明してください。"
          }
        ]
      }
    ]
  }
}'

ローカルファイルの受け渡し

以下の例では、ローカルファイルを渡す方法を示します。OpenAI 互換 API は Base64 エンコーディングのみをサポートしますが、DashScope は Base64 エンコーディングとファイルパスの両方をサポートします。

OpenAI 互換

Base64 エンコーディングを使用してローカルファイルを渡すには、Data URL を構築します。手順については、「Data URL の構築」をご参照ください。

Python

from openai import OpenAI
import os
import base64

# エンコード関数:ローカルファイルを Base64 エンコードされた文字列に変換します。
def encode_image(image_path):
    with open(image_path, "rb") as image_file:
        return base64.b64encode(image_file.read()).decode("utf-8")

# "xxx/eagle.png" をご利用のローカル画像の絶対パスに置き換えてください。
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)


# 以下の例では、ローカルの動画ファイルとローカルの画像リストを渡す方法を示します。

# [ローカル動画ファイル] ローカル動画を Data URL としてエンコードし、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?"}]

# [ローカル画像リスト] 複数のローカル画像を Base64 でエンコードし、リストとして 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');
  };
// "xxx/eagle.png" をご利用のローカル画像の絶対パスに置き換えてください。
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();

// 以下の例では、ローカルの動画ファイルとローカルの画像リストを渡す方法を示します。

// [ローカル動画ファイル] ローカル動画を Data URL としてエンコードし、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?" }]

// [ローカル画像リスト] 複数のローカル画像を Base64 でエンコードし、リストとして 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}] 
//   その後、openai.chat.completions.create({model: "kimi-k2.6", messages: messages}) を呼び出します

DashScope

Base64 エンコーディング

Base64 エンコーディングを使用してローカルファイルを渡すには、Data URL を構築します。手順については、「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"

# エンコード関数:ローカルファイルを Base64 エンコードされた文字列に変換します。
def encode_image(image_path):
    with open(image_path, "rb") as image_file:
        return base64.b64encode(image_file.read()).decode("utf-8")


# "xxx/eagle.png" をご利用のローカル画像の絶対パスに置き換えてください。
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(
    # DASHSCOPE_API_KEY 環境変数が設定されていない場合は、Model Studio API キーを直接渡してください。例: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"])

# 以下の例では、ローカルの動画ファイルとローカルの画像リストを渡す方法を示します。

# [ローカル動画ファイル]
#   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?"}]

# [ローカル画像リスト]
#   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 {
            // "xxx/eagle.png" をご利用のローカル画像の絶対パスに置き換えてください。
            callWithLocalFile("xxx/eagle.png");
        } catch (ApiException | NoApiKeyException | UploadFileException | IOException e) {
            System.out.println(e.getMessage());
        }
        System.exit(0);
    }
    
    // 以下の例では、ローカルの動画ファイルとローカルの画像リストを渡す方法を示します。
    // [ローカル動画ファイル]
    // 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();

    // [ローカル画像リスト]
    // 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();

}

ファイルパス

ローカルファイルパスを直接モデルに渡すことができます。このメソッドは DashScope Python および Java SDK でのみサポートされており、DashScope HTTP または OpenAI 互換 API では利用できません。以下の表は、各プログラミング言語およびオペレーティングシステムで必要なファイルパスの形式を示しています。

ファイルパスの指定 (画像の例)

システム

SDK

パス形式

Linux または macOS

Python SDK

file://{ファイルの絶対パス}

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

Java SDK

Windows

Python SDK

file://{ファイルの絶対パス}

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

Java SDK

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"

# "xxx/eagle.png" をご利用のローカル画像の絶対パスに置き換えてください。
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"])

# 以下の例では、ファイルパスを使用してローカルの動画とローカルの画像リストを渡す方法を示します。
# [ローカル動画ファイル]
#  video_path = "file:///path/to/local.mp4"
#  content: [{"video": video_path, "fps": 2}, {"text": "What is the content of this video?"}]

# [ローカル画像リスト]
# 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) {
        // 中国 (北京) リージョンの構成。{WorkspaceId} を実際のワークスペース ID に置き換えてください。他のリージョンの場合は、対応するベース URL を使用してください。
        Constants.baseHttpApiUrl = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1";
        try {
            // "xxx/eagle.png" をご利用のローカル画像の絶対パスに置き換えてください。
            callWithLocalFile("xxx/eagle.png");
        } catch (ApiException | NoApiKeyException | UploadFileException e) {
            System.out.println(e.getMessage());
        }
        System.exit(0);
    }
    
    // 以下の例では、ファイルパスを使用してローカルの動画とローカルの画像リストを渡す方法を示します。
    
    // [ローカル動画ファイル]
    //  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();

    // [ローカル画像リスト]
    
    //    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();
}

ファイルの制限

画像の制限

  • 画像解像度:

    • 最小サイズ:幅と高さはそれぞれ 10 ピクセルを超える必要があります。

    • アスペクト比:長辺と短辺の比率が 200:1 を超えてはなりません。

    • 最大解像度:推奨される最大値は 8K(7680x4320) です。これより高い解像度では、ファイルサイズが大きくなったり、ネットワーク転送が遅くなったりするため、API 呼び出しがタイムアウトする可能性があります。

  • サポートされている画像フォーマット

    • 4K(3840x2160) 未満の解像度では、以下のフォーマットがサポートされています。

      画像フォーマット

      ファイル拡張子

      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

    • 4K(3840x2160) から 8K(7680x4320) までの解像度では、JPEG、JPG、PNG のみがサポートされています。

  • 画像サイズ:

    • 公開 URL またはローカルパス経由で画像を提供する場合、そのサイズは 10 MB を超えてはなりません。

    • Base64 エンコーディングを使用する場合、エンコードされた文字列は 10 MB を超えてはなりません。

    ファイルを圧縮するには、「サイズ制限を満たすために画像または動画を圧縮する方法」をご参照ください。
  • サポートされる画像の数:複数の画像を提供する場合、すべての画像とテキストの合計トークン数がモデルの最大入力制限を超えてはなりません。

動画の制限

  • 画像リストとして:4 ~ 2,000 枚の画像。

  • 動画ファイルとして:

    • 動画サイズ:

      • 公開 URL 経由:最大 2 GB。

      • Base64 エンコーディング経由:エンコードされた文字列は 10 MB 未満である必要があります。

      • ローカルファイルパス経由:最大 100 MB。

    • 動画の持続時間:2 秒から 1 時間。

  • 動画フォーマット:MP4、AVI、MKV、MOV、FLV、WMV などのフォーマットがサポートされています。

  • 動画解像度:厳密な解像度制限はありませんが、最良の結果を得るためには 2K 以下を使用してください。高解像度は、モデルの理解を向上させることなく処理時間を増加させます。

  • 音声理解:モデルは動画ファイルの音声トラックを処理しません。

その他の特徴

モデル

マルチターン対話

ディープシンキング

ツール呼び出し

構造化出力

ウェブ検索

プレフィックス補完

コンテキストキャッシュ

kimi-k2.7-code

サポート

サポート

サポート

非サポート

非サポート

非サポート

サポート

kimi-k2.6

サポート

サポート

サポート

非サポート

非サポート

非サポート

サポート

kimi-k2.5

サポート

サポート

サポート

非サポート

非サポート

非サポート

サポート

kimi-k2-thinking

サポート

サポート

サポート

サポート

非サポート

非サポート

サポート

Moonshot-Kimi-K2-Instruct

サポート

非サポート

サポート

非サポート

サポート

非サポート

サポート

デフォルトパラメーター

モデル

enable_thinking

temperature

top_p

presence_penalty

fps

max_frames

kimi-k2.7-code

true (思考モードのみ)

1.0

0.95

0.0

2

2000

kimi-k2.6

false

思考モード:1.0

ノンシンキングモード:0.6

両モード:0.95

両モード:0.0

2

2000

kimi-k2.5

false

思考モード:1.0

ノンシンキングモード:0.6

両モード:0.95

両モード:0.0

2

2000

kimi-k2-thinking

-

1.0

-

-

-

-

Moonshot-Kimi-K2-Instruct

-

0.6

1.0

0

-

-

ハイフン (-) は、パラメーターが該当しないことを示します。

モデルと課金

Kimi シリーズは、Moonshot AI の大規模言語モデルです。

  • kimi-k2.7-code:コーディングに最も優れた Kimi モデルです。長文のコンテキスト命令により忠実に従い、プログラミングタスクでより高い成功率を達成します。テキスト、画像、動画の入力、思考モード、会話、エージェントタスクをサポートします。

  • kimi-k2.6:Kimi シリーズの最新かつ最も高性能なモデルです。長期間のコーディング、命令追従、自己修正において性能が向上しています。テキスト、画像、動画の入力、思考モードとノンシンキングモード、会話、エージェントタスクをサポートします。

  • kimi-k2.5:エージェントタスク、コード生成、視覚理解、その他の一般的な知能タスクに関するオープンソースのベンチマークで最先端 (SOTA) の性能を達成しています。画像、動画、テキストの入力、思考モードとノンシンキングモード、会話、エージェントタスクをサポートします。

  • kimi-k2-thinking: 深い思考モードにのみ対応しており、reasoning_content フィールドを介して推論プロセスを公開します。コーディングおよびツール呼び出しに優れており、論理的分析、計画、または深い理解を必要とするユースケースに適しています。

  • Moonshot-Kimi-K2-Instruct:ディープシンキングをサポートしません。より低いレイテンシで応答を生成し、迅速で直接的な回答が必要なユースケースに適しています。

`kimi-k2.7-code` の料金については、「モデル呼び出しの課金」をご参照ください。

料金とコンテキストウィンドウの詳細については、Model Studio コンソールをご参照ください。

課金は、入力および出力トークン数に基づいています。

思考モードでは、思考の連鎖が出力トークンとしてカウントされます。

エラーコード

モデルの呼び出しが失敗し、エラーメッセージが返された場合は、「エラーコード」をご参照ください。