Official Python SDK for Ainfera — the neutral infrastructure exchange for AI agents. Deploy, monitor, and trust-score agents from any framework (LangChain, CrewAI, OpenClaw).
Status: Alpha (v0.1.0). API surface may change before v1.0.
Ainfera ships two Python packages. Pick based on your use case:
| Package | Install | What it is |
|---|---|---|
ainfera |
pip install ainfera |
CLI — deploy, trust-score, kill-switch |
ainfera-sdk |
pip install ainfera-sdk |
This package. Typed async-capable Python client |
The CLI includes an embedded sync SDK at from ainfera.sdk import ...
— use ainfera-sdk if you want async clients and a standalone package
with no CLI dependencies.
pip install ainfera-sdkRequires Python 3.10+. Stripe Connect is a core dependency — no extra needed.
Install the extras matching your stack:
Agent frameworks
pip install "ainfera-sdk[langchain]" # LangChain + LangGraph
pip install "ainfera-sdk[crewai]" # Multi-agent crews
pip install "ainfera-sdk[openclaw]" # Ainfera-native frameworkModel providers
pip install "ainfera-sdk[anthropic]" # Claude models + MCP
pip install "ainfera-sdk[openai]" # GPT + Assistants
pip install "ainfera-sdk[huggingface]" # Open-weight models
pip install "ainfera-sdk[nvidia]" # NIM inference + guardrailsOr install everything:
pip install "ainfera-sdk[all]"from ainfera_sdk import Ainfera
client = Ainfera(api_key="ainf_sk_live_...")
# List your agents
for agent in client.agents.list():
print(agent.id, agent.name, agent.status)
# Deploy a new agent
agent = client.agents.create(
name="research-assistant",
framework="langchain",
compute_tier="standard",
)
# Fetch the composite trust score
score = client.trust.get_score(agent.id)
print(f"{score.overall_score} ({score.grade})")
# e.g. 847 (AA)The SDK reads AINFERA_API_KEY from the environment if no key is
passed. Base URL can be overridden with AINFERA_API_URL or the
base_url= constructor argument.
import asyncio
from ainfera_sdk import AsyncAinfera
async def main() -> None:
async with AsyncAinfera(api_key="ainf_sk_live_...") as client:
agents = await client.agents.list()
score = await client.trust.get_score(agents[0].id)
print(score.overall_score)
asyncio.run(main())The client exposes five sub-resources:
| Resource | What it does |
|---|---|
client.agents |
Deploy, list, update, kill, and delete agents |
client.trust |
Read trust scores, history, anomalies, and record events |
client.billing |
Inspect billing overview and metered usage |
client.execution |
Invoke agents and inspect execution runs |
client.registry |
Search the public agent registry (no auth required) |
client.agents.list(page=1, per_page=20) # list[Agent]
client.agents.get(agent_id) # Agent
client.agents.create(name=..., framework=...) # Agent
client.agents.update(agent_id, name="renamed") # Agent
client.agents.kill(agent_id) # emergency stop
client.agents.unkill(agent_id) # resume
client.agents.delete(agent_id) # permanent deleteThe Ainfera trust score is a geometric mean across five dimensions:
- Reliability — uptime, latency, error rate
- Quality — output correctness, groundedness, user feedback
- Cost-efficiency — cost per task vs. benchmark
- Security — prompt injection resistance, data-handling compliance
- Compliance — regulatory posture, audit completeness
Any single dimension at zero collapses the overall score. There is no gaming this.
client.trust.get_score(agent_id) # TrustScore
client.trust.get_history(agent_id) # list[TrustHistoryEntry]
client.trust.get_anomalies(agent_id) # list[Anomaly]
client.trust.record_event(agent_id, event_type="hallucination", data={...})
client.trust.recompute(agent_id) # TrustScore (forced recompute)
client.trust.badge_url(agent_id) # str (embed as SVG)Grade boundaries:
| Grade | Score |
|---|---|
| AAA | ≥ 900 |
| AA | ≥ 800 |
| A | ≥ 700 |
| BBB | ≥ 600 |
| BB | ≥ 500 |
| B | ≥ 400 |
| CCC | < 400 → auto-quarantine |
run = client.execution.invoke(agent_id, input={"query": "..."})
client.execution.get_run(run.id)
client.execution.list_runs(agent_id, limit=20)from ainfera_sdk import Ainfera
public = Ainfera(api_key=None) # registry endpoints are public
public.registry.search(q="research", framework="langchain")
public.registry.get(agent_id)
public.registry.stats()client.billing.overview() # BillingOverview
client.billing.usage(start="2026-04-01", end="2026-04-30")All non-2xx responses raise typed exceptions inheriting from
AinferaError, exposing .status_code, .message, and .response_body:
from ainfera_sdk import AuthError, NotFoundError, RateLimitError, ServerError
try:
client.agents.get("ag_missing")
except NotFoundError:
...
except AuthError:
...
except RateLimitError:
...
except ServerError:
...| Exception | HTTP status |
|---|---|
AuthError |
401, 403 |
ValidationError |
400, 422 |
NotFoundError |
404 |
RateLimitError |
429 |
ServerError |
5xx |
ApiError |
anything else non-2xx |
Supported now:
- LangChain
- CrewAI
- OpenClaw (Ainfera-native, Alpha Q3 2026)
Coming Q4 2026:
- AutoGen (Microsoft)
- LlamaIndex
- Google ADK
See examples/:
quickstart.py— list agents and fetch a trust scoredeploy_langchain.py— deploy a LangChain agent and invoke ittrust_monitoring.py— pull trust history and record events
git clone https://github.com/ainfera-ai/sdk-python.git
cd sdk-python
pip install -e ".[dev]"
# Tests (HTTP-mocked, no real API calls)
python -m pytest tests/ -v
# Lint + type check
ruff check ainfera_sdk/ --fix
ruff format ainfera_sdk/
mypy ainfera_sdk/ --strict- Homepage: https://ainfera.ai
- API docs: https://api.ainfera.ai/docs
- CLI: https://github.com/ainfera-ai/cli
- Issues: https://github.com/ainfera-ai/sdk-python/issues
Hizrian Raz — founder, Ainfera Pte. Ltd.
Apache 2.0 — see LICENSE. Copyright © Ainfera Pte. Ltd.