Skip to main content

Short Answer

If you generate a very large volume of images each month and want API response latency below 360ms, switching to another route may offer limited improvement because most alternative nodes are hosted overseas and can introduce additional network latency. First, test replacing the original root URL:
with the following HTTP endpoint:
Keep the request path unchanged. For example, replace https://api.apiyi.com/v1/images/generations with http://api.apiyi.com:16888/v1/images/generations.
HTTP does not provide TLS encryption. Your API key and request content are transmitted in plain text. Use this endpoint only on a trusted network or through a properly configured private line or tunnel. Do not call it directly over a public network.

Client Optimization

Some API gateways have unstable HTTP/2 behavior during persistent or streaming connections, which can cause interrupted transfers or additional retries. Configure a custom HTTP client to:
  • Force HTTP/1.1 and disable HTTP/2
  • Enable connection pooling and Keep-Alive to avoid creating a new connection for every request
  • Increase the read timeout to cover normal image-generation time instead of using a 500ms total timeout
  • Retry occasional network failures a limited number of times with backoff
Treat 500ms as a target for network overhead or task submission, not as a guaranteed image-completion time. Actual latency also depends on client location, ISP routing, concurrency, the selected image model, and upstream processing. Run tests at production-like concurrency and evaluate P95 and P99 latency before rollout.
1

Switch to the HTTP endpoint

Replace the root URL with http://api.apiyi.com:16888 while keeping the existing API path and authentication method.
2

Disable HTTP/2

Force HTTP/1.1 in your client and enable connection reuse.
3

Adjust timeouts and retries

Configure connection and read timeouts separately. The read timeout must cover normal image-processing time.
4

Run a concurrency test

Test with production-like concurrency and monitor P50, P95, P99 latency and failure rate.