-
-
Notifications
You must be signed in to change notification settings - Fork 0
feat:Add OpenAPI deprecations; update Images examples; clarify image_url #287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
WalkthroughAdds 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
Sequence Diagram(s)Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches🧪 Generate unit tests
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. Comment |
There was a problem hiding this 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
⛔ Files ignored due to path filters (21)
src/libs/Cohere/Generated/Cohere.CohereClient.Chat.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.CohereClient.Classify.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.CohereClient.Generate.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.CohereClient.Summarize.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.ConnectorsClient.CreateConnector.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.ConnectorsClient.DeleteConnector.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.ConnectorsClient.GetConnector.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.ConnectorsClient.ListConnectors.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.ConnectorsClient.OAuthAuthorizeConnector.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.ConnectorsClient.UpdateConnector.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.ICohereClient.Chat.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.ICohereClient.Classify.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.ICohereClient.Generate.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.ICohereClient.Summarize.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.IConnectorsClient.CreateConnector.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.IConnectorsClient.DeleteConnector.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.IConnectorsClient.GetConnector.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.IConnectorsClient.ListConnectors.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.IConnectorsClient.OAuthAuthorizeConnector.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.IConnectorsClient.UpdateConnector.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.ChatRequest.g.csis 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"
| 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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 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:
- publicOption B — deprecate the schema (if only the ChatConnector type is being retired):
components:
schemas:
ChatConnector:
+ deprecated: trueOption 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.yamlLength 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.
| 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.
| 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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 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 || trueLength 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.
| 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(); |
Summary by CodeRabbit