Overview
The RecallrAI client is the entry point for all SDK operations. It manages authentication and provides methods for user management.
Initialization
from recallrai import RecallrAI
client = RecallrAI(
api_key="rai_yourapikey",
project_id="project-uuid",
base_url="https://api.recallrai.com", # optional
timeout=60, # optional
)
Methods
create_user()
Create a new user in your project.
from recallrai.exceptions import UserAlreadyExistsError
try:
user = client.create_user(
user_id="user123",
metadata={"name": "John Doe", "role": "admin"}
)
print(f"Created user: {user.user_id}")
except UserAlreadyExistsError as e:
print(f"Error: {e}")
Unique identifier for the user. Must be unique within your project.
Optional metadata to associate with the user. Can contain any JSON-serializable data.
Returns: User object
Raises: UserAlreadyExistsError if user_id already exists
get_user()
Retrieve an existing user by ID.
from recallrai.exceptions import UserNotFoundError
try:
user = client.get_user("user123")
print(f"User metadata: {user.metadata}")
except UserNotFoundError as e:
print(f"Error: {e}")
The ID of the user to retrieve.
Returns: User object
Raises: UserNotFoundError if user doesn’t exist
list_users()
List all users in your project with optional filtering and pagination.
user_list = client.list_users(
offset=0,
limit=10,
metadata_filter={"role": "admin"}
)
print(f"Total users: {user_list.total}")
print(f"Has more: {user_list.has_more}")
for user in user_list.users:
print(f"User ID: {user.user_id}")
print(f"Metadata: {user.metadata}")
Number of users to skip. Default: 0
Maximum number of users to return. Default: 10
Filter users by metadata fields. Only users matching all specified fields are returned.
Returns: UserList object with:
users: List of User objects
total: Total number of users matching the filter
has_more: Boolean indicating if more results are available
Async Client
For async applications, use AsyncRecallrAI:
from recallrai import AsyncRecallrAI
client = AsyncRecallrAI(
api_key="rai_yourapikey",
project_id="project-uuid"
)
# All methods are the same, just use await
user = await client.create_user("user123")
user = await client.get_user("user123")
user_list = await client.list_users(limit=20)