Agent skill · Backend & API

api-ai-cohere-sdk

Official Cohere TypeScript SDK patterns -- CohereClientV2, chat, embeddings, rerank, RAG with citations, tool use, streaming, and model selection

majiayu000github.com/majiayu000GitHub ↗
claude-codeMIT
Install
npx skills add majiayu000/claude-skill-registry --skill api-ai-cohere-sdk --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 2
SKILL.md size: 19 KB
Bundled scripts: none
Path: skills/ai-llm/api-ai-cohere-sdk/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 534
Language: HTML

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

Review
written from the skill's own SKILL.md · Aug 5, 2026

What it does

Provides patterns and requirements for using the Cohere TypeScript SDK (CohereClientV2) to build chat, embeddings, rerank, and RAG workflows, including streaming via chatStream and handling tool use loops. Emphasizes correct embedding inputType, model specification on every call, and environment-based token handling.

How it works

  • Recommends initializing CohereClientV2 with a token obtained from environment variables.
  • Describes performing chat with an explicit model, and using chatStream for streaming content-delta events.
  • Requires embedding calls to specify inputType (e.g., search_document for indexing, search_query for querying) and to include embeddingTypes.
  • Explains rerank usage: provide a query and documents, and receive ordered results with relevance scores.
  • Describes passing documents to chat() for RAG with inline citations, and conducting a 4-step tool use loop: user message, model returns tool_calls, execute tools, then return results with matching tool_call_id.
  • Covers error handling with CohereError and CohereTimeoutError, including status codes and body for API errors.
  • Outlines model selection guidance and performance tips (batch embeddings, topN usage, finish_reason checks).

When to use it

  • Building Cohere Command model applications (chat, generation, summarization)
  • Creating semantic search pipelines with Cohere embeddings
  • Adding relevance scoring to search results with Cohere Rerank
  • Implementing RAG with inline citations
  • Building agentic workflows with tool use / function calling
  • Streaming chat responses for real-time UIs

What it can touch

  • Client initialization: CohereClientV2
  • Chat, chatStream, embeddings via embed, rerank, and chat with documents
  • Tools definitions for function calling within the 4-step loop
  • Error handling blocks using CohereError and CohereTimeoutError

Caveats

  • Requires explicitly using CohereClientV2 for all new code; V1 is legacy
  • Embeddings must specify inputType on every call to avoid garbage results
  • Do not hardcode API keys; use token from environment variables
  • Finish reasons must be checked to detect MAX_TOKENS truncation
From the SKILL.md

# Cohere SDK Patterns > **Quick Guide:** Use the `cohere-ai` npm package with `CohereClientV2` for all new Cohere integrations. V2 API requires `model` on every call. Use `chatStream` for streaming with `content-delta` events. Embeddings require `inputType` matching your use case (`search_document` for indexing, `search_query` for querying). Rerank scores documents by relevance. RAG works by passing `documents` to `chat()` -- the model returns inline citations automatically. Tool use follows a 4-step loop: user message, model returns `tool_calls`, you execute and return results, model generates cited response. --- <critical_requirements> ## CRITICAL: Before Using This Skill > **All code must follow project conventions in CLAUDE.md** (kebab-case, named exports, import ordering, `import type`, named constants) **(You MUST use `CohereClientV2` (not `CohereClient`) for all new code -- V2 is the current API with required `model` parameter)** **(You MUST specify `inputType` on every embed call -- `search_document` for indexing, `search_query` for querying -- mismatched types produce garbage similarity scores)** **(You MUST handle the tool use loop correctly: append the full assistant mes

What's inside
Steps it walks through
  1. CRITICAL: Before Using This Skill
  2. Examples Index
  3. Philosophy
  4. Core Patterns
  5. Pattern 1: Client Setup
  6. Pattern 2: Chat Completion
  7. Pattern 3: Streaming
  8. Pattern 4: Embeddings
  9. Pattern 5: Rerank
  10. Pattern 6: RAG with Documents
  11. Pattern 7: Tool Use / Function Calling
  12. Pattern 8: Error Handling
  13. Performance Optimization
  14. Model Selection for Cost/Speed
Ships with 1 file
  • metadata.json
More from claude-skill-registry
All skills →
About this skill
What does the api-ai-cohere-sdk skill do?

Official Cohere TypeScript SDK patterns -- CohereClientV2, chat, embeddings, rerank, RAG with citations, tool use, streaming, and model selection

How do I install it?

Run `npx skills add majiayu000/claude-skill-registry --skill api-ai-cohere-sdk --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going