flutterfire icon indicating copy to clipboard operation
flutterfire copied to clipboard

๐Ÿš€ [firebase_ai] Support JsonPart for Structured Prompt Input

Open lhengl opened this issue 1 month ago โ€ข 0 comments

What feature would you like to see?

It would be great if firebase_ai plugin supported a native JsonPart (or equivalent) when sending prompts to Gemini. The underlying Google AI SDK accepts multipart content, but currently it only allows JSON to be passed as encoded text as a workaround. This forces developers to manually serialize and escape JSON before sending it to the model, which is error-prone and adds a lot of unnecessary boilerplate.

Why would this be useful?

Many real apps using Gemini rely on structured state โ€” user profiles, session context, configs, domain models, etc. Having to wrap JSON in a text part makes prompting fragile, especially with deeply nested objects. A native JSON part would:

  • allow us to send structured data directly,
  • avoid escaping/formatting issues,
  • simplify prompts,
  • and align well with Geminiโ€™s structured output and function-calling capabilities.

Is there a missing a feature that is supported on an underlying SDK? Or is there a feature that you think would be useful to have in FlutterFire?

Itโ€™s a small feature, but it would greatly improve the developer experience for anyone using Gemini.

lhengl avatar Dec 09 '25 08:12 lhengl