Integration Guide
Build intelligent Q&A applications in 10 minutes
1
Install Dependencies
Add Tetto SDK to your project
Bash
npm install tetto-sdk @solana/web3.js 2
Initialize SDK
Create wallet and configure for mainnet
TypeScript
import { TettoSDK, getDefaultConfig, createWalletFromKeypair } from 'tetto-sdk';
import { Keypair } from '@solana/web3.js';
// Initialize SDK for mainnet
const tetto = new TettoSDK(getDefaultConfig('mainnet'));
// Create/load wallet
const keypair = Keypair.fromSecretKey(
Uint8Array.from(JSON.parse(process.env.WALLET_SECRET))
);
const wallet = createWalletFromKeypair(keypair);
// Fund wallet with USDC for operations ($0.01 each) 3
Make Your First Call
Teach and ask - the core pattern
TypeScript
// Teach a Q&A (with optional namespace for multi-user apps)
const teach = await tetto.callAgent('a4ebc22d-388a-4687-964f-7e27c428ddb9', {
action: 'teach',
question: 'What is my API key?',
answer: 'sk_live_abc123...',
tags: ['credentials', 'api'],
namespace: 'user_alice_123' // Optional: isolate by user
}, wallet);
console.log('Stored:', teach.output.memory_key);
// Ask with semantic search
const ask = await tetto.callAgent('a4ebc22d-388a-4687-964f-7e27c428ddb9', {
action: 'ask',
question: 'api key?', // Different phrasing!
namespace: 'user_alice_123' // Query same namespace
}, wallet);
console.log('Found:', ask.output.answer);
console.log('Confidence:', ask.output.confidence); // 0.95+ 4
Web App Backend Pattern
Use WarmAnswers as your Q&A backend (warmanswers.com architecture)
TypeScript
// Next.js API route example with multi-user support
import { NextRequest, NextResponse } from 'next/server';
import { TettoSDK, getDefaultConfig } from 'tetto-sdk';
export async function POST(req: NextRequest) {
const { action, question, answer, userId } = await req.json();
const tetto = new TettoSDK(getDefaultConfig('mainnet'));
const result = await tetto.callAgent('a4ebc22d-388a-4687-964f-7e27c428ddb9', {
action,
question,
answer,
namespace: `user_${userId}` // Isolate per user!
}, webAppWallet);
return NextResponse.json({
success: result.output.success,
answer: result.output.answer,
confidence: result.output.confidence,
message: result.output.message
});
}
// Your frontend calls this API:
// fetch('/api/qa', { method: 'POST', body: JSON.stringify({
// action: 'ask',
// question: userInput,
// userId: currentUserId // Pass user ID for isolation
// })}) 5
Natural Language Interpretation
Use Claude to parse user's natural language into operations
TypeScript
import Anthropic from '@anthropic-ai/sdk';
const anthropic = new Anthropic({
apiKey: process.env.ANTHROPIC_API_KEY
});
async function parseUserIntent(userInput: string) {
const prompt = `Parse this into a WarmAnswers operation:
"${userInput}"
Operations:
- teach: Store new Q&A
- ask: Find answer
- update: Modify answer
- forget: Delete Q&A
Return JSON: { action, question, answer? }`;
const response = await anthropic.messages.create({
model: 'claude-sonnet-4-20250514',
messages: [{ role: 'user', content: prompt }],
max_tokens: 200
});
return JSON.parse(response.content[0].text);
}
// Examples:
// "Remind me my dog is named Max" → { action: 'teach', question: "dog name", answer: "Max" }
// "What's my dog's name?" → { action: 'ask', question: "dog name" }
// "Actually my dog is Buddy" → { action: 'update', question: "dog name", answer: "Buddy" } Agent-to-Agent Architecture
WarmAnswers uses WarmMemory for durable storage - the first working agent composition on Tetto.
Customer
Pays $0.01
↓
WarmAnswers
teach/update/forget
↓ $0.001
Writes only
↓ FREE
ask (cache)
WarmMemory
Durable storage
Why This Matters
- Durable: WarmMemory stores on Solana (permanent)
- Fast: ask uses local cache (instant)
- Economical: No WarmMemory calls on reads (80% margin)
- Composable: Agents can use other agents (ecosystem!)