Getting Started with Aeion AI
Configure AI providers, set up automatic usage tracking, enable cost caps per tenant, and start making AI calls across 57 providers — all in Aeion OS.
Configure Your AI Providers
Navigate: AI → Providers → Add Provider
The AI module needs provider credentials. Each provider has its own setup:
OpenAI:
json
{
"providerId": "openai",
"name": "OpenAI",
"status": "active",
"credentials": {
"apiKey": "{{OPENAI_API_KEY}}"
},
"defaults": {
"textModel": "gpt-4o",
"imageModel": "dall-e-3",
"embeddingModel": "text-embedding-3-small"
}
}
Anthropic:
json
{
"providerId": "anthropic",
"name": "Anthropic",
"status": "active",
"credentials": {
"apiKey": "{{ANTHROPIC_API_KEY}}"
},
"defaults": {
"textModel": "claude-sonnet-4-20250514"
}
}
Google (Gemini on Vertex AI):
json
{
"providerId": "google",
"name": "Google AI",
"status": "active",
"credentials": {
"projectId": "{{GCP_PROJECT_ID}}",
"credentials": "{{GCP_SERVICE_ACCOUNT_JSON}}"
},
"defaults": {
"textModel": "gemini-2.0-flash"
}
}
All provider credentials are encrypted at rest using a key scoped to the AI layer — never stored in plaintext. Rotation is safe, revocation immediate.
Make Your First AI Call
Using the unified AI API:
```typescript // Text completion const result = await ctx.ai.complete({ model: "gpt-4o", messages: [ { role: "system", content: "You are a helpful assistant." }, { role: "user", content: "Summarize the quarterly report for Acme Corp." }, ], maxTokens: 1024, temperature: 0.7, }); // result.text → "Acme Corp's Q1 2026 revenue was $2.3M, up 18% from Q4 2025..."
// Image generation const image = await ctx.ai.generateImage({ model: "sd3.5-large", prompt: "A professional infographic showing Q1 revenue growth", size: "1024x1024", quality: "standard", }); // image.url → "https://cdn.aeionos.com/ai-generated/..."
// Speech synthesis const audio = await ctx.ai.speak({ model: "eleven_flash_v2_5", input: result.text, voice: "rachel", speed: 1.0, }); // audio.audioUrl → "https://cdn.aeionos.com/ai-generated/..."
// 3D mesh generation const mesh = await ctx.ai.generateMesh3D({ model: "tripo3d", prompt: "A low-poly stylized tree with autumn leaves", }); // mesh.modelUrl → "https://cdn.aeionos.com/ai-generated/..." ```
Provider routing is automatic: Pass any model name and the registry dispatches to the correct adapter. No provider selection needed.
Enable Automatic Usage Tracking
Usage tracking is automatic for all AI operations:
No configuration needed — it's event-driven. When any AI operation completes, ai.operation.completed fires and Aeion logs it:
```typescript // ai_usage_logs collection gets populated automatically // Every operation: timestamp, provider, model, tokens, cost, latency, status
// Query usage: const usage = await ctx.services["ai_usage_logs"].list({ where: { tenantId: { equals: tenantId }, createdAt: { gte: startDate, lte: endDate }, }, order: [{ field: "createdAt", direction: "desc" }], limit: 100, });
// Aggregate by provider: const byProvider = await usageService.getUsage({ tenantId, period: "monthly", groupBy: "provider", }); // → [{ providerId: "openai", operationCount: 4523, totalCost: 127.50 }, // { providerId: "anthropic", operationCount: 891, totalCost: 43.20 }] ```
Token counting:
```typescript // Pure JS, no API call — estimate tokens before making the call const tokens = estimateTokens(longText); // → 2847 tokens
// Pre-call cost estimation const cost = calculateTextCost("openai", "gpt-4o", tokens, 500); // → { inputCost: 0.014235, outputCost: 0.0075, totalCost: 0.021735 } ```
Set Up Cost Caps Per Tenant
Cost caps prevent runaway bills from AI operations:
json
// ai_budgets record (one per tenant + period)
{
"period": "monthly",
"limitUsd": 500,
"alertThresholdPercent": 80,
"actionOnExceed": "soft-block" // warn | soft-block | hard-block
}
How it works: Before every AI operation, Aeion checks the tenant's active budget row for that period against current spend. Crossing alertThresholdPercent fires an alert. If spend would exceed the limit, the configured actionOnExceed applies — warn (log + notify, call proceeds), soft-block (require admin override), or hard-block (reject the call).
Low-budget starter example:
json
// ai_budgets record for a new tenant during their 14-day trial
{
"period": "monthly",
"limitUsd": 5,
"actionOnExceed": "hard-block"
}
Set Up AI Dashboards
Navigate: AI → Dashboards → New Dashboard
json
{
"name": "Monthly AI Spend",
"type": "cost",
"config": {
"metrics": ["totalCost", "inputCost", "outputCost"],
"groupBy": "provider",
"dateRange": {
"start": "2026-05-01T00:00:00Z",
"end": "2026-05-31T23:59:59Z"
},
"chartType": "area"
}
}
Usage aggregations:
```typescript // By provider: which AI provider costs the most? groupBy: "provider";
// By user: which users are consuming the most AI budget? groupBy: "user";
// By operation type: text vs image vs audio vs 3D groupBy: "operationType";
// By model: which specific model is most expensive? groupBy: "model";
// By modality groupBy: "modality";
// By period period: "hourly" | "daily" | "weekly" | "monthly"; ```
Example: Top 10 users by AI spend:
typescript
const topUsers = await usageService.getUsage({
tenantId,
period: "monthly",
groupBy: "user",
limit: 10,
order: [{ field: "totalCost", direction: "desc" }],
});
Use Ollama for Local / Air-Gapped Deployment
No API calls, fully local, zero cost:
json
{
"providerId": "ollama",
"name": "Ollama Local",
"status": "active",
"credentials": {
"baseUrl": "http://localhost:11434"
},
"defaults": {
"textModel": "llama3",
"embeddingModel": "nomic-embed-text"
}
}
Deploy on-premise:
```bash # Install Ollama on the server curl -fsSL https://ollama.com/install.sh | sh
# Pull models ollama pull llama3 ollama pull mistral ollama pull nomic-embed-text
# Aeion AI connects to localhost:11434 ```
Available Ollama models:
- Text: llama3, llama3.1, llama3.2, mistral, mixtral, gemma2, phi3, qwen2.5, codellama
- Embeddings: nomic-embed-text, mxbai-embed-large, all-minilm
For air-gapped environments (government, healthcare, finance): Ollama + Aeion AI gives you full AI capabilities without any data leaving the network.
Quick Reference: All AI Operations
// Text / Chatawait ctx.ai.complete({ model, messages, maxTokens, temperature, tools });await ctx.ai.completeStream({ model, messages, maxTokens }); // streamingawait ctx.ai.chatCompletion({ model, messages }); // OpenAI-style chat shape// Reasoning + vision models (DeepSeek R1, o3, Claude, Gemini) are just models —// pass them to complete() / chatCompletion(), no separate method needed.
// Imageawait ctx.ai.generateImage({ model, prompt, size, quality });await ctx.ai.editImage({ model, image, mask, prompt }); // inpaint/edit
// Audioawait ctx.ai.speak({ model, input, voice, speed, format });await ctx.ai.transcribe({ model, audioUrl, language }); // STT
// Videoawait ctx.ai.generateVideo({ model, prompt, duration, resolution });
// 3Dawait ctx.ai.generateMesh3D({ model, prompt, format }); // .glb, .fbx, .obj
// Embeddingsawait ctx.ai.embed({ model, input }); // returns vector[float]await ctx.ai.rerank({ model, query, documents }); // relevance scores
// Musicawait ctx.ai.generateMusic({ model, prompt });
// Utilityawait ctx.ai.listModels(); // available models per providerawait ctx.ai.hasCapability(modality); // check provider/model supportawait ctx.ai.batch(requests); // batch multiple calls in one round trip