Index
Modules:
Name | Description |
---|---|
messages |
|
runs |
|
threads |
The |
Classes:
AsyncMessages
AsyncMessages(client: AsyncOpenAI)
Methods:
Name | Description |
---|---|
create |
Create a message. |
files |
|
list |
Returns a list of messages for a given thread. |
retrieve |
Retrieve a message. |
update |
Modifies a message. |
with_raw_response |
|
with_streaming_response |
|
create
async
create(
thread_id: str,
*,
content: str,
role: Literal["user"],
file_ids: List[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> Message
Create a message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content
|
str
|
The content of the message. |
required |
role
|
Literal['user']
|
The role of the entity that is creating the message. Currently only |
required |
file_ids
|
List[str] | NotGiven
|
A list of File IDs that
the message should use. There can be a maximum of 10 files attached to a
message. Useful for tools like |
NOT_GIVEN
|
metadata
|
Optional[object] | NotGiven
|
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. |
NOT_GIVEN
|
extra_headers
|
Headers | None
|
Send extra headers |
None
|
extra_query
|
Query | None
|
Add additional query parameters to the request |
None
|
extra_body
|
Body | None
|
Add additional JSON properties to the request |
None
|
timeout
|
float | Timeout | None | NotGiven
|
Override the client-level default timeout for this request, in seconds |
NOT_GIVEN
|
list
list(
thread_id: str,
*,
after: str | NotGiven = NOT_GIVEN,
before: str | NotGiven = NOT_GIVEN,
limit: int | NotGiven = NOT_GIVEN,
order: Literal["asc", "desc"] | NotGiven = NOT_GIVEN,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> AsyncPaginator[Message, AsyncCursorPage[Message]]
Returns a list of messages for a given thread.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
after
|
str | NotGiven
|
A cursor for use in pagination. |
NOT_GIVEN
|
before
|
str | NotGiven
|
A cursor for use in pagination. |
NOT_GIVEN
|
limit
|
int | NotGiven
|
A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. |
NOT_GIVEN
|
order
|
Literal['asc', 'desc'] | NotGiven
|
Sort order by the |
NOT_GIVEN
|
extra_headers
|
Headers | None
|
Send extra headers |
None
|
extra_query
|
Query | None
|
Add additional query parameters to the request |
None
|
extra_body
|
Body | None
|
Add additional JSON properties to the request |
None
|
timeout
|
float | Timeout | None | NotGiven
|
Override the client-level default timeout for this request, in seconds |
NOT_GIVEN
|
retrieve
async
retrieve(
message_id: str,
*,
thread_id: str,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> Message
Retrieve a message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
extra_headers
|
Headers | None
|
Send extra headers |
None
|
extra_query
|
Query | None
|
Add additional query parameters to the request |
None
|
extra_body
|
Body | None
|
Add additional JSON properties to the request |
None
|
timeout
|
float | Timeout | None | NotGiven
|
Override the client-level default timeout for this request, in seconds |
NOT_GIVEN
|
update
async
update(
message_id: str,
*,
thread_id: str,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> Message
Modifies a message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
metadata
|
Optional[object] | NotGiven
|
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. |
NOT_GIVEN
|
extra_headers
|
Headers | None
|
Send extra headers |
None
|
extra_query
|
Query | None
|
Add additional query parameters to the request |
None
|
extra_body
|
Body | None
|
Add additional JSON properties to the request |
None
|
timeout
|
float | Timeout | None | NotGiven
|
Override the client-level default timeout for this request, in seconds |
NOT_GIVEN
|
AsyncMessagesWithRawResponse
AsyncMessagesWithRawResponse(messages: AsyncMessages)
AsyncMessagesWithStreamingResponse
AsyncMessagesWithStreamingResponse(messages: AsyncMessages)
AsyncRuns
AsyncRuns(client: AsyncOpenAI)
Methods:
Name | Description |
---|---|
cancel |
Cancels a run that is |
create |
|
create_and_stream |
Create a Run stream |
list |
Returns a list of runs belonging to a thread. |
retrieve |
Retrieves a run. |
steps |
|
submit_tool_outputs |
|
submit_tool_outputs_stream |
Submit the tool outputs from a previous run and stream the run to a terminal |
update |
Modifies a run. |
with_raw_response |
|
with_streaming_response |
|
cancel
async
cancel(
run_id: str,
*,
thread_id: str,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> Run
Cancels a run that is in_progress
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
extra_headers
|
Headers | None
|
Send extra headers |
None
|
extra_query
|
Query | None
|
Add additional query parameters to the request |
None
|
extra_body
|
Body | None
|
Add additional JSON properties to the request |
None
|
timeout
|
float | Timeout | None | NotGiven
|
Override the client-level default timeout for this request, in seconds |
NOT_GIVEN
|
create
async
create(
thread_id: str,
*,
assistant_id: str,
additional_instructions: (
Optional[str] | NotGiven
) = NOT_GIVEN,
instructions: Optional[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
model: Optional[str] | NotGiven = NOT_GIVEN,
stream: Optional[Literal[False]] | NotGiven = NOT_GIVEN,
tools: (
Optional[Iterable[AssistantToolParam]] | NotGiven
) = NOT_GIVEN,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> Run
create(
thread_id: str,
*,
assistant_id: str,
stream: Literal[True],
additional_instructions: (
Optional[str] | NotGiven
) = NOT_GIVEN,
instructions: Optional[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
model: Optional[str] | NotGiven = NOT_GIVEN,
tools: (
Optional[Iterable[AssistantToolParam]] | NotGiven
) = NOT_GIVEN,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> AsyncStream[AssistantStreamEvent]
create(
thread_id: str,
*,
assistant_id: str,
stream: bool,
additional_instructions: (
Optional[str] | NotGiven
) = NOT_GIVEN,
instructions: Optional[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
model: Optional[str] | NotGiven = NOT_GIVEN,
tools: (
Optional[Iterable[AssistantToolParam]] | NotGiven
) = NOT_GIVEN,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> Run | AsyncStream[AssistantStreamEvent]
create(
thread_id: str,
*,
assistant_id: str,
additional_instructions: (
Optional[str] | NotGiven
) = NOT_GIVEN,
instructions: Optional[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
model: Optional[str] | NotGiven = NOT_GIVEN,
stream: (
Optional[Literal[False]] | Literal[True] | NotGiven
) = NOT_GIVEN,
tools: (
Optional[Iterable[AssistantToolParam]] | NotGiven
) = NOT_GIVEN,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> Run | AsyncStream[AssistantStreamEvent]
create_and_stream
create_and_stream(
*,
assistant_id: str,
additional_instructions: (
Optional[str] | NotGiven
) = NOT_GIVEN,
instructions: Optional[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
model: Optional[str] | NotGiven = NOT_GIVEN,
tools: (
Optional[Iterable[AssistantToolParam]] | NotGiven
) = NOT_GIVEN,
thread_id: str,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> AsyncAssistantStreamManager[
AsyncAssistantEventHandler
]
create_and_stream(
*,
assistant_id: str,
additional_instructions: (
Optional[str] | NotGiven
) = NOT_GIVEN,
instructions: Optional[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
model: Optional[str] | NotGiven = NOT_GIVEN,
tools: (
Optional[Iterable[AssistantToolParam]] | NotGiven
) = NOT_GIVEN,
thread_id: str,
event_handler: AsyncAssistantEventHandlerT,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> AsyncAssistantStreamManager[
AsyncAssistantEventHandlerT
]
create_and_stream(
*,
assistant_id: str,
additional_instructions: (
Optional[str] | NotGiven
) = NOT_GIVEN,
instructions: Optional[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
model: Optional[str] | NotGiven = NOT_GIVEN,
tools: (
Optional[Iterable[AssistantToolParam]] | NotGiven
) = NOT_GIVEN,
thread_id: str,
event_handler: (
AsyncAssistantEventHandlerT | None
) = None,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> (
AsyncAssistantStreamManager[AsyncAssistantEventHandler]
| AsyncAssistantStreamManager[
AsyncAssistantEventHandlerT
]
)
Create a Run stream
list
list(
thread_id: str,
*,
after: str | NotGiven = NOT_GIVEN,
before: str | NotGiven = NOT_GIVEN,
limit: int | NotGiven = NOT_GIVEN,
order: Literal["asc", "desc"] | NotGiven = NOT_GIVEN,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> AsyncPaginator[Run, AsyncCursorPage[Run]]
Returns a list of runs belonging to a thread.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
after
|
str | NotGiven
|
A cursor for use in pagination. |
NOT_GIVEN
|
before
|
str | NotGiven
|
A cursor for use in pagination. |
NOT_GIVEN
|
limit
|
int | NotGiven
|
A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. |
NOT_GIVEN
|
order
|
Literal['asc', 'desc'] | NotGiven
|
Sort order by the |
NOT_GIVEN
|
extra_headers
|
Headers | None
|
Send extra headers |
None
|
extra_query
|
Query | None
|
Add additional query parameters to the request |
None
|
extra_body
|
Body | None
|
Add additional JSON properties to the request |
None
|
timeout
|
float | Timeout | None | NotGiven
|
Override the client-level default timeout for this request, in seconds |
NOT_GIVEN
|
retrieve
async
retrieve(
run_id: str,
*,
thread_id: str,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> Run
Retrieves a run.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
extra_headers
|
Headers | None
|
Send extra headers |
None
|
extra_query
|
Query | None
|
Add additional query parameters to the request |
None
|
extra_body
|
Body | None
|
Add additional JSON properties to the request |
None
|
timeout
|
float | Timeout | None | NotGiven
|
Override the client-level default timeout for this request, in seconds |
NOT_GIVEN
|
submit_tool_outputs
async
submit_tool_outputs(
run_id: str,
*,
thread_id: str,
tool_outputs: Iterable[ToolOutput],
stream: Optional[Literal[False]] | NotGiven = NOT_GIVEN,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> Run
submit_tool_outputs(
run_id: str,
*,
thread_id: str,
stream: Literal[True],
tool_outputs: Iterable[ToolOutput],
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> AsyncStream[AssistantStreamEvent]
submit_tool_outputs(
run_id: str,
*,
thread_id: str,
stream: bool,
tool_outputs: Iterable[ToolOutput],
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> Run | AsyncStream[AssistantStreamEvent]
submit_tool_outputs(
run_id: str,
*,
thread_id: str,
tool_outputs: Iterable[ToolOutput],
stream: (
Optional[Literal[False]] | Literal[True] | NotGiven
) = NOT_GIVEN,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> Run | AsyncStream[AssistantStreamEvent]
submit_tool_outputs_stream
submit_tool_outputs_stream(
*,
tool_outputs: Iterable[ToolOutput],
run_id: str,
thread_id: str,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> AsyncAssistantStreamManager[
AsyncAssistantEventHandler
]
submit_tool_outputs_stream(
*,
tool_outputs: Iterable[ToolOutput],
run_id: str,
thread_id: str,
event_handler: AsyncAssistantEventHandlerT,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> AsyncAssistantStreamManager[
AsyncAssistantEventHandlerT
]
submit_tool_outputs_stream(
*,
tool_outputs: Iterable[ToolOutput],
run_id: str,
thread_id: str,
event_handler: (
AsyncAssistantEventHandlerT | None
) = None,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> (
AsyncAssistantStreamManager[AsyncAssistantEventHandler]
| AsyncAssistantStreamManager[
AsyncAssistantEventHandlerT
]
)
Submit the tool outputs from a previous run and stream the run to a terminal state.
update
async
update(
run_id: str,
*,
thread_id: str,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> Run
Modifies a run.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
metadata
|
Optional[object] | NotGiven
|
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. |
NOT_GIVEN
|
extra_headers
|
Headers | None
|
Send extra headers |
None
|
extra_query
|
Query | None
|
Add additional query parameters to the request |
None
|
extra_body
|
Body | None
|
Add additional JSON properties to the request |
None
|
timeout
|
float | Timeout | None | NotGiven
|
Override the client-level default timeout for this request, in seconds |
NOT_GIVEN
|
AsyncRunsWithRawResponse
AsyncRunsWithRawResponse(runs: AsyncRuns)
AsyncRunsWithStreamingResponse
AsyncRunsWithStreamingResponse(runs: AsyncRuns)
AsyncThreads
AsyncThreads(client: AsyncOpenAI)
Methods:
Name | Description |
---|---|
create |
Create a thread. |
create_and_run |
|
create_and_run_stream |
Create a thread and stream the run back |
delete |
Delete a thread. |
messages |
|
retrieve |
Retrieves a thread. |
runs |
|
update |
Modifies a thread. |
with_raw_response |
|
with_streaming_response |
|
create
async
create(
*,
messages: Iterable[Message] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> Thread
Create a thread.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
messages
|
Iterable[Message] | NotGiven
|
A list of messages to start the thread with. |
NOT_GIVEN
|
metadata
|
Optional[object] | NotGiven
|
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. |
NOT_GIVEN
|
extra_headers
|
Headers | None
|
Send extra headers |
None
|
extra_query
|
Query | None
|
Add additional query parameters to the request |
None
|
extra_body
|
Body | None
|
Add additional JSON properties to the request |
None
|
timeout
|
float | Timeout | None | NotGiven
|
Override the client-level default timeout for this request, in seconds |
NOT_GIVEN
|
create_and_run
async
create_and_run(
*,
assistant_id: str,
instructions: Optional[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
model: Optional[str] | NotGiven = NOT_GIVEN,
stream: Optional[Literal[False]] | NotGiven = NOT_GIVEN,
thread: Thread | NotGiven = NOT_GIVEN,
tools: Optional[Iterable[Tool]] | NotGiven = NOT_GIVEN,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> Run
create_and_run(
*,
assistant_id: str,
stream: Literal[True],
instructions: Optional[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
model: Optional[str] | NotGiven = NOT_GIVEN,
thread: Thread | NotGiven = NOT_GIVEN,
tools: Optional[Iterable[Tool]] | NotGiven = NOT_GIVEN,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> AsyncStream[AssistantStreamEvent]
create_and_run(
*,
assistant_id: str,
stream: bool,
instructions: Optional[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
model: Optional[str] | NotGiven = NOT_GIVEN,
thread: Thread | NotGiven = NOT_GIVEN,
tools: Optional[Iterable[Tool]] | NotGiven = NOT_GIVEN,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> Run | AsyncStream[AssistantStreamEvent]
create_and_run(
*,
assistant_id: str,
instructions: Optional[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
model: Optional[str] | NotGiven = NOT_GIVEN,
stream: (
Optional[Literal[False]] | Literal[True] | NotGiven
) = NOT_GIVEN,
thread: Thread | NotGiven = NOT_GIVEN,
tools: Optional[Iterable[Tool]] | NotGiven = NOT_GIVEN,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> Run | AsyncStream[AssistantStreamEvent]
create_and_run_stream
create_and_run_stream(
*,
assistant_id: str,
instructions: Optional[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
model: Optional[str] | NotGiven = NOT_GIVEN,
thread: Thread | NotGiven = NOT_GIVEN,
tools: Optional[Iterable[Tool]] | NotGiven = NOT_GIVEN,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> AsyncAssistantStreamManager[
AsyncAssistantEventHandler
]
create_and_run_stream(
*,
assistant_id: str,
instructions: Optional[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
model: Optional[str] | NotGiven = NOT_GIVEN,
thread: Thread | NotGiven = NOT_GIVEN,
tools: Optional[Iterable[Tool]] | NotGiven = NOT_GIVEN,
event_handler: AsyncAssistantEventHandlerT,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> AsyncAssistantStreamManager[
AsyncAssistantEventHandlerT
]
create_and_run_stream(
*,
assistant_id: str,
instructions: Optional[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
model: Optional[str] | NotGiven = NOT_GIVEN,
thread: Thread | NotGiven = NOT_GIVEN,
tools: Optional[Iterable[Tool]] | NotGiven = NOT_GIVEN,
event_handler: (
AsyncAssistantEventHandlerT | None
) = None,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> (
AsyncAssistantStreamManager[AsyncAssistantEventHandler]
| AsyncAssistantStreamManager[
AsyncAssistantEventHandlerT
]
)
Create a thread and stream the run back
delete
async
delete(
thread_id: str,
*,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> ThreadDeleted
Delete a thread.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
extra_headers
|
Headers | None
|
Send extra headers |
None
|
extra_query
|
Query | None
|
Add additional query parameters to the request |
None
|
extra_body
|
Body | None
|
Add additional JSON properties to the request |
None
|
timeout
|
float | Timeout | None | NotGiven
|
Override the client-level default timeout for this request, in seconds |
NOT_GIVEN
|
retrieve
async
retrieve(
thread_id: str,
*,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> Thread
Retrieves a thread.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
extra_headers
|
Headers | None
|
Send extra headers |
None
|
extra_query
|
Query | None
|
Add additional query parameters to the request |
None
|
extra_body
|
Body | None
|
Add additional JSON properties to the request |
None
|
timeout
|
float | Timeout | None | NotGiven
|
Override the client-level default timeout for this request, in seconds |
NOT_GIVEN
|
update
async
update(
thread_id: str,
*,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> Thread
Modifies a thread.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
metadata
|
Optional[object] | NotGiven
|
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. |
NOT_GIVEN
|
extra_headers
|
Headers | None
|
Send extra headers |
None
|
extra_query
|
Query | None
|
Add additional query parameters to the request |
None
|
extra_body
|
Body | None
|
Add additional JSON properties to the request |
None
|
timeout
|
float | Timeout | None | NotGiven
|
Override the client-level default timeout for this request, in seconds |
NOT_GIVEN
|
AsyncThreadsWithRawResponse
AsyncThreadsWithRawResponse(threads: AsyncThreads)
AsyncThreadsWithStreamingResponse
AsyncThreadsWithStreamingResponse(threads: AsyncThreads)
Messages
Messages(client: OpenAI)
Methods:
Name | Description |
---|---|
create |
Create a message. |
files |
|
list |
Returns a list of messages for a given thread. |
retrieve |
Retrieve a message. |
update |
Modifies a message. |
with_raw_response |
|
with_streaming_response |
|
create
create(
thread_id: str,
*,
content: str,
role: Literal["user"],
file_ids: List[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> Message
Create a message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content
|
str
|
The content of the message. |
required |
role
|
Literal['user']
|
The role of the entity that is creating the message. Currently only |
required |
file_ids
|
List[str] | NotGiven
|
A list of File IDs that
the message should use. There can be a maximum of 10 files attached to a
message. Useful for tools like |
NOT_GIVEN
|
metadata
|
Optional[object] | NotGiven
|
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. |
NOT_GIVEN
|
extra_headers
|
Headers | None
|
Send extra headers |
None
|
extra_query
|
Query | None
|
Add additional query parameters to the request |
None
|
extra_body
|
Body | None
|
Add additional JSON properties to the request |
None
|
timeout
|
float | Timeout | None | NotGiven
|
Override the client-level default timeout for this request, in seconds |
NOT_GIVEN
|
list
list(
thread_id: str,
*,
after: str | NotGiven = NOT_GIVEN,
before: str | NotGiven = NOT_GIVEN,
limit: int | NotGiven = NOT_GIVEN,
order: Literal["asc", "desc"] | NotGiven = NOT_GIVEN,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> SyncCursorPage[Message]
Returns a list of messages for a given thread.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
after
|
str | NotGiven
|
A cursor for use in pagination. |
NOT_GIVEN
|
before
|
str | NotGiven
|
A cursor for use in pagination. |
NOT_GIVEN
|
limit
|
int | NotGiven
|
A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. |
NOT_GIVEN
|
order
|
Literal['asc', 'desc'] | NotGiven
|
Sort order by the |
NOT_GIVEN
|
extra_headers
|
Headers | None
|
Send extra headers |
None
|
extra_query
|
Query | None
|
Add additional query parameters to the request |
None
|
extra_body
|
Body | None
|
Add additional JSON properties to the request |
None
|
timeout
|
float | Timeout | None | NotGiven
|
Override the client-level default timeout for this request, in seconds |
NOT_GIVEN
|
retrieve
retrieve(
message_id: str,
*,
thread_id: str,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> Message
Retrieve a message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
extra_headers
|
Headers | None
|
Send extra headers |
None
|
extra_query
|
Query | None
|
Add additional query parameters to the request |
None
|
extra_body
|
Body | None
|
Add additional JSON properties to the request |
None
|
timeout
|
float | Timeout | None | NotGiven
|
Override the client-level default timeout for this request, in seconds |
NOT_GIVEN
|
update
update(
message_id: str,
*,
thread_id: str,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> Message
Modifies a message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
metadata
|
Optional[object] | NotGiven
|
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. |
NOT_GIVEN
|
extra_headers
|
Headers | None
|
Send extra headers |
None
|
extra_query
|
Query | None
|
Add additional query parameters to the request |
None
|
extra_body
|
Body | None
|
Add additional JSON properties to the request |
None
|
timeout
|
float | Timeout | None | NotGiven
|
Override the client-level default timeout for this request, in seconds |
NOT_GIVEN
|
MessagesWithRawResponse
MessagesWithRawResponse(messages: Messages)
MessagesWithStreamingResponse
MessagesWithStreamingResponse(messages: Messages)
Runs
Runs(client: OpenAI)
Methods:
Name | Description |
---|---|
cancel |
Cancels a run that is |
create |
|
create_and_stream |
Create a Run stream |
list |
Returns a list of runs belonging to a thread. |
retrieve |
Retrieves a run. |
steps |
|
submit_tool_outputs |
|
submit_tool_outputs_stream |
Submit the tool outputs from a previous run and stream the run to a terminal |
update |
Modifies a run. |
with_raw_response |
|
with_streaming_response |
|
cancel
cancel(
run_id: str,
*,
thread_id: str,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> Run
Cancels a run that is in_progress
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
extra_headers
|
Headers | None
|
Send extra headers |
None
|
extra_query
|
Query | None
|
Add additional query parameters to the request |
None
|
extra_body
|
Body | None
|
Add additional JSON properties to the request |
None
|
timeout
|
float | Timeout | None | NotGiven
|
Override the client-level default timeout for this request, in seconds |
NOT_GIVEN
|
create
create(
thread_id: str,
*,
assistant_id: str,
additional_instructions: (
Optional[str] | NotGiven
) = NOT_GIVEN,
instructions: Optional[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
model: Optional[str] | NotGiven = NOT_GIVEN,
stream: Optional[Literal[False]] | NotGiven = NOT_GIVEN,
tools: (
Optional[Iterable[AssistantToolParam]] | NotGiven
) = NOT_GIVEN,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> Run
create(
thread_id: str,
*,
assistant_id: str,
stream: Literal[True],
additional_instructions: (
Optional[str] | NotGiven
) = NOT_GIVEN,
instructions: Optional[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
model: Optional[str] | NotGiven = NOT_GIVEN,
tools: (
Optional[Iterable[AssistantToolParam]] | NotGiven
) = NOT_GIVEN,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> Stream[AssistantStreamEvent]
create(
thread_id: str,
*,
assistant_id: str,
stream: bool,
additional_instructions: (
Optional[str] | NotGiven
) = NOT_GIVEN,
instructions: Optional[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
model: Optional[str] | NotGiven = NOT_GIVEN,
tools: (
Optional[Iterable[AssistantToolParam]] | NotGiven
) = NOT_GIVEN,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> Run | Stream[AssistantStreamEvent]
create(
thread_id: str,
*,
assistant_id: str,
additional_instructions: (
Optional[str] | NotGiven
) = NOT_GIVEN,
instructions: Optional[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
model: Optional[str] | NotGiven = NOT_GIVEN,
stream: (
Optional[Literal[False]] | Literal[True] | NotGiven
) = NOT_GIVEN,
tools: (
Optional[Iterable[AssistantToolParam]] | NotGiven
) = NOT_GIVEN,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> Run | Stream[AssistantStreamEvent]
create_and_stream
create_and_stream(
*,
assistant_id: str,
additional_instructions: (
Optional[str] | NotGiven
) = NOT_GIVEN,
instructions: Optional[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
model: Optional[str] | NotGiven = NOT_GIVEN,
tools: (
Optional[Iterable[AssistantToolParam]] | NotGiven
) = NOT_GIVEN,
thread_id: str,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> AssistantStreamManager[AssistantEventHandler]
create_and_stream(
*,
assistant_id: str,
additional_instructions: (
Optional[str] | NotGiven
) = NOT_GIVEN,
instructions: Optional[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
model: Optional[str] | NotGiven = NOT_GIVEN,
tools: (
Optional[Iterable[AssistantToolParam]] | NotGiven
) = NOT_GIVEN,
thread_id: str,
event_handler: AssistantEventHandlerT,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> AssistantStreamManager[AssistantEventHandlerT]
create_and_stream(
*,
assistant_id: str,
additional_instructions: (
Optional[str] | NotGiven
) = NOT_GIVEN,
instructions: Optional[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
model: Optional[str] | NotGiven = NOT_GIVEN,
tools: (
Optional[Iterable[AssistantToolParam]] | NotGiven
) = NOT_GIVEN,
thread_id: str,
event_handler: AssistantEventHandlerT | None = None,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> (
AssistantStreamManager[AssistantEventHandler]
| AssistantStreamManager[AssistantEventHandlerT]
)
Create a Run stream
list
list(
thread_id: str,
*,
after: str | NotGiven = NOT_GIVEN,
before: str | NotGiven = NOT_GIVEN,
limit: int | NotGiven = NOT_GIVEN,
order: Literal["asc", "desc"] | NotGiven = NOT_GIVEN,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> SyncCursorPage[Run]
Returns a list of runs belonging to a thread.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
after
|
str | NotGiven
|
A cursor for use in pagination. |
NOT_GIVEN
|
before
|
str | NotGiven
|
A cursor for use in pagination. |
NOT_GIVEN
|
limit
|
int | NotGiven
|
A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. |
NOT_GIVEN
|
order
|
Literal['asc', 'desc'] | NotGiven
|
Sort order by the |
NOT_GIVEN
|
extra_headers
|
Headers | None
|
Send extra headers |
None
|
extra_query
|
Query | None
|
Add additional query parameters to the request |
None
|
extra_body
|
Body | None
|
Add additional JSON properties to the request |
None
|
timeout
|
float | Timeout | None | NotGiven
|
Override the client-level default timeout for this request, in seconds |
NOT_GIVEN
|
retrieve
retrieve(
run_id: str,
*,
thread_id: str,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> Run
Retrieves a run.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
extra_headers
|
Headers | None
|
Send extra headers |
None
|
extra_query
|
Query | None
|
Add additional query parameters to the request |
None
|
extra_body
|
Body | None
|
Add additional JSON properties to the request |
None
|
timeout
|
float | Timeout | None | NotGiven
|
Override the client-level default timeout for this request, in seconds |
NOT_GIVEN
|
submit_tool_outputs
submit_tool_outputs(
run_id: str,
*,
thread_id: str,
tool_outputs: Iterable[ToolOutput],
stream: Optional[Literal[False]] | NotGiven = NOT_GIVEN,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> Run
submit_tool_outputs(
run_id: str,
*,
thread_id: str,
stream: Literal[True],
tool_outputs: Iterable[ToolOutput],
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> Stream[AssistantStreamEvent]
submit_tool_outputs(
run_id: str,
*,
thread_id: str,
stream: bool,
tool_outputs: Iterable[ToolOutput],
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> Run | Stream[AssistantStreamEvent]
submit_tool_outputs(
run_id: str,
*,
thread_id: str,
tool_outputs: Iterable[ToolOutput],
stream: (
Optional[Literal[False]] | Literal[True] | NotGiven
) = NOT_GIVEN,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> Run | Stream[AssistantStreamEvent]
submit_tool_outputs_stream
submit_tool_outputs_stream(
*,
tool_outputs: Iterable[ToolOutput],
run_id: str,
thread_id: str,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> AssistantStreamManager[AssistantEventHandler]
submit_tool_outputs_stream(
*,
tool_outputs: Iterable[ToolOutput],
run_id: str,
thread_id: str,
event_handler: AssistantEventHandlerT,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> AssistantStreamManager[AssistantEventHandlerT]
submit_tool_outputs_stream(
*,
tool_outputs: Iterable[ToolOutput],
run_id: str,
thread_id: str,
event_handler: AssistantEventHandlerT | None = None,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> (
AssistantStreamManager[AssistantEventHandler]
| AssistantStreamManager[AssistantEventHandlerT]
)
Submit the tool outputs from a previous run and stream the run to a terminal state.
update
update(
run_id: str,
*,
thread_id: str,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> Run
Modifies a run.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
metadata
|
Optional[object] | NotGiven
|
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. |
NOT_GIVEN
|
extra_headers
|
Headers | None
|
Send extra headers |
None
|
extra_query
|
Query | None
|
Add additional query parameters to the request |
None
|
extra_body
|
Body | None
|
Add additional JSON properties to the request |
None
|
timeout
|
float | Timeout | None | NotGiven
|
Override the client-level default timeout for this request, in seconds |
NOT_GIVEN
|
RunsWithRawResponse
RunsWithRawResponse(runs: Runs)
RunsWithStreamingResponse
RunsWithStreamingResponse(runs: Runs)
Threads
Threads(client: OpenAI)
Methods:
Name | Description |
---|---|
create |
Create a thread. |
create_and_run |
|
create_and_run_stream |
Create a thread and stream the run back |
delete |
Delete a thread. |
messages |
|
retrieve |
Retrieves a thread. |
runs |
|
update |
Modifies a thread. |
with_raw_response |
|
with_streaming_response |
|
create
create(
*,
messages: Iterable[Message] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> Thread
Create a thread.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
messages
|
Iterable[Message] | NotGiven
|
A list of messages to start the thread with. |
NOT_GIVEN
|
metadata
|
Optional[object] | NotGiven
|
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. |
NOT_GIVEN
|
extra_headers
|
Headers | None
|
Send extra headers |
None
|
extra_query
|
Query | None
|
Add additional query parameters to the request |
None
|
extra_body
|
Body | None
|
Add additional JSON properties to the request |
None
|
timeout
|
float | Timeout | None | NotGiven
|
Override the client-level default timeout for this request, in seconds |
NOT_GIVEN
|
create_and_run
create_and_run(
*,
assistant_id: str,
instructions: Optional[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
model: Optional[str] | NotGiven = NOT_GIVEN,
stream: Optional[Literal[False]] | NotGiven = NOT_GIVEN,
thread: Thread | NotGiven = NOT_GIVEN,
tools: Optional[Iterable[Tool]] | NotGiven = NOT_GIVEN,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> Run
create_and_run(
*,
assistant_id: str,
stream: Literal[True],
instructions: Optional[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
model: Optional[str] | NotGiven = NOT_GIVEN,
thread: Thread | NotGiven = NOT_GIVEN,
tools: Optional[Iterable[Tool]] | NotGiven = NOT_GIVEN,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> Stream[AssistantStreamEvent]
create_and_run(
*,
assistant_id: str,
stream: bool,
instructions: Optional[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
model: Optional[str] | NotGiven = NOT_GIVEN,
thread: Thread | NotGiven = NOT_GIVEN,
tools: Optional[Iterable[Tool]] | NotGiven = NOT_GIVEN,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> Run | Stream[AssistantStreamEvent]
create_and_run(
*,
assistant_id: str,
instructions: Optional[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
model: Optional[str] | NotGiven = NOT_GIVEN,
stream: (
Optional[Literal[False]] | Literal[True] | NotGiven
) = NOT_GIVEN,
thread: Thread | NotGiven = NOT_GIVEN,
tools: Optional[Iterable[Tool]] | NotGiven = NOT_GIVEN,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> Run | Stream[AssistantStreamEvent]
create_and_run_stream
create_and_run_stream(
*,
assistant_id: str,
instructions: Optional[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
model: Optional[str] | NotGiven = NOT_GIVEN,
thread: Thread | NotGiven = NOT_GIVEN,
tools: Optional[Iterable[Tool]] | NotGiven = NOT_GIVEN,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> AssistantStreamManager[AssistantEventHandler]
create_and_run_stream(
*,
assistant_id: str,
instructions: Optional[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
model: Optional[str] | NotGiven = NOT_GIVEN,
thread: Thread | NotGiven = NOT_GIVEN,
tools: Optional[Iterable[Tool]] | NotGiven = NOT_GIVEN,
event_handler: AssistantEventHandlerT,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> AssistantStreamManager[AssistantEventHandlerT]
create_and_run_stream(
*,
assistant_id: str,
instructions: Optional[str] | NotGiven = NOT_GIVEN,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
model: Optional[str] | NotGiven = NOT_GIVEN,
thread: Thread | NotGiven = NOT_GIVEN,
tools: Optional[Iterable[Tool]] | NotGiven = NOT_GIVEN,
event_handler: AssistantEventHandlerT | None = None,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> (
AssistantStreamManager[AssistantEventHandler]
| AssistantStreamManager[AssistantEventHandlerT]
)
Create a thread and stream the run back
delete
delete(
thread_id: str,
*,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> ThreadDeleted
Delete a thread.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
extra_headers
|
Headers | None
|
Send extra headers |
None
|
extra_query
|
Query | None
|
Add additional query parameters to the request |
None
|
extra_body
|
Body | None
|
Add additional JSON properties to the request |
None
|
timeout
|
float | Timeout | None | NotGiven
|
Override the client-level default timeout for this request, in seconds |
NOT_GIVEN
|
retrieve
retrieve(
thread_id: str,
*,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> Thread
Retrieves a thread.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
extra_headers
|
Headers | None
|
Send extra headers |
None
|
extra_query
|
Query | None
|
Add additional query parameters to the request |
None
|
extra_body
|
Body | None
|
Add additional JSON properties to the request |
None
|
timeout
|
float | Timeout | None | NotGiven
|
Override the client-level default timeout for this request, in seconds |
NOT_GIVEN
|
update
update(
thread_id: str,
*,
metadata: Optional[object] | NotGiven = NOT_GIVEN,
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> Thread
Modifies a thread.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
metadata
|
Optional[object] | NotGiven
|
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. |
NOT_GIVEN
|
extra_headers
|
Headers | None
|
Send extra headers |
None
|
extra_query
|
Query | None
|
Add additional query parameters to the request |
None
|
extra_body
|
Body | None
|
Add additional JSON properties to the request |
None
|
timeout
|
float | Timeout | None | NotGiven
|
Override the client-level default timeout for this request, in seconds |
NOT_GIVEN
|
ThreadsWithRawResponse
ThreadsWithRawResponse(threads: Threads)