Path parameters
-
The ID of the thread to run.
Body Required
-
The ID of the assistant to use to execute this run.
model string | null
Any of: The ID of the Model 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.
The ID of the Model 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.
Values are
gpt-4o
,gpt-4o-2024-05-13
,gpt-4-turbo
,gpt-4-turbo-2024-04-09
,gpt-4-0125-preview
,gpt-4-turbo-preview
,gpt-4-1106-preview
,gpt-4-vision-preview
,gpt-4
,gpt-4-0314
,gpt-4-0613
,gpt-4-32k
,gpt-4-32k-0314
,gpt-4-32k-0613
,gpt-3.5-turbo
,gpt-3.5-turbo-16k
,gpt-3.5-turbo-0613
,gpt-3.5-turbo-1106
,gpt-3.5-turbo-0125
, orgpt-3.5-turbo-16k-0613
.-
instructions string | null
Overrides the instructions of the assistant. This is useful for modifying the behavior on a per-run basis.
-
additional_instructions string | null
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.
-
additional_messages array[object] | null
Adds additional messages to the thread before creating the run.
-
tools array[object] | null
Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis.
Not more than
20
elements. -
metadata object | null
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.
-
temperature number | null
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.
Minimum value is
0
, maximum value is2
. Default value is1
. -
top_p number | null
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.
Minimum value is
0
, maximum value is1
. Default value is1
. -
stream boolean | null
If
true
, returns a stream of events that happen during the Run as server-sent events, terminating when the Run enters a terminal state with adata: [DONE]
message. -
max_prompt_tokens integer | null
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
incomplete
. Seeincomplete_details
for more info.Minimum value is
256
. -
max_completion_tokens integer | null
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
incomplete
. Seeincomplete_details
for more info.Minimum value is
256
. -
truncation_strategy object | null
Controls for how a thread will be truncated prior to the run. Use this to control the intial context window of the run.
tool_choice string | null | object
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
, orrequired
.response_format string | null | object
One of: auto
is the default valueValues are
none
orauto
.
curl \
-X POST https://api.openai.com/v1/threads/{thread_id}/runs \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"assistant_id":"string","model":"gpt-4-turbo","instructions":"string","additional_instructions":"string","additional_messages":[{"role":"user","content":"string","attachments":[{"file_id":"string","tools":[{"type":"code_interpreter"}]}],"metadata":{}}],"tools":[{"type":"code_interpreter"}],"metadata":{},"temperature":1,"top_p":1,"stream":true,"max_prompt_tokens":42,"max_completion_tokens":42,"truncation_strategy":{"type":"auto","last_messages":42},"tool_choice":"none","response_format":"none"}'
{
"assistant_id": "string",
"model": "gpt-4-turbo",
"instructions": "string",
"additional_instructions": "string",
"additional_messages": [
{
"role": "user",
"content": "string",
"attachments": [
{
"file_id": "string",
"tools": [
{
"type": "code_interpreter"
}
]
}
],
"metadata": {}
}
],
"tools": [
{
"type": "code_interpreter"
}
],
"metadata": {},
"temperature": 1,
"top_p": 1,
"stream": true,
"max_prompt_tokens": 42,
"max_completion_tokens": 42,
"truncation_strategy": {
"type": "auto",
"last_messages": 42
},
"tool_choice": "none",
"response_format": "none"
}
{
"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"
}