# Cohere Command R — Long-Context Tool-Use Model for Agents > Command R+ is Cohere's flagship LLM. 128K context, native tool use, RAG-tuned, multilingual. Cheaper than Claude Sonnet, comparable on tool-use benchmarks. ## Install Copy the content below into your project: ## Quick Use 1. Sign up at dashboard.cohere.com → copy API key 2. `pip install cohere` (or `npm install cohere-ai`) 3. `co.chat(model='command-r-plus-08-2024', message='...')` — add `tools=` and `documents=` for tool use / RAG --- ## Intro Command R+ is Cohere's flagship enterprise LLM — 128K context, native tool use, multilingual (10+ languages with strong fluency), and specifically tuned for RAG and agent workloads. Pricing slots between GPT-4o-mini and Claude Sonnet, with comparable benchmark performance on tool use and multi-step reasoning. Best for: enterprise agents, multilingual customer-facing AI, RAG pipelines where citations matter. Works with: Cohere API, AWS Bedrock, Azure, Oracle Cloud. Setup time: 2 minutes. --- ### Hello, Command R+ ```python import cohere co = cohere.Client(os.environ["COHERE_API_KEY"]) response = co.chat( model="command-r-plus-08-2024", message="Compare LFP and NMC battery chemistries.", temperature=0.3, ) print(response.text) ``` ### Native tool use ```python tools = [{ "name": "get_weather", "description": "Get current weather", "parameter_definitions": { "city": {"description": "City name", "type": "str", "required": True}, }, }] response = co.chat( model="command-r-plus-08-2024", message="What's the weather in Tokyo and Berlin? Compare.", tools=tools, ) # Loop until no more tool calls while response.tool_calls: tool_results = [] for tc in response.tool_calls: result = call_my_tool(tc.name, tc.parameters) tool_results.append({"call": tc, "outputs": [{"result": result}]}) response = co.chat( model="command-r-plus-08-2024", message="", tools=tools, tool_results=tool_results, ) print(response.text) ``` ### Built-in RAG mode ```python documents = [ {"title": "Doc 1", "snippet": "PyTorch is..."}, {"title": "Doc 2", "snippet": "TensorFlow is..."}, ] response = co.chat( model="command-r-plus-08-2024", message="Compare PyTorch and TensorFlow", documents=documents, ) print(response.text) # Output cites docs by ID — see response.citations for c in response.citations: print(f"{c.text} → {c.document_ids}") ``` ### Pricing snapshot (vs alternatives) | Model | Input $/1M tok | Output $/1M tok | |---|---|---| | Claude 3.5 Sonnet | $3 | $15 | | Command R+ | $2.50 | $10 | | GPT-4o | $2.50 | $10 | | Command R | $0.50 | $1.50 | | GPT-4o-mini | $0.15 | $0.60 | --- ### FAQ **Q: Is Command R free?** A: Cohere offers free trial credits on signup. After that, pay-per-token via cohere.com or via AWS Bedrock / Azure with their billing. Free tier suitable for prototyping; production needs a paid plan. **Q: How does Command R+ compare to Claude Sonnet?** A: On English benchmarks Sonnet leads slightly. Command R+ is competitive on tool-use and multilingual tasks at lower price. For enterprise / multilingual / RAG-heavy use cases Command R+ is often the better $/quality. **Q: Does Command R support function calling like OpenAI?** A: Yes — native tool use is first-class. Schema is similar but uses `parameter_definitions` instead of `parameters`. Cohere's SDK normalizes; with raw API account for the format diff. --- ## Source & Thanks > Built by [Cohere](https://github.com/cohere-ai). Commercial product with free trial. > > [docs.cohere.com](https://docs.cohere.com/docs/command-r-plus) — Command R+ documentation --- ## 快速使用 1. 在 dashboard.cohere.com 注册,复制 API key 2. `pip install cohere`(或 `npm install cohere-ai`) 3. `co.chat(model='command-r-plus-08-2024', message='...')`,加 `tools=` 和 `documents=` 启用工具 / RAG --- ## 简介 Command R+ 是 Cohere 旗舰企业 LLM —— 128K 上下文、原生工具使用、多语言(10+ 语言强流畅度)、专为 RAG 和 agent 工作负载调优。价格在 GPT-4o-mini 和 Claude Sonnet 之间,工具使用和多步推理 benchmark 上相当。适合企业 agent、多语言客户面 AI、需要引用的 RAG 流水线。兼容 Cohere API、AWS Bedrock、Azure、Oracle Cloud。装机时间 2 分钟。 --- ### Hello, Command R+ ```python import cohere co = cohere.Client(os.environ["COHERE_API_KEY"]) response = co.chat( model="command-r-plus-08-2024", message="Compare LFP and NMC battery chemistries.", temperature=0.3, ) print(response.text) ``` ### 原生工具使用 ```python tools = [{ "name": "get_weather", "description": "Get current weather", "parameter_definitions": { "city": {"description": "City name", "type": "str", "required": True}, }, }] response = co.chat( model="command-r-plus-08-2024", message="What's the weather in Tokyo and Berlin? Compare.", tools=tools, ) # 循环直到没有更多工具调用 while response.tool_calls: tool_results = [] for tc in response.tool_calls: result = call_my_tool(tc.name, tc.parameters) tool_results.append({"call": tc, "outputs": [{"result": result}]}) response = co.chat( model="command-r-plus-08-2024", message="", tools=tools, tool_results=tool_results, ) print(response.text) ``` ### 内置 RAG 模式 ```python documents = [ {"title": "Doc 1", "snippet": "PyTorch is..."}, {"title": "Doc 2", "snippet": "TensorFlow is..."}, ] response = co.chat( model="command-r-plus-08-2024", message="Compare PyTorch and TensorFlow", documents=documents, ) print(response.text) # 输出按 doc ID 引用 —— 看 response.citations for c in response.citations: print(f"{c.text} → {c.document_ids}") ``` ### 价格快照(vs 其他) | 模型 | 输入 $/百万 token | 输出 $/百万 token | |---|---|---| | Claude 3.5 Sonnet | $3 | $15 | | Command R+ | $2.50 | $10 | | GPT-4o | $2.50 | $10 | | Command R | $0.50 | $1.50 | | GPT-4o-mini | $0.15 | $0.60 | --- ### FAQ **Q: Command R 免费吗?** A: Cohere 注册送试用 credit。之后通过 cohere.com 按 token 付费,或通过 AWS Bedrock / Azure 用它们的计费。免费档够原型,生产要付费档。 **Q: Command R+ 跟 Claude Sonnet 比怎样?** A: 英文 benchmark Sonnet 略领先。Command R+ 在工具使用和多语言任务上有竞争力,价格更低。企业 / 多语言 / RAG 重的用例下 Command R+ 通常是更好的性价比。 **Q: Command R 像 OpenAI 那样支持 function calling 吗?** A: 支持 —— 原生工具使用是一等公民。Schema 类似,但用 `parameter_definitions` 而非 `parameters`。Cohere SDK 帮你规整;裸 API 注意格式差异。 --- ## 来源与感谢 > Built by [Cohere](https://github.com/cohere-ai). Commercial product with free trial. > > [docs.cohere.com](https://docs.cohere.com/docs/command-r-plus) — Command R+ documentation --- Source: https://tokrepo.com/en/workflows/cohere-command-r-long-context-tool-use-model-for-agents Author: Cohere