1# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
  2
  3from __future__ import annotations
  4
  5import time
  6import typing_extensions
  7from typing import Mapping, cast
  8from typing_extensions import Literal
  9
 10import httpx
 11
 12from .. import _legacy_response
 13from ..types import FilePurpose, file_list_params, file_create_params
 14from .._types import Body, Omit, Query, Headers, NotGiven, FileTypes, omit, not_given
 15from .._utils import extract_files, maybe_transform, deepcopy_minimal, async_maybe_transform
 16from .._compat import cached_property
 17from .._resource import SyncAPIResource, AsyncAPIResource
 18from .._response import (
 19    StreamedBinaryAPIResponse,
 20    AsyncStreamedBinaryAPIResponse,
 21    to_streamed_response_wrapper,
 22    async_to_streamed_response_wrapper,
 23    to_custom_streamed_response_wrapper,
 24    async_to_custom_streamed_response_wrapper,
 25)
 26from ..pagination import SyncCursorPage, AsyncCursorPage
 27from .._base_client import AsyncPaginator, make_request_options
 28from ..types.file_object import FileObject
 29from ..types.file_deleted import FileDeleted
 30from ..types.file_purpose import FilePurpose
 31
 32__all__ = ["Files", "AsyncFiles"]
 33
 34
 35class Files(SyncAPIResource):
 36    @cached_property
 37    def with_raw_response(self) -> FilesWithRawResponse:
 38        """
 39        This property can be used as a prefix for any HTTP method call to return
 40        the raw response object instead of the parsed content.
 41
 42        For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
 43        """
 44        return FilesWithRawResponse(self)
 45
 46    @cached_property
 47    def with_streaming_response(self) -> FilesWithStreamingResponse:
 48        """
 49        An alternative to `.with_raw_response` that doesn't eagerly read the response body.
 50
 51        For more information, see https://www.github.com/openai/openai-python#with_streaming_response
 52        """
 53        return FilesWithStreamingResponse(self)
 54
 55    def create(
 56        self,
 57        *,
 58        file: FileTypes,
 59        purpose: FilePurpose,
 60        expires_after: file_create_params.ExpiresAfter | Omit = omit,
 61        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
 62        # The extra values given here take precedence over values defined on the client or passed to this method.
 63        extra_headers: Headers | None = None,
 64        extra_query: Query | None = None,
 65        extra_body: Body | None = None,
 66        timeout: float | httpx.Timeout | None | NotGiven = not_given,
 67    ) -> FileObject:
 68        """Upload a file that can be used across various endpoints.
 69
 70        Individual files can be
 71        up to 512 MB, and the size of all files uploaded by one organization can be up
 72        to 1 TB.
 73
 74        - The Assistants API supports files up to 2 million tokens and of specific file
 75          types. See the
 76          [Assistants Tools guide](https://platform.openai.com/docs/assistants/tools)
 77          for details.
 78        - The Fine-tuning API only supports `.jsonl` files. The input also has certain
 79          required formats for fine-tuning
 80          [chat](https://platform.openai.com/docs/api-reference/fine-tuning/chat-input)
 81          or
 82          [completions](https://platform.openai.com/docs/api-reference/fine-tuning/completions-input)
 83          models.
 84        - The Batch API only supports `.jsonl` files up to 200 MB in size. The input
 85          also has a specific required
 86          [format](https://platform.openai.com/docs/api-reference/batch/request-input).
 87
 88        Please [contact us](https://help.openai.com/) if you need to increase these
 89        storage limits.
 90
 91        Args:
 92          file: The File object (not file name) to be uploaded.
 93
 94          purpose: The intended purpose of the uploaded file. One of: - `assistants`: Used in the
 95              Assistants API - `batch`: Used in the Batch API - `fine-tune`: Used for
 96              fine-tuning - `vision`: Images used for vision fine-tuning - `user_data`:
 97              Flexible file type for any purpose - `evals`: Used for eval data sets
 98
 99          expires_after: The expiration policy for a file. By default, files with `purpose=batch` expire
100              after 30 days and all other files are persisted until they are manually deleted.
101
102          extra_headers: Send extra headers
103
104          extra_query: Add additional query parameters to the request
105
106          extra_body: Add additional JSON properties to the request
107
108          timeout: Override the client-level default timeout for this request, in seconds
109        """
110        body = deepcopy_minimal(
111            {
112                "file": file,
113                "purpose": purpose,
114                "expires_after": expires_after,
115            }
116        )
117        files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
118        # It should be noted that the actual Content-Type header that will be
119        # sent to the server will contain a `boundary` parameter, e.g.
120        # multipart/form-data; boundary=---abc--
121        extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
122        return self._post(
123            "/files",
124            body=maybe_transform(body, file_create_params.FileCreateParams),
125            files=files,
126            options=make_request_options(
127                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
128            ),
129            cast_to=FileObject,
130        )
131
132    def retrieve(
133        self,
134        file_id: str,
135        *,
136        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
137        # The extra values given here take precedence over values defined on the client or passed to this method.
138        extra_headers: Headers | None = None,
139        extra_query: Query | None = None,
140        extra_body: Body | None = None,
141        timeout: float | httpx.Timeout | None | NotGiven = not_given,
142    ) -> FileObject:
143        """
144        Returns information about a specific file.
145
146        Args:
147          extra_headers: Send extra headers
148
149          extra_query: Add additional query parameters to the request
150
151          extra_body: Add additional JSON properties to the request
152
153          timeout: Override the client-level default timeout for this request, in seconds
154        """
155        if not file_id:
156            raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}")
157        return self._get(
158            f"/files/{file_id}",
159            options=make_request_options(
160                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
161            ),
162            cast_to=FileObject,
163        )
164
165    def list(
166        self,
167        *,
168        after: str | Omit = omit,
169        limit: int | Omit = omit,
170        order: Literal["asc", "desc"] | Omit = omit,
171        purpose: str | Omit = omit,
172        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
173        # The extra values given here take precedence over values defined on the client or passed to this method.
174        extra_headers: Headers | None = None,
175        extra_query: Query | None = None,
176        extra_body: Body | None = None,
177        timeout: float | httpx.Timeout | None | NotGiven = not_given,
178    ) -> SyncCursorPage[FileObject]:
179        """Returns a list of files.
180
181        Args:
182          after: A cursor for use in pagination.
183
184        `after` is an object ID that defines your place
185              in the list. For instance, if you make a list request and receive 100 objects,
186              ending with obj_foo, your subsequent call can include after=obj_foo in order to
187              fetch the next page of the list.
188
189          limit: A limit on the number of objects to be returned. Limit can range between 1 and
190              10,000, and the default is 10,000.
191
192          order: Sort order by the `created_at` timestamp of the objects. `asc` for ascending
193              order and `desc` for descending order.
194
195          purpose: Only return files with the given purpose.
196
197          extra_headers: Send extra headers
198
199          extra_query: Add additional query parameters to the request
200
201          extra_body: Add additional JSON properties to the request
202
203          timeout: Override the client-level default timeout for this request, in seconds
204        """
205        return self._get_api_list(
206            "/files",
207            page=SyncCursorPage[FileObject],
208            options=make_request_options(
209                extra_headers=extra_headers,
210                extra_query=extra_query,
211                extra_body=extra_body,
212                timeout=timeout,
213                query=maybe_transform(
214                    {
215                        "after": after,
216                        "limit": limit,
217                        "order": order,
218                        "purpose": purpose,
219                    },
220                    file_list_params.FileListParams,
221                ),
222            ),
223            model=FileObject,
224        )
225
226    def delete(
227        self,
228        file_id: str,
229        *,
230        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
231        # The extra values given here take precedence over values defined on the client or passed to this method.
232        extra_headers: Headers | None = None,
233        extra_query: Query | None = None,
234        extra_body: Body | None = None,
235        timeout: float | httpx.Timeout | None | NotGiven = not_given,
236    ) -> FileDeleted:
237        """
238        Delete a file and remove it from all vector stores.
239
240        Args:
241          extra_headers: Send extra headers
242
243          extra_query: Add additional query parameters to the request
244
245          extra_body: Add additional JSON properties to the request
246
247          timeout: Override the client-level default timeout for this request, in seconds
248        """
249        if not file_id:
250            raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}")
251        return self._delete(
252            f"/files/{file_id}",
253            options=make_request_options(
254                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
255            ),
256            cast_to=FileDeleted,
257        )
258
259    def content(
260        self,
261        file_id: str,
262        *,
263        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
264        # The extra values given here take precedence over values defined on the client or passed to this method.
265        extra_headers: Headers | None = None,
266        extra_query: Query | None = None,
267        extra_body: Body | None = None,
268        timeout: float | httpx.Timeout | None | NotGiven = not_given,
269    ) -> _legacy_response.HttpxBinaryResponseContent:
270        """
271        Returns the contents of the specified file.
272
273        Args:
274          extra_headers: Send extra headers
275
276          extra_query: Add additional query parameters to the request
277
278          extra_body: Add additional JSON properties to the request
279
280          timeout: Override the client-level default timeout for this request, in seconds
281        """
282        if not file_id:
283            raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}")
284        extra_headers = {"Accept": "application/binary", **(extra_headers or {})}
285        return self._get(
286            f"/files/{file_id}/content",
287            options=make_request_options(
288                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
289            ),
290            cast_to=_legacy_response.HttpxBinaryResponseContent,
291        )
292
293    @typing_extensions.deprecated("The `.content()` method should be used instead")
294    def retrieve_content(
295        self,
296        file_id: str,
297        *,
298        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
299        # The extra values given here take precedence over values defined on the client or passed to this method.
300        extra_headers: Headers | None = None,
301        extra_query: Query | None = None,
302        extra_body: Body | None = None,
303        timeout: float | httpx.Timeout | None | NotGiven = not_given,
304    ) -> str:
305        """
306        Returns the contents of the specified file.
307
308        Args:
309          extra_headers: Send extra headers
310
311          extra_query: Add additional query parameters to the request
312
313          extra_body: Add additional JSON properties to the request
314
315          timeout: Override the client-level default timeout for this request, in seconds
316        """
317        if not file_id:
318            raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}")
319        return self._get(
320            f"/files/{file_id}/content",
321            options=make_request_options(
322                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
323            ),
324            cast_to=str,
325        )
326
327    def wait_for_processing(
328        self,
329        id: str,
330        *,
331        poll_interval: float = 5.0,
332        max_wait_seconds: float = 30 * 60,
333    ) -> FileObject:
334        """Waits for the given file to be processed, default timeout is 30 mins."""
335        TERMINAL_STATES = {"processed", "error", "deleted"}
336
337        start = time.time()
338        file = self.retrieve(id)
339        while file.status not in TERMINAL_STATES:
340            self._sleep(poll_interval)
341
342            file = self.retrieve(id)
343            if time.time() - start > max_wait_seconds:
344                raise RuntimeError(
345                    f"Giving up on waiting for file {id} to finish processing after {max_wait_seconds} seconds."
346                )
347
348        return file
349
350
351class AsyncFiles(AsyncAPIResource):
352    @cached_property
353    def with_raw_response(self) -> AsyncFilesWithRawResponse:
354        """
355        This property can be used as a prefix for any HTTP method call to return
356        the raw response object instead of the parsed content.
357
358        For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers
359        """
360        return AsyncFilesWithRawResponse(self)
361
362    @cached_property
363    def with_streaming_response(self) -> AsyncFilesWithStreamingResponse:
364        """
365        An alternative to `.with_raw_response` that doesn't eagerly read the response body.
366
367        For more information, see https://www.github.com/openai/openai-python#with_streaming_response
368        """
369        return AsyncFilesWithStreamingResponse(self)
370
371    async def create(
372        self,
373        *,
374        file: FileTypes,
375        purpose: FilePurpose,
376        expires_after: file_create_params.ExpiresAfter | Omit = omit,
377        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
378        # The extra values given here take precedence over values defined on the client or passed to this method.
379        extra_headers: Headers | None = None,
380        extra_query: Query | None = None,
381        extra_body: Body | None = None,
382        timeout: float | httpx.Timeout | None | NotGiven = not_given,
383    ) -> FileObject:
384        """Upload a file that can be used across various endpoints.
385
386        Individual files can be
387        up to 512 MB, and the size of all files uploaded by one organization can be up
388        to 1 TB.
389
390        - The Assistants API supports files up to 2 million tokens and of specific file
391          types. See the
392          [Assistants Tools guide](https://platform.openai.com/docs/assistants/tools)
393          for details.
394        - The Fine-tuning API only supports `.jsonl` files. The input also has certain
395          required formats for fine-tuning
396          [chat](https://platform.openai.com/docs/api-reference/fine-tuning/chat-input)
397          or
398          [completions](https://platform.openai.com/docs/api-reference/fine-tuning/completions-input)
399          models.
400        - The Batch API only supports `.jsonl` files up to 200 MB in size. The input
401          also has a specific required
402          [format](https://platform.openai.com/docs/api-reference/batch/request-input).
403
404        Please [contact us](https://help.openai.com/) if you need to increase these
405        storage limits.
406
407        Args:
408          file: The File object (not file name) to be uploaded.
409
410          purpose: The intended purpose of the uploaded file. One of: - `assistants`: Used in the
411              Assistants API - `batch`: Used in the Batch API - `fine-tune`: Used for
412              fine-tuning - `vision`: Images used for vision fine-tuning - `user_data`:
413              Flexible file type for any purpose - `evals`: Used for eval data sets
414
415          expires_after: The expiration policy for a file. By default, files with `purpose=batch` expire
416              after 30 days and all other files are persisted until they are manually deleted.
417
418          extra_headers: Send extra headers
419
420          extra_query: Add additional query parameters to the request
421
422          extra_body: Add additional JSON properties to the request
423
424          timeout: Override the client-level default timeout for this request, in seconds
425        """
426        body = deepcopy_minimal(
427            {
428                "file": file,
429                "purpose": purpose,
430                "expires_after": expires_after,
431            }
432        )
433        files = extract_files(cast(Mapping[str, object], body), paths=[["file"]])
434        # It should be noted that the actual Content-Type header that will be
435        # sent to the server will contain a `boundary` parameter, e.g.
436        # multipart/form-data; boundary=---abc--
437        extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
438        return await self._post(
439            "/files",
440            body=await async_maybe_transform(body, file_create_params.FileCreateParams),
441            files=files,
442            options=make_request_options(
443                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
444            ),
445            cast_to=FileObject,
446        )
447
448    async def retrieve(
449        self,
450        file_id: str,
451        *,
452        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
453        # The extra values given here take precedence over values defined on the client or passed to this method.
454        extra_headers: Headers | None = None,
455        extra_query: Query | None = None,
456        extra_body: Body | None = None,
457        timeout: float | httpx.Timeout | None | NotGiven = not_given,
458    ) -> FileObject:
459        """
460        Returns information about a specific file.
461
462        Args:
463          extra_headers: Send extra headers
464
465          extra_query: Add additional query parameters to the request
466
467          extra_body: Add additional JSON properties to the request
468
469          timeout: Override the client-level default timeout for this request, in seconds
470        """
471        if not file_id:
472            raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}")
473        return await self._get(
474            f"/files/{file_id}",
475            options=make_request_options(
476                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
477            ),
478            cast_to=FileObject,
479        )
480
481    def list(
482        self,
483        *,
484        after: str | Omit = omit,
485        limit: int | Omit = omit,
486        order: Literal["asc", "desc"] | Omit = omit,
487        purpose: str | Omit = omit,
488        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
489        # The extra values given here take precedence over values defined on the client or passed to this method.
490        extra_headers: Headers | None = None,
491        extra_query: Query | None = None,
492        extra_body: Body | None = None,
493        timeout: float | httpx.Timeout | None | NotGiven = not_given,
494    ) -> AsyncPaginator[FileObject, AsyncCursorPage[FileObject]]:
495        """Returns a list of files.
496
497        Args:
498          after: A cursor for use in pagination.
499
500        `after` is an object ID that defines your place
501              in the list. For instance, if you make a list request and receive 100 objects,
502              ending with obj_foo, your subsequent call can include after=obj_foo in order to
503              fetch the next page of the list.
504
505          limit: A limit on the number of objects to be returned. Limit can range between 1 and
506              10,000, and the default is 10,000.
507
508          order: Sort order by the `created_at` timestamp of the objects. `asc` for ascending
509              order and `desc` for descending order.
510
511          purpose: Only return files with the given purpose.
512
513          extra_headers: Send extra headers
514
515          extra_query: Add additional query parameters to the request
516
517          extra_body: Add additional JSON properties to the request
518
519          timeout: Override the client-level default timeout for this request, in seconds
520        """
521        return self._get_api_list(
522            "/files",
523            page=AsyncCursorPage[FileObject],
524            options=make_request_options(
525                extra_headers=extra_headers,
526                extra_query=extra_query,
527                extra_body=extra_body,
528                timeout=timeout,
529                query=maybe_transform(
530                    {
531                        "after": after,
532                        "limit": limit,
533                        "order": order,
534                        "purpose": purpose,
535                    },
536                    file_list_params.FileListParams,
537                ),
538            ),
539            model=FileObject,
540        )
541
542    async def delete(
543        self,
544        file_id: str,
545        *,
546        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
547        # The extra values given here take precedence over values defined on the client or passed to this method.
548        extra_headers: Headers | None = None,
549        extra_query: Query | None = None,
550        extra_body: Body | None = None,
551        timeout: float | httpx.Timeout | None | NotGiven = not_given,
552    ) -> FileDeleted:
553        """
554        Delete a file and remove it from all vector stores.
555
556        Args:
557          extra_headers: Send extra headers
558
559          extra_query: Add additional query parameters to the request
560
561          extra_body: Add additional JSON properties to the request
562
563          timeout: Override the client-level default timeout for this request, in seconds
564        """
565        if not file_id:
566            raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}")
567        return await self._delete(
568            f"/files/{file_id}",
569            options=make_request_options(
570                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
571            ),
572            cast_to=FileDeleted,
573        )
574
575    async def content(
576        self,
577        file_id: str,
578        *,
579        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
580        # The extra values given here take precedence over values defined on the client or passed to this method.
581        extra_headers: Headers | None = None,
582        extra_query: Query | None = None,
583        extra_body: Body | None = None,
584        timeout: float | httpx.Timeout | None | NotGiven = not_given,
585    ) -> _legacy_response.HttpxBinaryResponseContent:
586        """
587        Returns the contents of the specified file.
588
589        Args:
590          extra_headers: Send extra headers
591
592          extra_query: Add additional query parameters to the request
593
594          extra_body: Add additional JSON properties to the request
595
596          timeout: Override the client-level default timeout for this request, in seconds
597        """
598        if not file_id:
599            raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}")
600        extra_headers = {"Accept": "application/binary", **(extra_headers or {})}
601        return await self._get(
602            f"/files/{file_id}/content",
603            options=make_request_options(
604                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
605            ),
606            cast_to=_legacy_response.HttpxBinaryResponseContent,
607        )
608
609    @typing_extensions.deprecated("The `.content()` method should be used instead")
610    async def retrieve_content(
611        self,
612        file_id: str,
613        *,
614        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
615        # The extra values given here take precedence over values defined on the client or passed to this method.
616        extra_headers: Headers | None = None,
617        extra_query: Query | None = None,
618        extra_body: Body | None = None,
619        timeout: float | httpx.Timeout | None | NotGiven = not_given,
620    ) -> str:
621        """
622        Returns the contents of the specified file.
623
624        Args:
625          extra_headers: Send extra headers
626
627          extra_query: Add additional query parameters to the request
628
629          extra_body: Add additional JSON properties to the request
630
631          timeout: Override the client-level default timeout for this request, in seconds
632        """
633        if not file_id:
634            raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}")
635        return await self._get(
636            f"/files/{file_id}/content",
637            options=make_request_options(
638                extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
639            ),
640            cast_to=str,
641        )
642
643    async def wait_for_processing(
644        self,
645        id: str,
646        *,
647        poll_interval: float = 5.0,
648        max_wait_seconds: float = 30 * 60,
649    ) -> FileObject:
650        """Waits for the given file to be processed, default timeout is 30 mins."""
651        TERMINAL_STATES = {"processed", "error", "deleted"}
652
653        start = time.time()
654        file = await self.retrieve(id)
655        while file.status not in TERMINAL_STATES:
656            await self._sleep(poll_interval)
657
658            file = await self.retrieve(id)
659            if time.time() - start > max_wait_seconds:
660                raise RuntimeError(
661                    f"Giving up on waiting for file {id} to finish processing after {max_wait_seconds} seconds."
662                )
663
664        return file
665
666
667class FilesWithRawResponse:
668    def __init__(self, files: Files) -> None:
669        self._files = files
670
671        self.create = _legacy_response.to_raw_response_wrapper(
672            files.create,
673        )
674        self.retrieve = _legacy_response.to_raw_response_wrapper(
675            files.retrieve,
676        )
677        self.list = _legacy_response.to_raw_response_wrapper(
678            files.list,
679        )
680        self.delete = _legacy_response.to_raw_response_wrapper(
681            files.delete,
682        )
683        self.content = _legacy_response.to_raw_response_wrapper(
684            files.content,
685        )
686        self.retrieve_content = (  # pyright: ignore[reportDeprecated]
687            _legacy_response.to_raw_response_wrapper(
688                files.retrieve_content,  # pyright: ignore[reportDeprecated],
689            )
690        )
691
692
693class AsyncFilesWithRawResponse:
694    def __init__(self, files: AsyncFiles) -> None:
695        self._files = files
696
697        self.create = _legacy_response.async_to_raw_response_wrapper(
698            files.create,
699        )
700        self.retrieve = _legacy_response.async_to_raw_response_wrapper(
701            files.retrieve,
702        )
703        self.list = _legacy_response.async_to_raw_response_wrapper(
704            files.list,
705        )
706        self.delete = _legacy_response.async_to_raw_response_wrapper(
707            files.delete,
708        )
709        self.content = _legacy_response.async_to_raw_response_wrapper(
710            files.content,
711        )
712        self.retrieve_content = (  # pyright: ignore[reportDeprecated]
713            _legacy_response.async_to_raw_response_wrapper(
714                files.retrieve_content,  # pyright: ignore[reportDeprecated],
715            )
716        )
717
718
719class FilesWithStreamingResponse:
720    def __init__(self, files: Files) -> None:
721        self._files = files
722
723        self.create = to_streamed_response_wrapper(
724            files.create,
725        )
726        self.retrieve = to_streamed_response_wrapper(
727            files.retrieve,
728        )
729        self.list = to_streamed_response_wrapper(
730            files.list,
731        )
732        self.delete = to_streamed_response_wrapper(
733            files.delete,
734        )
735        self.content = to_custom_streamed_response_wrapper(
736            files.content,
737            StreamedBinaryAPIResponse,
738        )
739        self.retrieve_content = (  # pyright: ignore[reportDeprecated]
740            to_streamed_response_wrapper(
741                files.retrieve_content,  # pyright: ignore[reportDeprecated],
742            )
743        )
744
745
746class AsyncFilesWithStreamingResponse:
747    def __init__(self, files: AsyncFiles) -> None:
748        self._files = files
749
750        self.create = async_to_streamed_response_wrapper(
751            files.create,
752        )
753        self.retrieve = async_to_streamed_response_wrapper(
754            files.retrieve,
755        )
756        self.list = async_to_streamed_response_wrapper(
757            files.list,
758        )
759        self.delete = async_to_streamed_response_wrapper(
760            files.delete,
761        )
762        self.content = async_to_custom_streamed_response_wrapper(
763            files.content,
764            AsyncStreamedBinaryAPIResponse,
765        )
766        self.retrieve_content = (  # pyright: ignore[reportDeprecated]
767            async_to_streamed_response_wrapper(
768                files.retrieve_content,  # pyright: ignore[reportDeprecated],
769            )
770        )