basic-formats

command
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

This sample demonstrates output formats: the setting that decides how a model's text is parsed back into Go values, and what a streamed chunk means along the way.

  • characterFlow (json) streams a growing value: every chunk is the whole object so far, with more fields filled in than the one before it.
  • castFlow (jsonl) streams a list an item at a time: a finished item is handed over once, not restated on every chunk.
  • ratingFlow (enum) constrains the answer to one label, so there is nothing to stream.

The rest are "text" (the default, no parsing), "array" (like jsonl, but one JSON array on the wire instead of one object per line), and "media".

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, otherwise only the final result comes back:

curl -N -X POST 'http://localhost:8080/castFlow?stream=true' \
  -H "Content-Type: application/json" \
  -d '{"data": {"premise": "a lighthouse keeper who befriends a whale"}}'

curl -X POST http://localhost:8080/ratingFlow \
  -H "Content-Type: application/json" \
  -d '{"data": {"premise": "a lighthouse keeper who befriends a whale"}}'

Jump to

Keyboard shortcuts

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