aion.api connects Python agents and tools to Aion platform APIs. It owns HTTP
authentication, typed GraphQL access, model-service configuration, and the
capability addressing models the MCP helpers are built on.
Use it directly when you need to construct Aion API clients, build capability
URLs, or pass typed capability references into framework-specific helpers.
Install
aion.api comes with the base install:
Authentication
The client reads Aion API credentials from environment variables:
Set them and authentication is handled for you: the client acquires and
refreshes its own access token, and the rest of the SDK —
aion.mcp and the
two authoring toolkits — authenticates through the same credentials. Values are
read from the process environment or from a .env file in the project root.
Control-plane addressing
The control-plane models describe how to address Aion capabilities without hard-coding URL strings. The core shape is:CapabilityReference.global_mcp() addresses the metatools server. Called with
no key, it selects AION_METATOOLS_MCP_CAPABILITY_KEY
(mcp.aion.metatools), so both forms above resolve to the same path.
Capability subjects
Capability kinds and keys
CapabilityKind identifies the protocol surface. HTTP-addressable values include
CapabilityKind.MCP_SERVER and CapabilityKind.A2A_ENDPOINT.
CapabilityKey identifies either:
- the primary capability of that kind for the addressed subject
- one concrete capability key declared by the behavior
capabilities segment under it:
key selects the primary capability. global_mcp() is the one
reference with a concrete default: the metatools key.
Runtime capability references
RuntimeCapabilityReference is a template for resolving a reference after an
AionRuntimeContext exists. It does not read from thread-local or ambient state. The framework
adapter must pass the current request context explicitly, or extract it from the framework’s
per-request context object.
CapabilitySubjectSource.INCOMING_DISTRIBUTION means the distribution from the current incoming
request’s Aion Distribution extension payload. It is request-scoped, not a global default.
Principal selectors
PrincipalSelector is request metadata used to tell Aion which runtime principal the call is being
made as. It is not a credential by itself; the API still validates the bearer token and the selected
principal.
For behavior-originated calls back to the control plane, such as MCP or A2A access,
AionRuntimeContext.get_principal_selector() derives this metadata from the active request. It
prefers the environment’s daemon identity when available and falls back to the environment id. Omitting
the selector can make the request look like the broader authenticated subject, which may be denied even
when the runtime daemon or environment would be allowed.
AionModelPrincipalError.
The MCP helpers derive the selector from AionRuntimeContext.get_principal_selector() when no
explicit selector is supplied.