Skip to content

OpenAI-Compatible (compat-oai)

The compat-oai plugin is a base implementation for connecting to any endpoint that follows the OpenAI API format.

<dependency>
<groupId>com.google.genkit</groupId>
<artifactId>genkit-plugin-compat-oai</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>

Connect to custom OpenAI-compatible endpoints:

import com.google.genkit.plugins.compatoai.CompatOaiPlugin;
Genkit genkit = Genkit.builder()
.plugin(CompatOaiPlugin.create(
"https://your-custom-endpoint.com/v1",
"your-api-key"))
.build();

This plugin serves as the base for several other plugins:

  • xAI (Grok)
  • DeepSeek
  • Mistral
  • Cohere
  • Groq
  • OpenAI
  • Query parameter support (for Azure OpenAI, versioning, etc.)
  • Tool calling
  • Streaming
  • Compatible with self-hosted LLM endpoints (vLLM, LiteLLM, etc.)