Generates a response from the model given an input message.
HTTP request
POST https://generativelanguage.googleapis.com/v1beta3/{model=tunedModels/*}:generateText
The URL uses gRPC Transcoding syntax.
Path parameters
Parameters | |
---|---|
model |
Required. The name of the |
Request body
The request body contains data with the following structure:
JSON representation |
---|
{ "prompt": { object ( |
Fields | |
---|---|
prompt |
Required. The free-form input text given to the model as a prompt. Given a prompt, the model will generate a TextCompletion response it predicts as the completion of the input text. |
safetySettings[] |
A list of unique that will be enforced on the |
stopSequences[] |
The set of character sequences (up to 5) that will stop output generation. If specified, the API will stop at the first appearance of a stop sequence. The stop sequence will not be included as part of the response. |
temperature |
Optional. Controls the randomness of the output. Note: The default value varies by model, see the Values can range from [0.0,1.0], inclusive. A value closer to 1.0 will produce responses that are more varied and creative, while a value closer to 0.0 will typically result in more straightforward responses from the model. |
candidateCount |
Optional. Number of generated responses to return. This value must be between [1, 8], inclusive. If unset, this will default to 1. |
maxOutputTokens |
Optional. The maximum number of tokens to include in a candidate. If unset, this will default to outputTokenLimit specified in the |
topP |
Optional. The maximum cumulative probability of tokens to consider when sampling. The model uses combined Top-k and nucleus sampling. Tokens are sorted based on their assigned probabilities so that only the most likely tokens are considered. Top-k sampling directly limits the maximum number of tokens to consider, while Nucleus sampling limits number of tokens based on the cumulative probability. Note: The default value varies by model, see the |
topK |
Optional. The maximum number of tokens to consider when sampling. The model uses combined Top-k and nucleus sampling. Top-k sampling considers the set of Note: The default value varies by model, see the |
Response body
If successful, the response body contains an instance of GenerateTextResponse
.
Authorization scopes
Requires one of the following OAuth scopes:
https://www.googleapis.com/auth/generative-language
https://www.googleapis.com/auth/generative-language.tuning
https://www.googleapis.com/auth/generative-language.tuning.readonly
For more information, see the Authentication Overview.