Imago LLM Marketplace
AI Inference Gateway native to TON/Telegram: OpenAI-compatible API, TON micropayments, MCP server, Telegram Mini App
Ask AI about Imago LLM Marketplace
Powered by Claude Β· Grounded in docs
I know everything about Imago LLM Marketplace. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
First LLM Marketplace on Cocoon and TON
Cocoon TEE privacy by default β’ pay with TON β’ MCP-native for AI agents
The Problem
TON has 1 billion+ Telegram users and the fastest-growing L1 blockchain. Yet developers building AI-powered bots and agents on TON face critical gaps:
- No agent infrastructure: AI agents cannot autonomously discover, call, and pay for LLM inference on TON
- Payment friction: every AI provider requires credit cards and KYC, incompatible with on-chain payments
- Zero privacy: every prompt is visible to the provider, with no hardware-level protection
The Solution
IMAGO is an AI inference gateway built on Cocoon and TON. One OpenAI-compatible endpoint, TON payments with zero KYC, and an MCP server so AI agents can autonomously call models and pay with TON credits. Private inference via Cocoon TEE where even IMAGO cannot see your prompts.
Key Features
| Feature | Description |
|---|---|
| OpenAI-Compatible API | Drop-in replacement: change one line of code (base_url) and it works |
| Multi-provider Models | GPT-4o, Claude, Llama, Qwen, Gemini and more via OpenRouter |
| TON Micropayments | Deposit TON β get credits β pay per token. No credit cards needed |
| MCP Server | AI agents (Claude, GPT) can autonomously call inference and pay in TON |
| Cocoon TEE Privacy | Hardware-isolated inference: prompts are encrypted, even IMAGO can't see them |
| Telegram Mini App | Full dashboard: models, balance, API keys, chat, right inside Telegram |
| Smart Contract | Tact contract on TON mainnet for trustless deposits |
| Streaming | Full SSE streaming support, identical to OpenAI API format |
Architecture
Agent Infrastructure
IMAGO is an MCP-native inference gateway. AI agents (Claude Desktop, Claude Code, or any MCP client) can autonomously discover models, run inference, check balance, and manage payments on TON.
MCP Tools
| Tool | What the agent does |
|---|---|
imago_list_models | Discover available models with context length and per-token pricing |
imago_chat | Send inference requests to any model (GPT-4o, Claude, Llama, Cocoon TEE) |
imago_get_balance | Check remaining credits before making calls |
imago_get_deposit_info | Get the TON deposit address and current exchange rate |
How an Agent Uses IMAGO
1. Agent receives a task requiring specialized AI
2. Calls imago_list_models β discovers models and pricing
3. Calls imago_get_balance β verifies sufficient credits
4. Calls imago_chat(model, messages) β gets inference result
5. Credits are deducted automatically per token (atomic, Postgres-backed)
6. Agent continues its workflow with the result
Why This Matters
Today, AI agents have no way to pay for inference on TON. Credit cards and KYC make autonomous agent-to-service payments impossible. IMAGO solves this:
- Agent autonomy: the agent decides which model to use, calls it, and pays -- all without human intervention
- On-chain payments: TON credits are deposited via smart contract, no KYC, no credit cards
- Model selection: agents pick the right model for each sub-task (cheap for simple queries, powerful for reasoning, private for sensitive data via Cocoon TEE)
- Standard protocol: built on MCP, works with Claude Desktop, Claude Code, and any MCP-compatible client
Quick Start
Use the API (2 lines of code)
from openai import OpenAI
client = OpenAI(
base_url="https://imago.market/v1",
api_key="sk-imago-YOUR_KEY" # Get from Telegram Mini App
)
response = client.chat.completions.create(
model="openai/gpt-4o-mini",
messages=[{"role": "user", "content": "Hello from TON!"}]
)
print(response.choices[0].message.content)
Use with TypeScript / Node.js
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://imago.market/v1",
apiKey: "sk-imago-YOUR_KEY",
});
const response = await client.chat.completions.create({
model: "openai/gpt-4o-mini",
messages: [{ role: "user", content: "Hello from TON!" }],
});
console.log(response.choices[0].message.content);
Use with cURL
curl https://imago.market/v1/chat/completions \
-H "Authorization: Bearer sk-imago-YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-4o-mini",
"messages": [{"role": "user", "content": "Hello!"}],
"stream": true
}'
Use with MCP (Claude Desktop / Claude Code)
IMAGO ships an MCP server so AI agents can discover models, call inference, and pay with TON autonomously.
# Clone and build the MCP server
git clone https://github.com/maxrihter/imago-LLM-marketplace.git
cd imago/packages/mcp-server && npm install && npm run build
Add to your MCP config (claude_desktop_config.json or .claude/settings.json):
{
"mcpServers": {
"imago": {
"command": "node",
"args": ["/path/to/imago/packages/mcp-server/build/index.js"],
"env": {
"IMAGO_API_KEY": "sk-imago-YOUR_KEY"
}
}
}
}
Now Claude can call AI models and pay with your TON credits autonomously. The agent has 4 tools: imago_chat, imago_list_models, imago_get_balance, imago_get_deposit_info.
Get Your API Key
- Open @imago_tonbot in Telegram
- Connect your TON wallet (2 taps)
- Deposit TON for credits
- Generate an API key. Done!
How It Works
1. Developer gets API key via Telegram Mini App
2. Deposits TON β credits are added instantly (on-chain polling)
3. Makes API calls (OpenAI-compatible) β credits deducted per token
4. AI agents use MCP to call inference autonomously
5. Cocoon TEE models available for privacy-sensitive workloads
Payment Flow
User sends TON β Smart Contract β TonCenter polling (15s) β
β Credits added (Postgres atomic) β Redis cache invalidated β
β API calls deduct credits per token β Settlement
Comparison
| Feature | IMAGO | OpenRouter | LiteLLM | Together.ai |
|---|---|---|---|---|
| OpenAI-compatible API | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| First on Cocoon TEE | :white_check_mark: | :x: | :x: | :x: |
| TON/Telegram native | :white_check_mark: | :x: | :x: | :x: |
| Decentralized payments | :white_check_mark: | :x: | :x: | :x: |
| MCP server for agents | :white_check_mark: | :x: | :x: | :x: |
| Hardware-level privacy (TEE) | :white_check_mark: | :x: | :x: | :x: |
| Telegram Mini App | :white_check_mark: | :x: | :x: | :x: |
| Self-hostable | :white_check_mark: | :x: | :white_check_mark: | :x: |
Project Structure
imago/
βββ packages/
β βββ api/ # Fastify API gateway (Node.js 22+)
β β βββ src/
β β β βββ routes/ # /v1/chat, /v1/models, /auth
β β β βββ services/ # OpenRouter, Cocoon, credits, TON poller
β β β βββ middleware/# Auth, Telegram initData validation
β β β βββ utils/ # TON address normalization
β β βββ prisma/ # Database schema
β βββ tma/ # React Telegram Mini App
β β βββ src/
β β βββ pages/ # 8 pages: Home, Models, Chat, Deposit...
β β βββ components/# 20+ UI components
β β βββ lib/ # Hooks, utilities
β βββ contracts/ # Tact smart contracts (TON mainnet)
β β βββ contracts/ # imago_market.tact
β β βββ scripts/ # Deploy scripts
β β βββ tests/ # Blueprint tests
β βββ mcp-server/ # MCP server for AI agents
β βββ src/ # 4 tools: chat, list_models, get_balance, deposit_info
βββ assets/ # Banner, architecture diagram
βββ .env.example # Environment template
βββ package.json # Monorepo workspace root
API Reference
Endpoints
| Method | Path | Auth | Description |
|---|---|---|---|
POST | /v1/chat/completions | Bearer | Chat completion (streaming + non-streaming) |
GET | /v1/models | none | List available models with pricing |
GET | /v1/usage | Bearer | Usage logs by model |
POST | /auth/keys | Telegram | Create API key |
GET | /auth/keys | Telegram | List keys + balance |
DELETE | /auth/keys/:id | Telegram | Deactivate API key |
GET | /auth/deposit | none | Deposit instructions + live TON price |
GET | /health | none | Health check (Postgres + Redis status) |
MCP Tools
See Agent Infrastructure for detailed MCP tools documentation and agent workflow.
Tech Stack
| Layer | Technology | Why |
|---|---|---|
| API Gateway | Node.js 22 + Fastify | High performance, OpenAI SDK compatible |
| Database | PostgreSQL + Prisma | ACID guarantees for credit balance |
| Cache | Redis | Rate limiting, credit cache, session data |
| AI Backend | OpenRouter + Cocoon TEE | Multi-provider routing + hardware privacy |
| Frontend | React 18 + Vite + Tailwind | TMA standard, fast builds |
| Blockchain | Tact + Blueprint | TON smart contracts |
| MCP | @modelcontextprotocol/sdk | Official MCP standard |
| Wallet | TON Connect 2.0 | Native Telegram wallet integration |
Local Development
Prerequisites
- Node.js 22+
- PostgreSQL 15+
- Redis 7+ (optional, works without it)
Setup
# Clone the repository
git clone https://github.com/maxrihter/imago-LLM-marketplace.git
cd imago
# Install dependencies
npm install
# Copy environment config
cp .env.example packages/api/.env
# Set up the database
cd packages/api
npx prisma db push
# Start development servers
cd ../..
npm run dev:api # API on :3000
npm run dev:tma # TMA on :5173
Security
- No plaintext keys stored: API keys are SHA-256 hashed before storage
- Atomic credit operations: PostgreSQL
UPDATE ... WHERE credits >= amountprevents races - Telegram initData HMAC: validates every TMA request via bot token
- Redis resilience: all Redis operations wrapped in try/catch, DB fallback
- Rate limiting: per-key + per-user + global limits
- Streaming timeouts: 120s abort with client disconnect detection
- TON address normalization: prevents duplicate accounts from address format variants
Cocoon TEE: Private AI, First on Market
IMAGO is the first LLM marketplace integrated with Cocoon TEE on TON mainnet. No other marketplace offers hardware-isolated inference in the TON ecosystem.
Cocoon runs models inside Intel TDX (Trust Domain Extensions) enclaves. This is not software encryption: it is hardware-level isolation verified by cryptographic attestation (RA-TLS).
What this means for you:
- Prompts are encrypted in transit and at rest
- Neither IMAGO nor Cocoon operators can read your data
- Attestation proof verifies the enclave is genuine before every session
Available model: cocoon/Qwen/Qwen3-32B. Use it like any other model in the API: same endpoint, same SDK, same credits.
TON Integration
- Smart Contract:
imago_market.tact(Tact), handles deposits and owner withdrawals - TON Connect 2.0: Native wallet connection in Telegram
- TonCenter Polling: Real-time deposit detection (15s intervals)
- TON Price Feed: Live TON/USD from Binance + CoinGecko with sanity bounds
Contributing
We welcome contributions! See CONTRIBUTING.md for guidelines.
License
MIT. Free to use, fork, and build on.
First LLM Marketplace on Cocoon and TON
imago.market β’ @imago_tonbot
