The Gemini API supports batch mode, which lets you process multiple requests in a single call. For more details, see the Batch mode guide.
Candidate
- JSON representation
- FinishReason
- GroundingAttribution
- AttributionSourceId
- GroundingPassageId
- SemanticRetrieverChunk
- GroundingMetadata
- SearchEntryPoint
- GroundingChunk
- Web
- GroundingSupport
- Segment
- RetrievalMetadata
- LogprobsResult
- TopCandidates
- Candidate
- UrlContextMetadata
- UrlMetadata
- UrlRetrievalStatus
A response candidate generated from the model.
Output only. Generated content returned from the model.
Optional. Output only. The reason why the model stopped generating tokens.
If empty, the model has not stopped generating tokens.
List of ratings for the safety of a response candidate.
There is at most one rating per category.
Output only. Citation information for model-generated candidate.
This field may be populated with recitation information for any text included in the content
. These are passages that are "recited" from copyrighted material in the foundational LLM's training data.
tokenCount
integer
Output only. Token count for this candidate.
Output only. Attribution information for sources that contributed to a grounded answer.
This field is populated for GenerateAnswer
calls.
Output only. Grounding metadata for the candidate.
This field is populated for GenerateContent
calls.
avgLogprobs
number
Output only. Average log probability score of the candidate.
Output only. Log-likelihood scores for the response tokens and top tokens
Output only. Metadata related to url context retrieval tool.
index
integer
Output only. Index of the candidate in the list of response candidates.
JSON representation |
---|
{ "content": { object ( |
FinishReason
Defines the reason why the model stopped generating tokens.
Enums | |
---|---|
FINISH_REASON_UNSPECIFIED |
Default value. This value is unused. |
STOP |
Natural stop point of the model or provided stop sequence. |
MAX_TOKENS |
The maximum number of tokens as specified in the request was reached. |
SAFETY |
The response candidate content was flagged for safety reasons. |
RECITATION |
The response candidate content was flagged for recitation reasons. |
LANGUAGE |
The response candidate content was flagged for using an unsupported language. |
OTHER |
Unknown reason. |
BLOCKLIST |
Token generation stopped because the content contains forbidden terms. |
PROHIBITED_CONTENT |
Token generation stopped for potentially containing prohibited content. |
SPII |
Token generation stopped because the content potentially contains Sensitive Personally Identifiable Information (SPII). |
MALFORMED_FUNCTION_CALL |
The function call generated by the model is invalid. |
IMAGE_SAFETY |
Token generation stopped because generated images contain safety violations. |
GroundingAttribution
Attribution for a source that contributed to an answer.
Output only. Identifier for the source contributing to this attribution.
Grounding source content that makes up this attribution.
JSON representation |
---|
{ "sourceId": { object ( |
AttributionSourceId
Identifier for the source contributing to this attribution.
source
Union type
source
can be only one of the following:Identifier for an inline passage.
Identifier for a Chunk
fetched via Semantic Retriever.
JSON representation |
---|
{ // source "groundingPassage": { object ( |
GroundingPassageId
Identifier for a part within a GroundingPassage
.
passageId
string
Output only. ID of the passage matching the GenerateAnswerRequest
's GroundingPassage.id
.
partIndex
integer
Output only. Index of the part within the GenerateAnswerRequest
's GroundingPassage.content
.
JSON representation |
---|
{ "passageId": string, "partIndex": integer } |
SemanticRetrieverChunk
Identifier for a Chunk
retrieved via Semantic Retriever specified in the GenerateAnswerRequest
using SemanticRetrieverConfig
.
source
string
Output only. Name of the source matching the request's SemanticRetrieverConfig.source
. Example: corpora/123
or corpora/123/documents/abc
chunk
string
Output only. Name of the Chunk
containing the attributed text. Example: corpora/123/documents/abc/chunks/xyz
JSON representation |
---|
{ "source": string, "chunk": string } |
GroundingMetadata
Metadata returned to client when grounding is enabled.
List of supporting references retrieved from specified grounding source.
List of grounding support.
webSearchQueries[]
string
Web search queries for the following-up web search.
Optional. Google search entry for the following-up web searches.
Metadata related to retrieval in the grounding flow.
JSON representation |
---|
{ "groundingChunks": [ { object ( |
SearchEntryPoint
Google search entry point.
renderedContent
string
Optional. Web content snippet that can be embedded in a web page or an app webview.
Optional. Base64 encoded JSON representing array of <search term, search url> tuple.
A base64-encoded string.
JSON representation |
---|
{ "renderedContent": string, "sdkBlob": string } |
GroundingChunk
Grounding chunk.
chunk_type
Union type
chunk_type
can be only one of the following:Grounding chunk from the web.
JSON representation |
---|
{
// chunk_type
"web": {
object ( |
Web
Chunk from the web.
uri
string
URI reference of the chunk.
title
string
Title of the chunk.
JSON representation |
---|
{ "uri": string, "title": string } |
GroundingSupport
Grounding support.
groundingChunkIndices[]
integer
A list of indices (into 'grounding_chunk') specifying the citations associated with the claim. For instance [1,3,4] means that grounding_chunk[1], grounding_chunk[3], grounding_chunk[4] are the retrieved content attributed to the claim.
confidenceScores[]
number
Confidence score of the support references. Ranges from 0 to 1. 1 is the most confident. This list must have the same size as the groundingChunkIndices.
Segment of the content this support belongs to.
JSON representation |
---|
{
"groundingChunkIndices": [
integer
],
"confidenceScores": [
number
],
"segment": {
object ( |
Segment
Segment of the content.
partIndex
integer
Output only. The index of a Part object within its parent Content object.
startIndex
integer
Output only. Start index in the given Part, measured in bytes. Offset from the start of the Part, inclusive, starting at zero.
endIndex
integer
Output only. End index in the given Part, measured in bytes. Offset from the start of the Part, exclusive, starting at zero.
text
string
Output only. The text corresponding to the segment from the response.
JSON representation |
---|
{ "partIndex": integer, "startIndex": integer, "endIndex": integer, "text": string } |
RetrievalMetadata
Metadata related to retrieval in the grounding flow.
googleSearchDynamicRetrievalScore
number
Optional. Score indicating how likely information from google search could help answer the prompt. The score is in the range [0, 1], where 0 is the least likely and 1 is the most likely. This score is only populated when google search grounding and dynamic retrieval is enabled. It will be compared to the threshold to determine whether to trigger google search.
JSON representation |
---|
{ "googleSearchDynamicRetrievalScore": number } |
LogprobsResult
Logprobs Result
Length = total number of decoding steps.
Length = total number of decoding steps. The chosen candidates may or may not be in topCandidates.
JSON representation |
---|
{ "topCandidates": [ { object ( |
TopCandidates
Candidates with top log probabilities at each decoding step.
Sorted by log probability in descending order.
JSON representation |
---|
{
"candidates": [
{
object ( |
Candidate
Candidate for the logprobs token and score.
token
string
The candidate’s token string value.
tokenId
integer
The candidate’s token id value.
logProbability
number
The candidate's log probability.
JSON representation |
---|
{ "token": string, "tokenId": integer, "logProbability": number } |
UrlContextMetadata
Metadata related to url context retrieval tool.
List of url context.
JSON representation |
---|
{
"urlMetadata": [
{
object ( |
UrlMetadata
Context of the a single url retrieval.
retrievedUrl
string
Retrieved url by the tool.
Status of the url retrieval.
JSON representation |
---|
{
"retrievedUrl": string,
"urlRetrievalStatus": enum ( |
UrlRetrievalStatus
Status of the url retrieval.
Enums | |
---|---|
URL_RETRIEVAL_STATUS_UNSPECIFIED |
Default value. This value is unused. |
URL_RETRIEVAL_STATUS_SUCCESS |
Url retrieval is successful. |
URL_RETRIEVAL_STATUS_ERROR |
Url retrieval is failed due to error. |
CitationMetadata
A collection of source attributions for a piece of content.
Citations to sources for a specific response.
JSON representation |
---|
{
"citationSources": [
{
object ( |
CitationSource
A citation to a source for a portion of a specific response.
startIndex
integer
Optional. Start of segment of the response that is attributed to this source.
Index indicates the start of the segment, measured in bytes.
endIndex
integer
Optional. End of the attributed segment, exclusive.
uri
string
Optional. URI that is attributed as a source for a portion of the text.
license
string
Optional. License for the GitHub project that is attributed as a source for segment.
License info is required for code citations.
JSON representation |
---|
{ "startIndex": integer, "endIndex": integer, "uri": string, "license": string } |
REST Resource: batches
Resource: Operation
This resource represents a long-running operation that is the result of a network API call.
name
string
The server-assigned name, which is only unique within the same service that originally returns it. If you use the default HTTP mapping, the name
should be a resource name ending with operations/{unique_id}
.
metadata
object
Service-specific metadata associated with the operation. It typically contains progress information and common metadata such as create time. Some services might not provide such metadata. Any method that returns a long-running operation should document the metadata type, if any.
An object containing fields of an arbitrary type. An additional field "@type"
contains a URI identifying the type. Example: { "id": 1234, "@type": "types.example.com/standard/id" }
.
done
boolean
If the value is false
, it means the operation is still in progress. If true
, the operation is completed, and either error
or response
is available.
result
Union type
error
or a valid response
. If done
== false
, neither error
nor response
is set. If done
== true
, exactly one of error
or response
can be set. Some services might not provide the result. result
can be only one of the following:The error result of the operation in case of failure or cancellation.
response
object
The normal, successful response of the operation. If the original method returns no data on success, such as Delete
, the response is google.protobuf.Empty
. If the original method is standard Get
/Create
/Update
, the response should be the resource. For other methods, the response should have the type XxxResponse
, where Xxx
is the original method name. For example, if the original method name is TakeSnapshot()
, the inferred response type is TakeSnapshotResponse
.
An object containing fields of an arbitrary type. An additional field "@type"
contains a URI identifying the type. Example: { "id": 1234, "@type": "types.example.com/standard/id" }
.
JSON representation |
---|
{
"name": string,
"metadata": {
"@type": string,
field1: ...,
...
},
"done": boolean,
// result
"error": {
object ( |
Method: batches.get
Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
Endpoint
gethttps: / /generativelanguage.googleapis.com /v1beta /{name=batches /*}
Path parameters
name
string
The name of the operation resource. It takes the form batches/{batches}
.
Request body
The request body must be empty.
Response body
If successful, the response body contains an instance of Operation
.
Method: batches.list
Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns UNIMPLEMENTED
.
Endpoint
gethttps: / /generativelanguage.googleapis.com /v1beta /{name=batches}
Path parameters
name
string
The name of the operation's parent resource. It takes the form batches
.
Query parameters
filter
string
The standard list filter.
pageSize
integer
The standard list page size.
pageToken
string
The standard list page token.
Request body
The request body must be empty.
Response body
If successful, the response body contains an instance of ListOperationsResponse
.
Method: batches.cancel
Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns google.rpc.Code.UNIMPLEMENTED
. Clients can use Operations.GetOperation
or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error
value with a google.rpc.Status.code
of 1
, corresponding to Code.CANCELLED
.
Endpoint
posthttps: / /generativelanguage.googleapis.com /v1beta /{name=batches /*}:cancel
Path parameters
name
string
The name of the operation resource to be cancelled. It takes the form batches/{batches}
.
Request body
The request body must be empty.
Response body
If successful, the response body is an empty JSON object.
Method: batches.delete
Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns google.rpc.Code.UNIMPLEMENTED
.
Endpoint
deletehttps: / /generativelanguage.googleapis.com /v1beta /{name=batches /*}
Path parameters
name
string
The name of the operation resource to be deleted. It takes the form batches/{batches}
.
Request body
The request body must be empty.
Response body
If successful, the response body is an empty JSON object.