Files
google__adk-docs/docs/agents/models/anthropic.md
Joe Fernandez 23b740df3b Models for Agents page reorg (#1128)
* fix(deploy): simplifying Agent Engine deployment

* revise and update ae deploy doc structure

* respond to review comments

* docs: break up Models page into multiple pages

- Create page per model and access method
- Push Models topic up to top level TOC entry

* updates based on review feedback

* fix broken links due to page move

* consistency updates and review input updates

* update gemini-2.0-flash to 2.5

* respond to review comments

* docs: update Python API docs to 1.22.0 (#1129)

* build(deps): bump golang.org/x/crypto (#987)

Bumps the go_modules group with 1 update in the /tools/feature-matrix directory: [golang.org/x/crypto](https://github.com/golang/crypto).


Updates `golang.org/x/crypto` from 0.42.0 to 0.45.0
- [Commits](https://github.com/golang/crypto/compare/v0.42.0...v0.45.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-version: 0.45.0
  dependency-type: indirect
  dependency-group: go_modules
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Sita Lakshmi Sangameswaran <sitalakshmi@google.com>

* Update model version from gemini-2.0 to gemini-2.5, since gemini-2.0-flash will be deprecated on Feb 5,2026. (#1132)

Co-authored-by: Joe Fernandez <joefernandez@users.noreply.github.com>

* Changes model MODEL_2_0_FLASH to MODEL_2_5_FLASH as gemini-2.0 is deprecating (#1131)

* Update model constants to use GEMINI 2.5

* Corrected model name

---------

Co-authored-by: Joe Fernandez <joefernandez@users.noreply.github.com>

* Add Agent Runtime pages for Web Interface and Command Line; reorganize existing Agent Runtime pages (#1130)

* Add pages for adk web, adk run, reorganize runtime pages

* Minor edit

* Updates based on review

* docs: break up Models page into multiple pages

- Create page per model and access method
- Push Models topic up to top level TOC entry

* minor update

* add placeholder file

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Polong Lin <polong-lin@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Sita Lakshmi Sangameswaran <sitalakshmi@google.com>
Co-authored-by: llalitkumarrr <llalitkumarrr@google.com>
Co-authored-by: Dinesh Thumma <160909147+DineshThumma9@users.noreply.github.com>
Co-authored-by: Kristopher Overholt <koverholt@google.com>
2026-01-13 15:03:29 -08:00

3.3 KiB

Claude models for ADK agents

Supported in ADKJava v0.2.0

You can integrate Anthropic's Claude models directly using an Anthropic API key or from a Vertex AI backend into your Java ADK applications by using the ADK's Claude wrapper class. You can also access Anthropic models through Google Cloud Vertex AI services. For more information, see the Third-Party Models on Vertex AI section. You can also use Anthropic models through the LiteLLM library for Python.

Get started

The following code examples show a basic implementation for using Gemini models in your agents:

public static LlmAgent createAgent() {

  AnthropicClient anthropicClient = AnthropicOkHttpClient.builder()
      .apiKey("ANTHROPIC_API_KEY")
      .build();

  Claude claudeModel = new Claude(
      "claude-3-7-sonnet-latest", anthropicClient
  );

  return LlmAgent.builder()
      .name("claude_direct_agent")
      .model(claudeModel)
      .instruction("You are a helpful AI assistant powered by Anthropic Claude.")
      .build();
}

Prerequisites

  1. Dependencies:

    • Anthropic SDK Classes (Transitive): The Java ADK's com.google.adk.models.Claude wrapper relies on classes from Anthropic's official Java SDK. These are typically included as transitive dependencies. For more information, see the Anthropic Java SDK.
  2. Anthropic API Key:

    • Obtain an API key from Anthropic. Securely manage this key using a secret manager.

Example implementation

Instantiate com.google.adk.models.Claude, providing the desired Claude model name and an AnthropicOkHttpClient configured with your API key. Then, pass the Claude instance to your LlmAgent, as shown in the following example:

import com.anthropic.client.AnthropicClient;
import com.google.adk.agents.LlmAgent;
import com.google.adk.models.Claude;
import com.anthropic.client.okhttp.AnthropicOkHttpClient; // From Anthropic's SDK

public class DirectAnthropicAgent {

  private static final String CLAUDE_MODEL_ID = "claude-3-7-sonnet-latest"; // Or your preferred Claude model

  public static LlmAgent createAgent() {

    // It's recommended to load sensitive keys from a secure config
    AnthropicClient anthropicClient = AnthropicOkHttpClient.builder()
        .apiKey("ANTHROPIC_API_KEY")
        .build();

    Claude claudeModel = new Claude(
        CLAUDE_MODEL_ID,
        anthropicClient
    );

    return LlmAgent.builder()
        .name("claude_direct_agent")
        .model(claudeModel)
        .instruction("You are a helpful AI assistant powered by Anthropic Claude.")
        // ... other LlmAgent configurations
        .build();
  }

  public static void main(String[] args) {
    try {
      LlmAgent agent = createAgent();
      System.out.println("Successfully created direct Anthropic agent: " + agent.name());
    } catch (IllegalStateException e) {
      System.err.println("Error creating agent: " + e.getMessage());
    }
  }
}