Getting Started
Get your memory-powered AI application running in just a few minutes.
What is Capi?
Capi is the memory layer for AI applications. It solves the problem of stateless AI by:
- Remembering user interactions and preferences
- Retrieving relevant context when needed
- Scaling from prototypes to production
Why Use Capi?
- Personalization: Build AI that truly understands each user
- Cost-Saving: Reduce redundant LLM context tokens by 60-90%
- Scalability: Handles from 100 to 100M+ memories
- Simplicity: Just two API endpoints to learn
Core Concepts
- Memories: Stored user interactions with text and metadata
- Users: Unique identifiers for memory isolation
- Context: Retrieved memories relevant to the current interaction
- Embeddings: Vector representations enabling semantic search
Quickstart Guide (5 Minutes to First Memory)
Step 1: Sign Up & Get API Key
- Go to capi.dev/sign-up
- Create your first project
- Generate an API key in the dashboard
Step 2: Store Your First Memory
curl -X POST https://capi.dev/api/v1/addMemory \
-H "Content-Type: application/json" \
-H "X-CAPI-API-Key: your-api-key-here" \
-d '{
"userId": "user-123",
"text": "User prefers dark mode and speaks French"
}'
Step 3: Retrieve Context
curl -X POST https://capi.dev/api/v1/retrieveContext \
-H "Content-Type: application/json" \
-H "X-CAPI-API-Key: your-api-key-here" \
-d '{
"userId": "user-123",
"query": "What interface preferences does this user have?",
"limit": 3
}'
Step 4: View Usage in Dashboard
- Go to your project dashboard
- Check the "Usage" tab to see:
- Memory operations
- Storage usage
- API call history
Step 5: Next Steps
Authentication
Getting Your API Key
- Log into capi.dev or create an account
- Select your project
- Navigate to "API Keys"
- You should already have a key created for you. if not Click "Generate New Key" to create a new one.
Using the API Key
Include it in the X-CAPI-API-Key
header for all requests:
fetch('https://capi.dev/api/v1/addMemory', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CAPI-API-Key': 'your-key-here' // 👈 Required header
},
body: JSON.stringify(payload)
});
Security Best Practices
- Never expose keys in client-side code
- Rotate keys every 90 days
- Use environment variables:
# .env CAPI_API_KEY=your-key-here
- Restrict keys to specific IPs if possible
Pro Tip
Use different API keys for development and production environments.
Full Code Example
// Complete Node.js example
const CAPI_BASE_URL = 'https://capi.dev/api/v1';
const API_KEY = process.env.CAPI_API_KEY;
async function chatWithMemory(userId, message) {
// 1. Store the user message
await fetch(`${CAPI_BASE_URL}/addMemory`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CAPI-API-Key': API_KEY
},
body: JSON.stringify({
userId,
text: `User said: ${message}`
})
});
// 2. Get relevant context
const context = await fetch(`${CAPI_BASE_URL}/retrieveContext`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CAPI-API-Key': API_KEY
},
body: JSON.stringify({
userId,
query: message,
limit: 3
})
}).then(res => res.json());
// 3. Use context in your LLM call
const prompt = `Context:\n${context.memories.join('\n')}\n\nUser: ${message}\nAI:`;
return generateAIResponse(prompt);
}