Python SDK
Overview
The Brevo Python SDK (brevo-python) is a fully typed client library for the Brevo API. It provides:
- A unified
Brevoclient with namespaced service clients - Native async support via
AsyncBrevo - Pydantic-based typed models with full type annotations
- Automatic retries with exponential backoff
- Raw response access with headers and status codes
- Custom
httpxclient support for proxies and mTLS
Version 4.0 is a full rewrite and is not backwards compatible with the v1.x SDK. The legacy v1.x SDK (brevo-python < 4.0) will continue to receive critical security updates but no new features. We recommend migrating to v4.x for new and existing projects.
Requirements
- Python 3.8+
httpx>= 0.21.2pydantic>= 1.9.2typing_extensions>= 4.0.0
Installation
Quick start
Initialize the client and send your first email:
Configuration
Pass keyword arguments to the constructor to configure the client:
Constructor parameters
Async client
Use AsyncBrevo for non-blocking calls. Pass httpx.AsyncClient instead of httpx.Client when providing a custom HTTP client:
Error handling
The SDK raises ApiError (or a typed subclass) for non-2xx HTTP responses:
Error classes
All ApiError instances expose:
status_code— HTTP status codebody— Parsed response bodyheaders— Response headers
Retries
Automatic retries with exponential backoff are enabled by default (2 retries). Configure at the client or request level:
Retry behavior
- Retryable status codes:
408,429,5xx - Backoff: Exponential with jitter
- Disable: Set
max_retries: 0inrequest_options
Timeouts
Default timeout is 60 seconds. Configure at the client or request level:
Recommended timeout values
Request options
All service methods accept a request_options dict as the final keyword argument:
Raw response access
Access response headers and status code via .with_raw_response:
Custom HTTP client
Override the default httpx client for proxies, custom transports, or mTLS:
Common integrations
Async with custom client
Custom timeout and transport
With event hooks
Available services
The Brevo and AsyncBrevo clients expose the following service namespaces: