List runs

GET /threads/{thread_id}/runs

Returns a list of runs belonging to a thread.

Path parameters

  • thread_id string Required

    The ID of the thread the run belongs to.

Query parameters

  • limit integer

    A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.

    Default value is 20.

  • order string

    Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.

    Values are asc or desc. Default value is desc.

  • after string

    A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.

  • before string

    A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.

Responses

  • 200 application/json

    OK

    Hide response attributes Show response attributes object
    • object string Required
    • data array[object] Required

      Represents an execution run on a thread.

      Hide data attributes Show data attributes object
      • id string Required

        The identifier, which can be referenced in API endpoints.

      • object string Required

        The object type, which is always thread.run.

        Value is thread.run.

      • created_at integer Required

        The Unix timestamp (in seconds) for when the run was created.

      • thread_id string Required

        The ID of the thread that was executed on as a part of this run.

      • assistant_id string Required

        The ID of the assistant used for execution of this run.

      • status string Required

        The status of the run, which can be either queued, in_progress, requires_action, cancelling, cancelled, failed, completed, incomplete, or expired.

        Values are queued, in_progress, requires_action, cancelling, cancelled, failed, completed, incomplete, or expired.

      • required_action object | null Required

        Details on the action required to continue the run. Will be null if no action is required.

        Hide required_action attributes Show required_action attributes object | null
        • type string Required

          For now, this is always submit_tool_outputs.

          Value is submit_tool_outputs.

        • submit_tool_outputs object Required

          Details on the tool outputs needed for this run to continue.

          Hide submit_tool_outputs attribute Show submit_tool_outputs attribute object
          • tool_calls array[object] Required

            Tool call objects

            Hide tool_calls attributes Show tool_calls attributes object
            • id string Required

              The ID of the tool call. This ID must be referenced when you submit the tool outputs in using the Submit tool outputs to run endpoint.

            • type string Required

              The type of tool call the output is required for. For now, this is always function.

              Value is function.

            • function object Required

              The function definition.

              Hide function attributes Show function attributes object
              • name string Required

                The name of the function.

              • arguments string Required

                The arguments that the model expects you to pass to the function.

      • last_error object | null Required

        The last error associated with this run. Will be null if there are no errors.

        Hide last_error attributes Show last_error attributes object | null
        • code string Required

          One of server_error, rate_limit_exceeded, or invalid_prompt.

          Values are server_error, rate_limit_exceeded, or invalid_prompt.

        • message string Required

          A human-readable description of the error.

      • expires_at integer | null Required

        The Unix timestamp (in seconds) for when the run will expire.

      • started_at integer | null Required

        The Unix timestamp (in seconds) for when the run was started.

      • cancelled_at integer | null Required

        The Unix timestamp (in seconds) for when the run was cancelled.

      • failed_at integer | null Required

        The Unix timestamp (in seconds) for when the run failed.

      • completed_at integer | null Required

        The Unix timestamp (in seconds) for when the run was completed.

      • incomplete_details object | null Required

        Details on why the run is incomplete. Will be null if the run is not incomplete.

        Hide incomplete_details attribute Show incomplete_details attribute object | null
        • reason string

          The reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run.

          Values are max_completion_tokens or max_prompt_tokens.

      • model string Required

        The model that the assistant used for this run.

      • instructions string Required

        The instructions that the assistant used for this run.

      • tools array[object] Required

        The list of tools that the assistant used for this run.

        Not more than 20 elements. Default value is [] (empty).

        One of:
      • metadata object | null Required

        Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format. Keys can be a maximum of 64 characters long and values can be a maxium of 512 characters long.

      • usage object | null Required

        Usage statistics related to the run. This value will be null if the run is not in a terminal state (i.e. in_progress, queued, etc.).

        Hide usage attributes Show usage attributes object | null
        • completion_tokens integer Required

          Number of completion tokens used over the course of the run.

        • prompt_tokens integer Required

          Number of prompt tokens used over the course of the run.

        • total_tokens integer Required

          Total number of tokens used (prompt + completion).

      • temperature number | null

        The sampling temperature used for this run. If not set, defaults to 1.

      • top_p number | null

        The nucleus sampling value used for this run. If not set, defaults to 1.

      • max_prompt_tokens integer | null Required

        The maximum number of prompt tokens specified to have been used over the course of the run.

        Minimum value is 256.

      • max_completion_tokens integer | null Required

        The maximum number of completion tokens specified to have been used over the course of the run.

        Minimum value is 256.

      • truncation_strategy object | null Required

        Controls for how a thread will be truncated prior to the run. Use this to control the intial context window of the run.

        Hide truncation_strategy attributes Show truncation_strategy attributes object | null
        • type string Required

          The truncation strategy to use for the thread. The default is auto. If set to last_messages, the thread will be truncated to the n most recent messages in the thread. When set to auto, messages in the middle of the thread will be dropped to fit the context length of the model, max_prompt_tokens.

          Values are auto or last_messages.

        • last_messages integer | null

          The number of most recent messages from the thread when constructing the context for the run.

          Minimum value is 1.

      • tool_choice string | null | object Required

        One of:

        none means the model will not call any tools and instead generates a message. auto means the model can pick between generating a message or calling one or more tools. required means the model must call one or more tools before responding to the user.

        Values are none, auto, or required.

      • response_format string | null | object Required

        One of:

        auto is the default value

        Values are none or auto.

    • first_id string Required
    • last_id string Required
    • has_more boolean Required
GET /threads/{thread_id}/runs
curl \
 -X GET https://api.openai.com/v1/threads/{thread_id}/runs \
 -H "Authorization: Bearer $ACCESS_TOKEN"
Response examples (200)
{
  "object": "list",
  "data": [
    {
      "id": "string",
      "object": "thread.run",
      "created_at": 42,
      "thread_id": "string",
      "assistant_id": "string",
      "status": "queued",
      "required_action": {
        "type": "submit_tool_outputs",
        "submit_tool_outputs": {
          "tool_calls": [
            {
              "id": "string",
              "type": "function",
              "function": {
                "name": "string",
                "arguments": "string"
              }
            }
          ]
        }
      },
      "last_error": {
        "code": "server_error",
        "message": "string"
      },
      "expires_at": 42,
      "started_at": 42,
      "cancelled_at": 42,
      "failed_at": 42,
      "completed_at": 42,
      "incomplete_details": {
        "reason": "max_completion_tokens"
      },
      "model": "string",
      "instructions": "string",
      "tools": [
        {
          "type": "code_interpreter"
        }
      ],
      "metadata": {},
      "usage": {
        "completion_tokens": 42,
        "prompt_tokens": 42,
        "total_tokens": 42
      },
      "temperature": 42.0,
      "top_p": 42.0,
      "max_prompt_tokens": 42,
      "max_completion_tokens": 42,
      "truncation_strategy": {
        "type": "auto",
        "last_messages": 42
      },
      "tool_choice": "none",
      "response_format": "none"
    }
  ],
  "first_id": "run_abc123",
  "last_id": "run_abc456",
  "has_more": false
}