Skip to main content
POST

Authorizations

x-goog-api-key
string
header
required

Send your DreamTo API Key in the x-goog-api-key header, the way the Google SDKs do by default; the ?key=<API Key> query parameter works too.

Path Parameters

model
string
default:gemini-4-hydrogen
required

ID of the model to use, for example gemini-4-hydrogen. See Models for the available models.

Body

application/json

Request to generate a completion from the model.

contents
object[]
required

Required. The content of the current conversation with the model.

For single-turn queries, this is a single instance. For multi-turn queries like chat, this is a repeated field that contains the conversation history and the latest request.

continuationToken
string<byte>

Optional. An opaque continuation token used to resume generation from a previous GenerateContent or StreamGenerateContent response that stopped with finish_reason set to CONTINUATION. Note that contents is mandatory and must identically replicate the prompt and conversation history from the initial request when continuation token is provided in a request.

tools
object[]

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. Supported Tools are Function and code_execution. Refer to the Function calling and the Code execution guides to learn more.

serviceTier
enum<string>

Optional. The service tier of the request.

Available options:
unspecified,
standard,
flex,
priority
toolConfig
object

Optional. Tool configuration for any Tool specified in the request. Refer to the Function calling guide for a usage example.

safetySettings
object[]

Optional. A list of unique SafetySetting instances for blocking unsafe content.

This will be enforced on the GenerateContentRequest.contents and GenerateContentResponse.candidates. There should not be more than one setting for each SafetyCategory type. The API will block any contents and responses that fail to meet the thresholds set by these settings. This list overrides the default settings for each SafetyCategory specified in the safety_settings. If there is no SafetySetting for a given SafetyCategory provided in the list, the API will use the default safety setting for that category. Harm categories HARM_CATEGORY_HATE_SPEECH, HARM_CATEGORY_SEXUALLY_EXPLICIT, HARM_CATEGORY_DANGEROUS_CONTENT, HARM_CATEGORY_HARASSMENT, HARM_CATEGORY_CIVIC_INTEGRITY, HARM_CATEGORY_JAILBREAK are supported. Refer to the guide for detailed information on available safety settings. Also refer to the Safety guidance to learn how to incorporate safety considerations in your AI applications.

labels
object

Optional. Labels with user-defined metadata for the request.

Optional. Labels must follow standard unified Cloud label requirements:

  • Label keys must start with a letter.
  • Label keys and values can be no longer than 63 characters (Unicode codepoints) and can only contain lowercase letters, numeric characters, underscores, and dashes.
  • International characters are allowed.

Usage:

  • Safety identifiers from aggregators: Use the key safety_identifier (e.g. {"safety_identifier": "user_session_123"})
cachedContent
string

Optional. The name of the content cached to use as context to serve the prediction. Format: cachedContents/{cachedContent}

generationConfig
object

Optional. Configuration options for model generation and outputs.

store
boolean

Optional. Configures the logging behavior for a given request. If set, it takes precedence over the project-level logging config.

systemInstruction
object

Optional. Developer set system instruction(s). Currently, text only.

Response

The model's reply, with the candidates and usage.

Response from the model supporting multiple candidate responses.

Safety ratings and content filtering are reported for both prompt in GenerateContentResponse.prompt_feedback and for each candidate in finish_reason and in safety_ratings. The API:

  • Returns either all requested candidates or none of them
  • Returns no candidates at all only if there was something wrong with the prompt (check prompt_feedback)
  • Reports feedback on each candidate in finish_reason and safety_ratings.
modelVersion
string
read-only

Output only. The model version used to generate the response.

candidates
object[]

Candidate responses from the model.

promptFeedback
object

Returns the prompt's feedback related to the content filters.

responseId
string
read-only

Output only. response_id is used to identify each response.

usageMetadata
object

Output only. Metadata on the generation requests' token usage.

modelStatus
object

Output only. The current model status of this model.