The Lightfast Memory API provides real-time semantic search across all your company's data sources. It enables AI tools, custom agents, and applications to access company knowledge through a unified, type-safe API.
API Endpoints
Add Memory
POST/memoriesIndex new content into a collection for semantic search
List Memories
GET/memoriesList all memories in a collection
Get Memory
GET/memories/{id}Retrieve a specific memory by ID from a collection
Search Memories
POST/memories/searchPerform semantic search across your indexed memories
Update Memory
PUT/memories/{id}Update existing memory content or metadata
Delete Memory
DELETE/memories/{id}Remove a memory from the collection permanently
Base URL
https://api.lightfast.ai/v1
Authentication
All API requests require authentication via API keys:
Authorization: Bearer lf_sk_live_abc123...
Key Types
| Type | Prefix | Permissions | Use Case |
|---|---|---|---|
| Secret Key | lf_sk_ | Full access (read, write, delete) | Server-side applications |
| Publishable Key | lf_pk_ | Read-only access | Client-side search UIs |
| Restricted Key | lf_rk_ | Custom scopes | Scoped integrations |
Core Concepts
Collections
Collections are logical groupings of related memories (e.g., github-org-name, discord-server-id). Data is automatically partitioned by source and organization.
Memories
A memory is an indexed piece of content with associated metadata. Each memory has:
- ID: Unique identifier within the collection
- Content: The text content to search
- Metadata: Structured data for filtering and context
- Embedding: Vector representation for semantic search
Semantic Search
Unlike keyword search, semantic search understands meaning and context. Searching for "authentication refactor" will find related PRs, issues, and discussions even if they don't contain those exact words.
Rate Limiting
| Tier | Searches/min | Writes/min | Quota |
|---|---|---|---|
| Free | 60 | 10 | 10K vectors |
| Pro | 600 | 100 | 100K vectors |
| Team | 3,000 | 500 | 500K vectors |
| Enterprise | Custom | Custom | Unlimited |
Rate limit information is included in response headers:
X-RateLimit-Limit: 600
X-RateLimit-Remaining: 542
X-RateLimit-Reset: 1642694400
Error Handling
All errors follow a consistent format:
{
"error": "rate_limit_exceeded",
"message": "Rate limit exceeded. Retry after 42 seconds.",
"details": {
"retryAfter": 42
},
"requestId": "req_abc123"
}
Common Error Codes
| Code | Status | Description |
|---|---|---|
invalid_request | 400 | Malformed request or invalid parameters |
authentication_failed | 401 | Invalid or missing API key |
permission_denied | 403 | Insufficient permissions for operation |
resource_not_found | 404 | Memory or collection does not exist |
conflict | 409 | Resource already exists |
rate_limit_exceeded | 429 | Too many requests |
internal_error | 500 | Unexpected server error |
SDKs
TypeScript/JavaScript
npm install @lightfast/memory
import { createMemory } from '@lightfast/memory'
const memory = createMemory({
apiKey: process.env.LIGHTFAST_API_KEY,
provider: 'chroma',
config: {
host: 'http://localhost:8000'
}
})
Python
pip install lightfast-memory
from lightfast_memory import Memory
memory = Memory(
api_key=os.getenv("LIGHTFAST_API_KEY"),
provider="chroma",
config={"host": "http://localhost:8000"}
)
Go
go get github.com/lightfastai/lightfast-go
import "github.com/lightfastai/lightfast-go/memory"
client := memory.NewClient(
memory.WithAPIKey(os.Getenv("LIGHTFAST_API_KEY")),
memory.WithProvider("chroma"),
)
Quick Start
1. Get your API key
Sign up at lightfast.ai and get your API key from the dashboard.
2. Index your first memory
await memory.addMemory({
collection: 'my-project',
id: 'doc-1',
content: 'Your content here...',
metadata: {
type: 'doc',
source: 'custom',
createdAt: new Date().toISOString()
}
})
3. Search your memories
const results = await memory.searchMemory({
query: 'your search query',
collections: ['my-project'],
limit: 10
})
Next Steps
- Add Memory - Index new content
- Search Memory - Semantic search
- Update Memory - Update existing content
- Delete Memory - Remove from index