clef-router
Route prompts between cheap and frontier LLMs using Cloudflare's Clef decision model.
Quick start
pip install clef-router
export CLEF_ACCOUNT_ID=your_cloudflare_account_id
export CLEF_API_TOKEN=your_cloudflare_api_token
from clef_router import ClefRouter
router = ClefRouter()
result = router.route("What is the capital of France?")
print(result.tier) # "cheap"
print(result.reason) # "classified as simple, confidence 0.90"
result = router.route("Design a distributed consensus algorithm")
print(result.tier) # "frontier"
How it works
prompt → Clef decision model (Cloudflare Workers AI) → tier
├─ simple → cheap model
├─ standard → cheap model
├─ complex → frontier model
└─ uncertain → frontier (confidence gate)
clef vs laya
| laya | Clef | |
|---|---|---|
| Latency | 5.8ms | 38.8ms (flash) / 209.3ms (full) |
| Quality (BFCL) | 38.13 | 98.76 |
| Context | 32k | 64k |
| Hosting | local CPU | Cloudflare API |
| Cost | $0 | Workers AI pricing |
Use laya-router for sub-10ms local routing. Use clef-router when quality matters more than latency.
License
Apache 2.0
Metadata
Release files for clef-router 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| clef_router-0.1.0.tar.gz | 3.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| clef_router-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.9 kB
Release files / clef_router-0.1.0.tar.gz
| Download URL | clef_router-0.1.0.tar.gz |
|---|---|
| Size | 3.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
48c3f8aba832e630e97de0ffe4346bde171e93b3fbfba288b16ed2163707c518
|
|
BLAKE2b-256 checksum How to use checksums |
4e8ff7bf96b66a0e690c2b4950346a44f4484c18d3cb04be7d9d46dcc6c7d9be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.21 {"installer":{"name":"uv","version":"0.12.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / clef_router-0.1.0-py3-none-any.whl
| Download URL | clef_router-0.1.0-py3-none-any.whl |
|---|---|
| Size | 3.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
82b89cda75d32e92226b591393731d5bde895a878148340fdbfc43f41b5e6675
|
|
BLAKE2b-256 checksum How to use checksums |
2d31ee3cc04716e497dba8eaec6215788f4cfd8ca416782e543c74e8d5de41af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.21 {"installer":{"name":"uv","version":"0.12.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|