GenerativeModel class

A facilitator for a given multimodal model (eg; Gemini).

modelName name of the model in the backend apiKey authentication key for interacting with the backend generationConfig configuration parameters to use for content generation safetySettings the safety bounds to use during alongside prompts during content generation

Constructors

GenerativeModel(String modelName, String apiKey, {GenerationConfig? generationConfig, List<SafetySetting>? safetySettings})

Properties

apiKey String
final
generationConfig GenerationConfig?
final
hashCode int
The hash code for this object.
no setterinherited
modelName String
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
safetySettings List<SafetySetting>?
final

Methods

countTokens(List<Content> prompt) Future<CountTokensResponse>
Counts the number of tokens used in a prompt.
generateContent(List<Content> prompt) Future<GenerateContentResponse>
Generates a response from the backend with the provided Contents. prompt A group of Contents to send to the model. Returns a GenerateContentResponse after some delay. Function should be called within a async function
generateContentFromImage(Uint8List prompt) Future<GenerateContentResponse>
Generates a response from the backend with the provided image represented Content.
generateContentFromText(String prompt) Future<GenerateContentResponse>
Generates a response from the backend with the provided text represented Content.
generateContentStream(List<Content> prompt) Future<Stream<GenerateContentResponse>>
Generates a streaming response from the backend with the provided Contents.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
startChat({List<Content> history = const []}) Chat
Creates a chat instance which internally tracks the ongoing conversation with the model.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited