Structured multi-agent collaboration using Claude as the reasoning engine. Routes, caches, and optimizes LLM calls at the edge.
- LLM routing — automatically select the best model for each task type (code, analysis, creative, summary)
- Token tracking — count and budget tokens per request, per agent, per session
- Response caching — cache identical or similar prompts to reduce cost and latency
- Cloudflare-native — designed for Cloudflare Workers deployment
- PRISM protocol — structured collaboration framework for coordinated multi-agent tasks
from claude_prism import PrismConfig, LLMRouter, TaskType, PrismEngine
# Configure
config = PrismConfig(default_model="claude-3.5-sonnet", cache_ttl_seconds=3600)
# Route to the best model for the task
router = LLMRouter(config)
model = router.select(TaskType.CODE_GENERATION)
# → "claude-3.5-sonnet" (or a cheaper model for simpler tasks)
# Run through the PRISM engine
engine = PrismEngine(config)
result = engine.process(
prompt="Explain this codebase",
task_type=TaskType.ANALYSIS,
context={"repo": "cocapn", "files_changed": 12},
)
print(result.response)
print(result.tokens_used)
print(result.cache_hit) # True if served from cacheThe edge intelligence layer for the SuperInstance fleet, deployed on Cloudflare.
- cocapn-sdk — One API key, any model
- api-gateway-1 — Unified API gateway
- cache-layer-optimizer — Cache optimization
pytest tests/Python 3.10+. MIT license.