Skip to main content

gemini_schema

Attribute Macro gemini_schema 

Source
#[gemini_schema]
Expand description

Attribute macro to derive the GeminiSchema trait for a struct or enum.

This allows the type to be used in structured output (set_json_mode) or as a parameter in a gemini_function.

§Requirements

  • For structs: only named fields are supported.
  • For enums: only unit variants (no data) are supported.
  • Field/variant types must also implement GeminiSchema.
  • Doc comments on fields and variants are extracted as descriptions in the schema.

§Example

#[gemini_schema]
struct SearchResult {
    /// The title of the page.
    title: String,
    /// The URL of the page.
    url: String,
}