> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://developer.ideogram.ai/v1/api-reference/generate-images/generate-p-image-ideogram/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developer.ideogram.ai/_mcp/server. # Generate with P-Image Ideogram POST https://api.ideogram.ai/v1/text-to-image/p-image-ideogram Content-Type: multipart/form-data Generates images synchronously using P-Image Ideogram. `quality` selects the generation quality level and `resolution` selects the output-size tier. Both parameters have defaults. Images links are available for a limited period of time; if you would like to keep the image, you must download them. Reference: https://developer.ideogram.ai/v1/api-reference/generate-images/generate-p-image-ideogram ## Authentication - `Api-Key` header (required) — API key for access control. Use in the header with the name \"Api-Key\" ## Request ### Body (multipart/form-data) This endpoint expects a multipart form. - `prompt` (string, required) — The prompt for image generation. Accepts either natural language or a structured Ideogram 4.0 JSON prompt; the server detects which was supplied. - `prompt_upsampling` (enum, optional) — Controls magic-prompt (prompt upsampling). Defaults to `AUTO`. - `seed` (integer, optional) — Random seed for reproducibility. - `quality` (enum, optional) — The generation quality level. Defaults to `MEDIUM`. - `resolution` (enum, optional) — The output-size tier. Defaults to `1K`. - `aspect_ratio` (enum, optional) — The output aspect ratio. Defaults to `1x1`. - `custom_width` (integer, optional) — Optional. An exact output width in pixels, used together with `custom_height` for output sizes outside the preset tiers. Must be a positive multiple of 16 between 16 and 4096, and `custom_width` × `custom_height` must not exceed 4,194,304 pixels (2048×2048). Cannot be combined with `resolution` or `aspect_ratio`; the request is billed at the resolution tier matching its total pixel count. - `custom_height` (integer, optional) — Optional. An exact output height in pixels, used together with `custom_width`. See `custom_width` for the accepted range and billing behavior. - `enable_copyright_detection` (boolean, optional) — Optional. Opt this request into post-generation copyright detection. ## Response ### 200 Image(s) generated successfully. - `created` (datetime, required) — The time the request was created. - `data` (list of ImageGenerationObjectV4, required) — A list of ImageObjects that contain the generated image(s). - `response_type` (enum, optional) — Discriminator for the postGenerateDesignV4 oneOf response. Always "url" for this shape. - Allowed values: `url` ## Errors ### 400 Bad Request Error Invalid input provided. - `any` ### 401 Unauthorized Error Not authorized. - `any` ### 422 Unprocessable Entity Error Prompt failed the safety check. - `error` (string, required) ### 429 Too Many Requests Error Too many requests. - `any` ## Types ### ImageGenerationObjectV4 - `prompt` (string, required) — The prompt used for the generation. This may be different from the original prompt. - `resolution` (string, required) — The output resolution of the image, in the format WIDTHxHEIGHT (e.g. 1024x1024). Not limited to the request resolution presets, since some endpoints accept custom output sizes. - `is_image_safe` (boolean, required) — Whether this request passes safety checks. If false, the url field will be empty. - `seed` (integer, required) — Random seed. Set for reproducible generation. - `url` (string, optional, nullable) — The direct link to the image generated. ## Examples **Request** ```json { "prompt": "string" } ``` **Response** ```json { "created": "2024-01-15T09:30:00Z", "data": [ { "prompt": "prompt", "resolution": "1024x1024", "is_image_safe": true, "seed": 12345, "url": "https://ideogram.ai/api/images/ephemeral/xtdZiqPwRxqY1Y7NExFmzB.png?exp=1743867804&sig=e13e12677633f646d8531a153d20e2d3698dca9ee7661ee5ba4f3b64e7ec3f89" }, { "prompt": "prompt", "resolution": "1024x1024", "is_image_safe": true, "seed": 12345, "url": "https://ideogram.ai/api/images/ephemeral/xtdZiqPwRxqY1Y7NExFmzB.png?exp=1743867804&sig=e13e12677633f646d8531a153d20e2d3698dca9ee7661ee5ba4f3b64e7ec3f89" } ], "response_type": "url" } ``` **SDK Code** ```python import requests url = "https://api.ideogram.ai/v1/text-to-image/p-image-ideogram" payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"aspect_ratio\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"custom_height\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"custom_width\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"enable_copyright_detection\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\nstring\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt_upsampling\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"quality\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"resolution\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"seed\"\r\n\r\n\r\n-----011000010111000001101001--\r\n" headers = { "Api-Key": "", "Content-Type": "multipart/form-data; boundary=---011000010111000001101001" } response = requests.post(url, data=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.ideogram.ai/v1/text-to-image/p-image-ideogram'; const form = new FormData(); form.append('aspect_ratio', ''); form.append('custom_height', ''); form.append('custom_width', ''); form.append('enable_copyright_detection', ''); form.append('prompt', 'string'); form.append('prompt_upsampling', ''); form.append('quality', ''); form.append('resolution', ''); form.append('seed', ''); const options = {method: 'POST', headers: {'Api-Key': ''}}; options.body = form; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.ideogram.ai/v1/text-to-image/p-image-ideogram" payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"aspect_ratio\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"custom_height\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"custom_width\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"enable_copyright_detection\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\nstring\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt_upsampling\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"quality\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"resolution\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"seed\"\r\n\r\n\r\n-----011000010111000001101001--\r\n") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Api-Key", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://api.ideogram.ai/v1/text-to-image/p-image-ideogram") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Api-Key"] = '' request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"aspect_ratio\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"custom_height\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"custom_width\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"enable_copyright_detection\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\nstring\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt_upsampling\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"quality\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"resolution\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"seed\"\r\n\r\n\r\n-----011000010111000001101001--\r\n" response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.ideogram.ai/v1/text-to-image/p-image-ideogram") .header("Api-Key", "") .body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"aspect_ratio\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"custom_height\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"custom_width\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"enable_copyright_detection\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\nstring\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt_upsampling\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"quality\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"resolution\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"seed\"\r\n\r\n\r\n-----011000010111000001101001--\r\n") .asString(); ``` ```php request('POST', 'https://api.ideogram.ai/v1/text-to-image/p-image-ideogram', [ 'multipart' => [ [ 'name' => 'prompt', 'contents' => 'string' ] ] 'headers' => [ 'Api-Key' => '', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.ideogram.ai/v1/text-to-image/p-image-ideogram"); var request = new RestRequest(Method.POST); request.AddHeader("Api-Key", ""); request.AddParameter("undefined", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"aspect_ratio\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"custom_height\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"custom_width\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"enable_copyright_detection\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\nstring\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt_upsampling\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"quality\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"resolution\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"seed\"\r\n\r\n\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = ["Api-Key": ""] let parameters = [ [ "name": "aspect_ratio", "value": ], [ "name": "custom_height", "value": ], [ "name": "custom_width", "value": ], [ "name": "enable_copyright_detection", "value": ], [ "name": "prompt", "value": "string" ], [ "name": "prompt_upsampling", "value": ], [ "name": "quality", "value": ], [ "name": "resolution", "value": ], [ "name": "seed", "value": ] ] let boundary = "---011000010111000001101001" var body = "" var error: NSError? = nil for param in parameters { let paramName = param["name"]! body += "--\(boundary)\r\n" body += "Content-Disposition:form-data; name=\"\(paramName)\"" if let filename = param["fileName"] { let contentType = param["content-type"]! let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8) if (error != nil) { print(error as Any) } body += "; filename=\"\(filename)\"\r\n" body += "Content-Type: \(contentType)\r\n\r\n" body += fileContent } else if let paramValue = param["value"] { body += "\r\n\r\n\(paramValue)" } } let request = NSMutableURLRequest(url: NSURL(string: "https://api.ideogram.ai/v1/text-to-image/p-image-ideogram")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```