Skip to content

Troubleshooting 树新在线 API Request Timeouts / 502 / 504

First, Identify Which Layer the Timeout Occurs On

Timeouts may originate from overly short client settings, intermediate CDN or proxy timeout limits, or slow upstream model generation. How to tell: a timeout exception thrown directly by the client indicates a local issue; receiving an HTTP 502/504 response body points to an intermediate layer or upstream timeout.

The Most Effective Fix for Long Completions Is to Enable Streaming

Non-streaming requests wait until the entire response is generated before sending the first byte, making long answers prone to intermediate timeouts. Setting stream: true lets the first token arrive quickly and keeps the connection alive. Simply add "stream": true to your request.

Client Timeout Settings

Python SDK example:

python
from openai import OpenAI
client = OpenAI(base_url="https://api.treenew.online/v1", timeout=180)

Increase the timeout value for long-running tasks.

Meaning of 502 / 504

These status codes are returned by the intermediate layer, indicating the upstream failed to respond within the allotted time. They are distinct from application-level errors. Transient occurrences can be retried; persistent ones should be reported.

Notes on Retrying

Long requests are non-idempotent; blind retries may incur duplicate charges. Use exponential backoff and limit the number of retries.

When to Provide Feedback

Report the issue when it persists, is reproducible, and occurs only with specific models. Please include reproduction steps.

See also

Home · Console