| name | cohere-upgrade-migration |
| description | Migrate from Cohere API v1 to v2 and upgrade SDK versions.
Use when upgrading cohere-ai SDK, migrating from CohereClient to CohereClientV2,
or handling breaking changes between API versions.
Trigger with phrases like "upgrade cohere", "cohere migration",
"cohere v1 to v2", "update cohere SDK", "cohere breaking changes".
|
| allowed-tools | Read, Write, Edit, Bash(npm:*), Bash(git:*) |
| version | 1.5.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","ai","nlp","cohere"] |
| compatibility | Designed for Claude Code |
Cohere Upgrade & Migration
Overview
Guide for migrating from Cohere API v1 to v2 and upgrading the cohere-ai TypeScript / cohere Python SDK. Covers every breaking change with before/after code.
Prerequisites
- Current Cohere SDK installed
- Git for version control
- Test suite available
Instructions
Step 1: Check Current Version
npm list cohere-ai
pip show cohere
npm view cohere-ai version
pip index versions cohere
Step 2: Create Upgrade Branch
git checkout -b upgrade/cohere-v2-migration
npm install cohere-ai@latest
Step 3: API v1 to v2 Breaking Changes
Client Import
import { CohereClient } from 'cohere-ai';
const cohere = new CohereClient({ token: '...' });
import { CohereClientV2 } from 'cohere-ai';
const cohere = new CohereClientV2({ token: '...' });
Chat Endpoint — Messages Format
const response = await cohere.chat({
message: 'Hello',
preamble: 'You are helpful.',
chatHistory: [
{ : , : },
{ : , : },
],
});
.(response.);
response = cohere.({
: ,
: [
{ : , : },
{ : , : },
{ : , : },
{ : , : },
],
});
.(response.?.?.[]?.);