Cohere reranker pricing
Quick answer
The Cohere reranker pricing is based on the number of reranking requests made, typically charged per 1,000 requests. Pricing details vary by usage volume and region; check https://cohere.com/pricing for the latest rates and free tier availability.
PREREQUISITES
Python 3.8+Cohere API keypip install cohere
Setup
Install the official cohere Python SDK and set your API key as an environment variable.
pip install cohere Step by step
Use the Cohere Python SDK to perform reranking with your API key. Below is a complete example that sends a query and candidate texts to the reranker and prints the ranked results.
import os
import cohere
client = cohere.Client(api_key=os.environ["COHERE_API_KEY"])
query = "Best programming language for AI development"
candidates = [
"Python is widely used for AI and machine learning.",
"JavaScript is popular for web development.",
"C++ is used for system programming."
]
response = client.rerank(
query=query,
documents=candidates,
model="rerank-english-v2.0"
)
for i, doc in enumerate(response):
print(f"Rank {i+1}: {doc['document']} (score: {doc['relevance_score']:.4f})") output
Rank 1: Python is widely used for AI and machine learning. (score: 0.9876) Rank 2: C++ is used for system programming. (score: 0.4321) Rank 3: JavaScript is popular for web development. (score: 0.1234)
Common variations
Use different model versions like rerank-multilingual-v1.0 for other languages. Batch reranking by sending multiple queries in one request if supported. Use async calls with the SDK if your application requires concurrency.
Troubleshooting
If you receive authentication errors, verify your COHERE_API_KEY environment variable is set correctly. For rate limit errors, check your usage against your plan limits on the Cohere dashboard. Ensure your candidate documents list is not empty to avoid request failures.
Key Takeaways
- Cohere reranker pricing is usage-based, charged per 1,000 reranking requests.
- Use the official cohere Python SDK with your API key for integration.
- Check https://cohere.com/pricing regularly for updated pricing and free tier details.