content
Creates, updates, deletes, gets or lists a content resource.
Overview
| Name | content |
| Type | Resource |
| Id | gemini.models.content |
Fields
The following fields are returned by SELECT queries:
- generate_content
| Name | Datatype | Description |
|---|---|---|
candidates | array | Candidate responses from the model. |
modelStatus | object | Output only. The current model status of this model. |
modelVersion | string | Output only. The model version used to generate the response. |
promptFeedback | object | Returns the prompt's feedback related to the content filters. |
responseId | string | Output only. response_id is used to identify each response. |
usageMetadata | object | Output only. Metadata on the generation requests' token usage. |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
generate_content | select | modelsId | model, contents, toolConfig, store, tools, systemInstruction, cachedContent, serviceTier, safetySettings, generationConfig | Generates a model response given an input GenerateContentRequest. Refer to the text generation guide for detailed usage information. Input capabilities differ between models, including tuned models. Refer to the model guide and tuning guide for details. |
batch_generate_content | exec | modelsId | Enqueues a batch of GenerateContent requests for batch processing. |
Parameters
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
modelsId | string | |
cachedContent | string | Optional. The name of the content cached to use as context to serve the prediction. Format: cachedContents/{cachedContent} |
contents | array | 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. |
generationConfig | object | Configuration options for model generation and outputs. Not all parameters are configurable for every model. |
model | string | Required. The name of the Model to use for generating the completion. Format: models/{model}. |
safetySettings | array | 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. |
serviceTier | string | Optional. The service tier of the request. |
store | boolean | Optional. Configures the logging behavior for a given request. If set, it takes precedence over the project-level logging config. |
systemInstruction | object | The base structured datatype containing multi-part content of a message. A Content includes a role field designating the producer of the Content and a parts field containing multi-part data that contains the content of the message turn. |
toolConfig | object | The Tool configuration containing parameters for specifying Tool use in the request. |
tools | array | 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. |
SELECT examples
- generate_content
Generates a model response given an input GenerateContentRequest. Refer to the text generation guide for detailed usage information. Input capabilities differ between models, including tuned models. Refer to the model guide and tuning guide for details.
- Query Shape
- Query Example
SELECT
candidates,
modelStatus,
modelVersion,
promptFeedback,
responseId,
usageMetadata
FROM gemini.models.content
WHERE modelsId = '{{ modelsId }}' -- required
AND model = '{{ model }}'
AND contents = '{{ contents }}'
AND toolConfig = '{{ toolConfig }}'
AND store = '{{ store }}'
AND tools = '{{ tools }}'
AND systemInstruction = '{{ systemInstruction }}'
AND cachedContent = '{{ cachedContent }}'
AND serviceTier = '{{ serviceTier }}'
AND safetySettings = '{{ safetySettings }}'
AND generationConfig = '{{ generationConfig }}'
;
SELECT
JSON_EXTRACT(candidates, '$[0].content.parts[0].text') AS reply,
JSON_EXTRACT(usageMetadata, '$.totalTokenCount') AS total_tokens,
modelVersion
FROM gemini.models.content
WHERE modelsId = 'gemini-2.5-flash'
AND contents = '[
{
"role": "user",
"parts": [{"text": "how does stackql work?"}]
}
]'
AND systemInstruction = '{"parts":[{"text":"You are a technical assistant. Answer in one short paragraph."}]}'
AND generationConfig = '{"maxOutputTokens": 2048}'
;
Lifecycle Methods
- batch_generate_content
Enqueues a batch of GenerateContent requests for batch processing.
EXEC gemini.models.content.batch_generate_content
@modelsId='{{ modelsId }}' --required
@@json=
'{
"batch": "{{ batch }}"
}'
;