Beginner Q&A: image API keeps timing out or failing to parse? Check timeout, response size limit and reference image URLs
An image generation call takes 20–120 seconds, returns a 2–5 MB original inline as base64, and needs reference images the server can download directly. Default 30/60-second timeouts, 1 MB response limits and private presigned links are the three most common causes of failure.
Short answer
When an image API "sometimes works, often fails", the model is usually not the problem; the client is not configured for image endpoints. SalpX docs group the most common causes into three items:1
- Client timeout of at least 300 seconds: one image takes 20–120 seconds, so 30 or 60-second defaults will cut off.
- Budget 10 MB for the response body: 2K/4K originals are 2–5 MB, and base64 adds about a third; a 1 MB default will blow up.
- Reference image URLs must be directly downloadable by any third party: presigned links or URLs needing login or a Referer cannot be fetched and fail before generation starts. If unsure, send base64.
Q1: Why does text work while images time out?
Text endpoints can stream, so the first token arrives quickly. Image endpoints return everything at once after the whole image is rendered. SalpX docs give 20–120 seconds per image, with 4K usually 15–60 seconds.1 If any layer, whether your HTTP client, gateway, reverse proxy or serverless function, has a lower timeout, the request is cut off on your side.
Order of investigation:
- See who raised the error: the SDK's
APITimeoutError, a 504 from your own gateway, or a browser network error. - List the timeout of every layer: client code, corporate proxy, reverse proxy, function platform. The shortest one decides.
- Official openai-python defaults to a 10-minute timeout and retries timeouts twice.2 If you use it, the problem is more likely elsewhere, and automatic retries can turn one task into several requests.
Q2: Why do I get 200 but my parser crashes?
On success the SalpX image API returns 200 with the image base64 inline in data[0].b64_json, not a URL.1 The JSON for one 4K image can approach or exceed 5 MB. Common crash points:
- Response body limits in the HTTP client or middleware (for example a 1 MB default).
- Logging middleware printing the whole response and overwhelming memory or the log system.
- A frontend storing the whole base64 string in state and freezing the page.
Fixes: raise the response limit above 10 MB; log only metadata such as status, request ID and data[0].size, never b64_json; decode and save to disk immediately, then pass the file path onward.
Q3: The reference image opens in my browser, so why the error?
Your browser has a session, cookies and a Referer; the server does not. Object storage presigned links may also have expired or be constrained by signature conditions when the server fetches them. SalpX docs require reference URLs to be directly downloadable by any third party, otherwise the request fails before generation.1
Self-check: from a machine with no session, request the URL from the command line without cookies. It only qualifies if you get the image. When unsure, send base64.
Q4: What other details trip people up?
nmust be1; larger values return 400.1- Failed generations are not billed, but a client timeout is not a failed generation; the server may have finished. Do not resubmit per-call tasks through automatic retries.
- With
sizethe output is JPEG; without it or withautoit is PNG. Pick the file extension from the actual format.1
Minimal working config
from openai import OpenAI
client = OpenAI(
base_url="https://www.salpx.com/v1",
timeout=300.0,
max_retries=0,
)
Then confirm three things: a response limit of at least 10 MB, no b64_json in logs, and reference images downloadable anonymously.
In one line
When an image call fails, check timeout, response size limit and reference image accessibility first. The cause is almost always one of the three.
Sources & attribution
This article references the public materials listed below. Analysis and wording are SalpX's own; quoted material remains the property of its original authors and publishers.
- SalpX API Reference — SalpX · accessed 2026-11-28Note:SalpX official docs: Base URL, Bearer auth, image size tiers, 4K model names, the clamp response header, and integration notes such as a 300s+ timeout, a 10 MB response budget and publicly downloadable reference images.
- openai-python README — OpenAI (GitHub) · accessed 2026-11-28Note:Official SDK docs: default timeout 10 minutes, 2 retries with short exponential backoff; connection errors, 408, 409, 429 and >=500 are retried; errors while consuming a stream are not; OPENAI_BASE_URL can replace base_url.
One key for Claude, GPT and 50+ models
The SalpX gateway is OpenAI-SDK compatible. Point base_url at https://www.salpx.com/v1 and you are done.