docs: clarify v2 usage for reasoning models - #290
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refines the README to reduce ambiguity around “reasoning model” usage by steering developers toward the v2 chat flow (CohereClientV2 / v2/chat) while clarifying that CohereClient remains compatible with the legacy v1/chat endpoint.
Changes:
- Reworded introductory and streaming documentation for clarity and consistency.
- Added explicit guidance recommending v2 usage for reasoning models and describing v1 backward compatibility.
- Updated code examples to use consistent TypeScript formatting and a v2-oriented Errors example.
Comments suppressed due to low confidence (2)
README.md:28
- The v2 usage example initializes
CohereClientV2with{}but the client requires auth viatokenor theCO_API_KEYenv var; without either, requests will throw an auth configuration error. Consider addingtoken: "YOUR_API_KEY"here or explicitly noting thatCO_API_KEYmust be set for this snippet to work as-written.
```typescript
import { CohereClientV2 } from "cohere-ai";
const cohere = new CohereClientV2({});
README.md:52
- Same as the main usage snippet:
new CohereClientV2({})will fail unlesstokenis provided orCO_API_KEYis set in the environment. Updating the streaming example to include auth (or a note aboutCO_API_KEY) would prevent copy/paste failures.
```typescript
import { CohereClientV2 } from "cohere-ai";
const cohere = new CohereClientV2({});
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| When the API returns a non-success status code (4xx or 5xx response), | ||
| a subclass of [CohereError](./src/errors/CohereError.ts) will be thrown: | ||
| a subclass of [CohereError](./src/errors/CohereError.ts) is thrown. | ||
|
|
||
| ```TypeScript | ||
| ```typescript | ||
| import { CohereClientV2, CohereError, CohereTimeoutError } from "cohere-ai"; | ||
|
|
There was a problem hiding this comment.
The Errors section text says "When the API returns a non-success status code ... a subclass of CohereError is thrown", but timeouts and some non-HTTP failures throw CohereTimeoutError (not a CohereError) and the example explicitly handles it. Please update this wording to reflect both HTTP status-code errors (CohereError subclasses) and non-status failures like timeouts (CohereTimeoutError).
There was a problem hiding this comment.
When the API returns a non-success status code, a subclass of CohereError is thrown. For non-HTTP failures, such as request timeouts, the SDK throws a CohereTimeoutError
Description
Summary
This PR improves README guidance for reasoning model usage with the V2 chat flow, while also clarifying legacy compatibility behavior.
Changes
Why is this needed?
Previously, usage guidance could be interpreted ambiguously for reasoning model workflows. This update reduces confusion and helps developers choose the correct client/endpoint path.
Validation
Checklist
Note
Low Risk
Documentation-only updates that clarify which client/endpoint to use; no runtime behavior changes.
Overview
Updates the README to explicitly recommend
CohereClientV2/v2/chatfor reasoning-capable chat, while clarifying thatCohereClientremains backward compatible with the legacyv1/chatendpoint.Also refreshes wording and examples for consistency (install command, code style, streaming and error-handling snippets) without changing SDK behavior.
Reviewed by Cursor Bugbot for commit e6d2428. Bugbot is set up for automated code reviews on this repo. Configure here.