Installation
Quick Start
Agent Class
The main entry point for the SDK. Manages discovery, registration, authentication, and requests.AgentConfig
Configuration dataclass for customizing agent behavior.Example: Basic Configuration
Example: Custom Credential Store
Methods
connect(base_url: str) -> DiscoveryDocument
Discover an AgentDoor-enabled service by fetching its discovery document from /.well-known/agentdoor.json.
Parameters:
base_url— Root URL of the service (e.g.https://api.example.com)
DiscoveryDocument
Example:
register(scopes: list[str] | None = None) -> Credential
Register the agent with the connected service using the two-step challenge-response flow.
Parameters:
scopes— List of permission scopes to request. IfNone, requests all available scopes.
Credential object containing the API key, agent ID, and granted scopes
Example:
authenticate() -> str
Obtain a short-lived bearer token for authenticated requests. The SDK automatically caches tokens and only requests new ones when the cached token expires.
Returns: A JWT bearer token string
Example:
request(method: str, path: str, **kwargs) -> httpx.Response
Make an authenticated HTTP request to the connected service. Automatically obtains or refreshes the bearer token before sending the request.
Parameters:
method— HTTP method (GET, POST, PUT, DELETE, etc.)path— Path relative to the service base URL**kwargs— Additional keyword arguments forwarded tohttpx.AsyncClient.request(e.g.json=,params=,headers=)
httpx.Response object
Example:
close()
Close the underlying HTTP client. Always call this when you’re done with the agent to clean up resources.
Example:
Properties
base_url: str | None
The base URL of the connected service, or None if not connected.
discovery: DiscoveryDocument | None
The discovery document, available after calling connect().
credential: Credential | None
The current credential, available after calling register().
is_connected: bool
Whether connect() has been called successfully.
is_registered: bool
Whether register() has completed successfully.
Data Classes
DiscoveryDocument
Represents the parsed/.well-known/agentdoor.json document.
Credential
Represents cached credentials for a service.Credential Stores
Credential stores manage persistence of agent credentials. The SDK provides two built-in implementations.InMemoryCredentialStore
Stores credentials in memory. Credentials are lost when the process exits.- Testing and development
- Ephemeral agents that don’t need persistent identity
- Serverless functions with short lifecycles
FileCredentialStore
Stores credentials in a JSON file on disk.- Long-running agents that need persistent identity
- Development workflows where you want to reuse credentials across runs
- Multi-service agents that connect to many APIs
Custom Credential Store
Implement theCredentialStore protocol to create your own storage backend:
Cryptography Functions
Low-level functions for Ed25519 keypair management and signing.generate_keypair() -> tuple[str, str]
Generate a fresh Ed25519 keypair.
Returns: A tuple of (public_key, secret_key) in base64 format
sign_message(message: str, secret_key: str) -> str
Sign a message with an Ed25519 secret key.
Returns: A base64-encoded signature
verify_signature(message: str, signature: str, public_key: str) -> bool
Verify an Ed25519 signature.
Returns: True if the signature is valid, False otherwise
Discovery Functions
discover(base_url: str, client: httpx.AsyncClient | None = None) -> DiscoveryDocument
Fetch and parse the AgentDoor discovery document from a service.
Error Handling
The Python SDK raises standard Python exceptions and httpx errors.RuntimeError
Raised when methods are called in the wrong order:httpx.HTTPStatusError
Raised when the service returns an error status code:Complete Example
LangChain Integration
The Python SDK works seamlessly with LangChain for building agentic AI systems:Next Steps
TypeScript SDK
Build agents in Node.js with TypeScript support
Examples
See complete agent implementations and integration patterns