Cohere Rerank 4
托管 API多语言免费档
Cohere Rerank 是最早的商用重排序 API 之一,至今仍是部署最广泛的产品之一。当前一代 Rerank 4(2026 年 4 月发布)提供两个版本 —— 偏精度的 rerank-v4.0-pro 与偏吞吐的 rerank-v4.0-fast —— 两者都是 32,000 token 上下文、支持 100+ 语言,接口为简洁的 REST + SDK。
可用模型
| 模型 ID | 语言 | 上下文 | 说明 |
|---|---|---|---|
rerank-v4.0-pro | 100+ 种语言 | 32,000 tokens | 当前旗舰;更高精度的重排序 |
rerank-v4.0-fast | 100+ 种语言 | 32,000 tokens | 更低延迟、更高吞吐 |
rerank-v3.5 | 100+ 种语言 | 4096 tokens/doc | 上一代多语言旗舰 |
默认用 rerank-v4.0-pro。当吞吐或尾延迟比最后一点精度更重要时再换 rerank-v4.0-fast —— 两者价格相差很小(每次检索 $0.0025 对 $0.002),所以该由质量而非成本来决定选型。
价格
| 档位 | 价格 | 限制 |
|---|---|---|
| 免费 | $0 | 每月 1,000 次 API 调用 |
rerank-v4.0-pro | $0.0025 / search | 一次检索 = 1 个 query + 最多 100 篇文档 |
rerank-v4.0-fast | $0.002 / search | 计费单位相同 |
| 企业版 | 定制 | SLA、私有部署选项 |
当前费率请查阅 Cohere 官方价格页 —— 上方数字可能已过时。
快速上手
Python
pip install cohere
import cohere
co = cohere.ClientV2("YOUR_API_KEY")
query = "How do I add reranking to my RAG pipeline?"
documents = [
"Rerankers score each query-passage pair jointly with a cross-encoder.",
"BM25 is a classical keyword-based retrieval method.",
"London is the capital of the United Kingdom.",
"Two-stage retrieval: retrieve 50 candidates, rerank to top 5.",
]
results = co.rerank(
model="rerank-v4.0-pro",
query=query,
documents=documents,
top_n=3,
)
for r in results.results:
print(f"{r.relevance_score:.4f} {documents[r.index][:80]}")
Node.js
import Cohere from "cohere-ai";
const co = new Cohere.Client({ token: "YOUR_API_KEY" });
const result = await co.rerank({
model: "rerank-v4.0-pro",
query: "How do I add reranking to my RAG pipeline?",
documents: ["...", "..."],
topN: 3,
});
result.results.forEach((r) => console.log(r.relevanceScore, documents[r.index]));
REST(curl)
curl https://api.cohere.com/v2/rerank \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "rerank-v4.0-pro",
"query": "How do I add reranking to my RAG pipeline?",
"documents": ["Rerankers score query-passage pairs...", "BM25 is..."],
"top_n": 3
}'
优缺点
优点
- 成熟的生产级 API,带 SLA
- 在 100+ 语言上质量稳定
- SDK 支持:Python、Node、Java、Go、curl
- 适合原型开发的慷慨免费额度
- 32,000 token 上下文窗口
- 简单、可预期的定价
缺点
- 权重闭源 —— 你依赖于 Cohere
- 高流量下按次成本会累积
- (大多数套餐)没有自建部署选项
- 延迟受网络限制(约 100–200 ms)