Quick Start
1. Get an API Key
Create a token in the console. Keys look like sk-xxxxxxxx.
Keep your key private
Make requests from your server. Do not embed the key in frontend code or client apps.
2. Send Your First Request
The default endpoint is https://api.llmnex.com; the Hong Kong acceleration endpoint is https://hk.llmnex.com. Change only the host, not the API path. The console URL is not an API endpoint. See Endpoints & Authentication.
Image generation requires explicit IMAGE output
The backend supports TEXT mode for a fast initial text response. To generate images, generationConfig.responseModalities must explicitly include "IMAGE"; use ["IMAGE"]. If omitted or set to TEXT only, Pro models may generate text.
curl -X POST "https://api.llmnex.com/v1beta/models/gemini-3-pro-image-c:generateContent" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
--max-time 300 \
-d '{"contents":[{"parts":[{"text":"a red ceramic teapot"}]}],"generationConfig":{"responseModalities":["IMAGE"]}}'curl -H "Authorization: Bearer YOUR_API_KEY" \
https://api.llmnex.com/v1/modelsThe example uses a model with the -c suffix and per-request billing. Models without -c use token-based billing. Query the models available to your key first to confirm the full name and billing mode. See Available Models.
3. Three Things to Know
Allow a 300-second client timeout for Gemini
Image generation is now significantly faster: roughly 15–25 seconds for 1K, 15–35 seconds for 2K, and 20–45 seconds for 4K (server generation time, excluding image transfer). These are not maximum latency guarantees. Keep a 300-second client timeout to allow for peak-time queues, retries and transfer.
Avoid aggressive retries
The service already retries internally. Do not add aggressive retry loops on the client. For 429, back off for 2–5 seconds and try once more; for 500, try once more after a short delay. Success is not guaranteed. For 503, inspect the message first: correct model-name or permission issues before retrying; only temporary upstream connection failures warrant one retry after backoff. Do not automatically repeat an unchanged 400 or 451 request. Include the X-Oneapi-Request-Id response header when reporting issues.
Treat 451 as terminal — do not retry
451 means content was blocked by safety checks. Change the prompt or reference image instead of automatically retrying the same request. Repeated submissions are not guaranteed to pass moderation; check your bill for actual charges.
Next Steps
- Image Generation Overview — models and selection
- Gemini API Guide — parameters, image editing, streaming and errors