API Reference
Complete reference documentation for all classes, methods, and exceptions in the Claro Python SDK.BaytClient
The main client class for interacting with the Claro API.Constructor
Raises:
ValueError- If no API key is provided andBAYT_API_KEYis not setValueError- If API key format is invalid (must start withsk_)
get_prompt()
Fetch a prompt by its package name.
Returns:
Prompt- Prompt object with content and metadata
BaytValidationError- If package name format is invalidBaytAuthError- If authentication fails (401, 403)BaytNotFoundError- If prompt is not found (404)BaytRateLimitError- If rate limit is exceeded after retries (429)BaytAPIError- For other API errors
list_prompts()
List prompts accessible to the authenticated user.
Returns:
Dictionary with the following keys:
prompts(List[Prompt]) - List of Prompt objectscursor(str) - Cursor for next pagehasMore(bool) - True if more pages available
BaytValidationError- If limit is not between 1 and 100BaytAuthError- If authentication failsBaytRateLimitError- If rate limit is exceededBaytAPIError- For other API errors
download_context_file()
Download a context file and return its content as bytes.
Returns:
bytes- File content
BaytAuthError- If authentication failsBaytNotFoundError- If context item is not foundBaytValidationError- If context item is not a file typeBaytAPIError- For other API errors
get_context_download_url()
Get a signed download URL for a context file.
Returns:
Dictionary with the following keys:
url(str) - Signed download URLexpiresIn(int) - Seconds until URL expires
BaytAuthError- If authentication failsBaytNotFoundError- If context item is not foundBaytValidationError- If context item is not a file typeBaytAPIError- For other API errors
Prompt
Represents a Claro prompt with all its content and metadata.Properties
Methods
has_context()
Check if the prompt has any context items.bool- True if prompt has context items
has_system_prompt()
Check if the prompt has a system prompt.bool- True if prompt has a system prompt
has_critique_prompt()
Check if the prompt has a critique prompt.bool- True if prompt has a critique prompt
get_file_contexts()
Get only file-type context items.List[ContextItem]- List of file context items
get_url_contexts()
Get only URL-type context items.List[ContextItem]- List of URL context items
extract_variables()
Extract variables from prompt content with optional type hints.name(str) - Variable nametype(str, optional) - Variable typedescription(str, optional) - Variable description
validate_variables()
Validate provided variables against expected variables.
Returns:
Dict[str, str]- Validation errors (empty if all valid)
to_dict()
Get the full dictionary representation of the prompt.Dict[str, Any]- Dictionary representation
Dictionary-Style Access
Prompts support dictionary-style access:ContextItem
Represents a context item (file or URL) attached to a prompt.Properties
Methods
is_file()
Check if this context item is a file.bool- True if type is “file”
is_url()
Check if this context item is a URL.bool- True if type is “url”
to_dict()
Get the full dictionary representation of the context item.Dict[str, Any]- Dictionary representation
Exceptions
All exceptions inherit fromBaytAPIError.
BaytAPIError
Base exception for all SDK errors.BaytAuthError
Authentication or authorization error (HTTP 401, 403).- Invalid API key
- Expired API key
- Insufficient permissions
- Workspace access denied
BaytNotFoundError
Resource not found error (HTTP 404).- Incorrect package name
- Wrong version number
- Prompt deleted
- No access to workspace
BaytRateLimitError
Rate limit exceeded error (HTTP 429).BaytValidationError
Invalid request parameters (HTTP 400).- Invalid package name format
- Out of range parameters
- Missing required fields
Type Hints
The SDK is fully typed. Import types for type checking:Complete Example
Next Steps
Quickstart
Get started with the SDK
Working with Prompts
Learn about prompts in detail
Error Handling
Handle errors gracefully
Advanced Features
Optimize performance