Skip to content

Anthropic

AgentRuntime implementation backed by a native client that posts directly to the Anthropic Messages API (https://api.anthropic.com/v1/messages) over java.net.http.HttpClient — no SDK dependency, no OpenAI-compatible translation layer in between. Streaming text_delta events are forwarded straight to the StreamingSession, and Anthropic’s tool_usetool_result loop drives @AiTool calls.

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

Drop the dependency alongside atmosphere-ai and the framework auto-detects it via ServiceLoader. AnthropicAgentRuntime 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 Anthropic Messages API automatically
}
}

The runtime reads the framework’s resolved llm.api-key, and falls back to system properties so standalone tests and CLI usage work without an Atmosphere-wide config:

PropertyPurposeDefault
anthropic.api.keyAPI key (falls back from llm.api-key)
anthropic.versionanthropic-version request header2023-06-01
anthropic.base.urlOverride for a sovereign / proxy endpointhttps://api.anthropic.com
anthropic.max.tokensmax_tokens on each requestclient default

The model is configured through the framework’s llm.model setting. The runtime stays unavailable until an API key is resolved — it never advertises availability on classpath presence alone (Runtime Truth).

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