Context Files and URLs
Prompts can have attached context items - files and URLs that provide additional information when using the prompt.Understanding Context
Context items are attachments that supplement a prompt:- Files - Documents, images, data files uploaded to Claro
- URLs - Web pages or external resources
Checking for Context
Before working with context, check if it exists:File Contexts
Getting File Contexts
File Metadata
Each file context provides:Downloading Files
Download file content to memory:Getting Download URLs
For large files or delegating downloads, get a signed URL:Download URLs expire after 1 hour by default. Generate a new URL if needed.
Example: Download All Files
URL Contexts
Getting URL Contexts
URL Metadata
Each URL context provides:Working with Mixed Context
Handle both files and URLs:Type Checking
Check context item types:Complete Example
Error Handling
Handle common errors when working with context:Best Practices
Check Context Existence
Check Context Existence
Always check if context exists before accessing:
Handle Large Files Carefully
Handle Large Files Carefully
For large files, consider using download URLs instead of downloading to memory:
Sanitize Filenames
Sanitize Filenames
Sanitize filenames before saving to disk:
Process Files by Type
Process Files by Type
Filter and process files based on MIME type:
Next Steps
Variables
Extract and validate variables in prompts
Error Handling
Handle errors gracefully
Advanced Features
Performance optimization and caching
API Reference
Complete API documentation