The request side (base_url, auth, switching models) is covered in Compatible Mode Calls. This page is purely about the response side: how to parse what comes back.
Two modes, one endpoint
The same/v1/chat/completions endpoint; only the stream flag changes the shape:
Non-streaming response
Stable structure — just readchoices[0].message.content:
Streaming response (SSE)
Streaming pushes chunks as Server-Sent Events, one per line asdata: {...}, ending with data: [DONE]:
delta.content:
Integration notes: a few differences, handled uniformly
Streaming details vary slightly between models, but following the rules below lets one code path cover them all.Robust reference parser
When you handle the raw SSE yourself (no SDK), this covers every difference above:Reasoning models (grok, qwen, glm, etc.) first stream
delta.reasoning_content (the chain of thought), then delta.content (the answer). The parser above reads only content, so the thinking is skipped automatically. To display the thinking, see Reasoning Model Output.Usage and billing
usagecomes back inline in non-streaming responses; in streaming it arrives in a trailing chunk (location per the table above — “record whenever present”).- Field breakdowns differ: the OpenAI family adds
completion_tokens_details, Gemini/Claude addinput_tokens/output_tokens, reasoning models addreasoning_tokens. Rely on the three standard fields:prompt_tokens/completion_tokens/total_tokens.
Related links
- Same group: Compatible Mode Calls · Reasoning Model Output · Native Calls
- Models & pricing: Models & Pricing Overview
- Get / manage tokens:
https://api.apiyi.com/token