Server-Side AI (Team Mode)

March 9, 2026 ยท View on GitHub

When running the Unforgit server for a team, you can configure server-side OpenAI integration so individual developers don't need their own API keys.

Configuration

Set these environment variables on the server:

# Required for AI features
OPENAI_API_KEY=sk-your-team-api-key

# Auto-generate embeddings when memories are created
AUTO_EMBEDDING_ENABLED=true

# LLM model for consolidation (default: gpt-5.4)
CONSOLIDATION_MODEL=gpt-5.4

Server AI Endpoints

MethodPathDescription
POST/v1/recallSemantic search - hybrid FTS + embedding similarity
POST/v1/embeddings/generate/:memoryIdGenerate embedding for one memory
POST/v1/embeddings/backfillGenerate embeddings for all memories
GET/v1/embeddings/statsEmbedding coverage statistics
POST/v1/auto-consolidate/previewFind consolidation candidates
POST/v1/auto-consolidateAuto-consolidate with LLM
POST/v1/auto-consolidate/executeExecute specific group
POST/v1/lifecycle/runRun the brain-like maintenance loop
GET/v1/suggestionsAI-powered curation suggestions
GET/v1/health/repoRepository health report

Examples

When OPENAI_API_KEY is set on the server, /v1/recall automatically uses hybrid scoring:

curl -X POST http://localhost:3737/v1/recall \
  -H "Authorization: Bearer hk_xxx" \
  -H "Content-Type: application/json" \
  -d '{"orgId":"org","repoId":"repo","query":"how to release to production"}'

Response includes searchType: "hybrid" when semantic search is active.

Auto-Consolidation

# Preview candidates
curl -X POST http://localhost:3737/v1/auto-consolidate/preview \
  -H "Authorization: Bearer hk_xxx" \
  -H "Content-Type: application/json" \
  -d '{"orgId":"org","repoId":"repo","threshold":0.5}'

# Execute consolidation
curl -X POST http://localhost:3737/v1/auto-consolidate \
  -H "Authorization: Bearer hk_xxx" \
  -H "Content-Type: application/json" \
  -d '{"orgId":"org","repoId":"repo","maxGroups":5}'

Health Check

curl "http://localhost:3737/v1/health/repo?orgId=org&repoId=repo" \
  -H "Authorization: Bearer hk_xxx"

Response:

{
  "overall": "healthy",
  "score": 85,
  "metrics": {
    "totalMemories": 150,
    "embeddingCoverage": 92,
    "consolidationRatio": 15
  },
  "recommendations": ["Consider consolidating similar memories"],
  "serverCapabilities": {
    "semanticSearch": true,
    "autoConsolidation": true,
    "autoEmbedding": true
  }
}