Documentation
¶
Overview ¶
This sample demonstrates the Anthropic plugin, which speaks Anthropic's native Messages API: a streaming flow that generates a joke with a model pinned through anthropic.ModelRef and the Anthropic SDK's own request type as its config.
compat_oai/anthropic reaches the same Claude models through the OpenAI-compatible endpoint instead. What differs is the response: this plugin returns Claude's thinking as Genkit reasoning parts with their signatures preserved, while the compatible endpoint keeps the thinking server-side.
Run it:
export ANTHROPIC_API_KEY=... go run .
Or with the Dev UI, to call the flow 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/jokesFlow?stream=true' \
-H "Content-Type: application/json" \
-d '{"data": {"topic": "bananas"}}'
Click to show internal directories.
Click to hide internal directories.