> For the complete documentation index, see [llms.txt](https://nsclouds.gitbook.io/aillm.nscloud.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://nsclouds.gitbook.io/aillm.nscloud.ai/image-generations/openai.md).

# OpenAI

### 1. Overview

OpenAI exposes image generation capabilities in this environment.

{% hint style="success" %}
This endpoint provides gpt-image-2 image capabilities through the OpenAI Images API.
{% endhint %}

**Supported models：**

* `gpt-image-2`

### 2. gpt-image-2 Parameter Notes

{% hint style="info" %}
`gpt-image-2` supports text-to-image generation. `n` may request 1-10 images, and the actual number of returned images can be lower than requested.
{% endhint %}

| Parameter            | Support                                                                                               |
| -------------------- | ----------------------------------------------------------------------------------------------------- |
| `prompt`             | Required. Reference maximum length is 32000 characters.                                               |
| `n`                  | Optional. Reference range is 1-10; the actual number of returned images can be lower than requested.  |
| `size`               | Optional. Supports `auto` and the fixed sizes listed below.                                           |
| `quality`            | Optional. Supports `low`, `medium`, and `high`; omitted, `auto`, and `standard` are billed as `high`. |
| `background`         | Optional. Supports `opaque` and `auto`.                                                               |
| `moderation`         | Optional. Supported only on image generations; accepts `low` and `auto`.                              |
| `output_format`      | Optional. Supports `png` and `jpeg`.                                                                  |
| `output_compression` | Optional. Range is 0-100 and applies only to `jpeg`; omit it for `png` or set it to 100.              |

Supported sizes: `auto`, `1024x1024`, `1024x1536`, `1536x1024`, `2048x2048`, `2048x1152`, `3840x2160`, `2160x3840`, `2048x1360`, `1360x2048`, `1152x2048`, `2048x1536`, `1536x2048`, `2048x880`, `880x2048`, `688x2048`, `2048x688`, `2048x1024`, `1024x2048`

### 3. API Details

## Create Image

> Generate images based on text prompts. Compatible with OpenAI's Images API.

```json
{"openapi":"3.1.0","info":{"title":"NSCloud AI API Documentation","version":"1.11.0"},"tags":[{"name":"image_generations_openai","description":"OpenAI's image generations API"}],"servers":[{"url":"https://aillm.nscloud.ai","description":"Global Server"}],"security":[{"APIKeyHeader":[]}],"components":{"securitySchemes":{"APIKeyHeader":{"type":"http","scheme":"bearer","description":"Authenticate using Bearer token format: 'Bearer YOUR_SECRET_TOKEN'"}},"schemas":{"ImageUsage":{"type":"object","description":"Resource usage summary for image generation.","properties":{"total_tokens":{"type":"integer","description":"Total token count."},"input_tokens":{"type":"integer","description":"Input token count."},"output_tokens":{"type":"integer","description":"Output token count."},"input_tokens_details":{"type":"object","description":"Optional breakdown of input token usage.","properties":{"text_tokens":{"type":"integer","description":"Input tokens attributed to text prompts."},"image_tokens":{"type":"integer","description":"Input tokens attributed to images."}},"additionalProperties":true}}},"ErrorResponse":{"type":"object","description":"Error response payload.","properties":{"error":{"$ref":"#/components/schemas/ErrorDetail"}}},"ErrorDetail":{"type":"object","description":"Error detail object.","properties":{"message":{"type":"string","description":"Human-readable error message."},"type":{"type":"string","description":"Error type."},"param":{"description":"Parameter associated with the error, if any.","type":["string","null"]},"code":{"description":"Machine-readable error code, if any.","type":["string","null"]}}}},"responses":{"ErrorResponse":{"description":"Error response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"paths":{"/v1/images/generations":{"post":{"tags":["image_generations_openai"],"summary":"Create Image","description":"Generate images based on text prompts. Compatible with OpenAI's Images API.","operationId":"createImageGeneration_openai","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","description":"gpt-image-2 image generation request body.","properties":{"model":{"type":"string","description":"Model ID to invoke."},"prompt":{"type":"string","maxLength":32000,"description":"Prompt used to generate the image."},"n":{"type":"integer","minimum":1,"maximum":10,"default":1,"description":"Number of images to request. The actual returned count can be lower than requested."},"size":{"type":"string","description":"Requested output image size.","enum":["auto","1024x1024","1024x1536","1536x1024","2048x2048","2048x1152","3840x2160","2160x3840","2048x1360","1360x2048","1152x2048","2048x1536","1536x2048","2048x880","880x2048","688x2048","2048x688","2048x1024","1024x2048"],"default":"1024x1024"},"quality":{"type":"string","description":"Requested image quality level.","enum":["low","medium","high"],"default":"high"},"background":{"type":"string","description":"Background handling mode.","enum":["opaque","auto"]},"moderation":{"type":"string","description":"Moderation strictness for image generation.","enum":["low","auto"]},"output_format":{"type":"string","description":"Output image format.","enum":["png","jpeg"],"default":"png"},"output_compression":{"type":"integer","minimum":0,"maximum":100,"description":"Compression level from 0 to 100. Applies only to jpeg; omit for png or set to 100."}},"required":["model","prompt"]}}}},"responses":{"200":{"description":"Success Response","content":{"application/json":{"schema":{"type":"object","description":"gpt-image-2 image generation response.","properties":{"created":{"type":"integer","description":"Unix timestamp in seconds when the response was created."},"background":{"type":"string","description":"Background type used for the generated image."},"output_format":{"type":"string","description":"Output image format."},"quality":{"type":"string","description":"Effective image quality used by the model."},"size":{"type":"string","description":"Final returned image size."},"data":{"type":"array","description":"Generated image results.","items":{"type":"object","properties":{"url":{"type":"string","description":"Generated image URL."},"revised_prompt":{"type":"string","description":"Prompt actually used or revised by the model."}}}},"usage":{"$ref":"#/components/schemas/ImageUsage"}}}}}},"400":{"$ref":"#/components/responses/ErrorResponse"},"401":{"$ref":"#/components/responses/ErrorResponse"},"429":{"$ref":"#/components/responses/ErrorResponse"}}}}}}
```
