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

# GPT-Image(1/1.5) Bildgenerierung

>  - Asynchroner Verarbeitungsmodus, gibt eine Task-ID für nachfolgende Abfragen zurück
- Unterstützt Text-zu-Bild, Bild-zu-Bild und Inpainting-Generierungsmodi
- Unterstützt transparente Hintergründe, mehrere Ausgabeformate und Qualitätsstufen
- Bis zu 4 Bilder pro Anfrage, mit bis zu 15 Referenzbildern 

```bash cURL theme={null}
curl --request POST \
  --url https://gccai.heqingsong.uk/v1/images/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "gpt-image-1-official",
    "prompt": "An ancient castle under a starry sky",
    "size": "1:1",
    "quality": "auto",
    "n": 1
  }'
```

```python Python theme={null}
import requests

url = "https://gccai.heqingsong.uk/v1/images/generations"

payload = {
    "model": "gpt-image-1-official",
    "prompt": "An ancient castle under a starry sky",
    "size": "1:1",
    "quality": "auto",
    "n": 1
}

headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript JavaScript theme={null}
const url = "https://gccai.heqingsong.uk/v1/images/generations";

const payload = {
  model: "gpt-image-1-official",
  prompt: "An ancient castle under a starry sky",
  size: "1:1",
  quality: "auto",
  n: 1,
};

const headers = {
  Authorization: "Bearer <token>",
  "Content-Type": "application/json",
};

fetch(url, {
  method: "POST",
  headers: headers,
  body: JSON.stringify(payload),
})
  .then((response) => response.json())
  .then((data) => console.log(data))
  .catch((error) => console.error("Error:", error));
```

```go Go theme={null}
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "io/ioutil"
    "net/http"
)

func main() {
    url := "https://gccai.heqingsong.uk/v1/images/generations"

    payload := map[string]interface{}{
        "model":   "gpt-image-1-official",
        "prompt":  "An ancient castle under a starry sky",
        "size":    "1:1",
        "quality": "auto",
        "n":       1,
    }

    jsonData, _ := json.Marshal(payload)

    req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
    req.Header.Set("Authorization", "Bearer <token>")
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()

    body, _ := ioutil.ReadAll(resp.Body)
    fmt.Println(string(body))
}
```

```java Java theme={null}
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;

public class Main {
    public static void main(String[] args) throws Exception {
        String url = "https://gccai.heqingsong.uk/v1/images/generations";

        String payload = """
        {
          "model": "gpt-image-1-official",
          "prompt": "An ancient castle under a starry sky",
          "size": "1:1",
          "quality": "auto",
          "n": 1
        }
        """;

        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create(url))
            .header("Authorization", "Bearer <token>")
            .header("Content-Type", "application/json")
            .POST(HttpRequest.BodyPublishers.ofString(payload))
            .build();

        HttpResponse<String> response = client.send(request,
            HttpResponse.BodyHandlers.ofString());

        System.out.println(response.body());
    }
}
```

```php PHP theme={null}
<?php

$url = "https://gccai.heqingsong.uk/v1/images/generations";

$payload = [
    "model" => "gpt-image-1-official",
    "prompt" => "An ancient castle under a starry sky",
    "size" => "1:1",
    "quality" => "auto",
    "n" => 1
];

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Authorization: Bearer <token>",
    "Content-Type: application/json"
]);

$response = curl_exec($ch);
curl_close($ch);

echo $response;
?>
```

```ruby Ruby theme={null}
require 'net/http'
require 'json'
require 'uri'

url = URI("https://gccai.heqingsong.uk/v1/images/generations")

payload = {
  model: "gpt-image-1-official",
  prompt: "An ancient castle under a starry sky",
  size: "1:1",
  quality: "auto",
  n: 1
}

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer <token>"
request["Content-Type"] = "application/json"
request.body = payload.to_json

response = http.request(request)
puts response.body
```

```swift Swift theme={null}
import Foundation

let url = URL(string: "https://gccai.heqingsong.uk/v1/images/generations")!

let payload: [String: Any] = [
    "model": "gpt-image-1-official",
    "prompt": "An ancient castle under a starry sky",
    "size": "1:1",
    "quality": "auto",
    "n": 1
]

var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("Bearer <token>", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpBody = try? JSONSerialization.data(withJSONObject: payload)

let task = URLSession.shared.dataTask(with: request) { data, response, error in
    if let error = error {
        print("Error: \(error)")
        return
    }

    if let data = data, let responseString = String(data: data, encoding: .utf8) {
        print(responseString)
    }
}

task.resume()
```

```csharp C# theme={null}
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static async Task Main(string[] args)
    {
        var url = "https://gccai.heqingsong.uk/v1/images/generations";

        var payload = @"{
            ""model"": ""gpt-image-1-official"",
            ""prompt"": ""An ancient castle under a starry sky"",
            ""size"": ""1:1"",
            ""quality"": ""auto"",
            ""n"": 1
        }";

        using var client = new HttpClient();
        client.DefaultRequestHeaders.Add("Authorization", "Bearer <token>");

        var content = new StringContent(payload, Encoding.UTF8, "application/json");
        var response = await client.PostAsync(url, content);
        var result = await response.Content.ReadAsStringAsync();

        Console.WriteLine(result);
    }
}
```

```dart Dart theme={null}
import 'dart:convert';
import 'package:http/http.dart' as http;

void main() async {
  final url = Uri.parse('https://gccai.heqingsong.uk/v1/images/generations');

  final payload = {
    'model': 'gpt-image-1-official',
    'prompt': 'An ancient castle under a starry sky',
    'size': '1:1',
    'quality': 'auto',
    'n': 1,
  };

  final response = await http.post(
    url,
    headers: {
      'Authorization': 'Bearer <token>',
      'Content-Type': 'application/json',
    },
    body: jsonEncode(payload),
  );

  print(response.body);
}
```

```r R theme={null}
library(httr)
library(jsonlite)

url <- "https://gccai.heqingsong.uk/v1/images/generations"

payload <- list(
  model = "gpt-image-1-official",
  prompt = "An ancient castle under a starry sky",
  size = "1:1",
  quality = "auto",
  n = 1
)

response <- POST(
  url,
  add_headers(
    Authorization = "Bearer <token>",
    `Content-Type` = "application/json"
  ),
  body = toJSON(payload, auto_unbox = TRUE),
  encode = "raw"
)

cat(content(response, "text"))
```

```json 200 theme={null}
{
  "code": 200,
  "data": [
    {
      "status": "submitted",
      "task_id": "task_01KXXXXXXXXXXXXXXX"
    }
  ]
}
```

```json 400 theme={null}
{
  "error": {
    "code": 400,
    "message": "Invalid request parameters",
    "type": "invalid_request_error"
  }
}
```

```json 401 theme={null}
{
  "error": {
    "code": 401,
    "message": "Authentication failed, please check your API key",
    "type": "authentication_error"
  }
}
```

```json 402 theme={null}
{
  "error": {
    "code": 402,
    "message": "Insufficient balance, please top up and try again",
    "type": "payment_required"
  }
}
```

```json 403 theme={null}
{
  "error": {
    "code": 403,
    "message": "Access forbidden, you do not have permission to access this resource",
    "type": "permission_error"
  }
}
```

```json 429 theme={null}
{
  "error": {
    "code": 429,
    "message": "Too many requests, please try again later",
    "type": "rate_limit_error"
  }
}
```

```json 500 theme={null}
{
  "error": {
    "code": 500,
    "message": "Internal server error, please try again later",
    "type": "server_error"
  }
}
```

```json 502 theme={null}
{
  "error": {
    "code": 502,
    "message": "Bad gateway, server temporarily unavailable",
    "type": "bad_gateway"
  }
}
```

## Unterstützte Modelle

| Modell | Beschreibung | Modi | Bild-zu-Bild | Max. Bilder | Abrechnung |
| - | - | - | - | - | - |
| `gpt-image-1-official` | Stabilität im Vordergrund, geeignet für allgemeine Bildgenerierung | Text-zu-Bild / Bild-zu-Bild | Unterstützt | 4 | Size × Quality |
| `gpt-image-1.5-official` | Neue Version, geeignet für höhere Qualität und komplexe Bearbeitung | Text-zu-Bild / Bild-zu-Bild | Unterstützt | 4 | Size × Quality |

## Autorisierung

**Authorization** `string` *required*

Alle API-Anfragen erfordern eine Authentifizierung per Bearer Token

API-Schlüssel erhalten:

Besuchen Sie die [Seite zur Verwaltung von API-Schlüsseln](https://gccai.heqingsong.uk/keys), um Ihren API-Schlüssel zu erhalten

Fügen Sie Folgendes in Ihren Anfrage-Headern hinzu:

```
Authorization: Bearer YOUR_API_KEY
```

## Body

**model** `string` *required*

Modellname

* `gpt-image-1-official` – Stabilität im Vordergrund, geeignet für allgemeine Bildgenerierung
* `gpt-image-1.5-official` – Neue Version, geeignet für höhere Qualität und komplexe Bearbeitung

**nsfw\_check** `boolean` (default: false)

Legt fest, ob der Inhalt vor dem Absenden des Bildauftrags moderiert wird.

* `true`: Prompts und Eingabebilder mit `omni-moderation-latest` prüfen
* `false` oder nicht angegeben: keine Moderationsanfrage und damit keine zusätzlichen Moderationskosten oder Verzögerung (Standard)

**prompt** `string` *required*

Textbeschreibung für die Bildgenerierung, unterstützt sowohl Chinesisch als auch Englisch

**size** `string` (default: 1:1)

Seitenverhältnis

Unterstützte Verhältnisse:

* `1:1` – Quadrat (Standard)
* `3:2` – Querformat
* `2:3` – Hochformat

**n** `integer` (default: 1)

Anzahl der zu generierenden Bilder

Bereich: 1–4

* Werte ≤ 0 werden als `1` behandelt
* Werte > 4 werden als `4` behandelt

**Warnung:** Muss eine reine Zahl sein (z. B. `1`), keine Anführungszeichen verwenden, sonst tritt ein Fehler auf

**quality** `string` (default: auto)

Bildqualität

* `auto` – Automatische Qualitätsauswahl (Standard)
* `low` – Schneller, sparsamer
* `medium` – Ausgewogenes Verhältnis zwischen Qualität und Kosten
* `high` – Höhere Qualität, höhere Kosten

**background** `string` (default: auto)

Hintergrundmodus

* `auto` – Automatischer Hintergrund (Standard)
* `opaque` – Undurchsichtiger Hintergrund
* `transparent` – Transparenter Hintergrund, empfohlen mit Ausgabeformat `png`

> [!WARNING]
>
> `background: transparent` kann nicht gleichzeitig mit `output_format: jpeg` verwendet werden

**moderation** `string` (default: auto)

Moderationsstufe

* `auto` – Standard-Moderationsstufe
* `low` – Mildere Moderation

**output\_format** `string` (default: png)

Ausgabeformat

* `png` – Standardformat, geeignet für transparente Hintergründe
* `jpeg` – Kleinere Dateigröße, geeignet für allgemeine Bildausgabe

> [!WARNING]
>
> `background: transparent` kann nicht gleichzeitig mit `output_format: jpeg` verwendet werden

**output\_compression** `integer`

Ausgabe-Kompressionsstufe, Bereich 0–100

* Nur für `jpeg` empfohlen
* Für `png` nicht empfohlen

**image\_urls** `array`

Array von URLs für Referenzbilder, aktiviert bei Angabe den Bild-zu-Bild-Modus

**Details**

* 1 Bild für die Bearbeitung mit einer einzelnen Referenz
* 2–15 Bilder für Mehrfachreferenz-Fusion-Bearbeitung
* Mehr als 15 Bilder werden abgelehnt
* Müssen öffentlich zugängliche, stabile Bild-URLs sein

**Limit:** Bis zu 15 Referenzbilder

**mask\_url** `string`

Masken-Bild-URL für Inpainting

* Muss zusammen mit `image_urls` verwendet werden
* Wird über die offizielle Bearbeitungs-API übermittelt

> [!WARNING]
>
> 1. Stellen Sie vor dem Hochladen der Maske sicher, dass der Alphakanal des Bildes auf „Ja" gesetzt ist.
>
> 2. Die Größe der Maske muss mit dem ersten Referenzbild übereinstimmen.

## Größenreferenz

Seitenverhältnisse werden nach außen verwendet; das System ordnet sie intern automatisch den offiziellen Abmessungen zu.

| Verhältnis | Tatsächliche Größe | Beschreibung |
| - | - | - |
| `1:1` | 1024x1024 | Quadrat |
| `2:3` | 1024x1536 | Hochformat |
| `3:2` | 1536x1024 | Querformat |

## Anwendungsbeispiele

**Text-zu-Bild (minimal)**

```json theme={null}
{
  "model": "gpt-image-1-official",
  "prompt": "An ancient castle under a starry sky"
}
```

**Text-zu-Bild (vollständige Parameter)**

```json theme={null}
{
  "model": "gpt-image-1-official",
  "prompt": "A flat icon of a glass bottle with no background",
  "size": "2:3",
  "quality": "high",
  "background": "transparent",
  "moderation": "low",
  "output_format": "png",
  "n": 1
}
```

**Bild-zu-Bild (einzelne Referenz)**

```json theme={null}
{
  "model": "gpt-image-1.5-official",
  "prompt": "Convert the reference image to illustration style, preserving the main outline",
  "size": "1:1",
  "quality": "auto",
  "image_urls": [
    "https://your-cdn.com/input.png"
  ],
  "n": 1
}
```

**Bild-zu-Bild (Mehrfachreferenz-Fusion)**

```json theme={null}
{
  "model": "gpt-image-1.5-official",
  "prompt": "Merge two reference images into an illustration poster, preserving the main outlines",
  "size": "1:1",
  "quality": "auto",
  "background": "transparent",
  "image_urls": [
    "https://your-cdn.com/input-a.png",
    "https://your-cdn.com/input-b.png"
  ],
  "moderation": "low",
  "output_format": "png",
  "n": 1
}
```

**Mehrere Bilder (n > 1)**

```json theme={null}
{
  "model": "gpt-image-1-official",
  "prompt": "Four minimalist poster variations of a red fox",
  "size": "1:1",
  "quality": "low",
  "output_format": "png",
  "n": 4
}
```

## Response

**code** `integer`

Statuscode der Antwort

**data** `array`

Array mit Antwortdaten

**Eigenschaften**

**status** `string`

Aufgabenstatus

* `submitted` – Eingereicht

**task\_id** `string`

Eindeutige Aufgabenkennung

## Hinweise

1. **Asynchrone Verarbeitung**: Nach dem Einreichen wird eine `task_id` zurückgegeben. Pollen Sie `/v1/tasks/{task_id}`, um die Ergebnisse abzurufen
2. **Modellauswahl**: Verwenden Sie `gpt-image-1-official` für die allgemeine Bildgenerierung; verwenden Sie `gpt-image-1.5-official` für hochwertige Bearbeitung und komplexe Bild-zu-Bild-Aufgaben
3. **Anforderungen an Bild-URLs**: Verwenden Sie für Bild-zu-Bild öffentlich zugängliche und stabile Bild-URLs
4. **Abrechnung**: Abrechnung pro erfolgreich generiertem Bild; keine Abrechnung bei Fehlern


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.