Class OmniModel
- All Implemented Interfaces:
Model,Action<ModelRequest,,ModelResponse, ModelResponseChunk> Registerable
Gemini Omni (gemini-omni-flash-preview) natively processes text, image, audio, and
video and produces video (with audio). It is served by the Interactions API (POST
/v1beta/interactions) rather than generateContent, and supports conversational
editing: each turn can build on a previous result.
Conversational editing. The Interactions API is stateful server-side. This model
bridges it to Genkit's stateless Model interface as follows:
- On the first turn, send a prompt (and optional media). The response's
custommap carries the returnedinteractionId. - To iteratively edit, pass that id back as the
previousInteractionIdconfig option on the nextgeneratecall, with the edit instruction as the prompt. The model applies the change while preserving elements you did not mention.
Supported config options (via the request config map): previousInteractionId,
aspectRatio (e.g. "16:9"), duration (e.g. "10s"), delivery ("inline" (default) |
"uri"), task ("text_to_video" | "image_to_video"), thinkingLevel,
maxOutputTokens.
Only the Gemini Developer API (API key) is supported; Vertex AI is not.
Note: the Interactions API is in preview; request/response field shapes may evolve.
-
Constructor Summary
ConstructorsConstructorDescriptionOmniModel(String modelName, GoogleGenAIPluginOptions options) Creates a new OmniModel. -
Method Summary
Modifier and TypeMethodDescriptiongetInfo()Gets information about the model's capabilities.getName()Returns the name of the action.run(ActionContext context, ModelRequest request) Generates a response from the given request.run(ActionContext context, ModelRequest request, Consumer<ModelResponseChunk> streamCallback) Generates a streaming response from the given request.booleanReturns whether this model supports streaming.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.google.genkit.ai.Model
getDesc, getInputSchema, getMetadata, getOutputSchema, getType, register, runJson, runJsonWithTelemetry
-
Constructor Details
-
OmniModel
Creates a new OmniModel.- Parameters:
modelName- the model name (e.g., "gemini-omni-flash-preview")options- the plugin options
-
-
Method Details
-
getName
Description copied from interface:ActionReturns the name of the action.- Specified by:
getNamein interfaceAction<ModelRequest,ModelResponse, ModelResponseChunk> - Returns:
- the action name
-
getInfo
Description copied from interface:ModelGets information about the model's capabilities. -
supportsStreaming
public boolean supportsStreaming()Description copied from interface:ModelReturns whether this model supports streaming.- Specified by:
supportsStreamingin interfaceModel- Returns:
- true if streaming is supported
-
run
Description copied from interface:ModelGenerates a response from the given request.- Specified by:
runin interfaceAction<ModelRequest,ModelResponse, ModelResponseChunk> - Specified by:
runin interfaceModel- Parameters:
context- the action contextrequest- the model request- Returns:
- the model response
-
run
public ModelResponse run(ActionContext context, ModelRequest request, Consumer<ModelResponseChunk> streamCallback) Description copied from interface:ModelGenerates a streaming response from the given request.- Specified by:
runin interfaceAction<ModelRequest,ModelResponse, ModelResponseChunk> - Specified by:
runin interfaceModel- Parameters:
context- the action contextrequest- the model requeststreamCallback- callback for streaming chunks- Returns:
- the final model response
-