# Streaming > Server-sent events in both formats — the event shapes differ, and mixing them up reads as silence. _Source: https://aiprimetech.io/docs/api-reference/streaming/ · Home > Docs > API reference_ Set `stream` to true and the response becomes `text/event-stream`. Both endpoints stream, but they emit **different event shapes**. ## Anthropic format ```bash curl -N https://aiprimetech.io/v1/messages \ -H "x-api-key: $CLAUDEAPIKEY" \ -H "anthropic-version: 2023-06-01" \ -H "content-type: application/json" \ -d '{"model":"claude-sonnet-4-6","max_tokens":512,"stream":true, "messages":[{"role":"user","content":"Count to five"}]}' ``` ```json event: message_start data: {"type":"message_start","message":{"id":"msg_...","usage":{"input_tokens":9}}} event: content_block_delta data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"One"}} event: message_delta data: {"type":"message_delta","delta":{"stop_reason":"end_turn"},"usage":{"output_tokens":14}} event: message_stop data: {"type":"message_stop"} ``` Text arrives in `content_block_delta` events at `delta.text`. Final output token counts arrive in `message_delta`, not `message_start`. ## OpenAI format ```json data: {"choices":[{"delta":{"content":"One"},"index":0}]} data: {"choices":[{"delta":{},"finish_reason":"stop","index":0}]} data: [DONE] ``` Text arrives at `choices[0].delta.content`, and the stream ends with a literal `data: [DONE]` sentinel that is not JSON. > This mismatch produces an empty response with no error: a client parsing `choices[].delta.content` against a Messages stream finds nothing, every time, and reports success. If streaming appears to work but returns nothing, check which shape you are parsing. ## Python, Anthropic SDK ```python from anthropic import Anthropic client = Anthropic(api_key="sk-your-key", base_url="https://aiprimetech.io") with client.messages.stream( model="claude-sonnet-4-6", max_tokens=512, messages=[{"role": "user", "content": "Count to five"}], ) as stream: for text in stream.text_stream: print(text, end="", flush=True) ``` ## Operational notes - Use `curl -N` when testing by hand, or curl buffers the whole stream and it looks like nothing is happening. - Disable proxy buffering in front of your own app (`proxy_buffering off` in nginx) or clients see the reply arrive in one lump at the end. - A dropped connection mid-stream still bills the tokens already generated. - Streaming does not change the price — only when the bytes arrive. - [Messages API](https://aiprimetech.io/docs/api-reference/messages/) — Non-streaming reference - [Errors](https://aiprimetech.io/docs/api-reference/errors/) — Failures mid-stream - [Troubleshooting](https://aiprimetech.io/docs/guides/troubleshooting/) — Empty responses --- _ClaudeAPIKey.dev is an independently operated, Anthropic-compatible API gateway. Not affiliated with Anthropic._