Skip to content

Conversation

@HavenDV
Copy link
Contributor

@HavenDV HavenDV commented Sep 19, 2025

Summary by CodeRabbit

  • Documentation
    • Marked multiple API endpoints and parameters as deprecated in the OpenAPI specification.
    • Annotated several operations with deprecation following 504 Gateway Timeout responses.
    • Updated Images examples for TypeScript, Python, Java, and Go to use the newer client pattern and clarified that image_url accepts a base64 data URI or a web URL.
    • Updated Go/TypeScript snippets with new client initialization syntax.
    • Curl example remains unchanged.

@coderabbitai
Copy link

coderabbitai bot commented Sep 19, 2025

Walkthrough

Adds deprecated: true flags to multiple OpenAPI paths, operations, and a parameter (search_queries_only). Updates embedded multi-language Images examples to a newer client pattern and clarifies image_url may be base64 data URI or web URL. Curl example remains unchanged. No public API signatures were altered.

Changes

Cohort / File(s) Summary
API deprecation annotations
src/libs/Cohere/openapi.yaml
Marked numerous operations and a parameter as deprecated (including search_queries_only). Several paths now explicitly set deprecated: true, often alongside 504 GatewayTimeout sections.
Example code updates (Images)
src/libs/Cohere/openapi.yaml
Revised embedded examples: TS switches to CohereClientV2 and new init syntax; Python/Java/Go add clarifying comment on image_url (base64 data URI or web URL). Curl example unchanged.

Sequence Diagram(s)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • github-actions

Poem

Thump-thump goes my reviewer’s heart,
Deprecated lanes now marked apart.
Images speak in base64 hues,
Or hop to URLs with clarifying cues.
One file garden, neatly trimmed—
Specs align, examples primmed.
Carrot-stamp: approved, I’m whimsically brimmed! 🥕🐇

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title Check ⚠️ Warning The title "feat:@coderabbitai" does not describe the changes in this PR; the diff updates src/libs/Cohere/openapi.yaml to mark many endpoints deprecated and refresh Images sample code across multiple languages, but the title gives no indication of that and reads like an unrelated mention. Because it fails to summarize the primary change concisely, it does not meet the PR title criteria. Please rename the PR to a short, descriptive title (for example: "chore(openapi): mark multiple endpoints deprecated and update Images examples" or "docs(openapi): deprecate search endpoints and refresh sample client usage"), reference the primary file (src/libs/Cohere/openapi.yaml), and remove the @mention; then update the PR description if necessary.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bot/update-openapi_202509192117

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@HavenDV HavenDV enabled auto-merge (squash) September 19, 2025 21:18
@coderabbitai coderabbitai bot changed the title feat:@coderabbitai feat:Add OpenAPI deprecations; update Images examples; clarify image_url Sep 19, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (9)
src/libs/Cohere/openapi.yaml (9)

168-174: Parameter deprecation needs migration guidance and timeline.

Deprecating search_queries_only without a replacement path leads to SDK friction. Add a reason, migration target, and (if known) sunset.

 search_queries_only:
   type: boolean
   description: "Defaults to `false`. …"
   deprecated: true
+  x-deprecation-reason: "Use <new parameter/flow> to request search query generation."
+  x-replaced-by: "<replacement_param_or_feature>"
+  x-sunset: "TBD"
   x-fern-audiences:
     - public

1128-1134: Add deprecation rationale and replacement for this operation as well.

Same feedback as hunk above; include x-deprecation-reason/x-replaced-by/x-sunset to guide SDK users.

 deprecated: true
+x-deprecation-reason: "Replaced by /v2/<new-path>."
+x-replaced-by: "/v2/<new-path>"
+x-sunset: "TBD"

1198-1204: Operation deprecation metadata missing.

Provide replacement and timeline to prevent client dead-ends.

 deprecated: true
+x-deprecation-reason: "Replaced by /v2/<new-path>."
+x-replaced-by: "/v2/<new-path>"
+x-sunset: "TBD"

1271-1277: Same: please include replacement and sunset.

 deprecated: true
+x-deprecation-reason: "Replaced by /v2/<new-path>."
+x-replaced-by: "/v2/<new-path>"
+x-sunset: "TBD"

1343-1349: Same: deprecation without migration path.

 deprecated: true
+x-deprecation-reason: "Replaced by /v2/<new-path>."
+x-replaced-by: "/v2/<new-path>"
+x-sunset: "TBD"

1421-1427: Same: add deprecation guidance.

 deprecated: true
+x-deprecation-reason: "Replaced by /v2/<new-path>."
+x-replaced-by: "/v2/<new-path>"
+x-sunset: "TBD"

1501-1507: Same: deprecation metadata is missing.

 deprecated: true
+x-deprecation-reason: "Replaced by /v2/<new-path>."
+x-replaced-by: "/v2/<new-path>"
+x-sunset: "TBD"

6623-6629: Same: please include replacement info and sunset.

 deprecated: true
+x-deprecation-reason: "Replaced by /v2/<new-path>."
+x-replaced-by: "/v2/<new-path>"
+x-sunset: "TBD"

7178-7184: Same: add migration guidance.

 deprecated: true
+x-deprecation-reason: "Replaced by /v2/<new-path>."
+x-replaced-by: "/v2/<new-path>"
+x-sunset: "TBD"
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 111c2a6 and fa647b5.

⛔ Files ignored due to path filters (21)
  • src/libs/Cohere/Generated/Cohere.CohereClient.Chat.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.CohereClient.Classify.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.CohereClient.Generate.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.CohereClient.Summarize.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.ConnectorsClient.CreateConnector.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.ConnectorsClient.DeleteConnector.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.ConnectorsClient.GetConnector.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.ConnectorsClient.ListConnectors.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.ConnectorsClient.OAuthAuthorizeConnector.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.ConnectorsClient.UpdateConnector.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.ICohereClient.Chat.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.ICohereClient.Classify.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.ICohereClient.Generate.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.ICohereClient.Summarize.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.IConnectorsClient.CreateConnector.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.IConnectorsClient.DeleteConnector.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.IConnectorsClient.GetConnector.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.IConnectorsClient.ListConnectors.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.IConnectorsClient.OAuthAuthorizeConnector.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.IConnectorsClient.UpdateConnector.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.ChatRequest.g.cs is excluded by !**/generated/**
📒 Files selected for processing (1)
  • src/libs/Cohere/openapi.yaml (12 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Test / Build, test and publish
🔇 Additional comments (1)
src/libs/Cohere/openapi.yaml (1)

1004-1010: Add deprecation metadata and link a replacement + sunset

  • Marking the operation deprecated is fine; add explicit replacement guidance and a sunset date so clients can migrate (use x-deprecation-reason, x-replaced-by, x-sunset).
  • I checked the spec: v2 alternatives exist for common v1 endpoints (e.g. chat → chatv2, embed → embedv2, rerank → rerankv2). Set x-replaced-by to the exact /v2 path and confirm the original operationId remains (or document SDK break).
 deprecated: true
+x-deprecation-reason: "Replaced by /v2/<new-path>."
+x-replaced-by: "/v2/<new-path>"
+x-sunset: "TBD"

Comment on lines 63 to 69
items:
$ref: '#/components/schemas/ChatConnector'
description: "Accepts `{\"id\": \"web-search\"}`, and/or the `\"id\"` for a custom [connector](https://docs.cohere.com/docs/connectors), if you've [created](https://docs.cohere.com/v1/docs/creating-and-deploying-a-connector) one.\n\nWhen specified, the model's reply will be enriched with information found by querying each of the connectors (RAG).\n\nCompatible Deployments: Cohere Platform\n"
deprecated: true
x-fern-audiences:
- public
conversation_id:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

🧩 Analysis chain

Scope and placement of deprecation under items is likely ineffective (and may be invalid on OAS 3.0).

You added deprecated: true under items while items also uses $ref. Many generators ignore sibling keys with $ref, and in OAS 3.0 siblings are invalid. If the intent is to deprecate the parameter (or the referenced schema), place deprecated at the parameter object level or on components/schemas/ChatConnector instead. Also clarify whether you’re deprecating the entire connectors parameter vs. only the "web-search" connector id.

Proposed fixes (choose one):

Option A — deprecate the parameter (preferred if the whole param is going away):

 items:
   $ref: '#/components/schemas/ChatConnector'
-  description: "Accepts {\"id\": \"web-search\"} ... "
-  deprecated: true
+description: "Accepts {\"id\": \"web-search\"} ... "
+deprecated: true
 x-fern-audiences:
   - public

Option B — deprecate the schema (if only the ChatConnector type is being retired):

 components:
   schemas:
     ChatConnector:
+      deprecated: true

Option C — if only specific connector ids like "web-search" are deprecated, prefer documenting a replacement and timeline via extension:

 description: "…"
+x-deprecation-reason: "The web-search connector is deprecated; migrate to <replacement>."
+x-sunset: "TBD"

Run to confirm OAS version and sibling usage:


🏁 Script executed:

#!/bin/bash
set -euo pipefail
echo "OpenAPI version:"
rg -n '^openapi:\s*' src/libs/Cohere/openapi.yaml -n
echo -e "\nChatConnector items block with context:"
rg -n -C3 "ChatConnector" src/libs/Cohere/openapi.yaml

Length of output: 11845


Move deprecated out of items — OpenAPI 3.0 forbids $ref siblings (openapi: 3.0.4)

openapi: 3.0.4 confirmed; src/libs/Cohere/openapi.yaml lines 63–66 show an items block with a $ref and a sibling deprecated: true — this is invalid/ignored by OAS 3.0 generators. Fix by removing the sibling and placing deprecation where it belongs:

  • Option A — preferred (deprecate the parameter):
 items:
   $ref: '#/components/schemas/ChatConnector'
-  description: "Accepts {\"id\": \"web-search\"} ... "
-  deprecated: true
+description: "Accepts {\"id\": \"web-search\"} ... "
+deprecated: true
 x-fern-audiences:
   - public
  • Option B — deprecate the schema (if the type is being retired):
 components:
   schemas:
     ChatConnector:
+      deprecated: true
  • Option C — if only specific connector ids (e.g. "web-search") are deprecated, document via extensions:
 description: "…"
+x-deprecation-reason: "The web-search connector is deprecated; migrate to <replacement>."
+x-sunset: "TBD"

File: src/libs/Cohere/openapi.yaml, lines ~63–66.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
items:
$ref: '#/components/schemas/ChatConnector'
description: "Accepts `{\"id\": \"web-search\"}`, and/or the `\"id\"` for a custom [connector](https://docs.cohere.com/docs/connectors), if you've [created](https://docs.cohere.com/v1/docs/creating-and-deploying-a-connector) one.\n\nWhen specified, the model's reply will be enriched with information found by querying each of the connectors (RAG).\n\nCompatible Deployments: Cohere Platform\n"
deprecated: true
x-fern-audiences:
- public
conversation_id:
description: "Accepts {\"id\": \"web-search\"} ... "
deprecated: true
schema:
type: array
items:
$ref: '#/components/schemas/ChatConnector'
x-fern-audiences:
- public
🤖 Prompt for AI Agents
In src/libs/Cohere/openapi.yaml around lines 63–69, there is an items block that
uses a $ref and also includes a sibling deprecated: true which is invalid in
OpenAPI 3.0; remove the deprecated sibling from the items/$ref node and instead
mark deprecation where allowed — e.g., set deprecated: true on the parameter
object that uses this schema (preferred), or mark the referenced schema
component as deprecated: true if the whole type is retired, or if only specific
enum values are deprecated document them via an extension (e.g.,
x-deprecated-values) and update any docs/comments accordingly.

Comment on lines 8772 to 8787
type: message-end
event: message-end
- code-samples:
- code: "const { CohereClientV2 } = require('cohere-ai');\n\nconst cohere = new CohereClientV2({});\n\n(async () => {\n const response = await cohere.chat({\n model: 'command-a-vision-07-2025',\n messages: [\n {\n role: 'user',\n content: [\n { type: 'text', text: 'Describe the logo!' },\n {\n type: 'image_url',\n imageUrl: {\n url: 'https://cohere.com/favicon-32x32.png',\n detail: 'auto',\n },\n },\n ],\n },\n ],\n });\n console.log(response.message.content[0].text);\n})();\n"
- code: "const { CohereClientV2 } = require('cohere-ai');\n\nconst cohere = new CohereClientV2({});\n\n(async () => {\n const response = await cohere.chat({\n model: 'command-a-vision-07-2025',\n messages: [\n {\n role: 'user',\n content: [\n { type: 'text', text: 'Describe the logo!' },\n {\n type: 'image_url',\n imageUrl: {\n // Can be either a base64 data URI or a web URL.\n url: 'https://cohere.com/favicon-32x32.png',\n detail: 'auto',\n },\n },\n ],\n },\n ],\n });\n console.log(response.message.content[0].text);\n})();\n"
name: Images
sdk: typescript
- code: "import cohere\n\nco = cohere.ClientV2()\n\nresponse = co.chat(\n model=\"command-a-vision-07-2025\",\n messages=[\n {\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": \"Describe the logo!\"\n },\n {\n \"type\": \"image_url\",\n \"image_url\": {\n \"url\": \"https://cohere.com/favicon-32x32.png\",\n \"detail\": \"auto\"\n }\n }\n ]\n \n }\n ]\n)\n\nprint(response)"
- code: "import cohere\n\nco = cohere.ClientV2()\n\nresponse = co.chat(\n model=\"command-a-vision-07-2025\",\n messages=[\n {\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": \"Describe the logo!\"\n },\n {\n \"type\": \"image_url\",\n \"image_url\": {\n # Can be either a base64 data URI or a web URL.\n \"url\": \"https://cohere.com/favicon-32x32.png\",\n \"detail\": \"auto\"\n }\n }\n ]\n \n }\n ]\n)\n\nprint(response)"
name: Images
sdk: python
- code: "/* (C)2024 */\npackage chatv2post;\n\nimport java.util.List;\n\nimport com.cohere.api.Cohere;\nimport com.cohere.api.resources.v2.requests.V2ChatRequest;\nimport com.cohere.api.types.ChatMessageV2;\nimport com.cohere.api.types.ChatResponse;\nimport com.cohere.api.types.Content;\nimport com.cohere.api.types.ImageContent;\nimport com.cohere.api.types.ImageUrl;\nimport com.cohere.api.types.TextContent;\nimport com.cohere.api.types.UserMessage;\nimport com.cohere.api.types.UserMessageContent;\n\npublic class Image {\n\n public static void main(String[] args) {\n Cohere cohere = Cohere.builder().clientName(\"snippet\").build();\n\n ChatResponse response\n = cohere\n .v2()\n .chat(\n V2ChatRequest.builder()\n .model(\"command-a-vision-07-2025\")\n .messages(\n List.of(\n ChatMessageV2.user(\n UserMessage.builder()\n .content(\n UserMessageContent.of(\n List.of(\n Content.text(\n TextContent.builder()\n .text(\"Describe the logo!\")\n .build()),\n Content.imageUrl(\n ImageContent.builder()\n .imageUrl(\n ImageUrl.builder()\n .url(\n \"https://cohere.com/favicon-32x32.png\")\n .build())\n .build()))))\n .build())))\n .build());\n System.out.println(response);\n }\n}\n"
- code: "/* (C)2024 */\npackage chatv2post;\n\nimport java.util.List;\n\nimport com.cohere.api.Cohere;\nimport com.cohere.api.resources.v2.requests.V2ChatRequest;\nimport com.cohere.api.types.ChatMessageV2;\nimport com.cohere.api.types.ChatResponse;\nimport com.cohere.api.types.Content;\nimport com.cohere.api.types.ImageContent;\nimport com.cohere.api.types.ImageUrl;\nimport com.cohere.api.types.TextContent;\nimport com.cohere.api.types.UserMessage;\nimport com.cohere.api.types.UserMessageContent;\n\npublic class Image {\n\n public static void main(String[] args) {\n Cohere cohere = Cohere.builder().clientName(\"snippet\").build();\n\n ChatResponse response\n = cohere\n .v2()\n .chat(\n V2ChatRequest.builder()\n .model(\"command-a-vision-07-2025\")\n .messages(\n List.of(\n ChatMessageV2.user(\n UserMessage.builder()\n .content(\n UserMessageContent.of(\n List.of(\n Content.text(\n TextContent.builder()\n .text(\"Describe the logo!\")\n .build()),\n Content.imageUrl(\n ImageContent.builder()\n .imageUrl(\n ImageUrl.builder()\n // Can be either a base64 data URI or a web URL.\n .url(\n \"https://cohere.com/favicon-32x32.png\")\n .build())\n .build()))))\n .build())))\n .build());\n System.out.println(response);\n }\n}\n"
name: Images
sdk: java
- code: "package main\n\nimport (\n\t\"context\"\n\t\"log\"\n\t\"os\"\n\n\tcohere \"github.com/cohere-ai/cohere-go/v2\"\n\tclient \"github.com/cohere-ai/cohere-go/v2/client\"\n)\n\nfunc main() {\n\tco := client.NewClient(client.WithToken(os.Getenv(\"CO_API_KEY\")))\n\n\tresp, err := co.V2.Chat(\n\t\tcontext.TODO(),\n\t\t&cohere.V2ChatRequest{\n\t\t\tModel: \"command-a-03-2025\",\n\t\t\tMessages: cohere.ChatMessages{\n\t\t\t\t{\n\t\t\t\t\tRole: \"user\",\n\t\t\t\t\tUser: &cohere.UserMessageV2{Content: &cohere.UserMessageV2Content{\n\t\t\t\t\t\tContentList: []*cohere.Content{\n\t\t\t\t\t\t\t{Type: \"text\", Text: &cohere.ChatTextContent{Text: \"Describe the logo!\"}},\n\t\t\t\t\t\t\t{Type: \"image_url\", ImageUrl: &cohere.ImageContent{\n\t\t\t\t\t\t\t\tImageUrl: &cohere.ImageUrl{\n\t\t\t\t\t\t\t\t\tUrl: \"https://cohere.com/favicon-32x32.png\",\n\t\t\t\t\t\t\t\t\tDetail: cohere.ImageUrlDetailAuto.Ptr(),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t}},\n\t\t\t\t\t\t}}},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t)\n\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tlog.Printf(\"%+v\", resp)\n}\n"
- code: "package main\n\nimport (\n\t\"context\"\n\t\"log\"\n\t\"os\"\n\n\tcohere \"github.com/cohere-ai/cohere-go/v2\"\n\tclient \"github.com/cohere-ai/cohere-go/v2/client\"\n)\n\nfunc main() {\n\tco := client.NewClient(client.WithToken(os.Getenv(\"CO_API_KEY\")))\n\n\tresp, err := co.V2.Chat(\n\t\tcontext.TODO(),\n\t\t&cohere.V2ChatRequest{\n\t\t\tModel: \"command-a-03-2025\",\n\t\t\tMessages: cohere.ChatMessages{\n\t\t\t\t{\n\t\t\t\t\tRole: \"user\",\n\t\t\t\t\tUser: &cohere.UserMessageV2{Content: &cohere.UserMessageV2Content{\n\t\t\t\t\t\tContentList: []*cohere.Content{\n\t\t\t\t\t\t\t{Type: \"text\", Text: &cohere.ChatTextContent{Text: \"Describe the logo!\"}},\n\t\t\t\t\t\t\t{Type: \"image_url\", ImageUrl: &cohere.ImageContent{\n\t\t\t\t\t\t\t\tImageUrl: &cohere.ImageUrl{\n\t\t\t\t\t\t\t\t\t// Can be either a base64 data URI or a web URL.\n\t\t\t\t\t\t\t\t\tUrl: \"https://cohere.com/favicon-32x32.png\",\n\t\t\t\t\t\t\t\t\tDetail: cohere.ImageUrlDetailAuto.Ptr(),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t}},\n\t\t\t\t\t\t}}},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t)\n\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tlog.Printf(\"%+v\", resp)\n}\n"
name: Images
sdk: go
- code: "curl --request POST \\\n --url https://api.cohere.com/v2/chat \\\n --header 'accept: application/json' \\\n --header 'content-type: application/json' \\\n --header \"Authorization: bearer $CO_API_KEY\" \\\n --data '{\n \"model\": \"command-a-vision-07-2025\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": \"Describe the logo!\"\n },\n {\n \"type\": \"image_url\",\n \"image_url\": {\n \"url\": \"https://cohere.com/favicon-32x32.png\",\n \"detail\": \"auto\"\n }\n }\n ]\n }\n ]\n }'\n"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

🧩 Analysis chain

Examples: fix a wrong model, add auth consistently, and align env var naming.

  • Go: uses command-a-03-2025 while others use command-a-vision-07-2025. Non‑vision model + image_url will fail. Switch to the vision model.
  • TypeScript/Python: client initialization shows no token; examples won’t run as-is. Include token via env var to match Go’s pattern.
  • Align all examples on the same env var (CO_API_KEY) for consistency.

(wrong model)
(auth/consistency)

TS:

-const { CohereClientV2 } = require('cohere-ai');
-
-const cohere = new CohereClientV2({});
+const { CohereClientV2 } = require('cohere-ai');
+const cohere = new CohereClientV2({ token: process.env.CO_API_KEY });

Python:

-import cohere
-
-co = cohere.ClientV2()
+import os, cohere
+co = cohere.ClientV2(os.environ["CO_API_KEY"])

Go:

-            Model: "command-a-03-2025",
+            Model: "command-a-vision-07-2025",

Optional (Java) — add token if the SDK does not auto-read env:

-        Cohere cohere = Cohere.builder().clientName("snippet").build();
+        Cohere cohere = Cohere.builder()
+                .token(System.getenv("CO_API_KEY"))
+                .clientName("snippet")
+                .build();

Quick checks:


🏁 Script executed:

#!/bin/bash
set -euo pipefail
echo "Find mismatched non-vision model in examples:"
rg -n "command-a-03-2025" src/libs/Cohere/openapi.yaml || true
echo "Find TS example without token key:"
rg -n -C2 "CohereClientV2\\(\\{\\}\\)" src/libs/Cohere/openapi.yaml || true
echo "Find Python ClientV2() without token:"
rg -n -C2 "ClientV2\\(\\)" src/libs/Cohere/openapi.yaml || true

Length of output: 79933


Fix model/auth mismatches in src/libs/Cohere/openapi.yaml examples

Many examples use non‑vision model "command-a-03-2025" while some of those examples send images (will fail). Several TypeScript and Python snippets instantiate clients without a token. Align all SDK examples to use CO_API_KEY and switch image-using examples to the vision model.

  • Change any example that sends image/image_url/image content to model "command-a-vision-07-2025" (e.g., Go chat with image at openapi.yaml ≈ line 8784).
  • Pass token from env CO_API_KEY in TypeScript and Python client initializations (TS examples at ≈7549, 7590, 7732; Python examples at ≈7552, 7593, 7735, 7937).
  • Keep curl/Go/cURL examples that already use Authorization: bearer $CO_API_KEY as canonical.

TS:

-const { CohereClientV2 } = require('cohere-ai');
-
-const cohere = new CohereClientV2({});
+const { CohereClientV2 } = require('cohere-ai');
+const cohere = new CohereClientV2({ token: process.env.CO_API_KEY });

Python:

-import cohere
-
-co = cohere.ClientV2()
+import os, cohere
+co = cohere.ClientV2(os.environ["CO_API_KEY"])

Go:

-            Model: "command-a-03-2025",
+            Model: "command-a-vision-07-2025",

Optional (Java) — add token if the SDK does not auto-read env:

-        Cohere cohere = Cohere.builder().clientName("snippet").build();
+        Cohere cohere = Cohere.builder()
+                .token(System.getenv("CO_API_KEY"))
+                .clientName("snippet")
+                .build();
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
type: message-end
event: message-end
- code-samples:
- code: "const { CohereClientV2 } = require('cohere-ai');\n\nconst cohere = new CohereClientV2({});\n\n(async () => {\n const response = await cohere.chat({\n model: 'command-a-vision-07-2025',\n messages: [\n {\n role: 'user',\n content: [\n { type: 'text', text: 'Describe the logo!' },\n {\n type: 'image_url',\n imageUrl: {\n url: 'https://cohere.com/favicon-32x32.png',\n detail: 'auto',\n },\n },\n ],\n },\n ],\n });\n console.log(response.message.content[0].text);\n})();\n"
- code: "const { CohereClientV2 } = require('cohere-ai');\n\nconst cohere = new CohereClientV2({});\n\n(async () => {\n const response = await cohere.chat({\n model: 'command-a-vision-07-2025',\n messages: [\n {\n role: 'user',\n content: [\n { type: 'text', text: 'Describe the logo!' },\n {\n type: 'image_url',\n imageUrl: {\n // Can be either a base64 data URI or a web URL.\n url: 'https://cohere.com/favicon-32x32.png',\n detail: 'auto',\n },\n },\n ],\n },\n ],\n });\n console.log(response.message.content[0].text);\n})();\n"
name: Images
sdk: typescript
- code: "import cohere\n\nco = cohere.ClientV2()\n\nresponse = co.chat(\n model=\"command-a-vision-07-2025\",\n messages=[\n {\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": \"Describe the logo!\"\n },\n {\n \"type\": \"image_url\",\n \"image_url\": {\n \"url\": \"https://cohere.com/favicon-32x32.png\",\n \"detail\": \"auto\"\n }\n }\n ]\n \n }\n ]\n)\n\nprint(response)"
- code: "import cohere\n\nco = cohere.ClientV2()\n\nresponse = co.chat(\n model=\"command-a-vision-07-2025\",\n messages=[\n {\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": \"Describe the logo!\"\n },\n {\n \"type\": \"image_url\",\n \"image_url\": {\n # Can be either a base64 data URI or a web URL.\n \"url\": \"https://cohere.com/favicon-32x32.png\",\n \"detail\": \"auto\"\n }\n }\n ]\n \n }\n ]\n)\n\nprint(response)"
name: Images
sdk: python
- code: "/* (C)2024 */\npackage chatv2post;\n\nimport java.util.List;\n\nimport com.cohere.api.Cohere;\nimport com.cohere.api.resources.v2.requests.V2ChatRequest;\nimport com.cohere.api.types.ChatMessageV2;\nimport com.cohere.api.types.ChatResponse;\nimport com.cohere.api.types.Content;\nimport com.cohere.api.types.ImageContent;\nimport com.cohere.api.types.ImageUrl;\nimport com.cohere.api.types.TextContent;\nimport com.cohere.api.types.UserMessage;\nimport com.cohere.api.types.UserMessageContent;\n\npublic class Image {\n\n public static void main(String[] args) {\n Cohere cohere = Cohere.builder().clientName(\"snippet\").build();\n\n ChatResponse response\n = cohere\n .v2()\n .chat(\n V2ChatRequest.builder()\n .model(\"command-a-vision-07-2025\")\n .messages(\n List.of(\n ChatMessageV2.user(\n UserMessage.builder()\n .content(\n UserMessageContent.of(\n List.of(\n Content.text(\n TextContent.builder()\n .text(\"Describe the logo!\")\n .build()),\n Content.imageUrl(\n ImageContent.builder()\n .imageUrl(\n ImageUrl.builder()\n .url(\n \"https://cohere.com/favicon-32x32.png\")\n .build())\n .build()))))\n .build())))\n .build());\n System.out.println(response);\n }\n}\n"
- code: "/* (C)2024 */\npackage chatv2post;\n\nimport java.util.List;\n\nimport com.cohere.api.Cohere;\nimport com.cohere.api.resources.v2.requests.V2ChatRequest;\nimport com.cohere.api.types.ChatMessageV2;\nimport com.cohere.api.types.ChatResponse;\nimport com.cohere.api.types.Content;\nimport com.cohere.api.types.ImageContent;\nimport com.cohere.api.types.ImageUrl;\nimport com.cohere.api.types.TextContent;\nimport com.cohere.api.types.UserMessage;\nimport com.cohere.api.types.UserMessageContent;\n\npublic class Image {\n\n public static void main(String[] args) {\n Cohere cohere = Cohere.builder().clientName(\"snippet\").build();\n\n ChatResponse response\n = cohere\n .v2()\n .chat(\n V2ChatRequest.builder()\n .model(\"command-a-vision-07-2025\")\n .messages(\n List.of(\n ChatMessageV2.user(\n UserMessage.builder()\n .content(\n UserMessageContent.of(\n List.of(\n Content.text(\n TextContent.builder()\n .text(\"Describe the logo!\")\n .build()),\n Content.imageUrl(\n ImageContent.builder()\n .imageUrl(\n ImageUrl.builder()\n // Can be either a base64 data URI or a web URL.\n .url(\n \"https://cohere.com/favicon-32x32.png\")\n .build())\n .build()))))\n .build())))\n .build());\n System.out.println(response);\n }\n}\n"
name: Images
sdk: java
- code: "package main\n\nimport (\n\t\"context\"\n\t\"log\"\n\t\"os\"\n\n\tcohere \"github.com/cohere-ai/cohere-go/v2\"\n\tclient \"github.com/cohere-ai/cohere-go/v2/client\"\n)\n\nfunc main() {\n\tco := client.NewClient(client.WithToken(os.Getenv(\"CO_API_KEY\")))\n\n\tresp, err := co.V2.Chat(\n\t\tcontext.TODO(),\n\t\t&cohere.V2ChatRequest{\n\t\t\tModel: \"command-a-03-2025\",\n\t\t\tMessages: cohere.ChatMessages{\n\t\t\t\t{\n\t\t\t\t\tRole: \"user\",\n\t\t\t\t\tUser: &cohere.UserMessageV2{Content: &cohere.UserMessageV2Content{\n\t\t\t\t\t\tContentList: []*cohere.Content{\n\t\t\t\t\t\t\t{Type: \"text\", Text: &cohere.ChatTextContent{Text: \"Describe the logo!\"}},\n\t\t\t\t\t\t\t{Type: \"image_url\", ImageUrl: &cohere.ImageContent{\n\t\t\t\t\t\t\t\tImageUrl: &cohere.ImageUrl{\n\t\t\t\t\t\t\t\t\tUrl: \"https://cohere.com/favicon-32x32.png\",\n\t\t\t\t\t\t\t\t\tDetail: cohere.ImageUrlDetailAuto.Ptr(),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t}},\n\t\t\t\t\t\t}}},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t)\n\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tlog.Printf(\"%+v\", resp)\n}\n"
- code: "package main\n\nimport (\n\t\"context\"\n\t\"log\"\n\t\"os\"\n\n\tcohere \"github.com/cohere-ai/cohere-go/v2\"\n\tclient \"github.com/cohere-ai/cohere-go/v2/client\"\n)\n\nfunc main() {\n\tco := client.NewClient(client.WithToken(os.Getenv(\"CO_API_KEY\")))\n\n\tresp, err := co.V2.Chat(\n\t\tcontext.TODO(),\n\t\t&cohere.V2ChatRequest{\n\t\t\tModel: \"command-a-03-2025\",\n\t\t\tMessages: cohere.ChatMessages{\n\t\t\t\t{\n\t\t\t\t\tRole: \"user\",\n\t\t\t\t\tUser: &cohere.UserMessageV2{Content: &cohere.UserMessageV2Content{\n\t\t\t\t\t\tContentList: []*cohere.Content{\n\t\t\t\t\t\t\t{Type: \"text\", Text: &cohere.ChatTextContent{Text: \"Describe the logo!\"}},\n\t\t\t\t\t\t\t{Type: \"image_url\", ImageUrl: &cohere.ImageContent{\n\t\t\t\t\t\t\t\tImageUrl: &cohere.ImageUrl{\n\t\t\t\t\t\t\t\t\t// Can be either a base64 data URI or a web URL.\n\t\t\t\t\t\t\t\t\tUrl: \"https://cohere.com/favicon-32x32.png\",\n\t\t\t\t\t\t\t\t\tDetail: cohere.ImageUrlDetailAuto.Ptr(),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t}},\n\t\t\t\t\t\t}}},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t)\n\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tlog.Printf(\"%+v\", resp)\n}\n"
name: Images
sdk: go
- code: "curl --request POST \\\n --url https://api.cohere.com/v2/chat \\\n --header 'accept: application/json' \\\n --header 'content-type: application/json' \\\n --header \"Authorization: bearer $CO_API_KEY\" \\\n --data '{\n \"model\": \"command-a-vision-07-2025\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": \"Describe the logo!\"\n },\n {\n \"type\": \"image_url\",\n \"image_url\": {\n \"url\": \"https://cohere.com/favicon-32x32.png\",\n \"detail\": \"auto\"\n }\n }\n ]\n }\n ]\n }'\n"
// TypeScript
const { CohereClientV2 } = require('cohere-ai');
const cohere = new CohereClientV2({ token: process.env.CO_API_KEY });
// Python
import os, cohere
co = cohere.ClientV2(os.environ["CO_API_KEY"])
// Go (update model for image examples)
Model: "command-a-vision-07-2025",
// Optional Java (if SDK doesn't auto-read env)
Cohere cohere = Cohere.builder()
.token(System.getenv("CO_API_KEY"))
.clientName("snippet")
.build();

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.

2 participants