Generates a response from the model given an input MessagePrompt
.
HTTP request
POST https://generativelanguage.googleapis.com/v1beta3/{model=models/*}:generateMessage
The URL uses gRPC Transcoding syntax.
For example:
curl https://generativelanguage.googleapis.com/v1beta2/models/chat-bison-001:generateMessage?key=$PALM_API_KEY \
-H 'Content-Type: application/json' \
-X POST \
-d '{
"prompt": {"messages": [{"content":"hi"}]},
"temperature": 0.1,
"candidateCount": 1}'
{
"candidates": [
{
"author": "1",
"content": "Hi there! How can I help you today?"
}
],
"messages": [
{
"author": "0",
"content": "hi"
}
]
}
Path parameters
Parameters | |
---|---|
model |
Required. The name of the model to use. Format: |
Request body
The request body contains data with the following structure:
JSON representation |
---|
{
"prompt": {
object ( |
Fields | |
---|---|
prompt |
Required. The structured textual input given to the model as a prompt. Given a prompt, the model will return what it predicts is the next message in the discussion. |
temperature |
Optional. Controls the randomness of the output. Values can range over |
candidateCount |
Optional. The number of generated response messages to return. This value must be between |
topP |
Optional. The maximum cumulative probability of tokens to consider when sampling. The model uses combined Top-k and nucleus sampling. Nucleus sampling considers the smallest set of tokens whose probability sum is at least |
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 |
Response body
The response from the model.
This includes candidate messages and conversation history in the form of chronologically-ordered messages.
If successful, the response body contains data with the following structure:
JSON representation |
---|
{ "candidates": [ { object ( |
Fields | |
---|---|
candidates[] |
Candidate response messages from the model. |
messages[] |
The conversation history used by the model. |
filters[] |
A set of content filtering metadata for the prompt and response text. This indicates which |
Authorization scopes
Requires the following OAuth scope:
https://www.googleapis.com/auth/generative-language
For more information, see the Authentication Overview.