GenerativeModel class final

A multimodel generative model (like Gemini).

Allows generating content and counting the number of tokens in a piece of content.

Available extensions

Properties

client → ApiClient
The API client.
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
model → ({String name, String prefix})
The normalized model name.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
tools List<Tool>?
List of Tool registered in the model
final

Methods

countTokens(Iterable<Content> contents) Future<CountTokensResponse>
Counts the total number of tokens in contents.
generateContent(Iterable<Content> prompt, {List<SafetySetting>? safetySettings, GenerationConfig? generationConfig, List<Tool>? tools, ToolConfig? toolConfig}) Future<GenerateContentResponse>
Generates content responding to prompt.
generateContentStream(Iterable<Content> prompt, {List<SafetySetting>? safetySettings, GenerationConfig? generationConfig, List<Tool>? tools, ToolConfig? toolConfig}) Stream<GenerateContentResponse>
Generates a stream of content responding to prompt.
makeRequest<T>(Task task, Map<String, Object?> params, T parse(Map<String, Object?>)) Future<T>
Make a unary request for task with JSON encodable params.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
startChat({List<Content>? history, List<SafetySetting>? safetySettings, GenerationConfig? generationConfig, int? maxTurns}) ChatSession

Available on GenerativeModel, provided by the StartChatExtension extension

Starts a ChatSession that will use this model to respond to messages.
taskUri(Task task) Uri
Returns a URI for the given task.
inherited
toString() String
A string representation of this object.
inherited

Operators

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