Skip to main content

Python SDK

PyPI version Python Support License: MIT The official Python SDK for interacting with Plugged.in’s Library API. Features both synchronous and asynchronous clients with comprehensive type hints using Pydantic models.

PyPI Package

View on PyPI Registry

GitHub Repository

Source code and examples

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

Important: Direct file uploads are no longer available via the public API. The client.uploads helpers now raise descriptive errors so legacy code fails fast. Use the Plugged.in web interface or upcoming ingestion pipeline for binary assets. AI-generated documents remain available through client.documents.create and client.uploads.upload_document.

Async Operations

Concurrent Operations

Async RAG Queries

Error Handling

The SDK provides typed exceptions for better error handling:

PAP Agents

The SDK provides full support for managing PAP (Plugged.in Agent Protocol) agents:

Creating Agents

Listing and Managing Agents

Heartbeats and Metrics

CRITICAL: Heartbeats contain ONLY liveness data. Resource telemetry goes in metrics (separate channel). This separation is PAP’s zombie prevention superpower.

Async Agent Operations

Agent States

Agents follow the PAP lifecycle state machine:
See PAP Agents Documentation for complete details on the Plugged.in Agent Protocol.

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

Configuration Options

Document Methods

RAG Methods

Upload Methods

Upload helpers now raise descriptive errors because binary ingestion is no longer available via the public API.

Clipboard Methods

Clipboard (Memory) Service

The Clipboard service provides persistent key-value storage for MCP tools and AI agents. Both sync and async clients are supported.

Named Access (Sync)

Named Access (Async)

Indexed (Stack) Access

List All Entries

Pydantic Models

Support