cohere-api
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "cohere-api" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-c2d78735794dae93499a08dc70628181f55b6a502775e5305823e572c969a86f. Verify the upstream source and version against https://github.com/TerminalSkills/skills before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
github.com
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Cohere API provides enterprise-grade NLP capabilities including embeddings, reranking, retrieval-augmented generation (RAG), and text generation. It is suited for building RAG pipelines, semantic search, document reranking, and enterprise NLP applications. Command R+ excels at tool calls and RAG; Embed v3 and Rerank 3 lead industry performance for search quality.
Introduction source: third_party · TerminalSkills · 1.0.0 Reference
SkillPi interpretation
- Software, accounts and paid services
- ```bash
- Testing
- Not tested
Browse files
Frontmatter
name: cohere-api
description: >-
Cohere API for enterprise NLP — embeddings, reranking, RAG, and text generation.
Use when building RAG pipelines, semantic search, document reranking, or enterprise
NLP applications. Command R+ excels at tool use and retrieval-augmented generation;
Embed v3 and Rerank 3 are best-in-class for search quality.
license: Apache-2.0
compatibility: "Python 3.9+ or Node.js 18+ with cohere SDK"
metadata:
author: terminal-skills
version: "1.0.0"
category: data-ai
tags: ["cohere", "embeddings", "rerank", "rag", "enterprise-nlp"]
use-cases:
- "Build a semantic search engine with Cohere Embed v3"
- "Improve RAG pipeline accuracy by reranking retrieved documents with Rerank 3"
- "Build an enterprise knowledge base Q&A system with Command R+"
agents: [claude-code, openai-codex, gemini-cli, cursor]Cohere API
Overview
Cohere provides enterprise-grade NLP models purpose-built for production use cases. Their flagship offerings are: Command R+ for RAG and agentic tasks, Embed v3 for state-of-the-art semantic embeddings, and Rerank 3 for dramatically improving search result relevance. All models are available via API with enterprise SLAs and on-premise deployment options.
Setup
# Python
pip install cohere
# TypeScript/Node
npm install cohere-ai
export COHERE_API_KEY=...
Available Models
| Model | Type | Best For |
|---|---|---|
command-r-plus |
Generation | Complex RAG, tool use, long context |
command-r |
Generation | Efficient RAG, cost-effective |
command |
Generation | Simple text tasks |
embed-english-v3.0 |
Embedding | English semantic search |
embed-multilingual-v3.0 |
Embedding | 100+ language search |
rerank-english-v3 |
Reranking | English document reranking |
rerank-multilingual-v3 |
Reranking | Multilingual reranking |
Instructions
Chat / Text Generation
import cohere
co = cohere.ClientV2(api_key="your_api_key") # or reads COHERE_API_KEY
response = co.chat(
model="command-r-plus",
messages=[
{"role": "user", "content": "Explain transformer architecture in plain English."},
],
)
print(response.message.content[0].text)
Document Embeddings
import cohere
co = cohere.ClientV2()
# Embed documents for indexing
docs = [
"Cohere provides enterprise NLP solutions.",
"Embeddings convert text into dense vectors.",
"RAG improves LLM answers with retrieved context.",
]
response = co.embed(
texts=docs,
model="embed-english-v3.0",
input_type="search_document", # "search_document" for indexing
embedding_types=["float"],
)
embeddings = response.embeddings.float_
print(f"Embedding shape: {len(embeddings)} x {len(embeddings[0])}") # 3 x 1024
Query Embeddings for Search
import cohere
import numpy as np
co = cohere.ClientV2()
# Query embedding — use "search_query" for queries
query = "How do embeddings work?"
query_response = co.embed(
texts=[query],
model="embed-english-v3.0",
input_type="search_query", # Different from "search_document"!
embedding_types=["float"],
)
query_vector = query_response.embeddings.float_[0]
# Find most similar documents using cosine similarity
def cosine_similarity(a, b):
return np.dot(a, b) / (np.linalg.norm(a) * np.linalg.norm(b))
# (assuming doc_embeddings is a list of previously embedded documents)
similarities = [cosine_similarity(query_vector, doc_emb) for doc_emb in doc_embeddings]
top_idx = np.argsort(similarities)[::-1][:5]
Reranking for RAG Improvement
import cohere
co = cohere.ClientV2()
query = "What are the benefits of renewable energy?"
# Initial candidates (from vector search or keyword search)
documents = [
"Solar panels convert sunlight into electricity efficiently.",
"Wind energy reduces carbon emissions significantly.",
"The history of fossil fuels dates back centuries.",
"Renewable energy creates jobs in local communities.",
"Nuclear power is debated as a clean energy source.",
"Oil prices fluctuate based on global demand.",
]
rerank_response = co.rerank(
model="rerank-english-v3",
query=query,
documents=documents,
top_n=3, # Return top 3 most relevant
)
for result in rerank_response.results:
print(f"Rank {result.index}: Score {result.relevance_score:.3f}")
print(f" {documents[result.index]}\n")
Command R+ for RAG with Citations
import cohere
co = cohere.ClientV2()
# RAG with grounding documents — Command R+ provides cited responses
documents = [
{"id": "doc1", "data": {"title": "Renewable Energy", "snippet": "Solar energy capacity grew 25% in 2024, reaching 1.5 TW globally."}},
{"id": "doc2", "data": {"title": "Climate Policy", "snippet": "The EU Green Deal targets 55% emissions reduction by 2030."}},
]
response = co.chat(
model="command-r-plus",
messages=[{"role": "user", "content": "What is the current state of renewable energy?"}],
documents=documents,
)
print(response.message.content[0].text)
# Citations reference specific document sources
if hasattr(response.message, "citations") and response.message.citations:
for citation in response.message.citations:
print(f"Citation: {citation}")
Tool Use with Command R+
import cohere
import json
co = cohere.ClientV2()
tools = [
{
"type": "function",
"function": {
"name": "get_stock_price",
"description": "Get the current stock price for a ticker symbol",
"parameters": {
"type": "object",
"properties": {
"ticker": {"type": "string", "description": "Stock ticker (e.g. AAPL)"},
},
"required": ["ticker"],
},
},
}
]
messages = [{"role": "user", "content": "What's the current Apple stock price?"}]
response = co.chat(
model="command-r-plus",
messages=messages,
tools=tools,
)
if response.message.tool_calls:
tool_call = response.message.tool_calls[0]
args = json.loads(tool_call.function.arguments)
print(f"Tool: {tool_call.function.name}, Args: {args}")
# Execute tool and return result
messages.append({"role": "assistant", "tool_calls": response.message.tool_calls})
messages.append({
"role": "tool",
"tool_call_id": tool_call.id,
"content": json.dumps({"price": 189.84, "change": "+1.2%"}),
})
final = co.chat(model="command-r-plus", messages=messages, tools=tools)
print(final.message.content[0].text)
Complete RAG Pipeline
import cohere
import numpy as np
co = cohere.ClientV2()
def build_rag_pipeline(documents: list[str]):
"""Embed a corpus of documents."""
response = co.embed(
texts=documents,
model="embed-english-v3.0",
input_type="search_document",
embedding_types=["float"],
)
return response.embeddings.float_
def retrieve_and_rerank(query: str, documents: list[str], doc_embeddings, top_k=10, top_n=3):
"""Vector search + rerank for best results."""
# Step 1: Embed query
q_resp = co.embed(
texts=[query],
model="embed-english-v3.0",
input_type="search_query",
embedding_types=["float"],
)
q_vec = q_resp.embeddings.float_[0]
# Step 2: Cosine similarity search
sims = [np.dot(q_vec, d) / (np.linalg.norm(q_vec) * np.linalg.norm(d)) for d in doc_embeddings]
candidates_idx = np.argsort(sims)[::-1][:top_k]
candidates = [documents[i] for i in candidates_idx]
# Step 3: Rerank candidates
reranked = co.rerank(
model="rerank-english-v3",
query=query,
documents=candidates,
top_n=top_n,
)
return [candidates[r.index] for r in reranked.results]
def answer_with_rag(query: str, context_docs: list[str]) -> str:
"""Generate answer grounded in retrieved documents."""
docs = [{"data": {"snippet": doc}} for doc in context_docs]
response = co.chat(
model="command-r-plus",
messages=[{"role": "user", "content": query}],
documents=docs,
)
return response.message.content[0].text
Guidelines
- Always use
input_type="search_document"when embedding docs andinput_type="search_query"for queries — this matters for retrieval quality. - Reranking adds ~100ms latency but often improves RAG answer quality by 20–40% vs vector search alone.
- Command R+ is optimized for RAG with grounding documents; use
documentsparameter for best citation quality. - The
embed-multilingual-v3.0model supports 100+ languages with a single model. - Cohere offers on-premise and private cloud deployment for enterprises requiring data isolation.
- For large corpora, use Cohere's batch embedding endpoint to process thousands of documents efficiently.
Current listing version
1.0.0
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 提供企业级 NLP 核心能力(嵌入、重排序、RAG、文本生成),直接解决语义搜索、文档重排序等明确业务痛点
- 覆盖 Command R+、Embed v3、Rerank 3 等主流模型,满足复杂 RAG 流水线构建需求
Highlights
- 触发描述精准覆盖 embeddings、reranking、RAG、semantic search 等核心场景变体
- 边界清晰,明确区分不同模型的最佳使用场景(如 Command R+ 用于复杂 RAG,Embed v3 用于语义搜索)
Highlights
- Phase 划分清晰(Setup/Models/Instructions/Guidelines),含完整端到端 RAG 流水线示例
- frontmatter 完整,单文件结构合理,Guidelines 提供关键最佳实践
Highlights
- 工具来源明确(cohere SDK),参数使用正确(如 input_type 区分 search_document/search_query)
- 覆盖主要异常场景(如 citations 检查、tool_calls 处理),Guidelines 强调关键配置项
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
-
Install or fetch external dependencies
Use official sources and pin versions. Check install scripts in an isolated environment. This document check does not cover code downloaded later.
Mentioned in main document · lines 32, 35 -
Accounts, secrets or authorization
Use a dedicated least-privilege account. Keep secrets out of public content and command logs; verify the receiving service and tenant.
Mentioned in main document · lines 61
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
```bash
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.