Streaming (SSE)
Stream replies as they are written: set stream:true on either endpoint and Anthropic SSE events arrive unchanged. Python, Node and fetch examples.
Set stream:true on either endpoint. Anthropic SSE event types arrive unchanged and unbuffered.
All models, capabilities, and prices Documentation index for AI agents:https://oneprovider.dev/docs/llms.txt Why stream
- Time-to-first-token drops from seconds to ~100ms.
- Long tool-use loops stay clear of the 6-minute limit for a response to start, because a stream starts answering right away. Any request is capped at 10 minutes, see Error codes .
- Better UX: progressive rendering instead of frozen spinners.
Event types
message_start— first event, returns assistant metadata.content_block_start·content_block_delta·content_block_stop— one set per text or tool_use block. Deltas are eithertext_deltaorinput_json_delta(for tool input).message_delta— stop_reason and usage update at the end.message_stop— final event.ping— keep-alive every ~15s.
Python (Anthropic SDK)
pythonwith client.messages.stream(
model="claude-sonnet-5-5",
max_tokens=1024,
messages=[{"role": "user", "content": "Tell me a haiku about Frankfurt."}],
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)
final = stream.get_final_message()
print("\n--", final.usage) Node / TypeScript
tsconst stream = client.messages.stream({
model: "claude-sonnet-5-5",
max_tokens: 1024,
messages: [{ role: "user", content: "Tell me a haiku about Frankfurt." }],
});
for await (const event of stream) {
if (event.type === "content_block_delta" && event.delta.type === "text_delta") {
process.stdout.write(event.delta.text);
}
}
const final = await stream.finalMessage();
console.log("--", final.usage); Raw fetch (browser, edge)
tsconst r = await fetch("https://api.oneprovider.dev/v1/messages", {
method: "POST",
headers: {
"x-api-key": KEY,
"anthropic-version": "2023-06-01",
"content-type": "application/json",
},
body: JSON.stringify({
model: "claude-sonnet-5-5",
max_tokens: 1024,
stream: true,
messages: [{ role: "user", content: "stream me a poem" }],
}),
});
const reader = r.body!.pipeThrough(new TextDecoderStream()).getReader();
while (true) {
const { value, done } = await reader.read();
if (done) break;
process.stdout.write(value);
} No buffering Events reach your client as soon as the model produces them. Any request, streaming included, is capped at 10 minutes; see Error codes . Quick answers
Which base URL do I use?
Claude Code and Anthropic SDKs use https://api.oneprovider.dev. OpenAI SDKs and OpenAI-compatible clients use https://api.oneprovider.dev/v1. One key works behind both; the model list is on the models page ; rates are on the pricing page .
How do I authenticate?
Send the raw sk-… key in x-api-key or Authorization: Bearer: one of them, never both. Keep the key in an environment variable, not in a file that gets committed. More on authentication .
Where do I get a key?
Open your cabinet in the Telegram bot @oneprovider_robot or at app.oneprovider.dev, top up the balance and press “Issue a key”. Each key can carry its own spend limit. Cabinet & API keys .
What do 401, 404 and 429 mean?
401: the key is missing, mistyped or sent in the wrong header; paste the whole key without quotes or spaces. 404: usually a wrong base URL, for example a missing or doubled /v1. 429 with “Insufficient balance”: the cabinet balance or the key’s spend limit is used up, so top up instead of retrying; any other 429 is a rate limit, so wait for Retry-After. Details: error codes and troubleshooting .
Why do streams cut off or reset?
VPN and VLESS proxies often buffer SSE or break HTTP/2 negotiation. OneProvider has no regional restrictions and does not buffer streams, so turn the proxy off and retry.
Where do I ask if this is not enough?
Message @Oneproviderhelpbot on Telegram or open “Support” in the web cabinet, with the HTTP status code and the exact error message. How support works .
Last updated: 2026-10-05 Found a bug? @Oneproviderhelpbot