Skip to content

files

Classes:

Name Description
AsyncFiles
AsyncFilesWithRawResponse
AsyncFilesWithStreamingResponse
Files
FilesWithRawResponse
FilesWithStreamingResponse

AsyncFiles

AsyncFiles(client: AsyncOpenAI)

Methods:

Name Description
create

Create an assistant file by attaching a

delete

Delete an assistant file.

list

Returns a list of assistant files.

retrieve

Retrieves an AssistantFile.

with_raw_response
with_streaming_response

create async

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

Create an assistant file by attaching a File to an assistant.

Parameters:

Name Type Description Default
file_id str

A File ID (with purpose="assistants") that the assistant should use. Useful for tools like retrieval and code_interpreter that can access files.

required
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(
    file_id: str,
    *,
    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
) -> FileDeleteResponse

Delete an assistant 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

list

list(
    assistant_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[
    AssistantFile, AsyncCursorPage[AssistantFile]
]

Returns a list of assistant files.

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(
    file_id: str,
    *,
    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
) -> AssistantFile

Retrieves an AssistantFile.

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
create
delete
list
retrieve

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)

AsyncFilesWithStreamingResponse

AsyncFilesWithStreamingResponse(files: AsyncFiles)

Attributes:

Name Type Description
create
delete
list
retrieve

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)

Files

Files(client: OpenAI)

Methods:

Name Description
create

Create an assistant file by attaching a

delete

Delete an assistant file.

list

Returns a list of assistant files.

retrieve

Retrieves an AssistantFile.

with_raw_response
with_streaming_response

create

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

Create an assistant file by attaching a File to an assistant.

Parameters:

Name Type Description Default
file_id str

A File ID (with purpose="assistants") that the assistant should use. Useful for tools like retrieval and code_interpreter that can access files.

required
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(
    file_id: str,
    *,
    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
) -> FileDeleteResponse

Delete an assistant 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

list

list(
    assistant_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[AssistantFile]

Returns a list of assistant files.

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(
    file_id: str,
    *,
    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
) -> AssistantFile

Retrieves an AssistantFile.

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
create
delete
list
retrieve

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)

FilesWithStreamingResponse

FilesWithStreamingResponse(files: Files)

Attributes:

Name Type Description
create
delete
list
retrieve

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)