Run these scripts from the repo root.
examples/streaming_example.exs- complete-message streaming helpers and raw-message handlingexamples/character_streaming_example.exs- partial-message streaming withinclude_partial_messages: true
If you use the SDK's default bundled CLI configuration, run:
mix run examples/streaming_example.exs
mix run examples/character_streaming_example.exsIf you want the examples to use an external claude binary instead of the bundled one, set:
# config/dev.exs
import Config
config :claude_code, cli_path: :globalThen run the same commands:
mix run examples/streaming_example.exs
mix run examples/character_streaming_example.exsIf you do not want to change config/dev.exs, require the example file from -e after setting :cli_path:
mix run -e 'Application.put_env(:claude_code, :cli_path, :global); Code.require_file("streaming_example.exs", "examples")'
mix run -e 'Application.put_env(:claude_code, :cli_path, :global); Code.require_file("character_streaming_example.exs", "examples")'This form matters: mix run -e '...' examples/foo.exs only evaluates the expression and does not also run the script.
- Run from the repository root so the relative
examplespath resolves correctly. - Ensure the external
claudebinary is on yourPATHwhen usingcli_path: :global. - Authenticate the Claude CLI first with either
ANTHROPIC_API_KEYorclaude /login.