Skip to main content
cohere-upgrade-migration 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".
Ir para a instalação Skills Marketplace Descubra e explore skills de IA criadas pela comunidade.
Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Copiar promptMostrar detalhes do prompt Um comando direto ignora o prompt de revisão. Verifique a origem antes de executá-lo.
npx skills add https://github.com/jeremylongshore/claude-code-plugins-plus-skills --skill cohere-upgrade-migrationO comando permanece em uma só linha. Role horizontalmente para revisá-lo antes de copiar.
Prefere uma cópia local? Baixe os arquivos disponíveis atualmente no SkillsMP.
Baixar Zip Baixando... Ocupações relacionadas SOC
Baseado na classificação ocupacional SOC
Mais deste repositório Implement user sign-up and sign-in flows with Clerk.
Use when building authentication UI, customizing sign-in experience,
or implementing OAuth social login.
Trigger with phrases like "clerk sign-in", "clerk sign-up",
"clerk login flow", "clerk OAuth", "clerk social login".
Implement session management and middleware with Clerk.
Use when managing user sessions, configuring route protection,
or implementing token refresh and custom JWT templates.
Trigger with phrases like "clerk session", "clerk middleware",
"clerk route protection", "clerk token", "clerk JWT".
Configure enterprise SSO, role-based access control, and organization management.
Use when implementing SSO integration, configuring role-based permissions,
or setting up organization-level controls.
Trigger with phrases like "clerk SSO", "clerk RBAC",
"clerk enterprise", "clerk roles", "clerk permissions", "clerk organizations".
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. ?. ?.[ ]?. );
role
'USER'
message
'Hi'
role
'CHATBOT'
message
'Hello!'
console
log
text
const
await
chat
model
'command-a-03-2025'
messages
role
'system'
content
'You are helpful.'
role
'user'
content
'Hi'
role
'assistant'
content
'Hello!'
role
'user'
content
'Hello'
console
log
message
content
0
text
Role Names v1 v2 USERuserCHATBOTassistantSYSTEMsystemTOOLtool
Embed Endpoint — Required Fields
const response = await cohere.embed ({
texts : ['hello' ],
});
const response = await cohere.embed ({
model : 'embed-v4.0' ,
texts : ['hello' ],
inputType : 'search_document' ,
embeddingTypes : ['float' ],
});
Rerank Endpoint — Model Required
const response = await cohere.rerank ({
query : 'best language' ,
documents : ['Python' , 'Rust' ],
});
const response = await cohere.rerank ({
model : 'rerank-v3.5' ,
query : 'best language' ,
documents : ['Python' , 'Rust' ],
topN : 2 ,
});
Classify Endpoint — Model Required
const response = await cohere.classify ({
inputs : ['great product' ],
examples : [],
});
const response = await cohere.classify ({
model : 'embed-english-v3.0' ,
inputs : ['great product' ],
examples : [],
});
Streaming Changes
const stream = cohere.chatStream ({ message : 'hello' });
for await (const event of stream) {
if (event.eventType === 'text-generation' ) {
process.stdout .write (event.text );
}
}
const stream = await cohere.chatStream ({
model : 'command-a-03-2025' ,
messages : [{ role : 'user' , content : 'hello' }],
});
for await (const event of stream) {
if (event.type === 'content-delta' ) {
process.stdout .write (event.delta ?.message ?.content ?.text ?? '' );
}
}
RAG / Documents
const response = await cohere.chat ({
message : 'question' ,
documents : [{ title : 'Doc' , snippet : 'content' }],
connectors : [{ id : 'web-search' }],
});
const response = await cohere.chat ({
model : 'command-a-03-2025' ,
messages : [{ role : 'user' , content : 'question' }],
documents : [
{ id : 'doc1' , data : { text : 'content' } },
],
});
Tool Use
const tools = [{
name : 'get_weather' ,
description : 'Get weather' ,
parameterDefinitions : {
city : { type : 'str' , required : true },
},
}];
const tools = [{
type : 'function' ,
function : {
name : 'get_weather' ,
description : 'Get weather' ,
parameters : {
type : 'object' ,
properties : { city : { type : 'string' } },
required : ['city' ],
},
},
}];
Step 4: Model Name Updates Old Name Current Name Status commandcommand-r7b-12-2024Use new ID command-rcommand-r-08-2024Use new ID command-r-pluscommand-r-plus-08-2024Use new ID command-nightlycommand-a-03-2025Use Command A embed-english-v3.0embed-v4.0Upgrade recommended rerank-english-v3.0rerank-v3.5Upgrade recommended
Step 5: Python Migration
import cohere
co = cohere.Client(api_key="..." )
response = co.chat(message="hello" )
print (response.text)
import cohere
co = cohere.ClientV2()
response = co.chat(
model="command-a-03-2025" ,
messages=[{"role" : "user" , "content" : "hello" }],
)
print (response.message.content[0 ].text)
Step 6: Run Tests and Verify npm test
git add -A
git commit -m "chore: migrate to Cohere API v2"
Migration Codemod (Find & Replace)
grep -rn "CohereClient\b" src/ --include="*.ts" | grep -v "CohereClientV2"
grep -rn "\.chat({" src/ --include="*.ts" -A2 | grep "message:"
grep -rn "response\.text\b" src/ --include="*.ts"
grep -rn "eventType.*text-generation" src/ --include="*.ts"
Output
Updated SDK to latest version
Migrated all endpoints from v1 to v2 format
Updated model IDs to current names
All tests passing against v2 API
Error Handling Error After Migration Cause Fix model is requiredMissed adding model param Add model to every call response.text is undefinedv1 response shape Use response.message?.content?.[0]?.text embedding_types requiredv2 embed requirement Add embeddingTypes: ['float'] input_type requiredv2 embed requirement Add inputType: 'search_document'
Resources
Next Steps For CI integration during upgrades, see cohere-ci-integration.