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
| Name | Type | Default | Description |
|---|---|---|---|
api_key | str | None | None | API key. If not provided, reads from BAYT_API_KEY environment variable |
base_url | str | "https://api.baytos.ai" | Base URL for the API |
max_retries | int | 3 | Maximum number of retry attempts for rate-limited requests |
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.| Name | Type | Description |
|---|---|---|
package_name | str | Package identifier (e.g., "@workspace/my-prompt:v1") |
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.| Name | Type | Default | Description |
|---|---|---|---|
limit | int | 20 | Maximum number of prompts to return (1-100) |
cursor | str | None | None | Pagination cursor from previous response |
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.| Name | Type | Description |
|---|---|---|
context_id | str | Context item ID from prompt.context |
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.| Name | Type | Description |
|---|---|---|
context_id | str | Context item ID from prompt.context |
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
| Property | Type | Description |
|---|---|---|
id | str | Unique prompt identifier |
title | str | Human-readable title |
description | str | None | Optional description |
generator | str | Main prompt content |
content | str | Alias for generator |
system | str | System prompt (may be empty) |
critique | str | Critique prompt (may be empty) |
namespace | str | Workspace slug |
slug | str | Prompt slug |
version | str | Version string (e.g., “v1”) |
package_name | str | Full package name |
is_draft | bool | True if version is v0 |
category | str | Prompt category |
context | List[ContextItem] | Attached context items |
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.| Name | Type | Description |
|---|---|---|
provided_variables | Dict[str, Any] | Variable names and values |
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
| Property | Type | Description |
|---|---|---|
id | str | Unique context item identifier |
type | "file" | "url" | Context item type |
label | str | None | Optional label |
created_at | int | None | Unix timestamp when created |
file_name | str | None | File name (files only) |
file_size | int | None | File size in bytes (files only) |
mime_type | str | None | MIME type (files only) |
url | str | None | URL (URLs only) |
url_fetched_at | int | None | Unix timestamp when URL was fetched (URLs only) |
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