> ## Documentation Index
> Fetch the complete documentation index at: https://apixo.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# GPT Image 1

> OpenAI image generation API for text-to-image and reference-guided creation

## Overview

GPT Image 1 is an OpenAI image generation model for prompt-based image creation and reference-guided generation. Use this page when you are ready to call the API after trying the model in the APIXO playground.

| Capability       | Value               |
| ---------------- | ------------------- |
| Model ID         | `gpt-image-1`       |
| Mode             | `gpt-image-1`       |
| Prompt length    | 1-10000 characters  |
| Reference images | 0-5 URLs            |
| Aspect ratios    | `1:1`, `2:3`, `3:2` |
| Number of images | `1`, `2`, `4`       |

## Endpoint and authentication

Base URL:

```text theme={null}
https://api.apixo.ai/api/v1
```

| Method | Endpoint                                  | Purpose                               |
| ------ | ----------------------------------------- | ------------------------------------- |
| `POST` | `/generateTask/gpt-image-1`               | Submit a generation task              |
| `GET`  | `/statusTask/gpt-image-1?taskId={taskId}` | Poll task status and retrieve results |

All requests require your APIXO API key:

```http theme={null}
Authorization: Bearer YOUR_API_KEY
```

Submit requests also require:

```http theme={null}
Content-Type: application/json
```

## Copy-paste async quickstart

This minimal request submits a text-to-image task and returns a `taskId`.

```bash theme={null}
curl -X POST "https://api.apixo.ai/api/v1/generateTask/gpt-image-1" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "async",
    "input": {
      "mode": "gpt-image-1",
      "prompt": "a cozy cyberpunk cafe with neon lights",
      "aspect_ratio": "3:2",
      "num_images": 1
    }
  }'
```

Successful response:

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678"
  }
}
```

Save the `taskId`; you need it to poll for the final result.

## Poll for result

```bash theme={null}
curl -X GET "https://api.apixo.ai/api/v1/statusTask/gpt-image-1?taskId=task_12345678" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

Processing response:

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "processing",
    "createTime": 1767965610929
  }
}
```

Success response:

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "success",
    "resultJson": "{\"resultUrls\":[\"https://file.apixo.ai/xxx.png\"]}",
    "createTime": 1767965610929,
    "completeTime": 1767965652317,
    "costTime": 41388
  }
}
```

Failed response:

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "failed",
    "failCode": "SensitiveContent",
    "failMsg": "Content violates provider policy, please adjust the prompt",
    "createTime": 1767965610929,
    "completeTime": 1767965620132,
    "costTime": 9040
  }
}
```

Parse `resultJson` after `state` becomes `success`:

```javascript theme={null}
const payload = JSON.parse(data.resultJson);
const imageUrls = payload.resultUrls;
```

## Request body

### Text-to-image

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "gpt-image-1",
    "prompt": "a cozy cyberpunk cafe with neon lights",
    "aspect_ratio": "3:2",
    "num_images": 1
  }
}
```

### Reference-guided generation

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "gpt-image-1",
    "prompt": "turn these references into a futuristic cityscape at sunset",
    "image_urls": [
      "https://example.com/ref1.jpg",
      "https://example.com/ref2.png"
    ],
    "aspect_ratio": "3:2",
    "num_images": 2
  }
}
```

## Parameters

<ParamField body="request_type" type="string" required default="async">
  Result delivery mode. Use `async` for polling with `statusTask`, or `callback` for webhook delivery.
</ParamField>

<ParamField body="callback_url" type="string">
  Required when `request_type` is `callback`. Must be a public HTTPS URL that can receive the final task payload. See [Webhooks](/api-reference/webhooks).
</ParamField>

<ParamField body="input" type="object" required>
  GPT Image 1 input parameters.

  <Expandable title="properties">
    <ParamField body="mode" type="string" required>
      APIXO routing mode. Supported value: `gpt-image-1`.
    </ParamField>

    <ParamField body="prompt" type="string" required>
      Text prompt describing the desired image. Supports 1-10000 characters.
    </ParamField>

    <ParamField body="aspect_ratio" type="string" required>
      Output aspect ratio. Supported values: `1:1`, `2:3`, `3:2`.
    </ParamField>

    <ParamField body="num_images" type="integer" required>
      Number of images to generate. Supported values: `1`, `2`, `4`. Legacy requests may use `nVariants`, but new integrations should use `num_images`.
    </ParamField>

    <ParamField body="image_urls" type="string[]">
      Optional reference image URLs. Supports up to 5 public HTTP(S) image URLs.
    </ParamField>
  </Expandable>
</ParamField>

## Response format

### Submit task response

`POST /generateTask/gpt-image-1` returns a task ID when the task is accepted:

<ResponseField name="code" type="integer">
  API status code. `200` means the task was accepted.
</ResponseField>

<ResponseField name="message" type="string">
  Human-readable status message.
</ResponseField>

<ResponseField name="data.taskId" type="string">
  Unique task identifier used with the status endpoint.
</ResponseField>

### Status response fields

<ResponseField name="taskId" type="string">
  Unique task identifier.
</ResponseField>

<ResponseField name="state" type="string">
  Current task state: `processing`, `success`, or `failed`.
</ResponseField>

<ResponseField name="resultJson" type="string">
  JSON string containing the generated image URLs. Present when `state` is `success`.
</ResponseField>

<ResponseField name="failCode" type="string">
  Machine-readable failure code. Present when `state` is `failed`.
</ResponseField>

<ResponseField name="failMsg" type="string">
  Human-readable failure message. Present when `state` is `failed`.
</ResponseField>

<ResponseField name="createTime" type="integer">
  Task creation timestamp in Unix milliseconds.
</ResponseField>

<ResponseField name="completeTime" type="integer">
  Task completion timestamp in Unix milliseconds. Present after completion.
</ResponseField>

<ResponseField name="costTime" type="integer">
  Processing duration in milliseconds. Present after completion.
</ResponseField>

## Webhook callback mode

Use callback mode when your backend should receive the final result automatically instead of polling.

```bash theme={null}
curl -X POST "https://api.apixo.ai/api/v1/generateTask/gpt-image-1" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "callback",
    "callback_url": "https://your-server.com/webhooks/apixo",
    "input": {
      "mode": "gpt-image-1",
      "prompt": "a clean product photo of wireless earbuds on soft stone",
      "aspect_ratio": "1:1",
      "num_images": 1
    }
  }'
```

See [Webhooks](/api-reference/webhooks) for delivery requirements and retry behavior.

## Billing

GPT Image 1 is billed per generated image. The selected `num_images` value determines the number of images requested.

| Unit  | APIXO price     | Market price    |
| ----- | --------------- | --------------- |
| Image | `$0.35 / image` | `$0.40 / image` |

For current route and market comparison pricing, see [Pricing](https://apixo.ai/pricing).

## Latency and polling

Actual latency may vary by prompt complexity, reference image count, provider route, and current queue load.

| Typical generation time | Recommended first poll         | Poll interval |
| ----------------------- | ------------------------------ | ------------- |
| About 30 seconds        | 20 seconds after task creation | 3-10 seconds  |

<Tip>
  For high-concurrency production workloads, use callback mode to avoid frequent polling.
</Tip>

Rate limits and concurrency can vary by account, API key, and route. If you receive `429`, slow down requests and retry with backoff. For account-level details, see [System APIs](/api-reference/system).

## Errors and troubleshooting

### HTTP errors

| Code  | Meaning                                                           | What to do                                       |
| ----- | ----------------------------------------------------------------- | ------------------------------------------------ |
| `400` | Invalid request body, mode, parameter, prompt, or image URL shape | Fix the request before retrying                  |
| `401` | Missing or invalid API key                                        | Check the `Authorization` header                 |
| `402` | Insufficient balance or quota                                     | Add balance or switch account/key                |
| `403` | Key or route cannot access the model                              | Check permissions and route strategy             |
| `429` | Rate limit, daily quota, or provider rate limit reached           | Retry with exponential backoff                   |
| `500` | Server error or unknown upstream error                            | Retry with backoff                               |
| `502` | Upstream provider error                                           | Retry with backoff                               |
| `504` | Upstream timeout                                                  | Retry or use callback mode for long-running jobs |

### Task failure codes

| Fail code              | Meaning                                                 | What to do                                           |
| ---------------------- | ------------------------------------------------------- | ---------------------------------------------------- |
| `SensitiveContent`     | Prompt or output was rejected by provider safety checks | Change the prompt or reference image                 |
| `PromptInvalid`        | Prompt format or content was rejected                   | Revise the prompt                                    |
| `ImageNotAccess`       | A reference image URL could not be reached              | Use a public, direct image URL                       |
| `ImageFormatIncorrect` | Image format is incorrect                               | Use a supported image format                         |
| `RateLimited`          | Provider or account rate limit was reached              | Retry with backoff                                   |
| `Timeout`              | Generation did not finish in time                       | Retry, reduce input complexity, or use callback mode |
| `Unknown error`        | Unmapped provider-side failure                          | Retry with backoff or try another route              |

### Tips

* `prompt` must be a non-empty string and cannot exceed 10000 characters.
* `aspect_ratio` is required. Use `1:1` for square outputs, `3:2` for landscape images, or `2:3` for portrait images.
* `num_images` is required. Supported values are `1`, `2`, and `4`.
* `image_urls` supports JPG, PNG, and WebP reference images, up to 10 MB per image. Use public, direct HTTP(S) image URLs.
* Result URLs are normally stored for 15 days. Download and store important outputs promptly.

See [Error Codes](/api-reference/errors) for the full error reference.

## Related links

* [Generation API Overview](/models)
* [Generate Task](/api-reference/generate-task)
* [Status Task](/api-reference/status-task)
* [Webhooks](/api-reference/webhooks)
* [Error Codes](/api-reference/errors)
* [Parameter Specification](/api-reference/parameters)
* [Routing Strategies](/concepts/routing-strategies)
* [Pricing](https://apixo.ai/pricing)
