@@ -34,13 +34,13 @@ option java_package = "com.google.ai.generativelanguage.v1";
3434service GenerativeService {
3535 option (google.api.default_host ) = "generativelanguage.googleapis.com" ;
3636
37- // Generates a response from the model given an input
38- // `GenerateContentRequest`.
39- //
40- // Input capabilities differ between models, including tuned models. See the
41- // [model guide](https://ai.google.dev/ models/gemini) and
42- // [tuning guide](https://ai.google.dev/docs/model_tuning_guidance) for
43- // details.
37+ // Generates a model response given an input `GenerateContentRequest`.
38+ // Refer to the [text generation
39+ // guide](https://ai.google.dev/gemini-api/docs/text-generation) for detailed
40+ // usage information. Input capabilities differ between models, including
41+ // tuned models. Refer to the [model
42+ // guide](https://ai.google.dev/gemini-api/ docs/models/gemini) and [tuning
43+ // guide](https://ai.google.dev/gemini-api/docs/model-tuning) for details.
4444 rpc GenerateContent (GenerateContentRequest )
4545 returns (GenerateContentResponse ) {
4646 option (google.api.http ) = {
@@ -54,8 +54,9 @@ service GenerativeService {
5454 option (google.api.method_signature ) = "model,contents" ;
5555 }
5656
57- // Generates a streamed response from the model given an input
58- // `GenerateContentRequest`.
57+ // Generates a [streamed
58+ // response](https://ai.google.dev/gemini-api/docs/text-generation?lang=python#generate-a-text-stream)
59+ // from the model given an input `GenerateContentRequest`.
5960 rpc StreamGenerateContent (GenerateContentRequest )
6061 returns (stream GenerateContentResponse ) {
6162 option (google.api.http ) = {
@@ -65,7 +66,9 @@ service GenerativeService {
6566 option (google.api.method_signature ) = "model,contents" ;
6667 }
6768
68- // Generates an embedding from the model given an input `Content`.
69+ // Generates a text embedding vector from the input `Content` using the
70+ // specified [Gemini Embedding
71+ // model](https://ai.google.dev/gemini-api/docs/models/gemini#text-embedding).
6972 rpc EmbedContent (EmbedContentRequest ) returns (EmbedContentResponse ) {
7073 option (google.api.http ) = {
7174 post : "/v1/{model=models/*}:embedContent"
@@ -74,8 +77,9 @@ service GenerativeService {
7477 option (google.api.method_signature ) = "model,content" ;
7578 }
7679
77- // Generates multiple embeddings from the model given input text in a
78- // synchronous call.
80+ // Generates multiple embedding vectors from the input `Content` which
81+ // consists of a batch of strings represented as `EmbedContentRequest`
82+ // objects.
7983 rpc BatchEmbedContents (BatchEmbedContentsRequest )
8084 returns (BatchEmbedContentsResponse ) {
8185 option (google.api.http ) = {
@@ -85,7 +89,9 @@ service GenerativeService {
8589 option (google.api.method_signature ) = "model,requests" ;
8690 }
8791
88- // Runs a model's tokenizer on input content and returns the token count.
92+ // Runs a model's tokenizer on input `Content` and returns the token count.
93+ // Refer to the [tokens guide](https://ai.google.dev/gemini-api/docs/tokens)
94+ // to learn more about tokens.
8995 rpc CountTokens (CountTokensRequest ) returns (CountTokensResponse ) {
9096 option (google.api.http ) = {
9197 post : "/v1/{model=models/*}:countTokens"
@@ -136,9 +142,10 @@ message GenerateContentRequest {
136142
137143 // Required. The content of the current conversation with the model.
138144 //
139- // For single-turn queries, this is a single instance. For multi-turn queries,
140- // this is a repeated field that contains conversation history + latest
141- // request.
145+ // For single-turn queries, this is a single instance. For multi-turn queries
146+ // like [chat](https://ai.google.dev/gemini-api/docs/text-generation#chat),
147+ // this is a repeated field that contains the conversation history and the
148+ // latest request.
142149 repeated Content contents = 2 [(google.api.field_behavior ) = REQUIRED ];
143150
144151 // Optional. A list of unique `SafetySetting` instances for blocking unsafe
@@ -153,7 +160,11 @@ message GenerateContentRequest {
153160 // `SafetyCategory` provided in the list, the API will use the default safety
154161 // setting for that category. Harm categories HARM_CATEGORY_HATE_SPEECH,
155162 // HARM_CATEGORY_SEXUALLY_EXPLICIT, HARM_CATEGORY_DANGEROUS_CONTENT,
156- // HARM_CATEGORY_HARASSMENT are supported.
163+ // HARM_CATEGORY_HARASSMENT are supported. Refer to the
164+ // [guide](https://ai.google.dev/gemini-api/docs/safety-settings)
165+ // for detailed information on available safety settings. Also refer to the
166+ // [Safety guidance](https://ai.google.dev/gemini-api/docs/safety-guidance) to
167+ // learn how to incorporate safety considerations in your AI applications.
157168 repeated SafetySetting safety_settings = 3
158169 [(google.api.field_behavior ) = OPTIONAL ];
159170
@@ -163,7 +174,7 @@ message GenerateContentRequest {
163174}
164175
165176// Configuration options for model generation and outputs. Not all parameters
166- // may be configurable for every model.
177+ // are configurable for every model.
167178message GenerationConfig {
168179 // Optional. Number of generated responses to return.
169180 //
@@ -173,11 +184,11 @@ message GenerationConfig {
173184
174185 // Optional. The set of character sequences (up to 5) that will stop output
175186 // generation. If specified, the API will stop at the first appearance of a
176- // stop sequence . The stop sequence will not be included as part of the
187+ // `stop_sequence` . The stop sequence will not be included as part of the
177188 // response.
178189 repeated string stop_sequences = 2 [(google.api.field_behavior ) = OPTIONAL ];
179190
180- // Optional. The maximum number of tokens to include in a candidate.
191+ // Optional. The maximum number of tokens to include in a response candidate.
181192 //
182193 // Note: The default value varies by model, see the `Model.output_token_limit`
183194 // attribute of the `Model` returned from the `getModel` function.
@@ -194,59 +205,68 @@ message GenerationConfig {
194205 // Optional. The maximum cumulative probability of tokens to consider when
195206 // sampling.
196207 //
197- // The model uses combined Top-k and nucleus sampling.
208+ // The model uses combined Top-k and Top-p ( nucleus) sampling.
198209 //
199210 // Tokens are sorted based on their assigned probabilities so that only the
200211 // most likely tokens are considered. Top-k sampling directly limits the
201- // maximum number of tokens to consider, while Nucleus sampling limits number
202- // of tokens based on the cumulative probability.
212+ // maximum number of tokens to consider, while Nucleus sampling limits the
213+ // number of tokens based on the cumulative probability.
203214 //
204- // Note: The default value varies by model, see the `Model.top_p`
205- // attribute of the `Model` returned from the `getModel` function.
215+ // Note: The default value varies by `Model` and is specified by
216+ // the`Model.top_p` attribute returned from the `getModel` function. An empty
217+ // `top_k` attribute indicates that the model doesn't apply top-k sampling
218+ // and doesn't allow setting `top_k` on requests.
206219 optional float top_p = 6 [(google.api.field_behavior ) = OPTIONAL ];
207220
208221 // Optional. The maximum number of tokens to consider when sampling.
209222 //
210- // Models use nucleus sampling or combined Top-k and nucleus sampling.
211- // Top-k sampling considers the set of `top_k` most probable tokens.
212- // Models running with nucleus sampling don't allow top_k setting.
223+ // Gemini models use Top-p ( nucleus) sampling or a combination of Top-k and
224+ // nucleus sampling. Top-k sampling considers the set of `top_k` most probable
225+ // tokens. Models running with nucleus sampling don't allow top_k setting.
213226 //
214- // Note: The default value varies by model, see the `Model.top_k`
215- // attribute of the `Model` returned from the `getModel` function. Empty
216- // `top_k` field in `Model` indicates the model doesn't apply top-k sampling
227+ // Note: The default value varies by `Model` and is specified by
228+ // the`Model.top_p` attribute returned from the `getModel` function. An empty
229+ // `top_k` attribute indicates that the model doesn't apply top-k sampling
217230 // and doesn't allow setting `top_k` on requests.
218231 optional int32 top_k = 7 [(google.api.field_behavior ) = OPTIONAL ];
219232}
220233
221- // Response from the model supporting multiple candidates .
234+ // Response from the model supporting multiple candidate responses .
222235//
223- // Note on safety ratings and content filtering. They are reported for both
236+ // Safety ratings and content filtering are reported for both
224237// prompt in `GenerateContentResponse.prompt_feedback` and for each candidate
225- // in `finish_reason` and in `safety_ratings`. The API contract is that :
226- // - either all requested candidates are returned or no candidates at all
227- // - no candidates are returned only if there was something wrong with the
228- // prompt (see `prompt_feedback`)
229- // - feedback on each candidate is reported on `finish_reason` and
238+ // in `finish_reason` and in `safety_ratings`. The API:
239+ // - Returns either all requested candidates or none of them
240+ // - Returns no candidates at all only if there was something wrong with the
241+ // prompt (check `prompt_feedback`)
242+ // - Reports feedback on each candidate in `finish_reason` and
230243// `safety_ratings`.
231244message GenerateContentResponse {
232245 // A set of the feedback metadata the prompt specified in
233246 // `GenerateContentRequest.content`.
234247 message PromptFeedback {
235- // Specifies what was the reason why prompt was blocked.
248+ // Specifies the reason why the prompt was blocked.
236249 enum BlockReason {
237250 // Default value. This value is unused.
238251 BLOCK_REASON_UNSPECIFIED = 0 ;
239252
240- // Prompt was blocked due to safety reasons. You can inspect
241- // `safety_ratings` to understand which safety category blocked it.
253+ // Prompt was blocked due to safety reasons. Inspect `safety_ratings`
254+ // to understand which safety category blocked it.
242255 SAFETY = 1 ;
243256
244- // Prompt was blocked due to unknown reaasons .
257+ // Prompt was blocked due to unknown reasons .
245258 OTHER = 2 ;
259+
260+ // Prompt was blocked due to the terms which are included from the
261+ // terminology blocklist.
262+ BLOCKLIST = 3 ;
263+
264+ // Prompt was blocked due to prohibited content.
265+ PROHIBITED_CONTENT = 4 ;
246266 }
247267
248268 // Optional. If set, the prompt was blocked and no candidates are returned.
249- // Rephrase your prompt.
269+ // Rephrase the prompt.
250270 BlockReason block_reason = 1 [(google.api.field_behavior ) = OPTIONAL ];
251271
252272 // Ratings for safety of the prompt.
@@ -256,13 +276,16 @@ message GenerateContentResponse {
256276
257277 // Metadata on the generation request's token usage.
258278 message UsageMetadata {
259- // Number of tokens in the prompt.
279+ // Number of tokens in the prompt. When `cached_content` is set, this is
280+ // still the total effective prompt size meaning this includes the number of
281+ // tokens in the cached content.
260282 int32 prompt_token_count = 1 ;
261283
262- // Total number of tokens across the generated candidates.
284+ // Total number of tokens across all the generated response candidates.
263285 int32 candidates_token_count = 2 ;
264286
265- // Total token count for the generation request (prompt + candidates).
287+ // Total token count for the generation request (prompt + response
288+ // candidates).
266289 int32 total_token_count = 3 ;
267290 }
268291
@@ -289,25 +312,42 @@ message Candidate {
289312 // The maximum number of tokens as specified in the request was reached.
290313 MAX_TOKENS = 2 ;
291314
292- // The candidate content was flagged for safety reasons.
315+ // The response candidate content was flagged for safety reasons.
293316 SAFETY = 3 ;
294317
295- // The candidate content was flagged for recitation reasons.
318+ // The response candidate content was flagged for recitation reasons.
296319 RECITATION = 4 ;
297320
321+ // The response candidate content was flagged for using an unsupported
322+ // language.
323+ LANGUAGE = 6 ;
324+
298325 // Unknown reason.
299326 OTHER = 5 ;
327+
328+ // Token generation stopped because the content contains forbidden terms.
329+ BLOCKLIST = 7 ;
330+
331+ // Token generation stopped for potentially containing prohibited content.
332+ PROHIBITED_CONTENT = 8 ;
333+
334+ // Token generation stopped because the content potentially contains
335+ // Sensitive Personally Identifiable Information (SPII).
336+ SPII = 9 ;
337+
338+ // The function call generated by the model is invalid.
339+ MALFORMED_FUNCTION_CALL = 10 ;
300340 }
301341
302- // Output only. Index of the candidate in the list of candidates.
342+ // Output only. Index of the candidate in the list of response candidates.
303343 optional int32 index = 3 [(google.api.field_behavior ) = OUTPUT_ONLY ];
304344
305345 // Output only. Generated content returned from the model.
306346 Content content = 1 [(google.api.field_behavior ) = OUTPUT_ONLY ];
307347
308348 // Optional. Output only. The reason why the model stopped generating tokens.
309349 //
310- // If empty, the model has not stopped generating the tokens.
350+ // If empty, the model has not stopped generating tokens.
311351 FinishReason finish_reason = 2 [
312352 (google.api.field_behavior ) = OPTIONAL ,
313353 (google.api.field_behavior ) = OUTPUT_ONLY
@@ -362,8 +402,8 @@ message EmbedContentRequest {
362402
363403 // Optional. Optional reduced dimension for the output embedding. If set,
364404 // excessive values in the output embedding are truncated from the end.
365- // Supported by newer models since 2024, and the earlier model
366- // (`models/embedding-001`) cannot specify this value .
405+ // Supported by newer models since 2024 only. You cannot set this value if
406+ // using the earlier model (`models/embedding-001`).
367407 optional int32 output_dimensionality = 5
368408 [(google.api.field_behavior ) = OPTIONAL ];
369409}
@@ -431,8 +471,14 @@ message CountTokensRequest {
431471 // when `generate_content_request` is set.
432472 repeated Content contents = 2 [(google.api.field_behavior ) = OPTIONAL ];
433473
434- // Optional. The overall input given to the model. CountTokens will count
435- // prompt, function calling, etc.
474+ // Optional. The overall input given to the `Model`. This includes the prompt
475+ // as well as other model steering information like [system
476+ // instructions](https://ai.google.dev/gemini-api/docs/system-instructions),
477+ // and/or function declarations for [function
478+ // calling](https://ai.google.dev/gemini-api/docs/function-calling).
479+ // `Model`s/`Content`s and `generate_content_request`s are mutually
480+ // exclusive. You can either send `Model` + `Content`s or a
481+ // `generate_content_request`, but never both.
436482 GenerateContentRequest generate_content_request = 3
437483 [(google.api.field_behavior ) = OPTIONAL ];
438484}
@@ -441,8 +487,7 @@ message CountTokensRequest {
441487//
442488// It returns the model's `token_count` for the `prompt`.
443489message CountTokensResponse {
444- // The number of tokens that the `model` tokenizes the `prompt` into.
445- //
446- // Always non-negative.
490+ // The number of tokens that the `Model` tokenizes the `prompt` into. Always
491+ // non-negative.
447492 int32 total_tokens = 1 ;
448493}
0 commit comments