OpenAI Chat Completion 4o Image API Application and Usage

OpenAI ChatGPT is a powerful AI conversational system that can generate smooth and natural replies within seconds based on input prompts. ChatGPT stands out in the industry for its excellent language understanding and generation capabilities. Today, ChatGPT is widely applied across various industries and fields, with its influence becoming increasingly significant. Whether for daily conversations, creative writing, professional consulting, or code programming, ChatGPT provides impressive intelligent assistance, greatly enhancing human work efficiency and creativity.

This document mainly introduces the usage process of the OpenAI Chat Completion 4o Image API, which allows us to easily utilize the official OpenAI ChatGPT’s multimodal conversational features.

Application Process

To use OpenAI Chat Completion 4o Image API, first open the Ace Data Cloud Console and copy your API Token.

If you are not logged in, you will be redirected to sign in and brought back to this page automatically.

A single API Token works across every service on the platform — no need to subscribe per service. New accounts receive free starter credit; when it runs low you can top up your shared balance in the console.

📘 Full documentation: OpenAI Chat Completion 4o Image API →

GPT-4o Drawing Model

Generating Images Based on Reference Images

Below is an example of generating a custom style image based on a given picture. First, let's look at the input image:

The reference image is a photo of a real person. We can transform its style, for example, turning it into an anime-style image. The specific request example is:

{
  "model": "gpt-4o-image",
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "生成动漫风格的图片,并且带上个帽子"
        },
        {
          "type": "image_url",
          "image_url": {
            "url": "https://cdn.acedata.cloud/qzx2z1.png"
          }
        }
      ]
    }
  ],
  "stream": false
}

Sample result:

{
  "id": "chatcmpl-89DPQxbLuyRNzH5YLCPYM5WElV3dm",
  "object": "chat.completion",
  "created": 1781020664,
  "model": "gpt-4o-image",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "\n\n> 🎨 生成中...\n\n![https://pro.filesystem.site/cdn/20260609/0f7b6cf1b14843b1bab8e261fe5765b3.png](https://pro.filesystem.site/cdn/20260609/0f7b6cf1b14843b1bab8e261fe5765b3.png)\n\n[点击下载](https://pro.filesystem.site/cdn/download/20260609/0f7b6cf1b14843b1bab8e261fe5765b3.png)"
      },
      "logprobs": null,
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 100,
    "completion_tokens": 122,
    "total_tokens": 222,
    "prompt_tokens_details": {
      "text_tokens": 93,
      "cached_tokens_details": {}
    },
    "completion_tokens_details": {}
  }
}

The message.content inside choices contains the complete generated conversation result, with the image embedded in Markdown format (the image link is a temporary address, please download and save it promptly). The generated image is indeed in anime style, as shown below:

Text-Only Image Generation

We can generate an image based on a prompt and receive the result in a conversational format. Below is an example with the prompt Create an image of a futuristic city at sunset:

{
  "model": "gpt-4o-image",
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "创建一张未来城市日落的图片"
        }
      ]
    }
  ],
  "stream": false
}

Sample result:

{
  "id": "chatcmpl-89DqkpQoPGkQqJ6kPKMKWejjLXVxQ",
  "object": "chat.completion",
  "created": 1781020587,
  "model": "gpt-4o-image",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "\n\n> 🎨 生成中...\n\n![https://pro.filesystem.site/cdn/20260609/ed2cca68732540fc99162ddc10ddc153.png](https://pro.filesystem.site/cdn/20260609/ed2cca68732540fc99162ddc10ddc153.png)\n\n[点击下载](https://pro.filesystem.site/cdn/download/20260609/ed2cca68732540fc99162ddc10ddc153.png)"
      },
      "logprobs": null,
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 17,
    "completion_tokens": 104,
    "total_tokens": 121,
    "prompt_tokens_details": {
      "text_tokens": 10,
      "cached_tokens_details": {}
    },
    "completion_tokens_details": {}
  }
}

The result matches the prompt, as shown below:

Multiple Images to One Image

We can also use multiple reference images to generate a single image. For example, using a photo of a handsome man and a coffee image, we can generate an image of the man drinking coffee. Below are the reference images:

Here is an example prompt: Generate an image of a man holding coffee and about to drink it:

{
  "model": "gpt-4o-image",
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "生成男生举着咖啡,并且马上要喝的样子"
        },
        {
          "type": "image_url",
          "image_url": {
            "url": "https://cdn.acedata.cloud/pqquv3.jpg"
          }
        },
        {
          "type": "image_url",
          "image_url": {
            "url": "https://cdn.acedata.cloud/h8j2i0.jpg"
          }
        }
      ]
    }
  ],
  "stream": false
}

Sample result:

{
  "id": "chatcmpl-89DnHbbzOIQvU1VzJrNjzMU8BRUgG",
  "object": "chat.completion",
  "created": 1781021018,
  "model": "gpt-4o-image",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "\n\n> 🎨 生成中...\n\n![https://pro.filesystem.site/cdn/20260610/f1d9ddee3c304230a9f92929f04b95be.png](https://pro.filesystem.site/cdn/20260610/f1d9ddee3c304230a9f92929f04b95be.png)\n\n[点击下载](https://pro.filesystem.site/cdn/download/20260610/f1d9ddee3c304230a9f92929f04b95be.png)"
      },
      "logprobs": null,
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 193,
    "completion_tokens": 116,
    "total_tokens": 309,
    "prompt_tokens_details": {
      "text_tokens": 186,
      "cached_tokens_details": {}
    },
    "completion_tokens_details": {}
  }
}

The generated result indeed combines the two images, as shown below:

Error Handling

When calling the API, if an error occurs, the API will return the corresponding error code and message. For example:

  • 400 token_mismatched: Bad request, possibly due to missing or invalid parameters.
  • 400 api_not_implemented: Bad request, possibly due to missing or invalid parameters.
  • 401 invalid_token: Unauthorized, invalid or missing authorization token.
  • 429 too_many_requests: Too many requests, you have exceeded the rate limit.
  • 500 api_error: Internal server error, something went wrong on the server.

Error Response Example

{
  "success": false,
  "error": {
    "code": "api_error",
    "message": "fetch failed"
  },
  "trace_id": "2cf86e86-22a4-46e1-ac2f-032c0f2a4e89"
}

Conclusion

Through this document, you have learned how to easily implement the official OpenAI ChatGPT multimodal image processing features using the OpenAI Chat Completion 4o Image API. We hope this document helps you better integrate and use the API. If you have any questions, please feel free to contact our technical support team.