Skip to main content
This guide reflects the current developer-preview contract: GPT Image 2 text-to-image through the certified KIE-compatible and APIMart-compatible routes. It does not promise unreleased models or arbitrary provider forwarding.

Authenticate safely

Keep the Yir API key on the server and send it only as a Bearer credential.

Track one logical request

Persist the idempotency key and task ID before polling.

Handle uncertain outcomes

Retry queries without turning a timeout into a second generation request.

Submission contract

1

Create an idempotency key

Generate one opaque value for one logical generation request. Reuse it only when retrying the identical request.
2

Submit through one compatible surface

Choose the KIE-compatible or APIMart-compatible shape your application already understands. Do not send an upstream provider credential.
3

Persist the returned task ID

Store the task ID with your local request record before starting background polling.
4

Poll to a terminal state

Use a bounded interval and an overall application deadline. Continue querying the same task after transient transport failures.
Never generate a fresh idempotency key merely because the submit response timed out. The original request may already have been accepted and may still create billing facts.

Required headers

string
required
A Yir credential in the form Bearer $YIR_API_KEY.
string
required
A caller-generated opaque identifier for the logical request. The same value with different request data is rejected.

Submit from your backend

string
required
Stable APIMart-compatible task identifier to persist and query.

Choose a compatible surface

Submit with POST /kie/api/v1/jobs/createTask, read data.taskId, and query GET /kie/api/v1/jobs/recordInfo?taskId=....

Polling and recovery

Start conservatively, add jitter, and enforce an overall deadline in your application. A polling timeout is not proof that generation failed.
No. Query the existing task ID. A second submit represents a second logical request unless it is an idempotent retry of identical data.
Include the Yir task ID, source path, approximate UTC time, HTTP status, public error code, and a safe key prefix. Never include the complete key, prompt, source media, or raw provider response.
Your integration is ready for a controlled test when it persists both identifiers, reuses the idempotency key for submit retries, polls the same task ID, and never exposes the Yir API key to browser code.