0

Cohere Provider

Cohere Provider explains the cloud layer of MTPX with practical guidance for building inspectable, tool-using agents.

Co
Cohere Provider
Chapter 029ProvidersCloudIndex
01Orientation

Cohere Provider belongs to the providers track. The page breaks the idea into responsibilities, implementation rules, failure modes, and the signals you should expose in a product UI.

Use this when

Use this when you need to understand how cohere provider affects a real MTPX agent before you wire it into an application.

  • What cohere provider owns in the runtime.
  • How it connects to planning, tool execution, events, providers, or storage.
  • What to log, test, and expose to users when this layer is active.
  • Common mistakes that make agent systems hard to inspect.
02 / syntax starter
from mtp import Agent
from mtp.providers import Groq

agent = Agent.MTPAgent(
    provider=Groq(model="llama-3.3-70b-versatile"),
    tools=tools,
)
03 / manual

Read the system

The complete source manual—syntax, examples, linked references, edge cases, and implementation notes.

Documentation index ↗

Cohere provides Command models with native RAG grounding and multi-step agentic tool use built into the model.

Install

bashpip install "mtpx[cohere]"

Or install the SDK directly:

bashpip install cohere

API Key Setup

  1. Install dotenv support:
bash   pip install python-dotenv

Or with the MTP extra:

bash   pip install "mtpx[dotenv]"
  1. Create a .env file in your project root:
text   COHERE_API_KEY=your_key_here
  1. Load it in your code before creating the provider:
python   from mtp import Agent

   Agent.load_dotenv_if_available()  # reads .env file

Get a free trial key at dashboard.cohere.com (no credit card required).

Option 2: System environment variable

bash# Linux/macOS
export COHERE_API_KEY="..."

# Windows PowerShell
$env:COHERE_API_KEY="..."

Quick Start

pythonfrom mtp import Agent
from mtp.providers import Cohere

Agent.load_dotenv_if_available()  # loads COHERE_API_KEY from .env

provider = Cohere(model="command-a-03-2025")
tools = Agent.ToolRegistry()
agent = Agent(provider=provider, tools=tools)

reply = agent.run_loop("What is 25 * 4 + 10?")
print(reply)

Parameters

ParameterTypeDefaultDescription
modelstr"command-a-03-2025"Cohere model ID
api_keystr | NoneNoneAPI key (falls back to COHERE_API_KEY env var)
temperaturefloat0.3Sampling temperature
max_tokensint4096Maximum response tokens
preamblestr | NoneNoneSystem prompt (Cohere's term for system instructions)
force_single_stepboolFalseForce single-step tool execution
clientAny | NoneNonePre-configured cohere.ClientV2 instance

Capabilities

CapabilityValue
Tool callingYes
Parallel tool callsNo
Input modalitiestext
StreamingFallback
Usage metricsBasic
Reasoning metadataNo
Native asyncNo (uses thread fallback)
  • command-a-03-2025 — Most capable, best tool use (default)
  • command-r-plus-08-2024 — Strong RAG + multi-step tool use
  • command-r-08-2024 — Fast, cheaper, solid tool calling
  • command-r7b-12-2024 — Lightweight, near-free

Strengths

  • Native RAG / document grounding — Cohere models are built for retrieval-augmented generation
  • Multi-step agentic tool use — Built into the model, not just bolted on
  • Structured JSON output — Reliable JSON generation
  • Complex reasoning chains — Excellent at multi-hop reasoning

Full Example

pythonfrom mtp import Agent
from mtp.providers import Cohere

Agent.load_dotenv_if_available()

provider = Cohere(
    model="command-a-03-2025",
    temperature=0.3,
    max_tokens=4096,
    preamble="You are a precise tool-using assistant.",
)

tools = Agent.ToolRegistry()
agent = Agent(provider=provider, tools=tools, debug_mode=True)

reply = agent.run_loop(
    "Calculate (25 * 4) + 10 and explain.",
    max_rounds=3,
)
print(reply)

Notes

  • Uses Cohere V2 API (ClientV2) with OpenAI-compatible message format.
  • Tool names with dots (.) are converted to double underscores (__) for Cohere compatibility, then converted back in responses.
  • The preamble parameter is Cohere's equivalent of a system prompt. If a system message is already in the conversation, preamble is not injected.
  • Text-only input (no image/audio/video/file support).

Source

src/mtp/providers/cohere_provider.py

01

Read

Understand where Cohere Provider sits in the agent loop before adding abstractions.

02

Wire

Connect the smallest useful provider, registry, store, or event stream first.

03

Observe

Expose events, logs, results, and failure states while the runtime is still moving.

04

Harden

Add policy, tests, retries, and audit traces after the behavior is visible.

Next docDeepSeek Provider