AI Module Technical Specifications
57 provider adapters across text / image / audio / video / 3D / embedding modalities, model registry with daily auto-refresh, automatic usage tracking with time-bucketed and per-dimension aggregation, cost estimation, token counting, and multi-modal AI operations.
System Metrics
Provider adapters
57 — one integration per provider
Built-in model definitions
100+, updated on every release
Collections
4 (providers, dashboards, usage logs, page templates)
Usage service
Time-bucketed + per-dimension aggregation, usage billing
Auto-refresh
Daily, discovers new provider models automatically
Modalities
9 buckets (text, image, audio, video, 3D, embeddings, rerank, STT, TTS)
Storage backends
S3, GCS, Azure Blob, R2, local
Architecture Overview
| Capability | What it handles |
|---|---|
| **Setup** | 57 provider registrations + auto-refresh of provider model lists |
| **Usage** | Usage aggregation (time-bucketed + per-dimension), usage billing |
| **Dashboard routes** | REST endpoints for usage/cost dashboards |
| **Voice command routes** | Voice command HTTP endpoints |
Provider Registry — Adapter Dispatch
Given a model name, the registry dispatches to the correct adapter automatically:
typescript
// "gpt-4o" → OpenAI
// "claude-sonnet-4-20250514" → Anthropic
// "gemini-2.0-flash" → Google
// "tripo3d-v2" → Tripo3D
57 registered providers, grouped by modality:
- Text / Reasoning (22): OpenAI, Anthropic, Google, Groq, DeepSeek, Mistral, Perplexity, xAI, Azure OpenAI, Together, Fireworks, OpenRouter, SambaNova, Ollama, HuggingFace, Moonshot, Cerebras, MiniMax, Blackbox, Novita, DashScope, Replicate
- Image generation: Stability, Ideogram, Recraft, OpenAI (DALL-E), Replicate, Fal
- 3D generation: Tripo3D, Meshy, Luma
- TTS: ElevenLabs, Cartesia, Kokoro, PlayHT, Speechmatics, Rev.ai, LMNT, Resemble, Rime, AssemblyAI, Pocket TTS, DashScope, Cohere, Voxtral, Supertonic, Novita
- STT: AssemblyAI, Deepgram, Gladia, Voxtral, Speechmatics, Rev.ai, Whisper (via OpenAI), Cohere, LlamaParse
- Video generation: Runway, Video Intelligence, Luma
- Embeddings / Reranking: Cohere, Cohere Rerank, Voyage, Jina, Nomic, Mixedbread
Usage Tracking & Billing
Every AI call generates a usage record with full context — provider, model, operation type, modality, token counts, cost breakdown, latency, tool-call count, streaming flag, and status.
Tracking is automatic — there's no manual logging call to make. When any AI operation completes, the platform records it to the usage log with tenant, user, provider, model, tokens, and cost.
Two aggregation views over the same usage log:
```typescript // Time-bucketed (hour / day / week / month), optionally filtered by provider or user async getAggregatedUsage( ctx: AeionContext, options: { startDate: Date; endDate: Date; period: "hour" | "day" | "week" | "month"; providerId?: string; userId?: string; }, ): Promise<AggregatedUsage[]>
// Grouped by a single dimension across the full date range async getUsageByDimension( ctx: AeionContext, options: { startDate: Date; endDate: Date; dimension: "provider" | "model" | "operationType" | "userId" | "source"; limit?: number; }, ): Promise<UsageByDimension[]> ```
Every usage record's status field can be success, error, or rate_limited — the last one recording when an upstream provider itself rejected a call for exceeding its rate limit. The AI module tracks and surfaces this, but doesn't enforce its own per-tenant spend cap; see the Billing module for tenant-level usage-limit enforcement.
Model Auto-Refresh System
A daily job keeps the model catalog current without a deploy:
- For each enabled provider (OpenAI, Anthropic, Google, Cohere, etc.), it checks the provider's live model list
- Compares that list against the cached model definitions
- Registers any new models into the registry
- Logs what was discovered — e.g. "discovered 3 new models from openai"
It also runs once on every boot, so newly-enabled providers get an immediate catalog pull.
Supported for auto-refresh: OpenAI, Anthropic, Google AI Studio, Cohere, Voyage AI, Mistral, Groq, DeepSeek, Together AI, Replicate, and any provider that exposes a public model-list endpoint.
Cost Estimation & Token Counting
Pre-call cost estimation means you can show a user an estimated cost before a call is made — no API round-trip required.
```typescript // Text — input + output tokens calculateTextCost(opts: { model, promptTokens, completionTokens?, providerId? });
// Image — flat per-image (sometimes per-resolution) calculateImageCost(opts: { model, resolution, count?, providerId? });
// Media (audio / video) — per-second or per-character calculateMediaCost(opts: { model, durationSeconds?, providerId? }); ```
Token estimation (pure JS, no API call):
```typescript function estimateTokens(text: string): number; // Rough approximation: 1 token ≈ 4 characters, regardless of language or model
// Examples: // "Hello world" (11 chars) → ~3 tokens // 1000 English words (~5,000 chars) → ~1,250 tokens ```
Current pricing (built-in, updated on every release):
- GPT-4o: $2.50/1M input, $10/1M output
- Claude 3.5 Sonnet: $3/1M input, $15/1M output
- Gemini 2.0 Flash: $0.075/1M input, $0.30/1M output
- DeepSeek R1: $0.55/1M input, $2.19/1M output
Data Model
Provider configs — one row per configured provider:
- Provider ID, display name, status (active / inactive / error)
- Encrypted credentials (API key, optional custom base URL, organization / project IDs)
- Default model per modality (text, image, audio, embedding)
Usage log — one row per AI call:
- Tenant, user, provider, model, operation type, modality
- Token counts, image/audio/video counts where relevant
- Cost breakdown (input / output / media / total)
- Latency, tool-call count, streaming flag
- Status (success / error) with error code + message when applicable
Dashboard configs — one row per saved dashboard:
- Name, type (cost / usage / provider / user / custom)
- Metrics tracked, group-by dimension, date range, filters, chart type
Neural Architecture Studio — Visual Model Builder
Aeion's AI layer isn't only a gateway to other providers' models — it can also build models. The Neural Architecture Studio is a visual, drag-and-drop builder for neural network architectures.
- Drag layer nodes (linear layers, convolutions, activations, pooling) onto a canvas and wire them into a graph.
- The builder compiles the graph into an idiomatic, readable PyTorch module — including the layer declarations and a correctly-ordered forward pass — ready to hand to a data scientist or train directly.
- Device targeting (GPU / Apple Silicon / CPU) is auto-detected, so the generated module trains on whatever hardware is available.
The result is plain PyTorch a data scientist can take to a GPU cluster — so a tenant can train proprietary models on private data rather than only consuming hosted inference. A companion Neural Swarm Visualizer renders the live agent/AI layer.
Key Architecture Decisions
Provider routing
Registry dispatch — One API, all providers, auto-routed by model name
Credentials
Encrypted at rest, per-tenant scoped — API keys never in plaintext, rotated safely
Usage tracking
Event-driven — Every AI operation tracked automatically, no manual calls
Model discovery
Daily auto-refresh — New models available within 24h, no code changes
Token estimation
Pure JS (no API call) — Pre-call cost estimation without latency or cost
Usage aggregation
Time-bucketed and per-dimension views over the same log — powers cost dashboards without a separate analytics pipeline
Multi-modal
Unified modality model — text/image/audio/video/3D/embedding/STT/TTS/rerank/vision/music