Skip to content

Index

Modules:

Name Description
files
messages

Classes:

Name Description
AsyncFiles
AsyncFilesWithRawResponse
AsyncFilesWithStreamingResponse
AsyncMessages
AsyncMessagesWithRawResponse
AsyncMessagesWithStreamingResponse
Files
FilesWithRawResponse
FilesWithStreamingResponse
Messages
MessagesWithRawResponse
MessagesWithStreamingResponse

AsyncFiles

AsyncFiles(client: AsyncOpenAI)

Methods:

Name Description
list

Returns a list of message files.

retrieve

Retrieves a message file.

with_raw_response
with_streaming_response

list

list(
    message_id: str,
    *,
    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[
    MessageFile, AsyncCursorPage[MessageFile]
]

Returns a list of message files.

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(
    file_id: str,
    *,
    thread_id: str,
    message_id: str,
    extra_headers: Headers | None = None,
    extra_query: Query | None = None,
    extra_body: Body | None = None,
    timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> MessageFile

Retrieves a message file.

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

with_raw_response

with_raw_response() -> AsyncFilesWithRawResponse

with_streaming_response

with_streaming_response() -> (
    AsyncFilesWithStreamingResponse
)

AsyncFilesWithRawResponse

AsyncFilesWithRawResponse(files: AsyncFiles)

Attributes:

Name Type Description
list
retrieve

list instance-attribute

list = async_to_raw_response_wrapper(list)

retrieve instance-attribute

retrieve = async_to_raw_response_wrapper(retrieve)

AsyncFilesWithStreamingResponse

AsyncFilesWithStreamingResponse(files: AsyncFiles)

Attributes:

Name Type Description
list
retrieve

list instance-attribute

list = async_to_streamed_response_wrapper(list)

retrieve instance-attribute

retrieve = async_to_streamed_response_wrapper(retrieve)

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 user is supported.

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 retrieval and code_interpreter that can access and use files.

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

files

files() -> AsyncFiles

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

NOT_GIVEN
before str | NotGiven

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.

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 created_at timestamp of the objects. asc for ascending order and desc for descending order.

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

with_raw_response

with_raw_response() -> AsyncMessagesWithRawResponse

with_streaming_response

with_streaming_response() -> (
    AsyncMessagesWithStreamingResponse
)

AsyncMessagesWithRawResponse

AsyncMessagesWithRawResponse(messages: AsyncMessages)

Methods:

Name Description
files

Attributes:

Name Type Description
create
list
retrieve
update

create instance-attribute

create = async_to_raw_response_wrapper(create)

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

AsyncMessagesWithStreamingResponse

AsyncMessagesWithStreamingResponse(messages: AsyncMessages)

Methods:

Name Description
files

Attributes:

Name Type Description
create
list
retrieve
update

create instance-attribute

create = async_to_streamed_response_wrapper(create)

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)

Files

Files(client: OpenAI)

Methods:

Name Description
list

Returns a list of message files.

retrieve

Retrieves a message file.

with_raw_response
with_streaming_response

list

list(
    message_id: str,
    *,
    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[MessageFile]

Returns a list of message files.

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(
    file_id: str,
    *,
    thread_id: str,
    message_id: str,
    extra_headers: Headers | None = None,
    extra_query: Query | None = None,
    extra_body: Body | None = None,
    timeout: float | Timeout | None | NotGiven = NOT_GIVEN
) -> MessageFile

Retrieves a message file.

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

with_raw_response

with_raw_response() -> FilesWithRawResponse

with_streaming_response

with_streaming_response() -> FilesWithStreamingResponse

FilesWithRawResponse

FilesWithRawResponse(files: Files)

Attributes:

Name Type Description
list
retrieve

list instance-attribute

list = to_raw_response_wrapper(list)

retrieve instance-attribute

retrieve = to_raw_response_wrapper(retrieve)

FilesWithStreamingResponse

FilesWithStreamingResponse(files: Files)

Attributes:

Name Type Description
list
retrieve

list instance-attribute

list = to_streamed_response_wrapper(list)

retrieve instance-attribute

retrieve = to_streamed_response_wrapper(retrieve)

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 user is supported.

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 retrieval and code_interpreter that can access and use files.

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

files

files() -> Files

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

NOT_GIVEN
before str | NotGiven

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.

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 created_at timestamp of the objects. asc for ascending order and desc for descending order.

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

with_raw_response

with_raw_response() -> MessagesWithRawResponse

with_streaming_response

with_streaming_response() -> MessagesWithStreamingResponse

MessagesWithRawResponse

MessagesWithRawResponse(messages: Messages)

Methods:

Name Description
files

Attributes:

Name Type Description
create
list
retrieve
update

create instance-attribute

create = to_raw_response_wrapper(create)

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

MessagesWithStreamingResponse

MessagesWithStreamingResponse(messages: Messages)

Methods:

Name Description
files

Attributes:

Name Type Description
create
list
retrieve
update

create instance-attribute

create = to_streamed_response_wrapper(create)

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