jpskill.com
🛠️ 開発・MCP コミュニティ

cohere-api

企業の自然言語処理向けCohere APIを活用し、埋め込みやランキング、RAG、テキスト生成を行い、RAGパイプライン構築、セマンティック検索、ドキュメントの再ランキング、企業向けNLPアプリケーション開発を支援するSkill。

📜 元の英語説明(参考)

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.

🇯🇵 日本人クリエイター向け解説

一言でいうと

企業の自然言語処理向けCohere APIを活用し、埋め込みやランキング、RAG、テキスト生成を行い、RAGパイプライン構築、セマンティック検索、ドキュメントの再ランキング、企業向けNLPアプリケーション開発を支援するSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o cohere-api.zip https://jpskill.com/download/14769.zip && unzip -o cohere-api.zip && rm cohere-api.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/14769.zip -OutFile "$d\cohere-api.zip"; Expand-Archive "$d\cohere-api.zip" -DestinationPath $d -Force; ri "$d\cohere-api.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して cohere-api.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → cohere-api フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

Cohere API

概要

Cohere は、本番環境での利用を目的として構築されたエンタープライズグレードの NLP モデルを提供します。その主要な製品は、RAG およびエージェントタスク向けの Command R+、最先端のセマンティック埋め込み向けの Embed v3、および検索結果の関連性を劇的に向上させる Rerank 3 です。すべてのモデルは、エンタープライズ SLA とオンプレミス展開オプションを備えた API 経由で利用できます。

セットアップ

# Python
pip install cohere

# TypeScript/Node
npm install cohere-ai
export COHERE_API_KEY=...

利用可能なモデル

モデル タイプ 最適な用途
command-r-plus 生成 複雑な RAG、ツール利用、長いコンテキスト
command-r 生成 効率的な RAG、費用対効果が高い
command 生成 簡単なテキストタスク
embed-english-v3.0 埋め込み 英語のセマンティック検索
embed-multilingual-v3.0 埋め込み 100 以上の言語の検索
rerank-english-v3 リランキング 英語のドキュメントのリランキング
rerank-multilingual-v3 リランキング 多言語のリランキング

指示

チャット / テキスト生成

import cohere

co = cohere.ClientV2(api_key="your_api_key")  # または 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)

ドキュメントの埋め込み

import cohere

co = cohere.ClientV2()

# インデックス作成のためにドキュメントを埋め込む
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"
    embedding_types=["float"],
)

embeddings = response.embeddings.float_
print(f"Embedding shape: {len(embeddings)} x {len(embeddings[0])}")  # 3 x 1024

検索のためのクエリ埋め込み

import cohere
import numpy as np

co = cohere.ClientV2()

# クエリ埋め込み — クエリには "search_query" を使用
query = "How do embeddings work?"

query_response = co.embed(
    texts=[query],
    model="embed-english-v3.0",
    input_type="search_query",  # "search_document" とは異なる!
    embedding_types=["float"],
)

query_vector = query_response.embeddings.float_[0]

# コサイン類似度を使用して最も類似したドキュメントを見つける
def cosine_similarity(a, b):
    return np.dot(a, b) / (np.linalg.norm(a) * np.linalg.norm(b))

# (doc_embeddings は以前に埋め込まれたドキュメントのリストであると仮定)
similarities = [cosine_similarity(query_vector, doc_emb) for doc_emb in doc_embeddings]
top_idx = np.argsort(similarities)[::-1][:5]

RAG 改善のためのリランキング

import cohere

co = cohere.ClientV2()

query = "What are the benefits of renewable energy?"

# 初期候補 (ベクトル検索またはキーワード検索から)
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,  # 上位 3 件の最も関連性の高いものを返す
)

for result in rerank_response.results:
    print(f"Rank {result.index}: Score {result.relevance_score:.3f}")
    print(f"  {documents[result.index]}\n")

引用付き RAG のための Command R+

import cohere

co = cohere.ClientV2()

# グラウンディングドキュメントを使用した RAG — Command R+ は引用された応答を提供します
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)

# 引用は特定のドキュメントソースを参照します
if hasattr(response.message, "citations") and response.message.citations:
    for citation in response.message.citations:
        print(f"Citation: {citation}")

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}")

    # ツールを実行して結果を返す
    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)

完全な RAG パイプライン

import cohere
import numpy as np

co = cohere.ClientV2()

def build_rag_pipeline(documents: list[str]):
    """ドキュメントのコーパスを埋め込む。"""
    response = co.embe
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

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 and input_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 documents parameter for best citation quality.
  • The embed-multilingual-v3.0 model 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.