First release with real network surface. Not published to PyPI yet —
publishing is gated on M5-S2 (t10-release-signing: SLSA L3 + sigstore +
PyPI Trusted Publishers / PEP 740).
Added
CryptoAIClient(api_key=..., base_url=..., timeout_s=...) — async client
composing 10 endpoint mixins.
ClientConfig — frozen dataclass with auth_headers() / base_headers()
helpers + redacted __repr__.
- Exception hierarchy (~12 classes):
CryptoAIError →
CryptoAIClientError / CryptoAIServerError / CryptoAITransportError,
with HTTP-status subclasses (Unauthorized, Forbidden, NotFound,
Conflict, Gone, UnprocessableEntity, TooManyRequests,
ServiceUnavailable, GatewayTimeout) + transport subclasses
(ConnectError, ClientTimeoutError, StreamError). Domain logic
branches on .code (server's type-URI slug).
- Endpoint mixins:
swap, strategies, ai, billing, risk, legal,
dsar, onboarding, public, health.
- Idempotency: auto-injects
X-Idempotency-Key: <uuid4> on mutating POSTs
(/v1/swap/execute, /v1/strategies, /v1/legal/consent,
/v1/legal/dsar/request, /v1/aa/session-keys, /v1/onboarding/age-gate).
Caller can supply a stable key via idempotency_key=.
- Retry policy: 3 retries (configurable) with full-jitter exponential
backoff; honors server-supplied
Retry-After on 429 / 503.
- SSE streaming:
client.ai.stream_chat(...) returns AsyncIterator[ChatChunk]
via httpx.AsyncClient.stream + line-buffered parse.
- Telemetry: opt-in via
[telemetry] extra + ClientConfig(telemetry_enabled=True).
Per-request OpenTelemetry span with cryptoai.endpoint,
cryptoai.request_id, http.method, http.status_code. No-op when
opentelemetry-api is not installed.
- Response models:
@dataclass(slots, frozen, kw_only) + TypedDict for
requests. Forgiving construction (unknown server fields are dropped).
- ASGI transport injection:
CryptoAIClient(..., transport=httpx.ASGITransport(app=...))
for in-process integration tests against the FastAPI app.
Tests
- 83 unit cases via
httpx.MockTransport covering config, exceptions,
internal helpers (idempotency, retry, SSE parser, telemetry), client
composition, and the swap / strategies / ai / public / legal / dsar /
onboarding mixins.
Distribution
- PyPI distribution name:
cryptoai-gateway (formerly skeleton
cryptoai-sdk).
- Python import path:
cryptoai_gateway (formerly cryptoai_sdk).
- Hatchling build;
src/cryptoai_gateway/ layout.
- Runtime deps:
httpx>=0.27,<1.0, websockets>=12,<14.
- Optional extras:
[validation] (pydantic>=2.6,<3), [telemetry]
(opentelemetry-api>=1.20), [dev] (ruff, mypy, pytest, pytest-asyncio,
pytest-httpx).
Not yet shipped (deferred to M5-S2+ or later)
- PyPI publishing pipeline (
t10-release-signing — M5-S2).
- Auto-generated Pydantic models from
docs/openapi.json (M5-S2).
- WebSocket portfolio stream (
tz10-ws-catalog — M6+).
- OAuth 2.1 client (
tz10-oauth — M6+).
cag_live_* API-key infrastructure surface (M6+).
- MT5 gateway (
tz10-mt5-gateway — M7+).