Skip to content

fix: bind ClientV2 legacy methods to v1 client - #297

Open
euisuh wants to merge 1 commit into
cohere-ai:mainfrom
euisuh:fix-clientv2-legacy-method-bindings
Open

fix: bind ClientV2 legacy methods to v1 client#297
euisuh wants to merge 1 commit into
cohere-ai:mainfrom
euisuh:fix-clientv2-legacy-method-bindings

Conversation

@euisuh

@euisuh euisuh commented Jul 24, 2026

Copy link
Copy Markdown

Summary

Fix CohereClientV2 legacy v1 endpoint methods so they are bound to the internal CohereClient instance instead of the V2Client instance.

CohereClientV2 exposes v2 methods through V2Client, but also keeps legacy v1 methods such as generate, classify, summarize, tokenize, detokenize, and checkApiKey by delegating to an internal v1 CohereClient. Those delegated methods need the v1 client as this; binding them to clientV2 can break legacy calls because the v2 client does not own the v1 request helpers/state.

This adds regression coverage that CohereClientV2.generate() routes through the v1 /v1/generate endpoint and sends the expected request body.

Test Plan

  • pnpm exec vitest src/test/client.test.ts --run
  • pnpm build
  • pnpm check src/ClientV2.ts src/test/client.test.ts
  • git diff --check

Note

Medium Risk
Fixes runtime behavior for all legacy v1 methods on CohereClientV2; incorrect binding could have caused subtle failures in production SDK usage.

Overview
Fixes incorrect this binding on CohereClientV2 legacy v1 APIs (generate, generateStream, classify, summarize, tokenize, detokenize, checkApiKey). Those methods were bound to the internal V2Client instead of the v1 CohereClient, which could break calls that rely on v1 request helpers and routing.

Legacy calls now delegate to the v1 client with the correct binding so requests hit v1 paths (e.g. /v1/generate) as intended.

Adds a regression test that CohereClientV2.generate() targets https://api.cohere.com/v1/generate with the expected body. Minor cleanup: type-only core import and formatting in ClientV2.ts / existing tests.

Reviewed by Cursor Bugbot for commit dd4ada0. Bugbot is set up for automated code reviews on this repo. Configure here.

CohereClientV2 exposes legacy v1 endpoints through an internal CohereClient, so bind those methods to that client instance instead of the V2 client. Add regression coverage for generate routing to the v1 endpoint.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant