How It Works
This page walks through the full lifecycle of an Aomi-powered assistant -- from your existing APIs to a deployed product your users can talk to. We use MyCoinDex, a fictional crypto exchange, as the running example.
The Pipeline
1. Your APIs
MyCoinDex exposes standard HTTP endpoints. Aomi does not modify them.
| Endpoint | Method | Description |
|---|---|---|
/prices/{symbol} | GET | Current token price |
/trades | POST | Execute a trade |
/portfolio/{userId} | GET | User portfolio and P&L |
/markets | GET | Available trading pairs |
/orderbook/{pair} | GET | Order book depth |
2. APIs Become AI Tools
Aomi wraps each endpoint as a tool -- a typed function the LLM can invoke during a conversation. Each tool has a name, a description (so the model knows when to use it), and typed parameters.
When a user asks "What's ETH trading at?", the model calls GetTokenPrice with { symbol: "ETH" }. The tool hits MyCoinDex's /prices/eth, returns the result, and the model composes a natural-language response.
Tools can execute concurrently. If the model needs both a price and a portfolio balance, it calls both tools in parallel.
3. Configuring the Assistant
Three settings define the assistant's behavior:
Preamble
The system prompt that shapes personality and rules:
You are the MyCoinDex trading assistant. You help users check
prices, manage portfolios, and execute trades.
Always confirm with the user before executing a trade.
Show prices in USD unless the user requests otherwise.Model Selection
The LLM that powers the assistant. Supported providers:
| Provider | Models |
|---|---|
| Anthropic | Claude Sonnet, Claude Haiku |
| OpenAI | GPT-4o, GPT-4o Mini |
| OpenRouter | Access to 100+ models |
Models can be changed at runtime via the control API -- no redeployment needed.
RAG Document Store (Optional)
If MyCoinDex has documentation, FAQs, or knowledge base articles, Aomi ingests them into a vector store. The assistant searches these documents when answering questions beyond tool capabilities.
4. Deployed as an App
The configured app becomes an app -- a self-contained assistant environment on Aomi's hosted backend.
App: "mycoindex"
Endpoint: POST /api/chat?app=mycoindex
Tools: GetTokenPrice, ExecuteTrade, GetPortfolio, ListMarkets
Preamble: MyCoinDex trading assistant
Model: Claude Sonnet (default, switchable)Each app is isolated. MyCoinDex's tools, preamble, and configuration do not affect other apps on the platform.
5. API Key and Authentication
MyCoinDex receives an API key scoped to their app. Every request includes:
X-API-Key: sk-mcd-a1b2c3d4e5f6
X-Session-Id: 550e8400-e29b-41d4-a716-446655440000The backend validates the key, confirms it authorizes access to the mycoindex app, and proceeds.
6. The Request Flow
Here is what happens when a user sends a message:
Step by Step
- User sends a message via the widget or headless integration.
- Frontend sends HTTP POST to
/api/chat?app=mycoindexwith the API key and session ID. - Backend validates the API key and loads the session.
- Backend sends message + history + tools to the selected LLM.
- LLM decides to call tools -- requests
GetPortfolioandGetTokenPrice. - Backend executes tool calls against MyCoinDex's APIs.
- Tool results go back to the LLM for interpretation.
- LLM streams its response -- the backend forwards each text chunk as an SSE event.
- Frontend renders incrementally -- the user sees text appear in real-time.
- Complete event signals the response is finished.
SSE Stream Format
The response is a stream of Server-Sent Events:
data: {"type":"text","content":"Your ETH "}
data: {"type":"text","content":"position is worth "}
data: {"type":"text","content":"$8,750"}
data: {"type":"tool_call","name":"GetPortfolio","args":{"userId":"user123"}}
data: {"type":"tool_result","name":"GetPortfolio","result":{"eth":2.5,"value_usd":8750}}
data: {"type":"complete"}Each event is a JSON object with a type field. The frontend processes these to render streaming text, tool call indicators, and completion state.
| Event Type | Purpose |
|---|---|
text | Incremental text chunk from the LLM |
tool_call | The model is invoking a tool |
tool_result | Result returned from a tool execution |
complete | Response finished |
What You Get
| Capability | Details | Managed By |
|---|---|---|
| AI assistant | Understands your product, calls your APIs | Aomi |
| Streaming chat | Real-time responses via SSE | Aomi |
| Tool execution | LLM calls your APIs as needed during conversations | Aomi |
| Session management | Persistent threads, history, and state | Aomi |
| Multi-model support | Switch between Claude, GPT-4o, and others at runtime | Aomi |
| Wallet integration | Optional Web3 wallet connect for on-chain actions | Aomi |
| Scaling and availability | Hosted infrastructure, no GPUs or LLM keys to manage | Aomi |
| Your API endpoints | Standard HTTP -- no modifications required | You |
| Frontend integration | Widget, headless, or Telegram | You |
| API key security | Store securely, never expose client-side | You |
Next Steps
- Apps and Authentication -- how API keys, apps, and sessions fit together.
- API Reference -- full HTTP endpoint documentation.
- Sessions -- how chat sessions are created and managed.