Streaming & troubleshooting
Streaming displays content while the model generates it. It does not change model prices or group multipliers. Check consumption in Usage Logs under the current billing rules.
Python streaming
Install the Python SDK and set key and model environment variables. Put this code in xuo_stream.py, then run python xuo_stream.py:
import os
from openai import OpenAI
with OpenAI(
api_key=os.environ["XUO_API_KEY"],
base_url="https://api.xuo.cc/v1",
timeout=60.0,
max_retries=0,
) as client:
with client.chat.completions.create(
model=os.environ["XUO_MODEL"],
messages=[{"role": "user", "content": "Hello"}],
stream=True,
) as stream:
for chunk in stream:
if chunk.choices:
text = chunk.choices[0].delta.content
if text:
print(text, end="", flush=True)
print()Node.js streaming
Install the Node.js SDK and set the environment variables. Put this code in xuo-stream.mjs, then run node xuo-stream.mjs:
import OpenAI from 'openai';
if (!process.env.XUO_API_KEY || !process.env.XUO_MODEL) {
throw new Error('Set XUO_API_KEY and XUO_MODEL in your terminal first.');
}
const client = new OpenAI({
apiKey: process.env.XUO_API_KEY,
baseURL: 'https://api.xuo.cc/v1',
timeout: 60_000,
maxRetries: 0,
});
const stream = await client.chat.completions.create({
model: process.env.XUO_MODEL,
messages: [{ role: 'user', content: 'Hello' }],
stream: true,
});
for await (const chunk of stream) {
const text = chunk.choices[0]?.delta.content;
if (text) process.stdout.write(text);
}
process.stdout.write('\n');These examples use Chat Completions. Responses has a different event format; do not parse it using choices[].delta.
Common errors
| Symptom | What to check |
|---|---|
| 401 / Unauthorized | Complete, valid key and correct Bearer header |
| 403 / Forbidden | Account, key permissions, model restrictions and group access |
| 404 / Path or model not found | Duplicated /v1, model ID and endpoint compatibility |
| 400 / Invalid parameters | Error details, supported parameters, endpoints and input types |
| Insufficient credit | Wallet, subscription balance and expiry, key credit limits |
| 429 / Rate limit | Error details and Retry-After; reduce concurrency and use limited retries |
| 5xx / Upstream error | Record time and request ID; check announcements or open a ticket |
SDK Base URL: https://api.xuo.cc/v1.
A 429 response is not necessarily caused by changing languages. Distinguish website login or registration limits, API rate limits and upstream model limits. Avoid repeated refreshing or rapid retries.
Timeouts, interrupted streams or buffered output
- Check network connectivity, model latency, reverse proxy timeouts and buffering settings.
- Enable
stream, read chunks incrementally, and ensure your backend and proxy do not buffer the whole response. - An interrupted stream may still consume credit. Check logs before retrying.
- To cancel generation in a web application, propagate cancellation through your backend and close the upstream connection. Stopping the display alone does not cancel the request.
Open a support ticket
Include the time, model ID, error code, redacted error details and request ID if available. Do not upload full keys or sensitive request content.
