Skip to content
Discussion options

You must be logged in to vote

Google seems to have a unified interface to generate "response". In the case of generating object, you'd call ai.models.generateContent with a responseSchema config. (See https://ai.google.dev/gemini-api/docs/structured-output)

You can slightly tweak the example on the page to achieve streaming. Below is a TS script with Google SDK. Turn thinking config on and off to see the difference.

import { GoogleGenAI, Type } from "@google/genai";

const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });

let thoughts = "";
let answer = "";

async function main() {
  const response = await ai.models.generateContentStream({
    model: "gemini-2.5-flash",
    contents:
      "List a few pop…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@frescoanalytics
Comment options

Answer selected by tfmcmahon
@tfmcmahon
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants