Boundless API
  • Product
  • Models
  • Pricing
  • Status
  • Docs
EN中
Get $5 on signup

Streaming

Stream responses token-by-token using Server-Sent Events (SSE).

On this page
  1. Enable Streaming
  2. Response Format
  3. Python Example
  4. TypeScript Example
  5. Billing
  6. Errors During Stream
  7. Related
Live model IDs

Copy exactly — case-sensitive, no spaces. Details →

  • claude-sonnet-4-6
  • claude-opus-4-8
  • claude-opus-4-7
  • claude-haiku-4-5-20251001
  • gpt-5.5
  • gpt-5.4
Full catalog →

Stream responses token-by-token using Server-Sent Events (SSE).


Enable Streaming

{
  "model": "claude-sonnet-4-6",
  "messages": [{"role": "user", "content": "Write a poem"}],
  "stream": true
}

Response Format

Each chunk is a data: line:

data: {"id":"chatcmpl-abc","object":"chat.completion.chunk","choices":[{"delta":{"content":"Hello"},"index":0}]}

data: {"id":"chatcmpl-abc","object":"chat.completion.chunk","choices":[{"delta":{"content":" world"},"index":0}]}

data: [DONE]

Python Example

from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://api.boundlessapi.com/v1",
)

stream = client.chat.completions.create(
    model="claude-sonnet-4-6",
    messages=[{"role": "user", "content": "Count to 5"}],
    stream=True,
)

for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)

TypeScript Example

const stream = await client.chat.completions.create({
  model: "claude-sonnet-4-6",
  messages: [{ role: "user", content: "Count to 5" }],
  stream: true,
});

for await (const chunk of stream) {
  const content = chunk.choices[0]?.delta?.content;
  if (content) process.stdout.write(content);
}

Billing

Streaming requests are billed on total tokens when the stream completes, same as non-streaming.

If stream is interrupted client-side, you are billed for tokens generated up to cancellation.


Errors During Stream

Errors may appear as:

data: {"error": {"message": "...", "code": "..."}}

Handle in your stream parser. See Error Codes.


Related

  • API Reference
  • Quickstart

© 2026 Boundless API · Home · Privacy Policy · Terms