threads
Creates, updates, deletes, gets or lists a threads resource.
Overview
| Name | threads |
| Type | Resource |
| Id | openai.assistants.threads |
Fields
The following fields are returned by SELECT queries:
- get
| Name | Datatype | Description |
|---|---|---|
id | string | The identifier, which can be referenced in API endpoints. |
created_at | integer (unixtime) | The Unix timestamp (in seconds) for when the thread was created. |
metadata | object | 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. (x-oaiTypeLabel: map) |
object | string | The object type, which is always thread. (thread) |
tool_resources | object | A 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:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get | select | thread_id | openai-organization, openai-project | |
create | insert | openai-organization, openai-project | ||
update | update | thread_id | openai-organization, openai-project | |
delete | delete | thread_id | openai-organization, openai-project | |
create_thread_and_run | exec | assistant_id | openai-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.
| Name | Datatype | Description |
|---|---|---|
thread_id | string | The ID of the thread to delete. |
openai-organization | string | Optionally scope the request to a specific organization (overrides the default associated with the API key). Addressable in SQL as openai_organization. |
openai-project | string | Optionally scope the request to a specific project (overrides the default associated with the API key). Addressable in SQL as openai_project. |
SELECT examples
- get
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
- create
- Manifest
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
;
# Description fields are for documentation purposes
- name: threads
props:
- name: messages
description: |
A list of [messages](https://platform.openai.com/docs/api-reference/messages) to start the thread with.
value:
- role: "{{ role }}"
content: "{{ content }}"
attachments: "{{ attachments }}"
metadata: "{{ metadata }}"
- name: tool_resources
description: |
A 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.
value:
code_interpreter:
file_ids:
- "{{ file_ids }}"
file_search:
vector_store_ids:
- "{{ vector_store_ids }}"
vector_stores:
- file_ids: "{{ file_ids }}"
chunking_strategy: "{{ chunking_strategy }}"
metadata: "{{ metadata }}"
- name: metadata
value: "{{ metadata }}"
description: |
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.
- name: openai-organization
value: "{{ openai-organization }}"
description: Optionally scope the request to a specific organization (overrides the default associated with the API key). Addressable in SQL as `openai_organization`.
description: Optionally scope the request to a specific organization (overrides the default associated with the API key). Addressable in SQL as `openai_organization`.
- name: openai-project
value: "{{ openai-project }}"
description: Optionally scope the request to a specific project (overrides the default associated with the API key). Addressable in SQL as `openai_project`.
description: Optionally scope the request to a specific project (overrides the default associated with the API key). Addressable in SQL as `openai_project`.
UPDATE examples
- update
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
- delete
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
- create_thread_and_run
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 }}"
}'
;