Expand description
Server-assigned request ids.
The id is stated by the server in the response (and in the first streamed chunk, before any content), so a client never has to invent one or correlate by heuristic. The alternative – matching a live request against a metrics snapshot by “the newest one that looks like mine” – is what a UI is forced into when the server stays silent, and it mis-attributes as soon as two chats run at once.
Format: chatcmpl- + a per-process random-ish stamp + a monotonic
counter. The stamp makes ids from two runs of the same binary
distinguishable (so a log spanning a restart does not collide); the
counter makes them unique within a run without a lock or an RNG
dependency. The prefix matches OpenAI’s, which some clients display.
Constants§
- PREFIX
- OpenAI uses this prefix for chat completion ids; clients occasionally display or match on it.
Functions§
- next_
request_ id - A fresh request id. Unique within this process, and in practice across restarts.