LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • Client
  • AsyncClient
  • Run Helpers
  • Run Trees
  • Evaluation
  • Schemas
  • Utilities
  • Wrappers
  • Anonymizer
  • Testing
  • Expect API
  • Middleware
  • Pytest Plugin
  • Deployment SDK
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

OverviewClientAsyncClientRun HelpersRun TreesEvaluationSchemasUtilitiesWrappersAnonymizerTestingExpect APIMiddlewarePytest PluginDeployment SDK
Language
Theme
Pythonlangsmith_openapi_client_responseBinaryAPIResponse
Class●Since v0.8

BinaryAPIResponse

Copy
BinaryAPIResponse(
  self,
  *,
  raw: httpx.Response,
  cast_to: type[R],
  client: BaseClient

Bases

APIResponse[bytes]

Methods

Inherited fromAPIResponse

Methods

Mparse
—

Returns the rich python representation of this response's data.

Mread
—

Read and return the binary response content.

Mtext
—

Read and decode the response content into a string.

Mjson
View source on GitHub
[
Any
,
Any
]
,
stream
:
bool
,
stream_cls
:
type
[
Stream
[
Any
]
]
|
type
[
AsyncStream
[
Any
]
]
|
None
,
options
:
FinalRequestOptions
,
retries_taken
:
int
=
0
)
—

Read and decode the JSON response content.

Mclose
—

Close the response and release the connection.

Miter_bytes
—

A byte-iterator over the decoded response content.

Miter_text
—

A str-iterator over the decoded response content

Miter_lines
—

Like iter_text() but will only yield chunks for each line

Inherited fromBaseAPIResponse

Attributes

Ahttp_response: httpx.ResponseAretries_taken: int
—

The number of retries made. If no retries happened this will be 0

Aheaders: httpx.HeadersAhttp_request: httpx.Request
—

Returns the httpx Request instance associated with the current response.

Astatus_code: intAurl: httpx.URL
—

Returns the URL for which the request was made.

Amethod: strAhttp_version: strAelapsed: datetime.timedelta
—

The time taken for the complete request/response cycle to complete.

Ais_closed: bool
—

Whether or not the response body has been closed.

method
write_to_file

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_streaming_response.get_binary_response()

Subclass of APIResponse providing helpers for dealing with binary data.

Note: If you want to stream the response data instead of eagerly reading it all at once then you should use .with_streaming_response when making the API request, e.g. .with_streaming_response.get_binary_response()