Python SDK
Installation
Requirements
- Python 3.8 or higher
- httpx for HTTP client
- pydantic for data validation
- typing-extensions for Python < 3.11
Quick Start
Synchronous Client
Asynchronous Client
Authentication
Get your API key from your Plugged.in Profile:Core Features
Document Management
List Documents
Get Document
Search Documents
Create AI-Generated Document
Update Document
RAG Operations
Simple Query
Query with Sources
Find Relevant Documents
File Uploads
Upload Single File
Upload from Memory
Batch Upload
Async Operations
Concurrent Operations
Async RAG Queries
Async File Upload
Error Handling
The SDK provides typed exceptions for better error handling:Type Safety with Pydantic
The SDK uses Pydantic models for comprehensive type safety:Advanced Configuration
Custom HTTP Client
Retry Configuration
Logging Configuration
Environment Variables
Store your API key securely using environment variables:Rate Limiting
The SDK automatically handles rate limiting with exponential backoff:- API Endpoints: 60 requests per minute
- Document Search: 10 requests per hour for AI documents
- RAG Queries: Subject to plan limits
Testing
Unit Testing with Mock
Integration Testing
Examples
Complete working examples are available in the GitHub repository:API Reference
Client Classes
Class | Description |
---|---|
PluggedInClient | Synchronous API client |
AsyncPluggedInClient | Asynchronous API client |
Configuration Options
Parameter | Type | Default | Description |
---|---|---|---|
api_key | str | required | Your Plugged.in API key |
base_url | str | https://plugged.in | API base URL |
timeout | float | 60.0 | Request timeout in seconds |
max_retries | int | 5 | Maximum retry attempts |
debug | bool | False | Enable debug logging |
Document Methods
Method | Description |
---|---|
list(filters) | List documents with optional filters |
get(id, include_content, include_versions) | Get a specific document |
search(query, filters, limit, offset) | Search documents semantically |
create(title, content, metadata) | Create a new document |
update(id, request) | Update an existing document |
delete(id) | Delete a document |
RAG Methods
Method | Description |
---|---|
ask_question(query) | Simple RAG query |
query_with_sources(query, project_uuid) | Query with source documents |
find_relevant_documents(query, project_uuid, limit) | Find relevant documents |
check_availability() | Check RAG service availability |
get_storage_stats() | Get storage statistics |
Upload Methods
Method | Description |
---|---|
upload_file(file, metadata, on_progress) | Upload a single file |
upload_batch(files, on_progress) | Upload multiple files |
track_upload(upload_id, on_update) | Track upload processing |
Support
- PyPI Package: https://pypi.org/project/pluggedinkit/
- GitHub Issues: Report bugs and request features
- Documentation: https://docs.plugged.in
- Discord: Join our community