Skip to content

OpenAI

The OpenAI plugin provides access to OpenAI’s models including GPT-4o, DALL-E, and text embeddings.

<dependency>
<groupId>com.google.genkit</groupId>
<artifactId>genkit-plugin-openai</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
Terminal window
export OPENAI_API_KEY=your-api-key
import 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());
  • openai/gpt-5.5 — Most capable flagship (also gpt-5.5-pro)
  • openai/gpt-5.4 — High-performance general model (also -mini, -nano, -pro)
  • openai/gpt-5 — GPT-5 base (also gpt-5-mini, gpt-5-nano, gpt-5-pro)
  • openai/gpt-4.1 — Smartest non-reasoning model (also gpt-4.1-mini)
  • openai/gpt-4o — Multimodal model
  • openai/gpt-4o-mini — Fast and cost-effective
  • openai/o3 — Reasoning model (also o3-pro)
EmbedResponse response = genkit.embed(
"openai/text-embedding-3-small", documents
);
  • 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

See the openai sample.