Skip to contents

This compatibility wrapper delegates to secure_chat() with provider = "gemini". New code should use that common provider path. It requires the suggested ellmer package and GEMINI_API_KEY or GOOGLE_API_KEY in the environment. No request is made until this function is called.

Usage

shield_gemini(
  prompt,
  policy = "enterprise_default",
  checks = "both",
  model = "gemini-2.5-flash",
  reviewer_model = "gemini-2.5-flash-lite",
  context = NULL,
  context_authorize = NULL,
  redaction = NULL,
  scanners = scanner_options(),
  show_tokens = FALSE,
  show_stats = FALSE,
  audit_content = c("metadata", "full")
)

Arguments

prompt

User prompt.

policy

A shieldr_policy or built-in policy name.

checks

One of "rules", "nlp", "llm", or "both".

model

Explicit Gemini assistant model name.

reviewer_model

Explicit Gemini semantic reviewer model name.

context

Optional data frame of retrieved context.

context_authorize

Optional row authorization function.

redaction

Optional redaction strategy.

scanners

Optional scanner configuration.

show_tokens

Whether to attach token counts.

show_stats

Show execution statistics as messages.

audit_content

"metadata" (default) or "full".

Value

A shieldr_result.

Details

The compatibility defaults retain the Gemini 2.5 model names used when this wrapper was introduced. Google may limit those models for new projects; new code should pass a current model explicitly to secure_chat(). Google determines free-tier eligibility, quotas, model availability, and data-use terms by account, project, and region. Review https://ai.google.dev/gemini-api/docs/pricing and https://ai.google.dev/gemini-api/docs/rate-limits, the provider's current data-use terms, and organizational policy before sending private content. Gemini requests transmit the cleaned prompt and admitted context to Google.

Examples

if (FALSE) { # \dontrun{
# Set GEMINI_API_KEY in your environment before running.
result <- shield_gemini(
  "Summarize this public note.",
  model = "gemini-3.8-flash",
  reviewer_model = "gemini-3.8-flash",
  show_stats = TRUE
)
result$output
} # }