快速开始
从密钥到路由流量,三步搞定。
2 · 发起路由调用
发送提示;获得任务类型与复杂度等级。
curl https://138.226.222.209/v1/route \
-H 'Authorization: Bearer cortiq_your_key' \
-H 'content-type: application/json' \
-d '{
"input": { "text": "Write a Python function to reverse a list" },
"taxonomy_id": "data-assistant"
}'
示例响应
{
"schema_version": "1.1",
"request_id": "req_18c98f1adb897a78001871",
"decision": {
"task_label": "code",
"confidence": 0.997,
"complexity": { "tier": "low", "score": 0.27, … },
"source": "router", …
},
"scores": [ { "task_label": "code", "probability": 0.997, … }, … ],
"usage": { "billable_decisions": 1, "oracle_calls": 0 },
"meta": { "model_version": "data-assistant@2026.08.02", "latency_ms": 0.03, … }
}
3 · 等级 → 你的模型
简单提示交给便宜/本地模型,困难的交给旗舰模型。
# your side — map the router's answer to your models tier == "low" → cheap / local (llama.cpp, Ollama, gpt-4o-mini) tier == "medium" → mid tier == "high" → flagship (Claude, GPT-4o, …)
不想自己写这套映射?下面是现成的开源网关,替你完成。
⚡ cortiq-gateway — 现成的开源网关
在此路由器之上提供一个 OpenAI 兼容端点:开箱即用的复杂度路由、/admin 网页控制台(7 种语言)、本地 .cmf 模型加云端供应商,以及首次启动向导。无参数命令会自动创建配置并打开浏览器。
# crates.io cargo install cortiq-gateway cortiq-gateway # Docker docker run -p 9000:9000 -v cortiq-data:/app/data ghcr.io/infosave2007/cortiq-gateway:latest
然后把任意 OpenAI 客户端指向 base_url http://localhost:9000/v1,model 填 "cortiq-auto";在控制台设置里粘贴路由器密钥。Linux、Windows、macOS 的预编译二进制在 GitHub Releases。
GitHub → infosave2007/cortiq-gateway4 · 获取任务列表 — GET /v1/taxonomies
一次调用返回账号的完整标签集 — 用实时列表构建路由设置,而不是把常量写死在代码里。
curl https://138.226.222.209/v1/taxonomies \
-H 'Authorization: Bearer cortiq_your_key'
示例响应
{
"schema_version": "1.1",
"taxonomies": [
{
"taxonomy_id": "data-assistant",
"taxonomy_version": "data-assistant@1",
"model_version": "data-assistant@2026.08.02",
"labels": [
"chitchat", "code", "creative-writing",
"extraction", "math", "qa",
"summarization", "translation"
]
}
]
}
/v1/route 的响应中不会出现完整集合(scores 只含前 3 名)— 该端点是完整列表的唯一来源。新增的标签会自动出现在这里。
API 参考
其余端点 — 同一个 Bearer 密钥,同一个基础 URL。
POST /v1/route:batch
批量分类:一次调用多个提示词;结果按 inputs 的顺序返回。
curl https://138.226.222.209/v1/route:batch \ -H 'Authorization: Bearer cortiq_your_key' \ -H 'content-type: application/json' \ -d '{ "taxonomy_id": "data-assistant", "inputs": [ { "text": "Fix this bug" }, { "text": "Переведи: добрый вечер" } ] }' # → { "results": [ { "request_id": …, "decision": { "task_label": "code", … } }, … ] }
POST /v1/feedback
纠正错误分类 — 传入 /v1/route 响应中的 request_id 和正确标签。路由器会从你的纠正中学习。
curl https://138.226.222.209/v1/feedback \ -H 'Authorization: Bearer cortiq_your_key' \ -H 'content-type: application/json' \ -d '{ "request_id": "req_…", "correct_task_label": "math" }' # → { "accepted": true, "message": "…" }
GET /v1/usage
账号用量与限额:计费决策数、oracle 调用数、配额与速率限制。
{
"account": { "id": "acct_…", "billable_decisions": 98, "decision_quota": 0, "rate_per_min": 60 },
"usage": { "cache_hits": 85, "oracle_calls": 58, "escalation_rate": 0.64, … }
}
GET /v1/taxonomies/{id}
按 id 获取单个分类法:版本、模型版本与完整标签列表。
GET /v1/healthz · GET /v1/readyz
存活与就绪检查 — 用于监控,无需鉴权。