Errors
The Memorer SDK raises typed exceptions for different error conditions.
Exception hierarchy
All exceptions inherit from MemorerError:
| Exception | HTTP Status | Description |
|---|---|---|
MemorerError | Any | Base exception for all SDK errors |
AuthenticationError | 401 | Invalid or missing API key |
AuthorizationError | 403 | Insufficient permissions |
NotFoundError | 404 | Resource doesn’t exist |
ValidationError | 400 | Invalid request parameters |
ConflictError | 409 | Resource conflict (e.g. duplicate) |
RateLimitError | 429 | Rate limit exceeded |
ServerError | 5xx | Server-side error |
NetworkError | — | Network connectivity issue |
StreamingError | — | Streaming response failure |
MemorerError attributes
All exceptions have these attributes:
| Attribute | Type | Description |
|---|---|---|
message | str | Human-readable error message |
status_code | int | None | HTTP status code (None for network errors) |
detail | str | None | Additional detail from the API |
response | Any | Raw response object |
RateLimitError
RateLimitError has an additional attribute:
| Attribute | Type | Description |
|---|---|---|
retry_after | int | None | Seconds to wait before retrying |
HTTP status codes
| Code | Description |
|---|---|
400 | Bad Request — Invalid parameters |
401 | Unauthorized — Invalid or missing API key |
403 | Forbidden — Insufficient permissions |
404 | Not Found — Resource doesn’t exist |
409 | Conflict — Resource already exists |
429 | Too Many Requests — Rate limit exceeded |
5xx | Server Error — Internal server error |
Error codes
| Code | HTTP Status | Description |
|---|---|---|
invalid_api_key | 401 | The API key is invalid or expired |
missing_api_key | 401 | No API key provided |
memory_not_found | 404 | The memory ID doesn’t exist |
entity_not_found | 404 | The entity ID doesn’t exist |
conversation_not_found | 404 | The conversation ID doesn’t exist |
rate_limit_exceeded | 429 | Too many requests, try again later |
content_too_large | 400 | Content exceeds maximum size |
invalid_owner_id | 400 | Owner ID format is invalid |
Rate limits
| Plan | Requests/minute | Memories/month |
|---|---|---|
| Free | 60 | 1,000 |
| Pro | 600 | 50,000 |
| Enterprise | Custom | Custom |
Handling errors in Python
from memorer import Memorer
from memorer.errors import MemorerError, RateLimitError, NotFoundError
client = Memorer(api_key="mem_sk_...")
user = client.for_user("user-123")
try:
result = user.remember("Some content")
except RateLimitError as e:
print(f"Rate limited. Retry after {e.retry_after} seconds")
except NotFoundError as e:
print(f"Not found: {e.message}")
except MemorerError as e:
print(f"API error ({e.status_code}): {e.message}")
if e.detail:
print(f" Detail: {e.detail}")Last updated on