Quick Answer
Most images and videos generated through APIYI (Veo 3.1, Sora, Nano Banana, gpt-image-2-vip, etc.) are returned as URLs hosted on global CDNs such as Cloudflare. Slow or timed-out downloads usually come from one of two places:- The network path from your server to the CDN: servers in mainland China reaching overseas CDNs are affected by cross-border bandwidth, ISP routing, and local DNS
- The storage side: when the storage nodes behind the CDN slow down, every route can be affected
*.r2.cloudflarestorage.com or a custom domain proxied through Cloudflare. Download speed depends on how efficiently your server can reach the nearest Cloudflare edge node.The API Succeeded, but the Image Won’t Download?
Image generation happens in two stages:- Your program calls the APIYI API, the image is generated, and a URL is returned
- Your program downloads the image from that URL
- The APIYI log shows the request as successful and billed — the image really was generated
- Your program reports errors like
Read timed outorConnection reset, and the host in the error is the image domain, notapi.apiyi.com Read timed outmeans the connection was established but no data arrived for a long time. It is not the same as “cannot connect”, and on its own it doesn’t tell you which side is at fault
Common Causes
Cross-border congestion
Suboptimal ISP routing
Poor DNS resolution
Firewall / security group limits
HTTP/2 & connection reuse
Single-threaded download
Troubleshooting Steps
Get your egress IP and CDN node
/cdn-cgi/trace path shows your egress IP and assigned node in one command. Works on Linux, macOS, and Windows cmd:ip= (egress IP), colo= (node code such as HKG, SIN, LAX, FRA), and loc= (region).- No output within 30 seconds: your server can’t reach the domain at all — focus on steps 4 and 5
- Instant output: the connection is fine and the problem is in the transfer — continue to step 3 for phase timing
Compare your laptop and your server
- Laptop fast, server slow: most likely the server’s network path, but the storage side may also be degraded for some routes only — send us both results
- Slow everywhere: most likely the storage side — contact us with the URL
Test basic network to the CDN
ping, mtr, traceroute to inspect latency and packet loss:curl -o /dev/null -m 60 -w "total=%{time_total} speed=%{speed_download}\n" "https://speed.cloudflare.com/__down?bytes=5000000"
(on Windows, replace /dev/null with NUL). If this is slow too, your server’s egress is the problem; if it’s fast and only the image URL is slow, send us the results.Packet loss, latency above 200ms, or routes bouncing overseas all indicate link-level problems.Measure real download speed
curl to inspect timing and throughput:- Linux / macOS
- Windows cmd
-m 60 makes curl give up after 60 seconds and still print the timings, so it never hangs. Run it again with -6 instead of -4: if only one protocol stalls, you can pin your program to the one that works.Focus on:time_namelookup: DNS resolution timetime_connect: TCP connect timetime_appconnect: TLS handshake complete; 0 means the handshake failedtime_starttransfer: Time to first byte (TTFB)size_download: Bytes actually received; 0 or very small means connected but the transfer stalledspeed_download: Average throughput (bytes/sec)
Inspect DNS resolution
Check the server itself
- Cloud console: is the traffic quota used up, is bandwidth throttled, is the account in arrears
- Is bandwidth saturated by another process (Windows: Task Manager → Performance → Ethernet; Linux:
iftop,nload) - Do security groups and firewalls allow port 443 and overseas IP ranges; were outbound rules changed recently
- Is the program going through a dead proxy: check
HTTP_PROXY/HTTPS_PROXY, and on Windows alsonetsh winhttp show proxy
Solutions
Option 1: Switch to a public DNS (easiest)
Default DNS on many servers resolves Cloudflare to distant nodes. Try these public DNS servers:Option 2: Optimize how you download
Parallel downloads
aria2c -x 8, Python asyncio + httpx) to saturate bandwidth.Short timeouts + retries
Connection reuse
httpx, requests.Session()) to avoid repeated handshakes.Stream to disk
timeout=120. When the connection stalls you wait 120 seconds for nothing, and the whole generation task is marked failed — wasting an image that was already generated and billed.
Option 3: Move to a better-connected region
If your use case allows it, prefer regions with good connectivity to Cloudflare:Overseas (recommended)
China: premium DCs
Hong Kong / Singapore
Avoid cheap VPS
Option 4: Relay through another host (last resort)
If your server really can’t reach Cloudflare quickly and you can’t change regions:- Use an overseas server as a relay: download to an overseas box first, then transfer back via a private/premium link
- Relay via your own object storage: mirror the asset into your own OSS / COS / S3 (e.g., a China-region bucket), and serve from there
- Pre-warm and cache: download once from your backend and serve subsequent requests from a local cache
Common Questions
Why is my laptop fast but my server slow?
Why is my laptop fast but my server slow?
The error says it can't connect to api.apiyi.com, but the host in the details is the image domain?
The error says it can't connect to api.apiyi.com, but the host in the details is the image domain?
I changed DNS but it's still slow — why?
I changed DNS but it's still slow — why?
Is Cloudflare R2 blocked in mainland China?
Is Cloudflare R2 blocked in mainland China?
Video downloads keep failing — what can I do?
Video downloads keep failing — what can I do?
aria2c or wget -c, with reasonable timeouts and retries:Can APIYI return Base64 instead of a CDN URL?
Can APIYI return Base64 instead of a CDN URL?
How do I confirm the bottleneck is my network, not the CDN?
How do I confirm the bottleneck is my network, not the CDN?
curl test from an overseas host (AWS Tokyo, Singapore, etc.). If it’s fast there but slow on your server, the bottleneck is between your server and Cloudflare — not the CDN itself.Related Docs
Network Proxy Configuration
Where are APIYI Servers?
Veo Video Generation API
Contact Support
- The failing image URL and when it was generated (or the request ID)
- Full
/cdn-cgi/traceoutput (one from your laptop, one from the server) curlphase-timing output (one run with-4, one with-6)tracert/mtroutput and the 5 MB test download result- Your server’s cloud provider and region
- Roughly when the problem started, with time zone, e.g.
21:23 (UTC+8)