Python SDK
Learn how to use Supermemory with Python
Installation
Basic Usage
To use the SDK, you’ll need an API key from Supermemory. Learn how to get one from Getting Started.
Creating Memories
You can create new memories by providing content to the API:
Type Hints
The Python SDK provides type hints for better IDE support and code completion:
Error Handling
The SDK throws exceptions when API requests fail. You can catch and handle these exceptions to provide better error handling in your application:
Error Types
The SDK provides specific error types for different error scenarios:
BadRequestError
(400)AuthenticationError
(401)PermissionDeniedError
(403)NotFoundError
(404)UnprocessableEntityError
(422)RateLimitError
(429)InternalServerError
(500+)APIConnectionError
(network issues)APIConnectionTimeoutError
(request timeout)
Retries and Timeouts
Automatic Retries
Certain errors are automatically retried with exponential backoff:
Configuring Timeouts
Requests time out after 60 seconds by default. You can configure this timeout:
Advanced Usage
Accessing Raw Response Data
You can access the raw response data from the API:
Custom HTTP Client
You can provide a custom HTTP client for the SDK to use:
Logging
The SDK provides logging capabilities to help with debugging:
Searching Memories
Search for memories with semantic search:
Working with Tags
You can add tags to memories for better organization and filtering:
Async Support
The SDK provides async support for non-blocking operations:
API Reference
For a complete API reference, please refer to the API documentation on the Supermemory website.