Skip to content

ainfera-ai/sdk-python

ainfera — Python SDK for Ainfera

PyPI version Python versions CI License: Apache 2.0

Agent-native inference routing by Ainfera. Signed AgentCards, provider-neutral routing, hash-chained AuditChains — out of the box.

Compatibility

Feature ainfera SDK openai SDK anthropic SDK
Routed inference
Streaming
Tool use
Receipt verification
Audit chain
Agent cards
Provider-neutral
Async support

API Versioning

The SDK targets Ainfera API v1. Breaking changes follow semantic versioning.

Install

pip install ainfera

Requires Python 3.10+.

Quickstart

One-shot signup provisions a Tenant + Agent + Wallet and returns a one-time API key — persist it, then build a bound client and run a signed Inference:

from ainfera import AinferaClient

# The signup endpoint is public — no API key required for this call.
result = AinferaClient().agents.signup(
    agent_handle="my-bot",
    owner_handle="your-github-login",
)
print(result.api_key)  # shown once — save it

client = AinferaClient.from_signup(result)
agent = client.agents.retrieve(result.agent_id)

response = agent.inference(
    model="claude-haiku-4-5",
    messages=[{"role": "user", "content": "Hello"}],
    max_tokens=20,
)
print(response.content)     # response.text is a deprecated 1.0.x alias
print(response.receipt_id)  # links to this call's AuditChain entry

If you already hold a key (also read from the AINFERA_API_KEY environment variable), construct the client directly and retrieve an existing Agent:

client = AinferaClient(api_key="ainfera_...")
agent = client.agents.retrieve("agent_...")

Ledger and AuditChain on Agent

Each agent exposes an append-only ledger handle backed by GET /v1/ledger/{agent_id}, and a locally-verifiable AuditChain:

entries = agent.ledger.entries(limit=20)
balance = agent.ledger.balance  # set after entries()

ok = agent.audit_chain.verify()  # walks the chain, verifies hashes offline

What is Ainfera?

The Inference of AI Agents. Ainfera Inference (the flagship product — the routing brain) picks the best model under your agent's budget and latency caps. Point at ainfera-inference and trust the researched decision. One Agent Card across all routed models. Every routing decision and inference call cryptographically audited. See ainfera.ai and the ainfera-routing decision library.

Features

  • Signed AgentCards per Agent (JWS, RFC 7515)
  • Provider-neutral routing across all routed models from many providers (Anthropic, OpenAI, Together, and more)
  • Atomic per-call settlement out of an Agent-scoped Wallet
  • Tamper-evident hash-chained AuditChain for every Agent
  • Local verification — auditors can verify a chain offline, no Ainfera trust required
  • Sync + async clients sharing one resource surface

Concepts

Compose, don't invent

This SDK is a thin wrapper around the Ainfera API. The underlying primitives align with — and link to — public standards work:

License

Apache 2.0. See LICENSE.

About

Agent-native inference routing by Ainfera. Python SDK — signed AgentCards, routed inference, audit chain.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors