cohere-sdk-patterns

Featured

Apply production-ready Cohere SDK patterns for TypeScript and Python. Use when implementing Cohere integrations, refactoring SDK usage, or establishing team coding standards for Cohere API v2. Trigger with phrases like "cohere SDK patterns", "cohere best practices", "cohere code patterns", "idiomatic cohere", "cohere wrapper".

AI & Automation 2,926 stars 433 forks Updated yesterday MIT

Install

View on GitHub

Quality Score: 99/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Cohere SDK Patterns ## Overview Production-ready patterns for the `cohere-ai` TypeScript SDK (CohereClientV2) and Python `cohere` package. Real model names, real API shapes, real error types. ## Prerequisites - `cohere-ai` v7+ installed (TypeScript) or `cohere` v5+ (Python) - Familiarity with async/await patterns - Understanding of Cohere API v2 endpoints ## Instructions ### Pattern 1: Singleton Client with Retry ```typescript // src/cohere/client.ts import { CohereClientV2, CohereError, CohereTimeoutError } from 'cohere-ai'; let instance: CohereClientV2 | null = null; export function getCohere(): CohereClientV2 { if (!instance) { if (!process.env.CO_API_KEY) { throw new Error('CO_API_KEY environment variable is required'); } instance = new CohereClientV2({ token: process.env.CO_API_KEY, }); } return instance; } export async function withRetry<T>( operation: () => Promise<T>, maxRetries = 3, baseDelayMs = 1000 ): Promise<T> { for (let attempt = 1; attempt <= maxRetries; attempt++) { try { return await operation(); } catch (err) { if (attempt === maxRetries) throw err; // Only retry on rate limits (429) and server errors (5xx) if (err instanceof CohereError) { const status = err.statusCode; if (status && status !== 429 && status < 500) throw err; } else if (!(err instanceof CohereTimeoutError)) { throw err; } const delay = baseDelayMs * Math.pow(2, at...

Details

Author
jeremylongshore
Repository
jeremylongshore/claude-code-plugins-plus-skills
Created
1 years ago
Last Updated
yesterday
Language
Python
License
MIT

Integrates with

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category