Class XAIPlugin

java.lang.Object
com.google.genkit.plugins.xai.XAIPlugin
All Implemented Interfaces:
Plugin

public class XAIPlugin extends Object implements Plugin
XAIPlugin provides XAI (x.ai / Grok) model integrations for Genkit. This plugin registers Grok models as Genkit actions using the OpenAI-compatible API.
  • Field Details

    • SUPPORTED_MODELS

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

    • XAIPlugin

      public XAIPlugin()
      Creates an XAIPlugin with default options (using XAI_API_KEY environment variable).
    • XAIPlugin

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

    • create

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

      public static XAIPlugin create()
      Creates an XAIPlugin using the XAI_API_KEY environment variable.
      Returns:
      a new XAIPlugin
    • 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 XAIPlugin 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., "grok-5")
      Returns:
      this plugin instance for method chaining
    • getOptions

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