Skip to main content

Python SDK for the Ainfera AI agent infrastructure platform

Project description

ainfera-sdk

PyPI Python License

Official Python SDK for the Ainfera AI agent infrastructure platform — deploy, monitor, and trust-score AI agents from any framework (LangChain, LlamaIndex, AutoGen, CrewAI, and more).

Install

pip install ainfera-sdk

Requires Python 3.10+.

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 its composite trust score
score = client.trust.get_score(agent.id)
print(f"{score.overall_score} ({score.grade})")

The SDK reads AINFERA_API_KEY from the environment if no key is passed. The 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

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)

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 a typed exception. Every SDK exception inherits from AinferaError and exposes .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

Examples

See the examples/ directory:

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

License

Apache-2.0. Copyright © Ainfera Pte. Ltd.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ainfera_sdk-0.1.0.tar.gz (18.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ainfera_sdk-0.1.0-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

Details for the file ainfera_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: ainfera_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ainfera_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 166a72848412ca3d8c39c5d2783381c796b4709650d915dc88d88de5f72a0c24
MD5 bcd6e5c6e0797ed9885b22d04ea3de49
BLAKE2b-256 0d2312e30ea4e273755f39b8e4a2c7f63869ac95cd01f00828dc6f903fafc4c6

See more details on using hashes here.

File details

Details for the file ainfera_sdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ainfera_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ainfera_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2fc12960e945e9eb3c55e9ca14fec06b06791f72cb40e40b98d799b5c5bfbd98
MD5 05734bca53e08b7ca61621ea7c682905
BLAKE2b-256 0044e548a61f1f6c49981bdbb3e04c5e97f1140a7bddbd20e3f36c6081b0df18

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page