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_responseAPIResponse
Class●Since v0.8

APIResponse

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

Bases

BaseAPIResponse[R]

Methods

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
View source on GitHub
[
Any
,
Any
]
,
stream
:
bool
,
stream_cls
:
type
[
Stream
[
Any
]
]
|
type
[
AsyncStream
[
Any
]
]
|
None
,
options
:
FinalRequestOptions
,
retries_taken
:
int
=
0
)
: httpx.Request
—

Returns the httpx Request instance associated with the current response.

Astatus_code: int
Aurl: httpx.URL
—

Returns the URL for which the request was made.

Amethod: str
Ahttp_version: str
Aelapsed: 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
parse
method
read
method
text
method
json
method
close
method
iter_bytes
method
iter_text
method
iter_lines

Read and return the binary response content.

Read and decode the response content into a string.

Read and decode the JSON response content.

Close the response and release the connection.

Automatically called if the response body is read to completion.

A byte-iterator over the decoded response content.

This automatically handles gzip, deflate and brotli encoded responses.

A str-iterator over the decoded response content that handles both gzip, deflate, etc but also detects the content's string encoding.

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

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

For lower-level control, see .read(), .json(), .iter_bytes().

You can customise the type that the response is parsed into through the to argument, e.g.

from langsmith_api import BaseModel

class MyModel(BaseModel):
    foo: str

obj = response.parse(to=MyModel)
print(obj.foo)