Configuration options for the plugin.
A Genkit plugin configured for an OpenAI-compatible service.
Usage: Import openAICompatible (or your chosen import name for the default
export) from this package (e.g., genkitx-openai). Then, invoke it within
the plugins array of configureGenkit, providing the necessary
PluginOptions.
Example:
import myOpenAICompatiblePlugin from 'genkitx-openai'; // Default import
export default configureGenkit({
plugins: [
myOpenAICompatiblePlugin({
name: 'gpt4o', // Name for this specific plugin configuration
apiKey: process.env.OPENAI_API_KEY,
// For a non-OpenAI compatible endpoint:
// baseURL: 'https://api.custom-llm-provider.com/v1',
}),
myOpenAICompatiblePlugin({
name: 'localLlama',
apiKey: 'ollama', // Or specific key if required by local server
baseURL: 'http://localhost:11434/v1', // Example for Ollama
}),
// ... other plugins
],
});
This module provides the
openAICompatibleplugin factory for Genkit. It enables interaction with OpenAI-compatible API endpoints, allowing users to leverage various AI models by configuring API keys and other client options.The core export is
openAICompatible, a function that acceptsPluginOptionsand returns a Genkit plugin.Key
PluginOptionsinclude:name: A string to uniquely identify this plugin instance (e.g., 'deepSeek', 'customOpenAI').apiKey: The API key for the service. If not provided directly, the plugin will attempt to use theOPENAI_API_KEYenvironment variable.initializer: An optional asynchronous function for custom setup after the OpenAI client is initialized. It receives the Genkit instance and the OpenAI client.ClientOptions(likebaseURL,timeout, etc.) can be passed to customize the OpenAI client.The returned plugin initializes an OpenAI client tailored to the provided options, making configured models available for use within Genkit flows.