Class AnthropicPlugin

java.lang.Object
com.google.genkit.plugins.anthropic.AnthropicPlugin
All Implemented Interfaces:
Plugin

public class AnthropicPlugin extends Object implements Plugin
AnthropicPlugin provides Anthropic Claude model integrations for Genkit. This plugin registers Claude models (Claude 3.5, Claude 3, Claude 2) as Genkit actions for text generation with support for streaming.
  • Field Details

    • SUPPORTED_MODELS

      public static final List<String> SUPPORTED_MODELS
      Supported Claude models.
  • Constructor Details

    • AnthropicPlugin

      public AnthropicPlugin()
      Creates an AnthropicPlugin with default options.
    • AnthropicPlugin

      public AnthropicPlugin(AnthropicPluginOptions options)
      Creates an AnthropicPlugin with the specified options.
      Parameters:
      options - the plugin options
  • Method Details

    • create

      public static AnthropicPlugin create(String apiKey)
      Creates an AnthropicPlugin with the specified API key.
      Parameters:
      apiKey - the Anthropic API key
      Returns:
      a new AnthropicPlugin
    • create

      public static AnthropicPlugin create()
      Creates an AnthropicPlugin using the ANTHROPIC_API_KEY environment variable.
      Returns:
      a new AnthropicPlugin
    • getName

      public String getName()
      Description copied from interface: Plugin
      Returns the unique identifier for the plugin. This name is used for registration and lookup.
      Specified by:
      getName in interface Plugin
      Returns:
      the plugin name
    • init

      public List<Action<?,?,?>> init()
      Description copied from interface: Plugin
      Initializes the plugin. This method is called once during Genkit initialization. The plugin should return a list of actions that it provides.
      Specified by:
      init in interface Plugin
      Returns:
      list of actions provided by this plugin
    • customModel

      public AnthropicPlugin customModel(String modelName)
      Registers a custom model name. Use this to work with models not in the default list. Call this method before passing the plugin to Genkit.builder().
      Parameters:
      modelName - the model name (e.g., "claude-4-opus-20260101")
      Returns:
      this plugin instance for method chaining
    • getOptions

      public AnthropicPluginOptions getOptions()
      Gets the plugin options.
      Returns:
      the options