What is the Agent SDK?
The Agent SDK is a client library that handles the complete lifecycle of agent-to-service authentication:- Discovery — Fetch service capabilities from
/.well-known/agentdoor.json - Registration — Register your agent’s public key and request scopes
- Challenge-Response — Prove ownership of your private key by signing a nonce
- Authentication — Receive API keys and short-lived JWT tokens
- Requests — Make authenticated API calls with automatic token refresh
- Payments — Optionally attach x402 payment headers for paid API access
Why Use AgentDoor?
No Browser Required
Agents authenticate using cryptographic keypairs. No need for headless browsers, session cookies, or OAuth redirect flows.
Service Discovery
Services advertise their capabilities, scopes, and pricing through a standard discovery document. Agents can autonomously explore new APIs.
Built-in Payments
Native x402 support lets agents pay for API access using on-chain wallets. No credit cards or manual billing.
Credential Caching
API keys and tokens are cached locally. Agents skip re-registration on subsequent connections to the same service.
Quick Example
How It Works
1. Discovery
When your agent connects to a service, the SDK fetches the discovery document from/.well-known/agentdoor.json. This document tells your agent:
- What scopes are available
- What authentication methods are supported
- Whether payments are required (and what payment networks/currencies)
- Rate limits and pricing
Example Discovery Document
2. Registration
Your agent sends its Ed25519 public key to the service’s registration endpoint. The service responds with a challenge nonce:3. Challenge-Response
Your agent signs the challenge message with its private key and sends the signature back to the verification endpoint:4. Making Requests
Once registered, your agent can make authenticated API calls. The SDK automatically:- Attaches the
Authorization: Bearer <token>header - Refreshes expired tokens using the
/agentdoor/authendpoint - Handles 401 responses by requesting a fresh token
- Optionally attaches x402 payment headers
Available SDKs
TypeScript SDK
Full-featured SDK for Node.js and Deno agents. Supports x402 payments, credential caching, and custom fetch functions.
Python SDK
Async-first Python SDK using httpx. Perfect for building LangChain agents and Python-based AI systems.
Core Concepts
Keypairs
Every agent has an Ed25519 keypair that serves as its identity. The SDK automatically generates and saves a keypair on first run:- Location:
~/.agentdoor/keys.json(configurable) - Format: JSON with base64-encoded public/secret keys
- Permissions:
0600(owner read/write only)
Credentials
After registration, the SDK caches your credentials locally:- Location:
~/.agentdoor/credentials.json(configurable) - Contents: API keys, tokens, scopes, and expiration times
- Per-service: Each service gets its own credential entry keyed by base URL
Sessions
ASession object represents an authenticated connection to a single service. Sessions provide:
- Convenient HTTP methods:
get(),post(),put(),delete(),patch() - Automatic authorization headers
- Token refresh on expiration
- x402 payment header injection
agent.connect() and can be reused for multiple requests.
Scopes
Scopes define what your agent is allowed to do. Services advertise available scopes in their discovery document. During registration, you can request specific scopes or request all available scopes. Example scopes:weather:read— Read current weather dataweather:forecast— Access forecast dataanalytics:write— Submit analytics events
Next Steps
TypeScript SDK
Installation, API reference, and advanced usage
Python SDK
Installation, API reference, and async patterns
Examples
Complete agent implementations including LangChain integration
Service Provider Docs
Learn how to make your API AgentDoor-compatible