Skip to content

About

Cloudflare implementation of PRISM.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Claude-PRISM-CF — LLM Routing & Optimization for Cloudflare

Structured multi-agent collaboration using Claude as the reasoning engine. Routes, caches, and optimizes LLM calls at the edge.

What This Gives You

  • 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

Quick Start

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 cache

API Reference

PrismConfig(default_model, cache_ttl_seconds, max_tokens_budget)

LLMRouter(config) — select(task_type) → model_name

TaskType — CODE_GENERATION, ANALYSIS, CREATIVE, SUMMARY, REVIEW

PrismEngine(config) — process(prompt, task_type, context) → PrismResult

TokenCounter / TokenUsage — Token budgeting and tracking

ResponseCache — TTL-based response cache with cache entry metadata

How It Fits

The edge intelligence layer for the SuperInstance fleet, deployed on Cloudflare.

Testing

pytest tests/

Python 3.10+. MIT license.

About

Cloudflare implementation of PRISM.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages