Python SDK — cryptoai-gateway

Async client (httpx) targeting Python 3.11+. Currently at version 0.2.0 (M5-S2 release with opt-in OpenTelemetry exporters).

Install

pip install cryptoai-gateway

# Optional extras
pip install 'cryptoai-gateway[validation]'         # pydantic models
pip install 'cryptoai-gateway[telemetry-exporters]' # OTel SDK + OTLP/HTTP

Quickstart

import asyncio
from cryptoai_gateway import CryptoAIClient, ClientConfig

async def main():
    config = ClientConfig(
        api_key="cag_live_...",
        base_url="https://api.cryptoai.gateway",
    )
    async with CryptoAIClient(config=config) as client:
        quote = await client.swap.quote(
            token_in="USDC",
            token_out="ETH",
            amount=1000,
            chain="ethereum",
        )
        print(quote.amount_out, quote.fee_usd)

asyncio.run(main())

Endpoint mixins

Error handling

All HTTP errors raise typed exceptions inheriting from CryptoAIError. Branch on .code (server's type-URI slug) for domain logic; retries on 429 / 503 are honored automatically per Retry-After.

Opt-in telemetry (M5-S2)

from cryptoai_gateway import configure_console_exporter, CryptoAIClient, ClientConfig

configure_console_exporter()
async with CryptoAIClient(
    config=ClientConfig(api_key="...", telemetry_enabled=True)
) as client:
    await client.public.stats()  # emits an OTel span to stdout

Next steps