Cohere
Use Cohere models with PraisonAI Agents
Environment Variables
Setting MODEL_NAME=cohere/command-r-plus is enough — no need to set OPENAI_BASE_URL. The COHERE_API_KEY environment variable is consulted; OPENAI_API_KEY is not used as a fallback.
If you just want the Cohere default, setting COHERE_API_KEY alone is enough — no MODEL_NAME, no llm=. Agent(...) picks cohere/command-r and routes it through litellm. See Provider Auto-Detection.
import os
from praisonaiagents import Agent
os.environ["MODEL_NAME"] = "cohere/command-r-plus"
os.environ["COHERE_API_KEY"] = "your-cohere-key"
agent = Agent(name="Cohere Agent", instructions="You are powered by Cohere")Models
- Recommended:
command-r-plus(best quality) - Fast/Cheap:
command-r(balanced) - Latest:
command-a-03-2025(newest) - Small:
command-r7b-12-2024(efficient)
Python
# export COHERE_API_KEY=your-api-key
from praisonaiagents import Agent
agent = Agent(
instructions="You are a helpful assistant",
llm="command-r-plus"
)
agent.start("Explain natural language processing")With Tools
# export COHERE_API_KEY=your-api-key
from praisonaiagents import Agent
def search_documents(query: str) -> str:
"""Search internal documents."""
return f"Found documents related to: {query}"
agent = Agent(
instructions="You are a document assistant",
llm="command-r",
tools=[search_documents]
)
agent.start("Find documents about machine learning")Multi-Agent
# export COHERE_API_KEY=your-api-key
from praisonaiagents import Agent, Task, AgentTeam
researcher = Agent(
instructions="You research topics thoroughly",
llm="command-r-plus"
)
writer = Agent(
instructions="You write clear summaries",
llm="command-r"
)
task1 = Task(description="Research NLP techniques", agent=researcher)
task2 = Task(description="Write a summary", agent=writer)
agents = AgentTeam(agents=[researcher, writer], tasks=[task1, task2])
agents.start()CLI
export COHERE_API_KEY=your-api-key
# Basic prompt
python -m praisonai "Explain AI" --llm command-r-plus
# Run agents.yaml
python -m praisonaiYAML
framework: praisonai
topic: NLP research
agents:
researcher:
role: NLP Researcher
goal: Research language processing techniques
instructions: You are an expert in NLP
llm:
model: command-r-plus
tasks:
research_task:
description: Research the latest NLP techniques
expected_output: Comprehensive NLP research report
writer:
role: Technical Writer
goal: Create clear documentation
instructions: You write clear technical content
llm:
model: command-r
tasks:
write_task:
description: Write a summary of the research
expected_output: Well-written technical summary