Skip to main content

Creating Plugins

Genkit plugins are modular extensions that add new capabilities to the framework. You can create custom plugins to integrate new model providers, vector stores, or any other functionality.

Plugin Architecture

A Genkit plugin implements the PluginProvider interface:

Plugin Types

Plugin API v1 (Legacy)

The original plugin API uses genkitPlugin:
The new plugin API supports direct model usage without Genkit instance:

Creating a Model Provider Plugin

Basic Model Plugin

Creating a Vector Store Plugin

Retriever and Indexer Plugin

Creating an Embedder Plugin

Plugin Lifecycle

Initialization Phase

  1. User configures plugin - When calling genkit({ plugins: [...] })
  2. Plugin initializer runs - The init function is called
  3. Actions registered - Models, retrievers, etc. are registered with Genkit

Resolution Phase (Optional)

  1. User references action - e.g., myProvider.model('unknown-model')
  2. Resolver called - The resolve function tries to create the action dynamically
  3. Action returned - If successful, action is used immediately

Listing Phase (Optional)

  1. Developer UI queries - Or programmatic discovery
  2. List function called - Returns metadata about available actions
  3. Actions displayed - User can see what’s available

Best Practices

1. Use TypeScript

2. Handle Authentication

3. Provide Model References

4. Support Streaming

5. Error Handling

6. Document Configuration

Testing Plugins

Publishing Plugins

See Publishing Plugins for details on publishing your plugin to npm.

Examples

Study these official plugins for reference: