Skip to main content

threads

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

Overview

Namethreads
TypeResource
Idazure.ai_agents.threads

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
idstringThe identifier, which can be referenced in API endpoints. Required.
created_atstring (date-time)The Unix timestamp, in seconds, representing when this object was created. Required.
metadataobjectA set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. Required.
objectstringThe object type, which is always 'thread'. Required. Default value is "thread".
tool_resourcesobjectA set of resources that are made available to the agent'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. Required.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectthread_id, endpointGets information about an existing thread.
listselectendpointlimit, order, after, beforeGets a list of threads that were previously created.
createinsertendpointCreates a new thread. Threads contain messages and can be run by agents.
updateexecthread_id, endpointModifies an existing thread.

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
endpointstringThe service endpoint host (no scheme), e.g. myaccount.table.cosmos.azure.com:443 - value of the client endpoint parameter. (default: )
thread_idstringThe ID of the thread to modify. Required.
afterstring
beforestringA 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. Default value is None.
limitintegerA limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. Default value is None.
orderstringSort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Known values are: "asc" and "desc". Default value is None.

SELECT examples

Gets information about an existing thread.

SELECT
id,
created_at,
metadata,
object,
tool_resources
FROM azure.ai_agents.threads
WHERE thread_id = '{{ thread_id }}' -- required
AND endpoint = '{{ endpoint }}' -- required
;

INSERT examples

Creates a new thread. Threads contain messages and can be run by agents.

INSERT INTO azure.ai_agents.threads (
endpoint
)
SELECT
'{{ endpoint }}'
RETURNING
id,
created_at,
metadata,
object,
tool_resources
;

Lifecycle Methods

Modifies an existing thread.

EXEC azure.ai_agents.threads.update 
@thread_id='{{ thread_id }}' --required,
@endpoint='{{ endpoint }}' --required
;