OpenAI
The OpenAI plugin provides access to OpenAI’s models including GPT-4o, DALL-E, and text embeddings.
Installation
Section titled “Installation”<dependency> <groupId>com.google.genkit</groupId> <artifactId>genkit-plugin-openai</artifactId> <version>1.0.0-SNAPSHOT</version></dependency>Configuration
Section titled “Configuration”export OPENAI_API_KEY=your-api-keyimport com.google.genkit.plugins.openai.OpenAIPlugin;
Genkit genkit = Genkit.builder() .plugin(OpenAIPlugin.create()) .build();
ModelResponse response = genkit.generate( GenerateOptions.builder() .model("openai/gpt-4o-mini") .prompt("Tell me about AI") .build());Available models
Section titled “Available models”openai/gpt-4o— Most capable modelopenai/gpt-4o-mini— Fast and cost-effectiveopenai/gpt-4-turbo— Previous generation flagshipopenai/o1-preview— Reasoning modelopenai/o1-mini— Fast reasoning model
Embeddings
Section titled “Embeddings”EmbedResponse response = genkit.embed( "openai/text-embedding-3-small", documents);Features
Section titled “Features”- Text generation and streaming
- Vision (image understanding)
- Tool calling
- Embeddings (text-embedding-3-small, text-embedding-3-large)
- Image generation (DALL-E 3/2)
- RAG support
Sample
Section titled “Sample”See the openai sample.