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_responseAsyncAPIResponseparse
Method●Since v0.8

parse

Copy
parse(
    self,
    *,
    to: type[_T] | None = None,
) -> R | _T
View source on GitHub

We support parsing:

  • BaseModel
  • dict
  • list
  • Union
  • str
  • httpx.Response

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)