Skip to content

Streaming (SSE)

  • Endpoint: POST https://api.olddog.shop/v1/chat/completions
  • Key parameter: stream: true
  • Response: text/event-stream (Server-Sent Events)

Use streaming when you want to receive tokens incrementally (for example, a typewriter effect).

Request parameters (same as non-streaming)

In addition to standard parameters, make sure to set:

NameTypeRequiredDescription
streambooleanYesMust be true.

cURL example (streaming)

bash
curl --request POST "https://api.olddog.shop/v1/chat/completions" \
  --header "Authorization: Bearer $OLD_DOG_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "model": "gpt-4o-mini",
    "stream": true,
    "messages": [
      { "role": "user", "content": "请用要点列出 5 条学习英语的建议。" }
    ]
  }'

Response notes

The server will continuously send multiple SSE data: event chunks until it ends with data: [DONE].