LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
    • Overview
    • Caches
    • Callbacks
    • Documents
    • Document loaders
    • Embeddings
    • Exceptions
    • Language models
    • Serialization
    • Output parsers
    • Prompts
    • Rate limiters
    • Retrievers
    • Runnables
    • Utilities
    • Vector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    OverviewCachesCallbacksDocumentsDocument loadersEmbeddingsExceptionsLanguage modelsSerializationOutput parsersPromptsRate limitersRetrieversRunnablesUtilitiesVector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    Language
    Theme
    Pythonlangchain-corerate_limitersBaseRateLimiter
    Class●Since v0.2

    BaseRateLimiter

    Base class for rate limiters.

    Usage of the base limiter is through the acquire and aacquire methods depending on whether running in a sync or async context.

    Implementations are free to add a timeout parameter to their initialize method to allow users to specify a timeout for acquiring the necessary tokens when using a blocking call.

    Current limitations:

    • Rate limiting information is not surfaced in tracing or callbacks. This means that the total time it takes to invoke a chat model will encompass both the time spent waiting for tokens and the time spent making the request.
    Copy
    BaseRateLimiter()

    Bases

    abc.ABC

    Methods

    method
    acquire

    Attempt to acquire the necessary tokens for the rate limiter.

    This method blocks until the required tokens are available if blocking is set to True.

    If blocking is set to False, the method will immediately return the result of the attempt to acquire the tokens.

    method
    aacquire

    Attempt to acquire the necessary tokens for the rate limiter.

    This method blocks until the required tokens are available if blocking is set to True.

    If blocking is set to False, the method will immediately return the result of the attempt to acquire the tokens.

    View source on GitHub