> For the complete documentation index, see [llms.txt](https://docs.cortecs.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cortecs.ai/api/images.md).

# Images

## Generate images

> Generates one or more images from a text prompt using the specified image-generation model.

```json
{"openapi":"3.0.0","info":{"title":"Cortecs Images API","version":"1.0.0"},"servers":[{"url":"https://api.cortecs.ai/v1"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"parameters":{"CostUnit":{"in":"header","name":"x-cortecs-cost-unit","description":"Unit for `usage.cost` and every `usage.cost_details` value. Defaults to CREDITS (1,000,000 credits = €1). EUR and USD return the corresponding currency amounts.","required":false,"schema":{"type":"string","enum":["CREDITS","EUR","USD"],"default":"CREDITS"}}},"schemas":{"ImageGenerationRequest":{"type":"object","required":["model","prompt"],"properties":{"model":{"type":"string","description":"The image-generation model to use."},"prompt":{"type":"string","description":"A text description of the image to generate."},"n":{"type":"integer","minimum":1,"description":"Number of images to generate. Provider support may vary.","default":1},"size":{"type":"string","description":"Requested output dimensions in widthxheight form. Provider support may vary."},"response_format":{"type":"string","enum":["url","b64_json"],"description":"The format of each generated image. Provider support may vary."},"preference":{"type":"string","enum":["speed","cost","balanced"],"description":"The provider preference for handling the request."},"allowed_providers":{"type":"array","items":{"type":"string"},"description":"Providers that may process the request."},"eu_native":{"type":"boolean","description":"Whether to consider only providers based and regulated within the EU."},"provider_order":{"type":"string","description":"Set to `custom` to try `allowed_providers` in the listed order instead of using preference-based routing.","enum":["custom"],"nullable":true},"quantizations":{"type":"array","items":{"type":"string","enum":["int4","int8","fp4","mxfp4","nvfp4","fp6","fp8","mxfp8","fp16","bf16","fp32","unknown"]},"description":"Restricts routing to endpoints whose quantization matches one of the listed values. `fp4` and `fp8` also match their family variants; `unknown` matches endpoints without a specified quantization.","nullable":true},"allow_quantization":{"type":"boolean","description":"Deprecated. Use `quantizations` instead. When `false`, excludes quantized endpoints.","deprecated":true},"allow_zero_data_retention":{"type":"boolean","description":"Whether to use only zero-data-retention providers."},"require_model_presets":{"type":"boolean","description":"Require a project preset alias for all model requests.","nullable":true},"enable_model_fallback":{"type":"boolean","description":"Whether to allow model fallback when the primary model is unavailable."},"fallbacks":{"type":"array","items":{"type":"string"},"description":"An ordered list of fallback model IDs to try if the requested model fails. A nonempty list overrides the default fallback chain."}}},"ImageGenerationResponse":{"type":"object","required":["created","data"],"properties":{"created":{"type":"integer","description":"Unix timestamp when the images were created."},"data":{"type":"array","items":{"type":"object","properties":{"b64_json":{"type":"string","nullable":true,"description":"Base64-encoded image data when requested or returned by the provider."},"url":{"type":"string","nullable":true,"description":"Image URL when returned by the provider. Provider support may vary."},"revised_prompt":{"type":"string","nullable":true,"description":"Provider-revised prompt when available."}}}},"size":{"type":"string","nullable":true,"description":"Output dimensions when reported by the provider."},"usage":{"type":"object","properties":{"input_tokens":{"type":"integer","description":"Prompt input tokens when reported by the provider."},"output_tokens":{"type":"integer","description":"Output tokens when reported by the provider."},"total_tokens":{"type":"integer","description":"Total tokens when reported by the provider."},"cost":{"type":"number","description":"Total image-request cost in the unit selected by `x-cortecs-cost-unit` (credits by default; 1,000,000 credits = €1)."},"cost_details":{"type":"object","description":"Cost breakdown in the unit selected by `x-cortecs-cost-unit`.","properties":{"image_generation_cost":{"type":"number","description":"Generated-image cost in the selected cost unit."},"prompt_cost":{"type":"number","description":"Prompt-input cost in the selected cost unit."}}}}}}}}},"paths":{"/images/generations":{"post":{"summary":"Generate images","description":"Generates one or more images from a text prompt using the specified image-generation model.","parameters":[{"$ref":"#/components/parameters/CostUnit"}],"operationId":"createImageGeneration","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ImageGenerationRequest"}}}},"responses":{"200":{"description":"Generated images.","headers":{},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ImageGenerationResponse"}}}},"500":{"description":"Internal server error."}}}}}}
```

## Edit an image

> Edits an uploaded image using a model tagged Image-Edit.

```json
{"openapi":"3.0.0","info":{"title":"Cortecs Images API","version":"1.0.0"},"servers":[{"url":"https://api.cortecs.ai/v1"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"parameters":{"CostUnit":{"in":"header","name":"x-cortecs-cost-unit","description":"Unit for `usage.cost` and every `usage.cost_details` value. Defaults to CREDITS (1,000,000 credits = €1). EUR and USD return the corresponding currency amounts.","required":false,"schema":{"type":"string","enum":["CREDITS","EUR","USD"],"default":"CREDITS"}}},"schemas":{"ImageEditRequest":{"type":"object","required":["model","prompt","image"],"properties":{"model":{"type":"string","description":"A model tagged Image-Edit."},"prompt":{"type":"string","description":"Instructions for editing the image."},"image":{"type":"string","format":"binary","description":"The source image to edit."},"size":{"type":"string","description":"Requested output dimensions. Provider support may vary."},"preference":{"type":"string","enum":["speed","cost","balanced"],"description":"The provider preference for handling the request."},"allowed_providers":{"type":"array","items":{"type":"string"},"description":"Providers that may process the request."},"eu_native":{"type":"boolean","description":"Whether to consider only providers based and regulated within the EU."},"provider_order":{"type":"string","description":"Set to `custom` to try `allowed_providers` in the listed order instead of using preference-based routing.","enum":["custom"],"nullable":true},"quantizations":{"type":"array","items":{"type":"string","enum":["int4","int8","fp4","mxfp4","nvfp4","fp6","fp8","mxfp8","fp16","bf16","fp32","unknown"]},"description":"Restricts routing to endpoints whose quantization matches one of the listed values. `fp4` and `fp8` also match their family variants; `unknown` matches endpoints without a specified quantization.","nullable":true},"allow_quantization":{"type":"boolean","description":"Deprecated. Use `quantizations` instead. When `false`, excludes quantized endpoints.","deprecated":true},"allow_zero_data_retention":{"type":"boolean","description":"Whether to use only zero-data-retention providers."},"require_model_presets":{"type":"boolean","description":"Require a project preset alias for all model requests.","nullable":true},"enable_model_fallback":{"type":"boolean","description":"Whether to allow model fallback when the primary model is unavailable."},"fallbacks":{"type":"array","items":{"type":"string"},"description":"An ordered list of fallback model IDs to try if the requested model fails. A nonempty list overrides the default fallback chain."}}},"ImageGenerationResponse":{"type":"object","required":["created","data"],"properties":{"created":{"type":"integer","description":"Unix timestamp when the images were created."},"data":{"type":"array","items":{"type":"object","properties":{"b64_json":{"type":"string","nullable":true,"description":"Base64-encoded image data when requested or returned by the provider."},"url":{"type":"string","nullable":true,"description":"Image URL when returned by the provider. Provider support may vary."},"revised_prompt":{"type":"string","nullable":true,"description":"Provider-revised prompt when available."}}}},"size":{"type":"string","nullable":true,"description":"Output dimensions when reported by the provider."},"usage":{"type":"object","properties":{"input_tokens":{"type":"integer","description":"Prompt input tokens when reported by the provider."},"output_tokens":{"type":"integer","description":"Output tokens when reported by the provider."},"total_tokens":{"type":"integer","description":"Total tokens when reported by the provider."},"cost":{"type":"number","description":"Total image-request cost in the unit selected by `x-cortecs-cost-unit` (credits by default; 1,000,000 credits = €1)."},"cost_details":{"type":"object","description":"Cost breakdown in the unit selected by `x-cortecs-cost-unit`.","properties":{"image_generation_cost":{"type":"number","description":"Generated-image cost in the selected cost unit."},"prompt_cost":{"type":"number","description":"Prompt-input cost in the selected cost unit."}}}}}}}}},"paths":{"/images/edits":{"post":{"summary":"Edit an image","description":"Edits an uploaded image using a model tagged Image-Edit.","parameters":[{"$ref":"#/components/parameters/CostUnit"}],"operationId":"createImageEdit","requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/ImageEditRequest"}}}},"responses":{"200":{"description":"Edited image.","headers":{},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ImageGenerationResponse"}}}},"400":{"description":"Invalid request."}}}}}}
```
