Back to News
RSS feedgithub.com

sjq simplifies OpenAI-compatible AI streaming in the terminal

Summary

sjq is a Rust command-line utility for reading OpenAI-compatible language-model streams as they arrive. It converts verbose Server-Sent Events from Chat Completions and the Responses API into compact one-line output, preserving text, reasoning fields, roles, tool calls, refusals, metadata, usage, and other non-null changes. The project says stream envelopes can account for about 98.6% to 99.1% of the wire size in its examples, so filtering them can also reduce the input tokens seen by coding agents by roughly 99%. It addresses a common jq failure: streamed responses are many SSE events rather than one JSON document, and curl's `-i` can additionally pass HTTP headers into the parser. Users can install sjq through a Homebrew tap, build it with Cargo, pipe an existing stream into it, or let it run curl. The tool supports saved-stream replay, line timestamps, automatic color handling, and passthrough for errors and unrecognized events. For Responses API streams, it suppresses repeated `.done` echoes and predictable sequence or index fields, showing them when the stream is inconsistent. When it controls curl, sjq reports connection, TLS, TTFB, first-token, first-content, total-time, and speed measurements; piped and replayed input has more limited timing information.