Class Claude

java.lang.Object
com.google.adk.models.BaseLlm
com.google.adk.models.Claude

public class Claude extends BaseLlm
Represents the Claude Generative AI model by Anthropic.

Live connections are not supported for Claude.

  • Constructor Details

    • Claude

      public Claude(String modelName, com.anthropic.client.AnthropicClient anthropicClient)
      Constructs a new Claude instance. Requests sent through anthropicClient carry ADK's usage-tracking headers, added to the ones the client already sends.
      Parameters:
      modelName - The name of the Claude model to use (e.g., "claude-3-opus-20240229").
      anthropicClient - The Anthropic API client instance.
    • Claude

      public Claude(String modelName, com.anthropic.client.AnthropicClient anthropicClient, int maxTokens)
      Constructs a new Claude instance with a default for the maximum number of tokens to generate.
      Parameters:
      modelName - The name of the Claude model to use.
      anthropicClient - The Anthropic API client instance.
      maxTokens - The max_tokens sent when the request config sets no maxOutputTokens.
  • Method Details

    • builder

      public static Claude.Builder builder()
      Returns a builder for Claude. Use it for options the constructors don't take, such as reasoning effort.
    • generateContent

      public io.reactivex.rxjava3.core.Flowable<LlmResponse> generateContent(LlmRequest llmRequest, boolean stream)
      Description copied from class: BaseLlm
      Generates one content from the given LLM request and tools.
      Specified by:
      generateContent in class BaseLlm
      Parameters:
      llmRequest - The LLM request containing the input prompt and parameters.
      stream - A boolean flag indicating whether to stream the response.
      Returns:
      A Flowable of LlmResponses. For non-streaming calls, it will only yield one LlmResponse. For streaming calls, it may yield more than one LlmResponse, but all yielded LlmResponses should be treated as one content by merging their parts.
    • connect

      public BaseLlmConnection connect(LlmRequest llmRequest)
      Description copied from class: BaseLlm
      Creates a live connection to the LLM.
      Specified by:
      connect in class BaseLlm
    • capabilities

      public LlmCapabilities capabilities()
      Reports LlmCapabilities.outputSchemaAndTools() as false: this class drops a response schema sent beside function declarations.
      Overrides:
      capabilities in class BaseLlm