basic-structured

command
v1.13.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 3, 2026 License: Apache-2.0 Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

This sample demonstrates typed output: the Go type you ask for is the schema the model is held to, so the answer comes back as a struct, not a string.

  • simpleJokesFlow streams plain text with WithStreaming.
  • structuredJokesFlow streams a typed Joke with GenerateDataStream.
  • recipeFlow does the same for a nested Recipe.

jsonschema tags describe each field to the model, which is what makes the generated values sensible.

Run it:

go run .

Or with the Dev UI, to call the flows from a browser and read a trace of every run at http://localhost:4000/traces:

curl -sL cli.genkit.dev | bash    # install the Genkit CLI, once
genkit start -- go run .

Or over HTTP. Streaming needs ?stream=true:

curl -N -X POST 'http://localhost:8080/structuredJokesFlow?stream=true' \
  -H "Content-Type: application/json" \
  -d '{"data": {"topic": "bananas"}}'

curl -N -X POST 'http://localhost:8080/recipeFlow?stream=true' \
  -H "Content-Type: application/json" \
  -d '{"data": {"dish": "tacos", "cuisine": "Mexican", "servingSize": 4, "maxPrepMinutes": 30}}'

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL