=encoding utf8

=head1 NAME

OpenAPI::Client::OpenAI::Path::threads-thread_id-runs - Documentation for the /threads/{thread_id}/runs path.

=head1 OPERATIONS

=head2 GET /threads/{thread_id}/runs

=head3 listRuns

  $client->list_runs({
      body => { ... },
  });

Returns a list of runs belonging to a thread.

=head4 Path/query parameters

=over

=item * C<thread_id> (in path, required, string) - The ID of the thread the run belongs to.

=item * C<limit> (in query, optional, integer) - A limit on the number of objects to be returned. Limit can range between 1 and
100, and the default is 20.

Default: 20

=item * C<order> (in query, optional, string) - Sort order by the C<created_at> timestamp of the objects. C<asc> for ascending
order and C<desc> for descending order.

Allowed values: asc, desc

Default: desc

=item * C<after> (in query, optional, string) - A cursor for use in pagination. C<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.

=item * C<before> (in query, optional, string) - A cursor for use in pagination. C<before> is an object ID that defines your
place in the list. For instance, if you make a list request and receive 100
objects, starting with obj_foo, your subsequent call can include
before=obj_foo in order to fetch the previous page of the list.

=back

=head4 Responses

B<200 - OK>

Content-Type: application/json

Example:

    {
       "data" : [
          "{\n  \"id\": \"run_abc123\",\n  \"object\": \"thread.run\",\n  \"created_at\": 1698107661,\n  \"assistant_id\": \"asst_abc123\",\n  \"thread_id\": \"thread_abc123\",\n  \"status\": \"completed\",\n  \"started_at\": 1699073476,\n  \"expires_at\": null,\n  \"cancelled_at\": null,\n  \"failed_at\": null,\n  \"completed_at\": 1699073498,\n  \"last_error\": null,\n  \"model\": \"gpt-4o\",\n  \"instructions\": null,\n  \"tools\": [{\"type\": \"file_search\"}, {\"type\": \"code_interpreter\"}],\n  \"metadata\": {},\n  \"incomplete_details\": null,\n  \"usage\": {\n    \"prompt_tokens\": 123,\n    \"completion_tokens\": 456,\n    \"total_tokens\": 579\n  },\n  \"temperature\": 1.0,\n  \"top_p\": 1.0,\n  \"max_prompt_tokens\": 1000,\n  \"max_completion_tokens\": 1000,\n  \"truncation_strategy\": {\n    \"type\": \"auto\",\n    \"last_messages\": null\n  },\n  \"response_format\": \"auto\",\n  \"tool_choice\": \"auto\",\n  \"parallel_tool_calls\": true\n}\n"
       ],
       "first_id" : "run_abc123",
       "has_more" : false,
       "last_id" : "run_abc456",
       "object" : "list"
    }

=head2 POST /threads/{thread_id}/runs

=head3 createRun

  $client->create_run({
      body => { ... },
  });

Create a run.

=head4 Path/query parameters

=over

=item * C<thread_id> (in path, required, string) - The ID of the thread to run.

=item * C<include[]> (in query, optional, array) - A list of additional fields to include in the response. Currently the only
supported value is
C<step_details.tool_calls[I<].file_search.results[>].content> to fetch the
file search result content.

See the
L<file search tool documentation|https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings>
for more information.

=back

=head4 Request body

Content-Type: application/json

Example:

    {
       "assistant_id" : "asst_abc123",
       "cancelled_at" : null,
       "completed_at" : 1699063291,
       "created_at" : 1699063290,
       "expires_at" : null,
       "failed_at" : null,
       "id" : "run_abc123",
       "incomplete_details" : null,
       "instructions" : null,
       "last_error" : null,
       "max_completion_tokens" : 1000,
       "max_prompt_tokens" : 1000,
       "metadata" : {},
       "model" : "gpt-4o",
       "object" : "thread.run",
       "parallel_tool_calls" : true,
       "response_format" : "auto",
       "started_at" : 1699063290,
       "status" : "queued",
       "temperature" : 1,
       "thread_id" : "thread_abc123",
       "tool_choice" : "auto",
       "tools" : [
          {
             "type" : "code_interpreter"
          }
       ],
       "top_p" : 1,
       "truncation_strategy" : {
          "last_messages" : null,
          "type" : "auto"
       },
       "usage" : null
    }

=head4 Responses

B<200 - OK>

Content-Type: application/json

Example:

    {
       "assistant_id" : "asst_abc123",
       "cancelled_at" : null,
       "completed_at" : 1699063291,
       "created_at" : 1699063290,
       "expires_at" : null,
       "failed_at" : null,
       "id" : "run_abc123",
       "incomplete_details" : null,
       "instructions" : null,
       "last_error" : null,
       "max_completion_tokens" : 1000,
       "max_prompt_tokens" : 1000,
       "metadata" : {},
       "model" : "gpt-4o",
       "object" : "thread.run",
       "parallel_tool_calls" : true,
       "response_format" : "auto",
       "started_at" : 1699063290,
       "status" : "queued",
       "temperature" : 1,
       "thread_id" : "thread_abc123",
       "tool_choice" : "auto",
       "tools" : [
          {
             "type" : "code_interpreter"
          }
       ],
       "top_p" : 1,
       "truncation_strategy" : {
          "last_messages" : null,
          "type" : "auto"
       },
       "usage" : null
    }

=head1 SCHEMAS

=head2 AssistantsApiResponseFormatOption

Specifies the format that the model must output. Compatible with
L<GPT-4o|https://platform.openai.com/docs/models#gpt-4o> ,
L<GPT-4 Turbo|https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4> ,
and all GPT-3.5 Turbo models since C<gpt-3.5-turbo-1106> .

Setting to C<{ "type": "json_schema", "json_schema": {...} }> enables
Structured Outputs which ensures the model will match your supplied JSON
schema. Learn more in the
L<Structured Outputs guide|https://platform.openai.com/docs/guides/structured-outputs>
.

Setting to C<{ "type": "json_object" }> enables JSON mode, which ensures the
message the model generates is valid JSON.

B<Important:> when using JSON mode, you B<must> also instruct the model to
produce JSON yourself via a system or user message. Without this, the model
may generate an unending stream of whitespace until the generation reaches the
token limit, resulting in a long-running and seemingly "stuck" request. Also
note that the message content may be partially cut off if
C<finish_reason="length"> , which indicates the generation exceeded
C<max_tokens> or the conversation exceeded the max context length.

=head2 CreateMessageRequest

Properties:

=over

=item * C<attachments> (anyOf)

=item * C<content> (oneOf, required)

=item * C<metadata> (Metadata)

See L</Metadata> below for shape.

=item * C<role> (string, required) - The role of the entity that is creating the message. Allowed values include: -
C<user> : Indicates the message is sent by an actual user and should be used
in most cases to represent user-generated messages. - C<assistant> : Indicates
the message is generated by the assistant. Use this value to insert messages
from the assistant into the conversation.

Allowed values: user, assistant

=back

=head2 CreateRunRequest

Properties:

=over

=item * C<additional_instructions> (string) - Appends additional instructions at the end of the instructions for the run.
This is useful for modifying the behavior on a per-run basis without
overriding other instructions.

=item * C<additional_messages> (array of CreateMessageRequest) - Adds additional messages to the thread before creating the run.

=item * C<assistant_id> (string, required) - The ID of the
L<assistant|https://platform.openai.com/docs/api-reference/assistants> to use
to execute this run.

=item * C<instructions> (string) - Overrides the
L<instructions|https://platform.openai.com/docs/api-reference/assistants/createAssistant>
of the assistant. This is useful for modifying the behavior on a per-run
basis.

=item * C<max_completion_tokens> (integer) - The maximum number of completion tokens that may be used over the course of
the run. The run will make a best effort to use only the number of completion
tokens specified, across multiple turns of the run. If the run exceeds the
number of completion tokens specified, the run will end with status
C<incomplete> . See C<incomplete_details> for more info.

=item * C<max_prompt_tokens> (integer) - The maximum number of prompt tokens that may be used over the course of the
run. The run will make a best effort to use only the number of prompt tokens
specified, across multiple turns of the run. If the run exceeds the number of
prompt tokens specified, the run will end with status C<incomplete> . See
C<incomplete_details> for more info.

=item * C<metadata> (Metadata)

See L</Metadata> below for shape.

=item * C<model> (anyOf) - The ID of the L<Model|https://platform.openai.com/docs/api-reference/models>
to be used to execute this run. If a value is provided here, it will override
the model associated with the assistant. If not, the model associated with the
assistant will be used.

=item * C<parallel_tool_calls> (ParallelToolCalls)

See L</ParallelToolCalls> below for shape.

=item * C<reasoning_effort> (ReasoningEffort)

See L</ReasoningEffort> below for shape.

=item * C<response_format> (AssistantsApiResponseFormatOption)

See L</AssistantsApiResponseFormatOption> below for shape.

=item * C<stream> (boolean) - If C<true> , returns a stream of events that happen during the Run as
server-sent events, terminating when the Run enters a terminal state with a
C<data: [DONE]> message.

=item * C<temperature> (number) - What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
make the output more random, while lower values like 0.2 will make it more
focused and deterministic.

Default: 1

=item * C<tool_choice> (allOf)

=item * C<tools> (array of object) - Override the tools the assistant can use for this run. This is useful for
modifying the behavior on a per-run basis.

=item * C<top_p> (number) - An alternative to sampling with temperature, called nucleus sampling, where
the model considers the results of the tokens with top_p probability mass. So
0.1 means only the tokens comprising the top 10% probability mass are
considered.

We generally recommend altering this or temperature but not both.

Default: 1

=item * C<truncation_strategy> (allOf)

=back

=head2 ListRunsResponse

Properties:

=over

=item * C<data> (array of RunObject, required)

=item * C<first_id> (string, required)

=item * C<has_more> (boolean, required)

=item * C<last_id> (string, required)

=item * C<object> (string, required)

=back

=head2 Metadata

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, and querying for objects via API or the dashboard.

Keys are strings with a maximum length of 64 characters. Values are strings
with a maximum length of 512 characters.

=head2 ParallelToolCalls

Whether to enable
L<parallel function calling|https://platform.openai.com/docs/guides/function-calling#configuring-parallel-function-calling>
during tool use.

=head2 ReasoningEffort

Constrains effort on reasoning for
L<reasoning models|https://platform.openai.com/docs/guides/reasoning> .
Currently supported values are C<none> , C<minimal> , C<low> , C<medium> ,
C<high> , and C<xhigh> . Reducing reasoning effort can result in faster
responses and fewer tokens used on reasoning in a response.

- C<gpt-5.1> defaults to C<none> , which does not perform reasoning. The
supported reasoning values for C<gpt-5.1> are C<none> , C<low> , C<medium> ,
and C<high> . Tool calls are supported for all reasoning values in gpt-5.1. -
All models before C<gpt-5.1> default to C<medium> reasoning effort, and do not
support C<none> . - The C<gpt-5-pro> model defaults to (and only supports)
C<high> reasoning effort. - C<xhigh> is supported for all models after
C<gpt-5.1-codex-max> .

=head2 RunCompletionUsage

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

=head2 RunObject

Properties:

=over

=item * C<assistant_id> (string, required) - The ID of the
L<assistant|https://platform.openai.com/docs/api-reference/assistants> used
for execution of this run.

=item * C<cancelled_at> (integer, required) - The Unix timestamp (in seconds) for when the run was cancelled.

=item * C<completed_at> (integer, required) - The Unix timestamp (in seconds) for when the run was completed.

=item * C<created_at> (integer, required) - The Unix timestamp (in seconds) for when the run was created.

=item * C<expires_at> (integer, required) - The Unix timestamp (in seconds) for when the run will expire.

=item * C<failed_at> (integer, required) - The Unix timestamp (in seconds) for when the run failed.

=item * C<id> (string, required) - The identifier, which can be referenced in API endpoints.

=item * C<incomplete_details> (object, required) - Details on why the run is incomplete. Will be C<null> if the run is not
incomplete.

=item * C<instructions> (string, required) - The instructions that the
L<assistant|https://platform.openai.com/docs/api-reference/assistants> used
for this run.

=item * C<last_error> (object, required) - The last error associated with this run. Will be C<null> if there are no
errors.

=item * C<max_completion_tokens> (integer, required) - The maximum number of completion tokens specified to have been used over the
course of the run.

=item * C<max_prompt_tokens> (integer, required) - The maximum number of prompt tokens specified to have been used over the
course of the run.

=item * C<metadata> (Metadata, required)

See L</Metadata> below for shape.

=item * C<model> (string, required) - The model that the
L<assistant|https://platform.openai.com/docs/api-reference/assistants> used
for this run.

=item * C<object> (string, required) - The object type, which is always C<thread.run> .

Allowed values: thread.run

=item * C<parallel_tool_calls> (ParallelToolCalls, required)

See L</ParallelToolCalls> below for shape.

=item * C<required_action> (object, required) - Details on the action required to continue the run. Will be C<null> if no
action is required.

=item * C<response_format> (AssistantsApiResponseFormatOption, required)

See L</AssistantsApiResponseFormatOption> below for shape.

=item * C<started_at> (integer, required) - The Unix timestamp (in seconds) for when the run was started.

=item * C<status> (string, required) - The status of the run, which can be either C<queued> , C<in_progress> ,
C<requires_action> , C<cancelling> , C<cancelled> , C<failed> , C<completed> ,
C<incomplete> , or C<expired> .

Allowed values: queued, in_progress, requires_action, cancelling, cancelled, failed, completed, incomplete, expired

=item * C<temperature> (number) - The sampling temperature used for this run. If not set, defaults to 1.

=item * C<thread_id> (string, required) - The ID of the L<thread|https://platform.openai.com/docs/api-reference/threads>
that was executed on as a part of this run.

=item * C<tool_choice> (allOf, required)

=item * C<tools> (array of object, required) - The list of tools that the
L<assistant|https://platform.openai.com/docs/api-reference/assistants> used
for this run.

Default: []

=item * C<top_p> (number) - The nucleus sampling value used for this run. If not set, defaults to 1.

=item * C<truncation_strategy> (allOf, required)

=item * C<usage> (RunCompletionUsage, required)

See L</RunCompletionUsage> below for shape.

=back

=head2 RunToolCallObject

Properties:

=over

=item * C<function> (object, required) - The function definition.

=item * C<id> (string, required) - The ID of the tool call. This ID must be referenced when you submit the tool
outputs in using the
L<Submit tool outputs to run|https://platform.openai.com/docs/api-reference/runs/submitToolOutputs>
endpoint.

=item * C<type> (string, required) - The type of tool call the output is required for. For now, this is always
C<function> .

Allowed values: function

=back

=head1 SEE ALSO

L<OpenAPI::Client::OpenAI::Path>

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2023-2026 by Nelson Ferraz

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.14.0 or,
at your option, any later version of Perl 5 you may have available.

=cut
