- Streams incremental JSON chunks from InceptionLabs’ mercury-coder
API, but any
data:
‑prefixed SSE works). - Renders them live in ncurses.
- On
diffusion_progress >= 1.0
↳ shows the full transcript ↳ waits on/dev/tty
, not the pipe, so it blocks even whenstdin
has hit EOF. - Wipes the screen before
endwin()
→ zero prompt garbage.
gcc -o diffuse diffuse.c -I/opt/homebrew/include -L/opt/homebrew/lib -lncurses -ljson-c
curl -sN https://api.inceptionlabs.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $INCEPTION_API_KEY" \
-d '{
"model": "mercury-coder-small",
"messages": [
{"role": "user", "content": "Hello! What is a diffusion model? Explain like a MrBeast video"}
],
"max_tokens": 500,
"stream": true,
"diffusing": true
}' |./diffuse
You'll want to have these:
brew install ncurses json-c
why not just less?
Because less doesn’t animate in place, and its “follow” mode still drops you back to the prompt the instant the pipe closes. diffuse.c is single‑purpose, 200 LOC, zero dependencies besides ncurses + json‑c—perfect for embedding in your dotfiles or piping through fzf later.