We're working on a new version of our documentation - it will be out soon! In the meantime, you can use our SDK READMEs on GitHub for usage instructions.
The RecallrAI SDK implements a comprehensive exception hierarchy to help you handle different error scenarios gracefully. All SDK exceptions inherit from the base RecallrAIError class.
Raised when there’s an issue with your API key or project ID authentication.
from recallrai.exceptions import AuthenticationErrortry: client = RecallrAI(api_key="invalid_key", project_id="project-uuid") user = client.get_user("user123")except AuthenticationError as e: print(f"Authentication failed: {e}") # Prompt user to check their API credentials
Raised when the RecallrAI API returns a 5xx error code.
from recallrai.exceptions import InternalServerErrortry: user = client.create_user("user123")except InternalServerError as e: print(f"Server error: {e}") # Retry after a delay or contact support
Raised when the API rate limit has been exceeded (HTTP 429).
from recallrai.exceptions import RateLimitErrortry: users = client.list_users(limit=100)except RateLimitError as e: print(f"Rate limit exceeded: {e}") if hasattr(e, 'retry_after'): print(f"Retry after {e.retry_after} seconds") # Wait and retry
When available, the retry_after value indicates how long to wait before retrying the request.
Raised when attempting to access a user that doesn’t exist.
from recallrai.exceptions import UserNotFoundErrortry: user = client.get_user("nonexistent_user")except UserNotFoundError as e: print(f"User not found: {e}") # Create the user or handle gracefully
Occurs when creating a user with an ID that already exists.
from recallrai.exceptions import UserAlreadyExistsErrortry: user = client.create_user("user123")except UserAlreadyExistsError as e: print(f"User already exists: {e}") # Get the existing user instead user = client.get_user("user123")
Raised when filtering user memories by categories that don’t exist in the project.
from recallrai.exceptions import InvalidCategoriesErrortry: user = client.get_user("user123") memories = user.list_memories(categories=["invalid_category"])except InvalidCategoriesError as e: print(f"Invalid categories: {e.invalid_categories}") # Use valid categories from your project
The exception contains the list of invalid categories in the invalid_categories attribute.
Raised when attempting to access a non-existent session.
from recallrai.exceptions import SessionNotFoundErrortry: user = client.get_user("user123") session = user.get_session("nonexistent_session")except SessionNotFoundError as e: print(f"Session not found: {e}") # Create a new session
Occurs when performing an operation that’s not valid for the current session state.
from recallrai.exceptions import InvalidSessionStateErrorfrom recallrai.models import MessageRoletry: user = client.get_user("user123") session = user.get_session("session-uuid") # Trying to add a message to a processed session session.add_message(role=MessageRole.USER, content="Hello")except InvalidSessionStateError as e: print(f"Invalid session state: {e}") # Create a new session for new messages
You cannot add messages to a session that has already been processed.
Raised when attempting to access a merge conflict that doesn’t exist.
from recallrai.exceptions import MergeConflictNotFoundErrortry: user = client.get_user("user123") conflict = user.get_merge_conflict("nonexistent_conflict")except MergeConflictNotFoundError as e: print(f"Merge conflict not found: {e}")
Occurs when trying to resolve a merge conflict that has already been processed.
from recallrai.exceptions import MergeConflictAlreadyResolvedErrortry: conflict.resolve(answers)except MergeConflictAlreadyResolvedError as e: print(f"Conflict already resolved: {e}") # Refresh to get latest status conflict.refresh()
Raised when the provided questions don’t match the original clarifying questions.
from recallrai.exceptions import MergeConflictInvalidQuestionsErrortry: conflict.resolve(answers)except MergeConflictInvalidQuestionsError as e: print(f"Invalid questions: {e}") if e.invalid_questions: print(f"These questions are invalid: {e.invalid_questions}")
Raised when an answer is not one of the valid options for a question.
from recallrai.exceptions import MergeConflictInvalidAnswerErrortry: conflict.resolve(answers)except MergeConflictInvalidAnswerError as e: print(f"Invalid answer: {e}") if e.question and e.valid_options: print(f"Question: {e.question}") print(f"Valid options: {e.valid_options}")
Raised when provided data doesn’t meet the required format or constraints.
from recallrai.exceptions import ValidationErrortry: # Invalid parameter value context = session.get_context(min_top_k=200) # Out of rangeexcept ValidationError as e: print(f"Validation error: {e}")
Catch more specific exceptions before general ones:
from recallrai.exceptions import UserNotFoundError, RecallrAIErrortry: user = client.get_user("user123")except UserNotFoundError as e: # Handle specific case print(f"Creating new user...") user = client.create_user("user123")except RecallrAIError as e: # General fallback print(f"SDK error: {e}")