Skip to main content

threads

Creates, updates, deletes, gets or lists a threads resource.

Overview

Namethreads
TypeResource
Idopenai.assistants.threads

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
idstringThe identifier, which can be referenced in API endpoints.
created_atinteger (unixtime)The Unix timestamp (in seconds) for when the thread was created.
metadataobjectSet 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. (x-oaiTypeLabel: map)
objectstringThe object type, which is always thread. (thread)
tool_resourcesobjectA set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type of tool. For example, the code_interpreter tool requires a list of file IDs, while the file_search tool requires a list of vector store IDs.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectthread_idopenai-organization, openai-project
createinsertopenai-organization, openai-project
updateupdatethread_idopenai-organization, openai-project
deletedeletethread_idopenai-organization, openai-project
create_thread_and_runexecassistant_idopenai-organization, openai-project

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
thread_idstringThe ID of the thread to delete.
openai-organizationstringOptionally scope the request to a specific organization (overrides the default associated with the API key). Addressable in SQL as openai_organization.
openai-projectstringOptionally scope the request to a specific project (overrides the default associated with the API key). Addressable in SQL as openai_project.

SELECT examples

OK

SELECT
id,
created_at,
metadata,
object,
tool_resources
FROM openai.assistants.threads
WHERE thread_id = '{{ thread_id }}' -- required
AND "openai-organization" = '{{ openai-organization }}'
AND "openai-project" = '{{ openai-project }}'
;

INSERT examples

No description available.

INSERT INTO openai.assistants.threads (
messages,
tool_resources,
metadata,
"openai-organization",
"openai-project"
)
SELECT
'{{ messages }}',
'{{ tool_resources }}',
'{{ metadata }}',
'{{ openai-organization }}',
'{{ openai-project }}'
RETURNING
id,
created_at,
metadata,
object,
tool_resources
;

UPDATE examples

No description available.

UPDATE openai.assistants.threads
SET
tool_resources = '{{ tool_resources }}',
metadata = '{{ metadata }}'
WHERE
thread_id = '{{ thread_id }}' --required
AND "openai-organization" = '{{ openai-organization}}'
AND "openai-project" = '{{ openai-project}}'
RETURNING
id,
created_at,
metadata,
object,
tool_resources;

DELETE examples

No description available.

DELETE FROM openai.assistants.threads
WHERE thread_id = '{{ thread_id }}' --required
AND "openai-organization" = '{{ openai-organization }}'
AND "openai-project" = '{{ openai-project }}'
;

Lifecycle Methods

OK

EXEC openai.assistants.threads.create_thread_and_run
@openai-organization='{{ openai-organization }}',
@openai-project='{{ openai-project }}'
@@json=
'{
"assistant_id": "{{ assistant_id }}",
"thread": "{{ thread }}",
"model": "{{ model }}",
"instructions": "{{ instructions }}",
"tools": "{{ tools }}",
"tool_resources": "{{ tool_resources }}",
"metadata": "{{ metadata }}",
"temperature": {{ temperature }},
"top_p": {{ top_p }},
"stream": {{ stream }},
"max_prompt_tokens": {{ max_prompt_tokens }},
"max_completion_tokens": {{ max_completion_tokens }},
"truncation_strategy": "{{ truncation_strategy }}",
"tool_choice": "{{ tool_choice }}",
"parallel_tool_calls": {{ parallel_tool_calls }},
"response_format": "{{ response_format }}"
}'
;