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

# Create response (OpenAI Responses API)

> OpenAI Responses API, used to create model responses.
Supports multi-turn conversations, tool calling, reasoning, and other features.

Add asynchronous image generation examples for OpenAI Responses API. `background=true` is used to submit background tasks; the create API returns `status=queued` and the full `id` immediately, then use that `id` to call `GET /v1/responses/{response_id}` to query the result.

## Asynchronous image generation flow

1. Call `POST /v1/responses`, and pass `tools=[{ "type": "image_generation" }]` and `background=true` in the request body.
2. Save the full `id` returned by the create API, for example `resp_xxx`. Do not truncate, rewrite, or save only `metadata.task_id`.
3. Call `GET /v1/responses/{response_id}` to query until `status=completed` or `status=failed`.
4. After success, read `output[].url` to get the image URL.

### Example of creating an asynchronous image task

```http
POST /v1/responses
Content-Type: application/json
```

```json
{
  "model": "gpt-image-2-2k",
  "input": "生成一张 2K 横屏产品海报，白色运动鞋，干净棚拍光线，高级商业摄影风格。",
  "stream": false,
  "tools": [
    {
      "type": "image_generation"
    }
  ],
  "background": true
}
```

Create API response example:

```json
{
  "id": "resp_xxx",
  "created_at": 1780649146,
  "error": null,
  "incomplete_details": null,
  "instructions": null,
  "metadata": {
    "task_id": "010c31178d26436ca6194cde07931b33"
  },
  "model": "gpt-image-2-2k",
  "object": "response",
  "output": [],
  "parallel_tool_calls": true,
  "temperature": null,
  "tool_choice": null,
  "tools": null,
  "top_p": null,
  "max_output_tokens": null,
  "previous_response_id": null,
  "reasoning": null,
  "status": "queued",
  "text": null,
  "truncation": null,
  "usage": null,
  "user": null,
  "store": null
}
```

Supported models: `gpt-image-2-2k`, `gpt-image-2-4k`, and `nano-banana-pro`.



## OpenAPI

````yaml api-reference/en/openapi.json POST /v1/responses
openapi: 3.0.0
info:
  title: Overseas Expansion Camp API Reference Documentation
  version: 1.0.0
  description: Public AI Gateway API Reference
servers:
  - url: https://api.aiid.edu.kg
security:
  - BearerAuth: []
tags:
  - name: OpenAI format (Chat)
  - name: OpenAI Format (Responses)
  - name: Gemini Format for Image Generation
  - name: Image generationOpenAI DALL-E format
  - name: List models
  - name: Video generationHappyHorse and Wan
  - name: Video generation Kling format
  - name: Video generation Omni and Veo formats
  - name: Video generation Seedance
  - name: Video generation Sora compatible formats
  - name: Video generation Vidu
  - name: Music generation task format
paths:
  /v1/responses:
    post:
      tags:
        - OpenAI Format (Responses)
      summary: Create response (OpenAI Responses API)
      description: >-
        OpenAI Responses API, used to create model responses.

        Supports multi-turn conversations, tool calling, reasoning, and other
        features.


        Add asynchronous image generation examples for OpenAI Responses API.
        `background=true` is used to submit background tasks; the create API
        returns `status=queued` and the full `id` immediately, then use that
        `id` to call `GET /v1/responses/{response_id}` to query the result.


        ## Asynchronous image generation flow


        1. Call `POST /v1/responses`, and pass `tools=[{ "type":
        "image_generation" }]` and `background=true` in the request body.

        2. Save the full `id` returned by the create API, for example
        `resp_xxx`. Do not truncate, rewrite, or save only `metadata.task_id`.

        3. Call `GET /v1/responses/{response_id}` to query until
        `status=completed` or `status=failed`.

        4. After success, read `output[].url` to get the image URL.


        ### Example of creating an asynchronous image task


        ```http

        POST /v1/responses

        Content-Type: application/json

        ```


        ```json

        {
          "model": "gpt-image-2-2k",
          "input": "生成一张 2K 横屏产品海报，白色运动鞋，干净棚拍光线，高级商业摄影风格。",
          "stream": false,
          "tools": [
            {
              "type": "image_generation"
            }
          ],
          "background": true
        }

        ```


        Create API response example:


        ```json

        {
          "id": "resp_xxx",
          "created_at": 1780649146,
          "error": null,
          "incomplete_details": null,
          "instructions": null,
          "metadata": {
            "task_id": "010c31178d26436ca6194cde07931b33"
          },
          "model": "gpt-image-2-2k",
          "object": "response",
          "output": [],
          "parallel_tool_calls": true,
          "temperature": null,
          "tool_choice": null,
          "tools": null,
          "top_p": null,
          "max_output_tokens": null,
          "previous_response_id": null,
          "reasoning": null,
          "status": "queued",
          "text": null,
          "truncation": null,
          "usage": null,
          "user": null,
          "store": null
        }

        ```


        Supported models: `gpt-image-2-2k`, `gpt-image-2-4k`, and
        `nano-banana-pro`.
      operationId: createResponse
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ResponsesRequest'
              properties: {}
            examples:
              responses_image_async:
                summary: Asynchronous image generation
                value:
                  model: gpt-image-2-2k
                  input: 生成一张 2K 横屏产品海报，白色运动鞋，干净棚拍光线，高级商业摄影风格。
                  stream: false
                  tools:
                    - type: image_generation
                  background: true
        required: true
      responses:
        '200':
          description: Response created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponsesResponse'
              examples:
                responses_image_async_queued:
                  summary: Image generation asynchronous creation response
                  value:
                    id: resp_xxx
                    created_at: 1780649146
                    error: null
                    incomplete_details: null
                    instructions: null
                    metadata:
                      task_id: 010c31178d26436ca6194cde07931b33
                    model: gpt-image-2-2k
                    object: response
                    output: []
                    parallel_tool_calls: true
                    temperature: null
                    tool_choice: null
                    tools: null
                    top_p: null
                    max_output_tokens: null
                    previous_response_id: null
                    reasoning: null
                    status: queued
                    text: null
                    truncation: null
                    usage: null
                    user: null
                    store: null
          headers: {}
      deprecated: false
      security:
        - BearerAuth: []
components:
  schemas:
    ResponsesRequest:
      type: object
      required:
        - model
      properties:
        model:
          type: string
        input:
          description: Input content, can be a string or an array of messages
          oneOf:
            - type: string
            - type: array
              items:
                type: object
                properties: {}
        instructions:
          type: string
        max_output_tokens:
          type: integer
        temperature:
          type: number
        top_p:
          type: number
        stream:
          type: boolean
        tools:
          type: array
          items:
            type: object
            properties: {}
        tool_choice:
          oneOf:
            - type: string
            - type: object
              properties: {}
        reasoning:
          type: object
          properties:
            effort:
              type: string
              enum:
                - low
                - medium
                - high
            summary:
              type: string
        previous_response_id:
          type: string
        truncation:
          type: string
          enum:
            - auto
            - disabled
    ResponsesResponse:
      type: object
      properties:
        id:
          type: string
        object:
          type: string
          example: response
        created_at:
          type: integer
        status:
          type: string
          enum:
            - completed
            - failed
            - in_progress
            - incomplete
        model:
          type: string
        output:
          type: array
          items:
            type: object
            properties:
              type:
                type: string
              id:
                type: string
              status:
                type: string
              role:
                type: string
              content:
                type: array
                items:
                  type: object
                  properties:
                    type:
                      type: string
                    text:
                      type: string
        usage:
          $ref: '#/components/schemas/Usage'
    Usage:
      type: object
      properties:
        prompt_tokens:
          type: integer
          description: Prompt Tokens
        completion_tokens:
          type: integer
          description: Completion Tokens
        total_tokens:
          type: integer
          description: Total Tokens
        prompt_tokens_details:
          type: object
          properties:
            cached_tokens:
              type: integer
            text_tokens:
              type: integer
            audio_tokens:
              type: integer
            image_tokens:
              type: integer
        completion_tokens_details:
          type: object
          properties:
            text_tokens:
              type: integer
            audio_tokens:
              type: integer
            reasoning_tokens:
              type: integer
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: |-
        Use Bearer Token authentication.
        Format: `Authorization: Bearer sk-xxxxxx`

````