codios-sdk
Python SDK for Codios — A2A Agent Security Layer.
Installation
pip install codios-sdk
# With FastAPI middleware
pip install "codios-sdk[fastapi]"
Quick start
Verify a contract (in your agent)
import os
from codios import verify_contract
CODIOS_PUBLIC_KEY = os.environ["CODIOS_PUBLIC_KEY"]
# contract dict comes from the X-Codios-Contract header sent by the caller
result = verify_contract(contract, CODIOS_PUBLIC_KEY, requested_action="summarize")
if not result.valid:
raise PermissionError(f"Rejected: {result.reason}")
# reason: contract_expired | invalid_signature | action_not_permitted | action_forbidden
FastAPI middleware
import os
from fastapi import FastAPI, Depends
from codios.middleware.fastapi import require_contract, ContractClaims
app = FastAPI()
# Set CODIOS_PUBLIC_KEY in your environment (from Codios dashboard)
@app.post("/summarize")
async def summarize(
body: dict,
claims: ContractClaims = Depends(require_contract("summarize")),
):
# Contract is already verified at this point
print(f"Caller: {claims.issuer_did}")
return {"result": "..."}
The middleware reads X-Codios-Contract from the request header, verifies the Ed25519 signature offline (no network call), checks expiry, and validates the requested action is in allowed_actions.
Generate a keypair (for registering a new agent)
from codios import generate_keypair
kp = generate_keypair()
print(kp.did) # did:key:z6Mk...
print(kp.public_key) # base64 — register this with Codios
print(kp.private_key) # base64 — store securely, never share
How it works
- Agent A wants to call Agent B. It requests a signed contract from Codios API (
POST /contracts). - Codios signs the contract with its Ed25519 platform key and returns it.
- Agent A sends the contract in the
X-Codios-Contractheader when calling Agent B. - Agent B's SDK verifies the signature locally — zero network latency, no single point of failure.
- If valid, the call proceeds. The result is logged to the Codios audit trail.
Environment variables
| Variable | Description |
|---|---|
CODIOS_PUBLIC_KEY |
Base64 Ed25519 public key — from Codios dashboard Settings |
Metadata
Release files for codios-sdk 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| codios_sdk-0.1.0.tar.gz | 5.4 kB | Without provenance | Details for codios_sdk-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| codios_sdk-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for codios_sdk-0.1.0-py3-none-any.whl |
Total release size: 12.5 kB
Release files / codios_sdk-0.1.0.tar.gz
| Download URL | codios_sdk-0.1.0.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e3ec5091c7bc501ccce1cf9c0415f9b7f52d08485c0f1af263900f82e84d500d
|
|
BLAKE2b-256 checksum How to use checksums |
bd1015ec5d145bb21369be102d1abe824a0b6f77f608d2844e6f2afd1a86121c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / codios_sdk-0.1.0-py3-none-any.whl
| Download URL | codios_sdk-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a7fe3c677da4f798af7288fa9a537eaca1993d40e8afb054f304748f71122184
|
|
BLAKE2b-256 checksum How to use checksums |
b2c69539f24cf14c09cd18469ab782f66fb6bebaccc177ccf8c4bc39660ac115
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Security for codios-sdk 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.