GetAPI.ONE
Generate images with GetAPI.ONE
Select an image model from the live catalog, send the smallest declared request to the ONE image route, validate the response shape, and store output safely.
Prepare a supported request
- Open the current catalog and select a model whose declared endpoint is image generation.
- Review live pricing before a billable call; this guide does not freeze a price.
- Start with one output and only fields shown for that model’s contract.
POST https://www.getapi.one/v1/images/generationsSend a minimal generation
- Set GETAPI_ONE_API_KEY in a trusted process environment.
- Copy the exact image model ID from the current catalog.
- Describe the subject, composition, and constraints in the prompt.
- Submit one result first, then expand optional fields only after confirming model support.
- Decode bounded base64 output locally. If the response contains a URL, record it for an approved downloader with explicit egress/host rules and redirect revalidation instead of dereferencing it in the API process.
curl --fail-with-body https://www.getapi.one/v1/images/generations \
-H "Authorization: Bearer $GETAPI_ONE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "<IMAGE_MODEL_ID_FROM_CURRENT_CATALOG>",
"prompt": "A clean product diagram of a secure server-side API flow",
"n": 1
}' > image-response.jsonimport base64
import json
from pathlib import Path
from urllib.parse import urlsplit
payload = json.loads(Path("image-response.json").read_text(encoding="utf-8"))
item = payload["data"][0]
if item.get("b64_json"):
image_bytes = base64.b64decode(item["b64_json"], validate=True)
if len(image_bytes) > 25 * 1024 * 1024:
raise ValueError("Image exceeds the local 25 MB safety limit")
Path("generated-image.bin").write_bytes(image_bytes)
elif item.get("url"):
url = item["url"]
parsed = urlsplit(url)
if parsed.scheme != "https" or not parsed.hostname:
raise ValueError("Refusing an invalid or non-HTTPS image URL")
# Do not dereference provider-controlled URLs from a generic server example.
# Give this record to an approved downloader that enforces your egress and
# host policy, rejects private/link-local/loopback destinations, revalidates
# every redirect, sends no ONE credential, and bounds the response bytes.
Path("generated-image-url.txt").write_text(url, encoding="utf-8")
print("URL recorded for an egress-controlled downloader")
else:
raise ValueError("Expected data[0].url or data[0].b64_json")
Evaluate the result
| Check | Pass condition |
|---|---|
| Prompt fidelity | Required subject and composition are present. |
| Safety and rights | Output is suitable for the intended audience and you have rights to supplied inputs. |
| Response contract | Inspect data[0].url or data[0].b64_json, validate it, and save the returned bytes. |
| Operational record | Model ID, prompt version, request ID if available, and outcome are recorded without the key. |
Verify the expected result
- The HTTP request succeeds and the body contains the image result shape your selected model returns.
- A decoded base64 file opens as the expected image type, or a URL result is recorded and then retrieved only by your approved egress-controlled downloader.
- The ONE console records the request or corresponding usage.
Fix image request errors
| Symptom | Action |
|---|---|
| Unsupported parameter | Remove optional size, quality, format, or count fields until they are confirmed for that exact model. |
| Empty or unusable output | Inspect the complete JSON body and handle its actual URL or encoded-data field; do not assume one provider shape. |
| Policy or input rejection | Revise the input instead of repeatedly resubmitting the same request. |
Store inputs and outputs safely
- Keep keys server-side and validate prompt length, output count, and optional fields before forwarding.
- Do not send confidential source images or personal data unless your approved data handling allows it.
- Treat returned URLs as temporary unless the provider contract explicitly says otherwise; copy approved output to controlled storage.
- Never forward the GetAPI.ONE Authorization header to a returned image URL.
- Treat returned URLs as untrusted input: enforce an explicit egress and host policy, block private/link-local/loopback destinations, and revalidate every redirect in the dedicated downloader.