Skip to content

openai.resources.beta

The beta modules provides a unified interface for accessing beta features of the API, encapsulating synchronous and asynchronous access to resources in beta.

The module aggregates the beta functionalities related to features like yet considered generally available (GA), offering a simplified entry point for interacting with these resources. It is designed to facilitate easy access to the cutting-edge features still under development, enabling developers to experiment with and leverage new capabilities before they become GA.

Modules:

Name Description
assistants
beta

The beta modules provides a unified interface for accessing beta features of the API, encapsulating synchronous and asynchronous access to resources in beta.

The module aggregates the beta functionalities related to features like yet considered generally available (GA), offering a simplified entry point for interacting with these resources. It is designed to facilitate easy access to the cutting-edge features still under development, enabling developers to experiment with and leverage new capabilities before they become GA.

threads

Classes:

Name Description
Assistants
AssistantsWithRawResponse
AssistantsWithStreamingResponse
AsyncAssistants
AsyncAssistantsWithRawResponse
AsyncAssistantsWithStreamingResponse
AsyncBeta
AsyncBetaWithRawResponse
AsyncBetaWithStreamingResponse
AsyncThreads
AsyncThreadsWithRawResponse
AsyncThreadsWithStreamingResponse
Beta
BetaWithRawResponse
BetaWithStreamingResponse
Threads
ThreadsWithRawResponse
ThreadsWithStreamingResponse

Assistants

Assistants(client: OpenAI)

Methods:

Name Description
create

Create an assistant with a model and instructions.

delete

Delete an assistant.

files
list

Returns a list of assistants.

retrieve

Retrieves an assistant.

update

Modifies an assistant.

with_raw_response
with_streaming_response

create

create(
    *,
    model: str,
    description: Optional[str] | NotGiven = NOT_GIVEN,
    file_ids: List[str] | NotGiven = NOT_GIVEN,
    instructions: Optional[str] | NotGiven = NOT_GIVEN,
    metadata: Optional[object] | NotGiven = NOT_GIVEN,
    name: Optional[str] | NotGiven = NOT_GIVEN,
    tools: (
        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
) -> Assistant

Create an assistant with a model and instructions.

Parameters:

Name Type Description Default
model str

ID of the model to use. You can use the List models API to see all of your available models, or see our Model overview for descriptions of them.

required
description Optional[str] | NotGiven

The description of the assistant. The maximum length is 512 characters.

NOT_GIVEN
file_ids List[str] | NotGiven

A list of file IDs attached to this assistant. There can be a maximum of 20 files attached to the assistant. Files are ordered by their creation date in ascending order.

NOT_GIVEN
instructions Optional[str] | NotGiven

The system instructions that the assistant uses. The maximum length is 32768 characters.

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
name Optional[str] | NotGiven

The name of the assistant. The maximum length is 256 characters.

NOT_GIVEN
tools Iterable[AssistantToolParam] | NotGiven

A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types code_interpreter, retrieval, or function.

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

delete

delete(
    assistant_id: str,
    *,
    extra_headers: Headers | None = None,
    extra_query: Query | None = None,
    extra_body: Body | None = None,
    timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> AssistantDeleted

Delete an assistant.

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

files

files() -> Files

list

list(
    *,
    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[Assistant]

Returns a list of assistants.

Parameters:

Name Type Description Default
after str | NotGiven

A cursor for use in pagination.

NOT_GIVEN

after 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 after=obj_foo in order to fetch the next page of the list.

before: A 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.

limit: A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.

order: Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request

extra_body: Add additional JSON properties to the request

timeout: Override the client-level default timeout for this request, in seconds

retrieve

retrieve(
    assistant_id: str,
    *,
    extra_headers: Headers | None = None,
    extra_query: Query | None = None,
    extra_body: Body | None = None,
    timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> Assistant

Retrieves an assistant.

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(
    assistant_id: str,
    *,
    description: Optional[str] | NotGiven = NOT_GIVEN,
    file_ids: List[str] | NotGiven = NOT_GIVEN,
    instructions: Optional[str] | NotGiven = NOT_GIVEN,
    metadata: Optional[object] | NotGiven = NOT_GIVEN,
    model: str | NotGiven = NOT_GIVEN,
    name: Optional[str] | NotGiven = NOT_GIVEN,
    tools: (
        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
) -> Assistant

Modifies an assistant.

Parameters:

Name Type Description Default
description Optional[str] | NotGiven

The description of the assistant.

NOT_GIVEN

The maximum length is 512 characters.

file_ids: A list of File IDs attached to this assistant. There can be a maximum of 20 files attached to the assistant. Files are ordered by their creation date in ascending order. If a file was previously attached to the list but does not show up in the list, it will be deleted from the assistant.

instructions: The system instructions that the assistant uses. The maximum length is 32768 characters.

metadata: 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.

model: ID of the model to use. You can use the List models API to see all of your available models, or see our Model overview for descriptions of them.

name: The name of the assistant. The maximum length is 256 characters.

tools: A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types code_interpreter, retrieval, or function.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request

extra_body: Add additional JSON properties to the request

timeout: Override the client-level default timeout for this request, in seconds

with_raw_response

with_raw_response() -> AssistantsWithRawResponse

with_streaming_response

with_streaming_response() -> (
    AssistantsWithStreamingResponse
)

AssistantsWithRawResponse

AssistantsWithRawResponse(assistants: Assistants)

Methods:

Name Description
files

Attributes:

Name Type Description
create
delete
list
retrieve
update

create instance-attribute

create = to_raw_response_wrapper(create)

delete instance-attribute

delete = to_raw_response_wrapper(delete)

list instance-attribute

list = to_raw_response_wrapper(list)

retrieve instance-attribute

retrieve = to_raw_response_wrapper(retrieve)

update instance-attribute

update = to_raw_response_wrapper(update)

files

AssistantsWithStreamingResponse

AssistantsWithStreamingResponse(assistants: Assistants)

Methods:

Name Description
files

Attributes:

Name Type Description
create
delete
list
retrieve
update

create instance-attribute

create = to_streamed_response_wrapper(create)

delete instance-attribute

delete = to_streamed_response_wrapper(delete)

list instance-attribute

list = to_streamed_response_wrapper(list)

retrieve instance-attribute

retrieve = to_streamed_response_wrapper(retrieve)

update instance-attribute

update = to_streamed_response_wrapper(update)

files

AsyncAssistants

AsyncAssistants(client: AsyncOpenAI)

Methods:

Name Description
create

Create an assistant with a model and instructions.

delete

Delete an assistant.

files
list

Returns a list of assistants.

retrieve

Retrieves an assistant.

update

Modifies an assistant.

with_raw_response
with_streaming_response

create async

create(
    *,
    model: str,
    description: Optional[str] | NotGiven = NOT_GIVEN,
    file_ids: List[str] | NotGiven = NOT_GIVEN,
    instructions: Optional[str] | NotGiven = NOT_GIVEN,
    metadata: Optional[object] | NotGiven = NOT_GIVEN,
    name: Optional[str] | NotGiven = NOT_GIVEN,
    tools: (
        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
) -> Assistant

Create an assistant with a model and instructions.

Parameters:

Name Type Description Default
model str

ID of the model to use. You can use the List models API to see all of your available models, or see our Model overview for descriptions of them.

required
description Optional[str] | NotGiven

The description of the assistant. The maximum length is 512 characters.

NOT_GIVEN
file_ids List[str] | NotGiven

A list of file IDs attached to this assistant. There can be a maximum of 20 files attached to the assistant. Files are ordered by their creation date in ascending order.

NOT_GIVEN
instructions Optional[str] | NotGiven

The system instructions that the assistant uses. The maximum length is 32768 characters.

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
name Optional[str] | NotGiven

The name of the assistant. The maximum length is 256 characters.

NOT_GIVEN
tools Iterable[AssistantToolParam] | NotGiven

A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types code_interpreter, retrieval, or function.

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

delete async

delete(
    assistant_id: str,
    *,
    extra_headers: Headers | None = None,
    extra_query: Query | None = None,
    extra_body: Body | None = None,
    timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> AssistantDeleted

Delete an assistant.

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

files

files() -> AsyncFiles

list

list(
    *,
    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[Assistant, AsyncCursorPage[Assistant]]

Returns a list of assistants.

Parameters:

Name Type Description Default
after str | NotGiven

A cursor for use in pagination.

NOT_GIVEN

after 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 after=obj_foo in order to fetch the next page of the list.

before: A 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.

limit: A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.

order: Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request

extra_body: Add additional JSON properties to the request

timeout: Override the client-level default timeout for this request, in seconds

retrieve async

retrieve(
    assistant_id: str,
    *,
    extra_headers: Headers | None = None,
    extra_query: Query | None = None,
    extra_body: Body | None = None,
    timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> Assistant

Retrieves an assistant.

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(
    assistant_id: str,
    *,
    description: Optional[str] | NotGiven = NOT_GIVEN,
    file_ids: List[str] | NotGiven = NOT_GIVEN,
    instructions: Optional[str] | NotGiven = NOT_GIVEN,
    metadata: Optional[object] | NotGiven = NOT_GIVEN,
    model: str | NotGiven = NOT_GIVEN,
    name: Optional[str] | NotGiven = NOT_GIVEN,
    tools: (
        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
) -> Assistant

Modifies an assistant.

Parameters:

Name Type Description Default
description Optional[str] | NotGiven

The description of the assistant.

NOT_GIVEN

The maximum length is 512 characters.

file_ids: A list of File IDs attached to this assistant. There can be a maximum of 20 files attached to the assistant. Files are ordered by their creation date in ascending order. If a file was previously attached to the list but does not show up in the list, it will be deleted from the assistant.

instructions: The system instructions that the assistant uses. The maximum length is 32768 characters.

metadata: 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.

model: ID of the model to use. You can use the List models API to see all of your available models, or see our Model overview for descriptions of them.

name: The name of the assistant. The maximum length is 256 characters.

tools: A list of tool enabled on the assistant. There can be a maximum of 128 tools per assistant. Tools can be of types code_interpreter, retrieval, or function.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request

extra_body: Add additional JSON properties to the request

timeout: Override the client-level default timeout for this request, in seconds

with_raw_response

with_raw_response() -> AsyncAssistantsWithRawResponse

with_streaming_response

with_streaming_response() -> (
    AsyncAssistantsWithStreamingResponse
)

AsyncAssistantsWithRawResponse

AsyncAssistantsWithRawResponse(assistants: AsyncAssistants)

Methods:

Name Description
files

Attributes:

Name Type Description
create
delete
list
retrieve
update

create instance-attribute

create = async_to_raw_response_wrapper(create)

delete instance-attribute

delete = async_to_raw_response_wrapper(delete)

list instance-attribute

list = async_to_raw_response_wrapper(list)

retrieve instance-attribute

retrieve = async_to_raw_response_wrapper(retrieve)

update instance-attribute

update = async_to_raw_response_wrapper(update)

files

AsyncAssistantsWithStreamingResponse

AsyncAssistantsWithStreamingResponse(
    assistants: AsyncAssistants,
)

Methods:

Name Description
files

Attributes:

Name Type Description
create
delete
list
retrieve
update

create instance-attribute

create = async_to_streamed_response_wrapper(create)

delete instance-attribute

delete = async_to_streamed_response_wrapper(delete)

list instance-attribute

list = async_to_streamed_response_wrapper(list)

retrieve instance-attribute

retrieve = async_to_streamed_response_wrapper(retrieve)

update instance-attribute

update = async_to_streamed_response_wrapper(update)

AsyncBeta

AsyncBeta(client: AsyncOpenAI)

Methods:

Name Description
assistants
threads
with_raw_response
with_streaming_response

assistants

assistants() -> AsyncAssistants

threads

threads() -> AsyncThreads

with_raw_response

with_raw_response() -> AsyncBetaWithRawResponse

with_streaming_response

with_streaming_response() -> AsyncBetaWithStreamingResponse

AsyncBetaWithRawResponse

AsyncBetaWithRawResponse(beta: AsyncBeta)

Methods:

Name Description
assistants
threads

assistants

threads

AsyncBetaWithStreamingResponse

AsyncBetaWithStreamingResponse(beta: AsyncBeta)

Methods:

Name Description
assistants
threads

assistants

threads

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

messages

messages() -> AsyncMessages

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

runs

runs() -> AsyncRuns

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

with_raw_response

with_raw_response() -> AsyncThreadsWithRawResponse

with_streaming_response

with_streaming_response() -> (
    AsyncThreadsWithStreamingResponse
)

AsyncThreadsWithRawResponse

AsyncThreadsWithRawResponse(threads: AsyncThreads)

Methods:

Name Description
messages
runs

Attributes:

Name Type Description
create
create_and_run
delete
retrieve
update

create instance-attribute

create = async_to_raw_response_wrapper(create)

create_and_run instance-attribute

create_and_run = async_to_raw_response_wrapper(
    create_and_run
)

delete instance-attribute

delete = async_to_raw_response_wrapper(delete)

retrieve instance-attribute

retrieve = async_to_raw_response_wrapper(retrieve)

update instance-attribute

update = async_to_raw_response_wrapper(update)

messages

runs

AsyncThreadsWithStreamingResponse

AsyncThreadsWithStreamingResponse(threads: AsyncThreads)

Methods:

Name Description
messages
runs

Attributes:

Name Type Description
create
create_and_run
delete
retrieve
update

create instance-attribute

create = async_to_streamed_response_wrapper(create)

create_and_run instance-attribute

create_and_run = async_to_streamed_response_wrapper(
    create_and_run
)

delete instance-attribute

delete = async_to_streamed_response_wrapper(delete)

retrieve instance-attribute

retrieve = async_to_streamed_response_wrapper(retrieve)

update instance-attribute

update = async_to_streamed_response_wrapper(update)

messages

Beta

Beta(client: OpenAI)

Methods:

Name Description
assistants
threads
with_raw_response
with_streaming_response

assistants

assistants() -> Assistants

threads

threads() -> Threads

with_raw_response

with_raw_response() -> BetaWithRawResponse

with_streaming_response

with_streaming_response() -> BetaWithStreamingResponse

BetaWithRawResponse

BetaWithRawResponse(beta: Beta)

Methods:

Name Description
assistants
threads

assistants

assistants() -> AssistantsWithRawResponse

threads

BetaWithStreamingResponse

BetaWithStreamingResponse(beta: Beta)

Methods:

Name Description
assistants
threads

assistants

threads

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

messages

messages() -> Messages

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

runs

runs() -> Runs

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

with_raw_response

with_raw_response() -> ThreadsWithRawResponse

with_streaming_response

with_streaming_response() -> ThreadsWithStreamingResponse

ThreadsWithRawResponse

ThreadsWithRawResponse(threads: Threads)

Methods:

Name Description
messages
runs

Attributes:

Name Type Description
create
create_and_run
delete
retrieve
update

create instance-attribute

create = to_raw_response_wrapper(create)

create_and_run instance-attribute

create_and_run = to_raw_response_wrapper(create_and_run)

delete instance-attribute

delete = to_raw_response_wrapper(delete)

retrieve instance-attribute

retrieve = to_raw_response_wrapper(retrieve)

update instance-attribute

update = to_raw_response_wrapper(update)

messages

runs

ThreadsWithStreamingResponse

ThreadsWithStreamingResponse(threads: Threads)

Methods:

Name Description
messages
runs

Attributes:

Name Type Description
create
create_and_run
delete
retrieve
update

create instance-attribute

create = to_streamed_response_wrapper(create)

create_and_run instance-attribute

create_and_run = to_streamed_response_wrapper(
    create_and_run
)

delete instance-attribute

delete = to_streamed_response_wrapper(delete)

retrieve instance-attribute

retrieve = to_streamed_response_wrapper(retrieve)

update instance-attribute

update = to_streamed_response_wrapper(update)

messages

runs