Returns a structured (JSON) response from the Gemini API.
Usage
gemini_structured(
prompt,
schema,
model = "2.5-flash",
temperature = 1,
maxOutputTokens = 8192,
topK = 40,
topP = 0.95,
seed = 1234,
timeout = 60
)
Arguments
- prompt
The prompt (question) to send to the model.
- schema
JSON schema (as a list) for the expected response.
- model
Model to use. Default is '2.5-flash'.
- temperature
Sampling temperature. Default is 1.
- maxOutputTokens
Maximum number of output tokens. Default is 8192.
- topK
Top-k value. Default is 40.
- topP
Top-p value. Default is 0.95.
- seed
Random seed. Default is 1234.
- timeout
Request timeout in seconds. Default is 60.
Examples
if (FALSE) { # \dontrun{
schema <- list(
type = "ARRAY",
items = list(
type = "OBJECT",
properties = list(
recipeName = list(type = "STRING"),
ingredients = list(
type = "ARRAY",
items = list(type = "STRING")
)
),
propertyOrdering = c("recipeName", "ingredients")
)
)
gemini_structured(
"List a few popular cookie recipes, and include the amounts of ingredients.",
schema
)
} # }