Skip to content

Cohere

AgentRuntime implementation backed by a native client that posts directly to the Cohere v2 Chat API (POST /v2/chat) over java.net.http.HttpClient — no SDK dependency, no OpenAI-compatible translation layer in between. The runtime forwards Cohere’s native SSE event types (content-delta, tool-plan-delta, tool-call-start, tool-call-delta, citation-start), so streaming “thinking” tokens and RAG citations render on the client without lossy translation through an OpenAI-shaped proxy.

<dependency>
<groupId>org.atmosphere</groupId>
<artifactId>atmosphere-cohere</artifactId>
<version>${project.version}</version>
</dependency>

Drop the dependency alongside atmosphere-ai and the framework auto-detects it via ServiceLoader. CohereAgentRuntime has priority 100, taking precedence over the built-in client (priority 0):

@AiEndpoint(path = "/ai/chat", systemPrompt = "You are a helpful assistant")
public class MyChat {
@Prompt
public void onPrompt(String message, StreamingSession session) {
session.stream(message); // uses the Cohere v2 Chat API automatically
}
}

Set the API key via the framework’s llm.api-key, an environment variable, or a system property:

Terminal window
export LLM_API_KEY=your-cohere-key
# or, equivalently:
java -Dcohere.api.key=your-cohere-key -jar app.jar

The runtime registers itself at priority 100 and the framework picks it up when the jar is on the classpath alongside a configured key.

Point the runtime at any environment that speaks the Cohere v2 wire protocol (for example Command A+ deployed on customer infrastructure) by overriding cohere.base.url.

  • Spring Boot AI Chat — drop atmosphere-cohere on the classpath and the same @AiEndpoint code switches to Cohere