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".
설치로 이동 Skills Marketplace 커뮤니티가 만든 AI 스킬을 발견하고 탐색하세요.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/jeremylongshore/claude-code-plugins-plus-skills --skill cohere-upgrade-migration명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
Zip 다운로드 다운로드 중... 이 저장소의 다른 Skills 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".
jeremylongshore
jeremylongshore/claude-code-plugins-plus-skills
GitHub 저장소 열기 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.