Event Streams for API Clients
Sections OpenAI Chat Completions OpenAI Responses Anthropic Messages Side by side Supporting more than one

Three vendor stream formats

All three formats below are carried over the same server-sent events framing, so one parser serves them all. What differs is the content of each event: where the text is, how tool calls are split, where usage numbers appear and how the end is marked. The field names here are taken from each vendor's documentation, linked in every section; check there for anything newer.

OpenAI Chat Completions

Described in the Chat Completions reference.

OpenAI Responses

Described in the Responses streaming events reference.

Anthropic Messages

Described in the streaming documentation.

Side by side

QuestionChat CompletionsResponsesMessages
How to recognise an eventShape of the JSON chunktype fieldevent line and type field
New textchoices[].delta.contentresponse.output_text.deltatext_delta in content_block_delta
Tool argumentsdelta.tool_calls[].function.arguments piecesresponse.function_call_arguments.deltainput_json_delta pieces
UsageOptional final chunk with empty choicesIn the completed responseCumulative, in message_delta
End markerdata: [DONE]response.completedmessage_stop
Error in streamNot covered here; check the referenceerror eventerror event

Supporting more than one

Normalise early. Convert each vendor's events into a small internal set (text added, tool arguments added, usage updated, finished, failed) right after parsing, and let the rest of the application see only those. The parser from earlier stays shared; only one function per vendor knows the field names above, and when a vendor adds an event type, that function is the only place to change.