java changedcli-sdks-libraries/sdks/java
Nearest release: v2.1.318, published 17 hours before this site recorded the change. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.
Recorded here
Lines+41added
Lines−1removed
From line
30
where the diff opens
First seen
14 Aug 2026
this site's first read of the page
Recorded edits34to this page, all time
### Add-ons
The whole hunk
from line 30, old and new numbered
/
from line 30
3030 </Tab>
3131</Tabs>
3232
33### Add-ons
34
35Cloud platform integrations and the client-side MCP helpers ship as separate add-on artifacts. Install an add-on alongside `anthropic-java`, which provides `AnthropicOkHttpClient`. Use the same version for both. This example adds the client-side MCP helpers:
36
37<Tabs>
38 <Tab title="Gradle">
39 ```kotlin
40 implementation("com.anthropic:anthropic-java:3.4.0")
41 implementation("com.anthropic:anthropic-java-mcp:3.4.0")
42 ```
43 </Tab>
44
45 <Tab title="Maven">
46 ```xml
47 <dependency>
48 <groupId>com.anthropic</groupId>
49 <artifactId>anthropic-java</artifactId>
50 <version>3.4.0</version>
51 </dependency>
52 <dependency>
53 <groupId>com.anthropic</groupId>
54 <artifactId>anthropic-java-mcp</artifactId>
55 <version>3.4.0</version>
56 </dependency>
57 ```
58 </Tab>
59</Tabs>
60
61For another add-on, replace `anthropic-java-mcp` with its artifact name. [Platform integrations](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/java#platform-integrations) lists the artifact for each cloud platform. [Client-side MCP helpers](https://platform.claude.com/docs/en/agents-and-tools/mcp-connector#client-side-mcp-helpers) covers `anthropic-java-mcp` and the Java version it requires.
62
3363## Requirements
3464
3565This library requires Java 8 or later.
from line 151
121151
122152```java
123153import com.anthropic.client.AnthropicClient;
154import com.anthropic.client.okhttp.AnthropicOkHttpClient;
124155
156AnthropicClient client = AnthropicOkHttpClient.fromEnv();
157
125158AnthropicClient clientWithOptions = client.withOptions(optionsBuilder -> {
126159 optionsBuilder.baseUrl("https://example.com");
127160 optionsBuilder.maxRetries(42);
from line 834
801834Each class in the SDK has an associated builder for constructing it. Each class is immutable once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy.
802835
803836```java
837import com.anthropic.models.messages.MessageCreateParams;
838import com.anthropic.models.messages.Model;
839
804840MessageCreateParams params = MessageCreateParams.builder()
805841 .maxTokens(1024L)
806842 .addUserMessage("Hello, Claude")
from line 1135
10991135
11001136The Java SDK also supports Claude Models on Google Cloud (Anthropic managed) through `GoogleCloudBackend`, from the `com.anthropic:anthropic-java-google-cloud` dependency. This backend is in beta. Create it with `GoogleCloudBackend.builder()` or `GoogleCloudBackend.fromEnv()`. `fromEnv()` reads `ANTHROPIC_GOOGLE_CLOUD_WORKSPACE_ID`, `ANTHROPIC_GOOGLE_CLOUD_PROJECT`, and Google Application Default Credentials. See [Project, location, and workspace resolution](https://platform.claude.com/docs/en/build-with-claude/claude-models-on-google-cloud/anthropic-managed#project-location-and-workspace-resolution).
11011137
1102The platform artifacts are add-ons to the base `com.anthropic:anthropic-java` dependency, which provides `AnthropicOkHttpClient`, so install both. Each `Backend` implementation is passed to the client with `.backend()` on `AnthropicOkHttpClient.builder()`. Each cloud backend pulls in its respective cloud-platform SDK classes as transitive dependencies.
1138Install each platform artifact alongside the base `anthropic-java` dependency, as shown in [Add-ons](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/java#add-ons). Each `Backend` implementation is passed to the client with `.backend()` on `AnthropicOkHttpClient.builder()`.
11031139
11041140## Advanced usage
11051141
from line 1144
11081144To access HTTP headers, status codes, and the raw response body, prefix any HTTP method call with `withRawResponse()`:
11091145
11101146```java
1147import com.anthropic.client.AnthropicClient;
1148import com.anthropic.client.okhttp.AnthropicOkHttpClient;
11111149import com.anthropic.core.http.Headers;
11121150import com.anthropic.core.http.HttpResponseFor;
11131151import com.anthropic.models.messages.Message;
11141152import com.anthropic.models.messages.MessageCreateParams;
11151153import com.anthropic.models.messages.Model;
1154
1155AnthropicClient client = AnthropicOkHttpClient.fromEnv();
11161156
11171157MessageCreateParams params = MessageCreateParams.builder()
11181158 .maxTokens(1024L)
No line in this hunk matches that.