ai-provider-cohere-sdk
Cohere SDK Patterns
Quick Guide: Use the
cohere-ainpm package withCohereClientV2for all new Cohere integrations. V2 API requiresmodelon every call. UsechatStreamfor streaming withcontent-deltaevents. Embeddings requireinputTypematching your use case (search_documentfor indexing,search_queryfor querying). Rerank scores documents by relevance. RAG works by passingdocumentstochat()-- the model returns inline citations automatically. Tool use follows a 4-step loop: user message, model returnstool_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 message (with tool_calls) to messages, then append tool role results with matching tool_call_id)
(You MUST check finish_reason in responses -- MAX_TOKENS means the output was truncated)
More from agents-inc/skills
web-animation-css-animations
CSS Animation patterns - transitions, keyframes, scroll-driven animations, @property, GPU-accelerated properties, accessibility with prefers-reduced-motion
24web-animation-view-transitions
View Transitions API patterns - same-document transitions, cross-document MPA transitions, shared element animations, pseudo-element styling, accessibility
21web-testing-playwright-e2e
Playwright E2E testing patterns - test structure, Page Object Model, locator strategies, assertions, network mocking, visual regression, parallel execution, fixtures, and configuration
21web-styling-cva
Class Variance Authority - type-safe component variant styling with cva(), compound variants, and VariantProps
20web-animation-framer-motion
Motion (formerly Framer Motion) animation patterns - motion components, variants, gestures, layout animations, scroll-linked animations, accessibility
20web-i18n-next-intl
Type-safe i18n for Next.js App Router
19