Basic Weather Agent
A simple agent that connects to a weather API, makes authenticated requests, and handles multiple services.- Persistent keypairs — The agent’s identity is stored in
agent-keys.jsonand reused across runs - Automatic discovery — The SDK fetches service capabilities from
/.well-known/agentdoor.json - Credential caching — After the first registration, subsequent runs skip the registration flow
- Session-based requests — The
Sessionobject handles authorization headers and token refresh
Multi-Service Agent
Connect to multiple AgentDoor-enabled services with a single agent identity.- Each service gets its own credentials (different
agent_id,api_key,token) - The agent’s Ed25519 keypair is shared across all services
- Credentials are cached separately per service base URL
Paid Requests with x402
Make paid API requests using on-chain wallets.Connect to Service
The service’s discovery document includes payment information (networks, currencies, facilitator)
Service Validates Payment
The service checks the payment header, verifies the wallet signature, and deducts USDC
X-PAYMENT header.
LangChain Integration
Wrap AgentDoor sessions as LangChain tools so LLM agents can autonomously discover and call external APIs.- Tool Wrapping — Each AgentDoor session method becomes a LangChain
DynamicStructuredTool - Schema Validation — Zod schemas ensure the LLM provides valid parameters
- Error Handling — Tools return error messages as JSON so the LLM can retry or inform the user
- Multi-Step Reasoning — The LLM agent decides which tools to call and in what order
Ephemeral Agent
Create a temporary agent that doesn’t cache credentials or persist its keypair.- Testing and development
- Serverless functions with short lifecycles
- One-off scripts that don’t need persistent identity
- CI/CD pipelines
Error Handling
Handle common error scenarios gracefully.- TypeScript
- Python
| Code | Description | Handling |
|---|---|---|
NO_MATCHING_SCOPES | Requested scopes not available | Request different scopes or check discovery doc |
RATE_LIMITED | Too many requests (HTTP 429) | Implement exponential backoff |
CHALLENGE_EXPIRED | Challenge nonce expired (HTTP 410) | Restart registration flow |
ALREADY_REGISTERED | Agent already registered (HTTP 409) | Use cached credentials or clear cache |
TIMEOUT | Request timed out | Increase timeoutMs or retry |
NETWORK_ERROR | Network failure | Check connectivity and retry |
Custom Fetch Function
Inject a custom fetch implementation for logging, retries, or testing.- Request/response logging
- Custom retry logic
- Proxying requests through a VPN or corporate proxy
- Testing with mock responses
Credential Management
Manually inspect and clear cached credentials.Next Steps
TypeScript SDK Reference
Complete API documentation for the TypeScript SDK
Python SDK Reference
Complete API documentation for the Python SDK
Service Provider Guide
Learn how to make your API AgentDoor-compatible
x402 Payments
Deep dive into paid API access with x402