Cohere
The Cohere provider uses provider key cohere and the HPD-Agent.Providers.Cohere package. ModelName is a Cohere chat model id for chat, or a Cohere embedding model id for embeddings.
The provider package is currently net10.0 only because the underlying TryAGI-generated Cohere SDK targets net10.0.
Set an API key:
export COHERE_API_KEY="..."Use fluent chat setup first:
using HPD.Agent;
using HPD.Agent.Providers.Cohere;
var agent = await new AgentBuilder()
.WithCohere(model: "command-r-plus")
.BuildAsync();
var result = await agent.RunAsync("Write one sentence about Cohere setup.");
Console.WriteLine(result.Text);Provider construction stays small. Put model behavior on the agent's Clients.Chat default or a run's complete Clients.Chat replacement, and use Cohere request options only for Cohere-only request fields:
using HPD.Agent;
using HPD.Agent.Providers.Cohere;
var agent = await new AgentBuilder()
.WithCohere(model: "command-r-plus")
.WithCohereChatRequestOptions(cohere =>
{
cohere.StrictTools = true;
cohere.CitationMode = CohereCitationMode.Accurate;
cohere.SafetyMode = CohereSafetyMode.Strict;
cohere.ThinkingTokenBudget = 2048;
cohere.Documents =
[
new CohereChatDocument
{
Id = "setup",
Data = new Dictionary<string, object>
{
["title"] = "Setup note",
["body"] = "Runtime model behavior belongs on Clients.Chat."
}
}
];
})
.BuildAsync();The provider helper writes the same portable fields, typed providerConfig, and typed providerOptions into Clients.Chat. Use the runtime selection guide for the canonical JSON and YAML shape.
Embeddings
Cohere also registers the embeddings provider family under the same cohere key:
using HPD.Agent;
using HPD.Agent.Providers.Cohere;
var agent = await new AgentBuilder()
.WithCohereEmbeddings(model: "embed-english-v3.0")
.BuildAsync();The equivalent family config is:
{
"Clients": {
"Embeddings": {
"ProviderKey": "cohere",
"ModelName": "embed-english-v3.0"
}
}
}Runtime Chat Options
Use ChatClientConfig for shared model-call behavior such as temperature, top-p, top-k, max output tokens, stop sequences, tools, tool mode, seed, and generic reasoning options. Put agent-level defaults in AgentConfig.Clients.Chat; use AgentRunConfig.Clients.Chat for complete per-run replacements.
The Cohere adapter maps the common MEAI chat options to Cohere Chat v2 request fields:
| HPD chat option | Cohere request field |
|---|---|
ModelId | model |
Temperature | temperature |
TopP | p |
TopK | k |
MaxOutputTokens | max_tokens |
Seed | seed |
StopSequences | stop_sequences |
ResponseFormat | response_format |
Tools | tools |
ToolMode | tool_choice |
Reasoning | thinking |
Use CohereChatRequestOptions for Cohere-only request properties:
| Option | Cohere key | Meaning |
|---|---|---|
StrictTools | strict_tools | Forces tool calls to follow their tool definitions strictly. |
Documents | documents | Relevant source documents that the model can cite while generating an answer. |
CitationMode | citation_mode | Citation generation mode. Supported values include enabled, disabled, accurate, fast, and off. |
SafetyMode | safety_mode | Safety instruction mode. Supported values include contextual, off, and strict. |
Logprobs | logprobs | Includes output token log probabilities in the raw Cohere response. |
ThinkingEnabled | thinking_enabled | Overrides whether Cohere thinking is enabled. If unset, generic Reasoning controls this. |
ThinkingTokenBudget | thinking_token_budget | Maximum number of tokens the model can use for thinking. |
Priority | priority | Request priority. Lower numbers indicate higher priority; Cohere defaults to 0. |
CohereChatDocument supports:
| Option | Meaning |
|---|---|
Id | Optional identifier referenced by Cohere citations. |
Text | Plain document text for simple string documents. |
Data | Structured document data and metadata. |
Construction Options
CohereProviderConfig exposes Cohere-specific embedding defaults for the embeddings family:
| Option | Purpose |
|---|---|
EmbeddingModelId | Default embedding model id for the embeddings provider family. |
For embeddings, WithCohereEmbeddings(...) stores the embedding model in the embeddings family config.
Caveats
Cohere chat and embeddings are available only when the HPD-Agent.Providers.Cohere package is referenced by a net10.0 application.
The current TryAGI Cohere MEAI streaming adapter returns a single final update rather than token-by-token streaming.
Runtime validation checks model, endpoint, and embedding model options. Runtime chat options are applied through Clients.Chat and AgentRunConfig.Clients.Chat. Generic reasoning is mapped to Cohere thinking; set ThinkingEnabled or ThinkingTokenBudget only when you need Cohere-specific control. Credentials are resolved lazily when a run first acquires this provider client; a missing credential fails that run, not BuildAsync().