Skip to content

ainfera-ai/sdk-python

ainfera-sdk

PyPI Python License

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.

Two packages

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.

Install

pip install ainfera-sdk

Requires Python 3.10+. Stripe Connect is a core dependency — no extra needed.

Framework extras (optional)

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 framework

Model 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 + guardrails

Or install everything:

pip install "ainfera-sdk[all]"

Quickstart

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.

Async

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())

Resources

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)

Agents

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 delete

Trust

The 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

Execution

run = client.execution.invoke(agent_id, input={"query": "..."})
client.execution.get_run(run.id)
client.execution.list_runs(agent_id, limit=20)

Registry (no auth required)

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()

Billing

client.billing.overview()                              # BillingOverview
client.billing.usage(start="2026-04-01", end="2026-04-30")

Error handling

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

Frameworks

Supported now:

  • LangChain
  • CrewAI
  • OpenClaw (Ainfera-native, Alpha Q3 2026)

Coming Q4 2026:

  • AutoGen (Microsoft)
  • LlamaIndex
  • Google ADK

Examples

See examples/:

Development

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

Links

Maintainer

Hizrian Raz — founder, Ainfera Pte. Ltd.

License

Apache 2.0 — see LICENSE. Copyright © Ainfera Pte. Ltd.

About

Official Python SDK for Ainfera. Trust scores, agent discovery, embeddable badges. Powered by NVIDIA NIM and NeMo Guardrails.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages