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
  • RemoteGraph
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

OverviewClientAsyncClientRun HelpersRun TreesEvaluationSchemasUtilitiesWrappersAnonymizerTestingExpect APIMiddlewarePytest PluginDeployment SDKRemoteGraph
Language
Theme
PythonlangsmithclientClientrequest_with_retries
Method●Since v0.0

request_with_retries

Send a request with retries.

Copy
request_with_retries(
  self,
  ,
  method: Literal['GET', 'POST', 'PUT', 'PATCH', 'DELETE'],
  pathname: str,
  *,
  request_kwargs: Optional[Mapping] = None,
  stop_after_attempt: int = 1,
  retry_on: Optional[Sequence[type[BaseException]]] = None,
  to_ignore: Optional[Sequence[type[BaseException]]] = None,
  handle_response: Optional[Callable[[requests.Response, int], Any]] = None,
  _context: str = '',
  **kwargs: Any = {}
) -> requests.Response

Parameters

NameTypeDescription
method*Literal['GET', 'POST', 'PUT', 'PATCH', 'DELETE']

The HTTP request method.

pathname*str

The pathname of the request URL. Will be appended to the API URL.

request_kwargsOptional[Mapping]
Default:None

Additional request parameters.

stop_after_attemptint
Default:1

The number of attempts to make.

retry_onOptional[Sequence[type[BaseException]]]
Default:None

The exceptions to retry on.

In addition to: [LangSmithConnectionError, LangSmithAPIError].

to_ignoreOptional[Sequence[type[BaseException]]]
Default:None

The exceptions to ignore / pass on.

handle_responseOptional[Callable[[requests.Response, int], Any]]
Default:None

A function to handle the response and return whether to continue retrying.

_contextstr
Default:''

The context of the request.

**kwargsAny
Default:{}

Additional keyword arguments to pass to the request.

View source on GitHub