Generate content with multimodal inputs.
Endpoint
post
https://{service-endpoint}/v1beta1/{model}:generateContent
Where {service-endpoint}
is one of the supported service endpoints.
Path parameters
model
string
Required. The name of the publisher model requested to serve the prediction. Format: projects/{project}/locations/{location}/publishers/*/models/*
Request body
The request body contains data with the following structure:
contents[]
object (Content
)
Required. The content of the current conversation with the model.
For single-turn queries, this is a single instance. For multi-turn queries, this is a repeated field that contains conversation history + latest request.
cachedContent
string
Optional. The name of the cached content used as context to serve the prediction. Note: only used in explicit caching, where users can have control over caching (e.g. what content to cache) and enjoy guaranteed cost savings. Format: projects/{project}/locations/{location}/cachedContents/{cachedContent}
tools[]
object (Tool
)
Optional. A list of Tools
the model may use to generate the next response.
A Tool
is a piece of code that enables the system to interact with external systems to perform an action, or set of actions, outside of knowledge and scope of the model.
toolConfig
object (ToolConfig
)
Optional. Tool config. This config is shared for all tools provided in the request.
safetySettings[]
object (SafetySetting
)
Optional. Per request settings for blocking unsafe content. Enforced on GenerateContentResponse.candidates.
generationConfig
object (GenerationConfig
)
Optional. Generation config.
systemInstruction
object (Content
)
Optional. The user provided system instructions for the model. Note: only text should be used in parts and content in each part will be in a separate paragraph.
Example request
Text
Java
Node.js
Python
Multi-modal
Java
Node.js
Python
Advanced Use Case
Go
Node.js
Ground with public data
Java
Node.js
Ground with private data
Java
Node.js
Response body
If successful, the response body contains an instance of GenerateContentResponse
.