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

Alibaba Cloud Model Studio:実行ステップ

最終更新日:Oct 11, 2026

実行ステップは、エージェントが実行中に実行する操作 (モデルやツールの呼び出しなど) を記述します。

重要Assistant API は非推奨になりました。代替として Responses API に移行してください。Responses API には、複数の組み込みツールが含まれており、マルチターンコンテキスト管理をサポートしています。

実行ステップのリスト

実行タスクのすべてのステップのリストを返します。

リクエストの例

HTTP

curl --location 'https://dashscope-intl.aliyuncs.com/api/v1/threads/thread_cc2a3e9d-436b-482b-91c5-377e0f376506/runs/run_3de634fa-75d4-4370-adcf-92ba2a60c396/steps?limit=20&order=asc' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"

SDK

import dashscope
from dashscope import Steps
import os

dashscope.base_http_api_url = 'https://dashscope-intl.aliyuncs.com/api/v1'
steps = Steps.list(
    'run_id',
    # API キーを環境変数として設定することを推奨します。設定しない場合は、`api_key=os.getenv(...)` を `api_key="your_api_key"` に置き換えてください。
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    thread_id='thread_id',
    limit=20
)
import com.alibaba.dashscope.common.GeneralListParam;
import com.alibaba.dashscope.common.ListResult;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.InvalidateParameter;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.threads.runs.RunStep;
import com.alibaba.dashscope.threads.runs.Runs;
import com.alibaba.dashscope.utils.Constants;

public class Main {
    static {
        Constants.baseHttpApiUrl="https://dashscope-intl.aliyuncs.com/api/v1";
    }
    public static void main(String[] args) throws ApiException, NoApiKeyException, InputRequiredException, InvalidateParameter, InterruptedException {
        Runs runs = new Runs();
        // API キーを環境変数として設定することを推奨します。設定しない場合は、`apiKey(System.getenv(...))` を `apiKey("your_api_key")` に置き換えてください。
        GeneralListParam listSteps = GeneralListParam.builder()
                .apiKey(System.getenv("DASHSCOPE_API_KEY"))
                .build();
        ListResult<RunStep> run = runs.listSteps("threadId", "runId", listSteps);
    }
}

リクエストボディ

パラメーター名

型

必須

デフォルト

説明

run_id

string

はい

ステップをリストする対象の実行の ID。

thread_id

string

はい

スレッドの ID。

limit

integer

いいえ

None

取得する実行ステップの数。デフォルトは None です。None の値は、サーバー側のデフォルト値を使用します。

order

string

いいえ

None

created_at フィールドに基づいて結果をソートする順序。このパラメーターは `asc` (昇順) または `desc` (降順) に設定できます。デフォルト値は None で、サーバー側のデフォルトのソートメソッドが使用されることを示します。

after

string

いいえ

None

ページネーションのカーソルとして使用する実行ステップの ID。指定された場合、このステップの直後の結果ページを返します。

before

string

いいえ

None

ページネーションのカーソルとして使用する実行ステップの ID。指定された場合、このステップの直前の結果ページを返します。

workspace

string

はい

None

`api_key` がサブワークスペースの API キーである場合にのみ、Alibaba Cloud Model Studio のワークスペース ID が必要です。

api_key

string

はい

None

Model Studio の API キー。API キーを環境変数として設定することを推奨します。

レスポンスの例

{
    "object": "list",
    "data": [
        {
            "id": "[REDACTED]",
            "object": "thread.run.step",
            "created_at": 1711517599333,
            "assistant_id": "[REDACTED]",
            "thread_id": "[REDACTED]",
            "run_id": "[REDACTED]",
            "type": "message_creation",
            "status": "completed",
            "step_details": {
                "type": "message_creation",
                "message_creation": {
                    "message_id": "[REDACTED]"
                }
            },
            "last_error": {
                "code": "",
                "message": ""
            },
            "expired_at": 0,
            "cancelled_at": -1,
            "failed_at": -1,
            "completed_at": -1,
            "metadata": {},
            "usage": {}
        }
    ],
    "first_id": "[REDACTED]",
    "last_id": "[REDACTED]",
    "has_more": false,
    "request_id": "[REDACTED]"
}

レスポンスボディ

実行ステップオブジェクトのリスト

実行ステップの取得

リクエストの例

HTTP

コードの例
curl --location 'https://dashscope-intl.aliyuncs.com/api/v1/threads/thread_cc2a3e9d-436b-482b-91c5-377e0f376506/runs/run_3de634fa-75d4-4370-adcf-92ba2a60c396/steps/step_4db180b5-d44a-4b12-9390-4307c6cb87a5' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $DASHSCOPE_API_KEY"

SDK

コードの例
import dashscope
from dashscope import Steps
import os

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

step = Steps.retrieve(
    'step_id',
    # API キーを環境変数として設定することを推奨します。設定しない場合は、`api_key=os.getenv(...)` を `api_key="your_api_key"` に置き換えてください。
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    thread_id='thread_id',
    run_id='run_id'
)
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.InvalidateParameter;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.threads.runs.RunStep;
import com.alibaba.dashscope.threads.runs.Runs;
import com.alibaba.dashscope.utils.Constants;

public class Main {
    static {
        Constants.baseHttpApiUrl="https://dashscope-intl.aliyuncs.com/api/v1";
    }
    public static void main(String[] args) throws ApiException, NoApiKeyException, InputRequiredException, InvalidateParameter, InterruptedException {
        Runs runs = new Runs();
        // API キーを環境変数として設定することを推奨します。設定しない場合は、`apiKey=System.getenv(...)` を `apiKey="your_api_key"` に置き換えてください。
        String apiKey = System.getenv("DASHSCOPE_API_KEY");
        RunStep run = runs.retrieveStep("threadId", "runId", "stepId", apiKey);
    }
}

リクエストボディ

パラメーター名

型

必須

デフォルト

説明

step_id

string

はい

取得する RunStep の ID。

thread_id

string

はい

スレッドの ID。

run_id

string

はい

実行の ID。

workspace

string

はい

None

サブワークスペースの API キーを使用している場合にのみ、Alibaba Cloud Model Studio のワークスペース ID が必要です。

api_key

string

はい

None

Model Studio の API キー。API キーを環境変数として設定することを推奨します。

レスポンスの例

{
    "assistant_id": "[REDACTED]",
    "cancelled_at": null,
    "completed_at": 1735025124000,
    "created_at": 1735025123150,
    "expired_at": null,
    "failed_at": null,
    "id": "[REDACTED]",
    "last_error": null,
    "metadata": {},
    "object": "thread.run.step",
    "request_id": "[REDACTED]",
    "run_id": "[REDACTED]",
    "status": "completed",
    "step_details": {
        "message_creation": {
            "message_id": "[REDACTED]"
        },
        "type": "message_creation"
    },
    "thread_id": "[REDACTED]",
    "type": "message_creation",
    "usage": null
}

レスポンスボディ

指定された ID に一致する実行ステップオブジェクト。

実行ステップオブジェクト

実行の実行プロセスにおけるステップを表します。

オブジェクトの例

{
  "id": "[REDACTED]",
  "assistant_id": "[REDACTED]",
  "cancelled_at": null,
  "completed_at": 1678886400,
  "created_at": 1678886300,
  "expired_at": null,
  "failed_at": null,
  "last_error": null,
  "metadata": {
    "user_id": "[REDACTED]",
    "context": "order_processing"
  },
  "object": "thread.run.step",
  "run_id": "[REDACTED]",
  "status": "completed",
  "step_details": {
    "type": "message_creation",
    "message_creation": {
      "message_id": "[REDACTED]"
    }
  },
  "thread_id": "[REDACTED]",
  "type": "message_creation",
  "usage": {
    "prompt_tokens": 10,
    "completion_tokens": 20,
    "total_tokens": 30
  }
}

オブジェクトの属性

パラメーター名

型

説明

id

string

API エンドポイントで参照できる、実行ステップの一意の識別子。

assistant_id

string

この実行ステップに関連付けられているアシスタントの ID。

cancelled_at

integer

実行ステップがキャンセルされたときの 13 桁の UNIX タイムスタンプ (ミリ秒単位)。

completed_at

integer

実行ステップが完了したときの 13 桁の UNIX タイムスタンプ (ミリ秒単位)。

created_at

integer

実行ステップが作成されたときの 13 桁の UNIX タイムスタンプ (ミリ秒単位)。

expired_at

integer

実行ステップが期限切れになったときの 13 桁の UNIX タイムスタンプ (ミリ秒単位)。親の実行が期限切れになった場合、ステップも期限切れと見なされます。

failed_at

integer

実行ステップが失敗したときの 13 桁の UNIX タイムスタンプ (ミリ秒単位)。

last_error

object

この実行ステップに関連付けられている最後のエラー。エラーが発生しなかった場合は null です。

metadata

map

オブジェクトにアタッチできる最大 16 個のキーと値のペアのセット。これは、オブジェクトに関する追加情報を構造化されたフォーマットで保存するために使用されます。キーの最大長は 64 文字、値の最大長は 512 文字です。

object

string

オブジェクトタイプ。常に thread.run.step です。

run_id

string

この実行ステップが属する実行の ID。

status

string

実行ステップのステータス。有効な値:`in_progress`、`cancelled`、`failed`、`completed`、または `expired`。

step_details

object

実行ステップの詳細。

thread_id

string

実行中のスレッドの ID。

type

string

実行ステップのタイプ。有効な値:`message_creation` または `tool_calls`。

usage

object

リソース使用量の統計。

status_code

integer

HTTP ステータスコード。注:このパラメーターは内部処理に使用されます。ほとんどの場合、このパラメーターを気にする必要はありません。

エラーコード

呼び出しが失敗し、エラーメッセージが返された場合は、トラブルシューティングについて「エラーメッセージ」をご参照ください。