gpt-image-2-generate is OpenAI’s latest text-to-image model. It excels at following complex prompts, rendering accurate text within images, and producing photorealistic outputs across a wide range of styles.
Billing is based on the actual token consumption reported by OpenAI for each request. Users are charged according to the real usage of input text tokens, cached input text tokens, input image tokens, cached input image tokens, and output image tokens.The final cost may vary depending on prompt length, whether input images are provided, image size, quality, number of generated images, and other request parameters.
The following table is provided as a reference only for common quality and resolution combinations. These are estimated per-image prices and may differ from the final billed amount, which is always based on actual token usage.
from openai import OpenAIclient = OpenAI( api_key="YOUR_API_KEY", base_url="https://console.gmicloud.ai/api/v1/ie/requestqueue/apikey/requests/v1")response = client.images.generate( model="gpt-image-2", prompt="A red fox in an autumn forest", size="1024x1024", quality="medium")print(response.data[0].b64_json)