Official SDK for Agent Clear — the AI agent service marketplace
Project description
agentclear
Official SDK for Agent Clear — the AI agent service marketplace.
Agent Clear lets AI agents discover and pay for API services. This SDK provides:
- Provider middleware — protect your API with the 402 viral loop so agents can discover and pay for your service
- Consumer client — discover and call services through the Agent Clear metered proxy
Installation
pip install agentclear
Quick Start: Consumer (AI Agent)
Async
from agentclear import AgentClearClient
client = AgentClearClient(api_key="axk_your_key_here")
# Discover services by natural language query
result = await client.discover("sentiment analysis")
for svc in result.services:
print(f"{svc.name} — ${svc.price_per_call}/call")
# Call a service through the metered proxy
response = await client.call(
result.services[0].id,
{"text": "I love this product!"},
)
print(response.data)
Sync
from agentclear import AgentClearClient
client = AgentClearClient(api_key="axk_your_key_here")
result = client.discover_sync("sentiment analysis")
response = client.call_sync(result.services[0].id, {"text": "I love this product!"})
print(response.data)
Quick Start: Provider (402 Middleware)
FastAPI Decorator
from fastapi import FastAPI, Request
from agentclear import require_payment
app = FastAPI()
@app.post("/analyze")
@require_payment(service_id="my-sentiment-api", price=0.005)
async def analyze(request: Request):
body = await request.json()
return {"sentiment": "positive", "score": 0.95}
ASGI Middleware (all routes)
from fastapi import FastAPI
from agentclear import AgentClearMiddleware
app = FastAPI()
app.add_middleware(
AgentClearMiddleware,
service_id="my-sentiment-api",
price=0.005,
)
@app.post("/analyze")
async def analyze(request: Request):
body = await request.json()
return {"sentiment": "positive", "score": 0.95}
When an agent calls your API without a valid key, they receive:
{
"error": "Payment Required",
"message": "This API requires $0.005/call via Agent Clear.",
"signup_url": "https://agentclear.dev/signup",
"docs_url": "https://agentclear.dev/docs",
"service_id": "my-sentiment-api",
"price_per_call": 0.005,
"platform": "agentclear"
}
API Reference
AgentClearClient
AgentClearClient(
api_key: str, # Required — your axk_ API key
base_url: str = "https://agentclear.dev",
framework_ref: str | None = None, # Optional rev-share tracking
)
await client.discover(query, limit=10) / client.discover_sync(...)
Search for services by natural language.
| Parameter | Type | Default | Description |
|---|---|---|---|
query |
str |
— | Semantic search query |
limit |
int |
10 |
Max results |
Returns DiscoverResponse.
await client.call(service_id, payload, timeout=30.0) / client.call_sync(...)
Call a service through the metered proxy.
| Parameter | Type | Default | Description |
|---|---|---|---|
service_id |
str |
— | Service to call |
payload |
dict |
— | JSON body to forward |
timeout |
float |
30.0 |
Timeout in seconds |
Returns ServiceResponse.
await client.services(...) / client.services_sync(...)
List available services with optional filtering.
| Parameter | Type | Default | Description |
|---|---|---|---|
limit |
int | None |
None |
Max results |
offset |
int | None |
None |
Pagination offset |
protocol |
str | None |
None |
Filter by protocol |
Returns ServicesResponse.
require_payment(service_id, price, platform_url=...)
Decorator for FastAPI/Starlette endpoints. Returns 402 for unauthenticated requests.
AgentClearMiddleware
ASGI middleware class. Protects all routes with 402 payment required.
Documentation
Full documentation at https://agentclear.dev/docs.
License
MIT — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agentclear-0.1.0.tar.gz.
File metadata
- Download URL: agentclear-0.1.0.tar.gz
- Upload date:
- Size: 10.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f948958cfa3f80496a6abad2e98f0db8c13dc92158051bfb2eaefd373c90504
|
|
| MD5 |
527477e5396ddffd36c03bf5e57953d3
|
|
| BLAKE2b-256 |
6fd339f309d9bbc4dffe6240848d61b2569254f3c67a9aa5d1274ba5ab2eb1f4
|
File details
Details for the file agentclear-0.1.0-py3-none-any.whl.
File metadata
- Download URL: agentclear-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c93e12781a6a072a49d9f262c8b67eca6209bc36f882af535c83c768152d977d
|
|
| MD5 |
e6f6813cfe4e75151e61473b1aadab93
|
|
| BLAKE2b-256 |
4e746818f052371f3a44c5aebdf95034a5777d101e0f018122d0a3f5992857ea
|