Skip to contents

Validates Gemini API connectivity with a minimal request. Useful for testing configuration, API keys, and network connectivity before executing complex operations.

Usage

artgemini_health_check(ml = NULL, timeout = 10)

Arguments

ml

Model to test (default: package default model)

timeout

Request timeout in seconds (default: 10)

Value

Logical TRUE if successful, otherwise throws an error with diagnostic information

Details

Performs a minimal Gemini API request to verify:

  • API key is valid

  • Network connectivity to Gemini API

  • Model is accessible

  • Basic request/response cycle works

On success, returns TRUE invisibly. On failure, throws an error with details about what went wrong (authentication, network, API error, etc.).

The health check uses a simple single-word prompt to minimize token usage and response time.

Examples

if (FALSE) { # \dontrun{
# Check default model
artgemini_health_check()

# Check specific model
artgemini_health_check(ml = "gemini-2.0-flash-exp")

# Use in conditional logic
if (artgemini_health_check()) {
  message("Gemini API is ready")
}

# Health check: short
artgemini_health_check(timeout = 10)
} # }