MCPcopy Create free account
hub / github.com/anomalyco/opencode-sdk-python / write_to_file

Method write_to_file

src/opencode_ai/_response.py:482–496  ·  view source on GitHub ↗

Write the output to the given file. Accepts a filename or any path-like object, e.g. pathlib.Path Note: if you want to stream the data to the file instead of writing all at once then you should use `.with_streaming_response` when making the API request, e.g. `.with_

(
        self,
        file: str | os.PathLike[str],
    )

Source from the content-addressed store, hash-verified

480 """
481
482 def write_to_file(
483 self,
484 file: str | os.PathLike[str],
485 ) -> None:
486 """Write the output to the given file.
487
488 Accepts a filename or any path-like object, e.g. pathlib.Path
489
490 Note: if you want to stream the data to the file instead of writing
491 all at once then you should use `.with_streaming_response` when making
492 the API request, e.g. `.with_streaming_response.get_binary_response()`
493 """
494 with open(file, mode="wb") as f:
495 for data in self.iter_bytes():
496 f.write(data)
497
498
499class AsyncBinaryAPIResponse(AsyncAPIResponse[bytes]):

Callers

nothing calls this directly

Calls 1

iter_bytesMethod · 0.45

Tested by

no test coverage detected