From 5cb92fde54e7ff0fba004be2521c94a4e1dae758 Mon Sep 17 00:00:00 2001 From: Akhil Madhu Menon Date: Wed, 29 Apr 2026 15:18:42 +0530 Subject: [PATCH 1/6] Update Azure-OpenAI docs to include Image Editing section --- .../llms/azure-openai/azure-openai.mdx | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/integrations/llms/azure-openai/azure-openai.mdx b/integrations/llms/azure-openai/azure-openai.mdx index 6f660e29..7e1b91af 100644 --- a/integrations/llms/azure-openai/azure-openai.mdx +++ b/integrations/llms/azure-openai/azure-openai.mdx @@ -261,6 +261,31 @@ Log view for an image generation request on Azure OpenAI More information on image generation is available in the [API Reference](https://portkey.ai/docs/api-reference/completions-1#create-image). +## Image Editing + +Azure OpenAI image edit requests use `multipart/form-data` because the request can include binary image inputs. For these requests, keep using your Portkey provider or virtual key configuration for routing, but pass the Azure deployment/model name directly in the multipart `model` field. + +For example, use: + +```python +image = portkey.images.edit( + model="gpt-image-2", + prompt="Add snow", + image=[("image.png", image_bytes, "image/png")], + size="1024x1024", +) +``` + +Do not pass the Portkey provider-prefixed alias in the multipart `model` field: + +```python +model="@azure/gpt-image-2" +``` + + +Portkey does not rewrite provider-prefixed model aliases inside multipart payloads. Multipart requests can contain large binary files, so the model value should already match the Azure deployment/model name expected by Azure OpenAI. + + --- ## Azure Government Cloud From 8329642289a9913f58a7c2ad81df40d320d2b1b1 Mon Sep 17 00:00:00 2001 From: Akhil Madhu Menon Date: Wed, 29 Apr 2026 15:32:45 +0530 Subject: [PATCH 2/6] Added runnable version of the code --- integrations/llms/azure-openai/azure-openai.mdx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/integrations/llms/azure-openai/azure-openai.mdx b/integrations/llms/azure-openai/azure-openai.mdx index 7e1b91af..678eebf6 100644 --- a/integrations/llms/azure-openai/azure-openai.mdx +++ b/integrations/llms/azure-openai/azure-openai.mdx @@ -268,12 +268,13 @@ Azure OpenAI image edit requests use `multipart/form-data` because the request c For example, use: ```python -image = portkey.images.edit( - model="gpt-image-2", - prompt="Add snow", - image=[("image.png", image_bytes, "image/png")], - size="1024x1024", -) +with open("image.png", "rb") as image_file: + image = portkey.images.edit( + model="gpt-image-2", + prompt="Add snow", + image=[("image.png", image_file.read(), "image/png")], + size="1024x1024", + ) ``` Do not pass the Portkey provider-prefixed alias in the multipart `model` field: From 4422b20bcfb75196780ea0d4b8519d4777a53e76 Mon Sep 17 00:00:00 2001 From: Akhil Madhu Menon Date: Wed, 29 Apr 2026 15:47:51 +0530 Subject: [PATCH 3/6] Made this change provider agnostic --- .../images/create-image-edit.mdx | 4 +++ .../llms/azure-openai/azure-openai.mdx | 26 ------------------- .../image-generation.mdx | 26 +++++++++++++++++++ 3 files changed, 30 insertions(+), 26 deletions(-) diff --git a/api-reference/inference-api/images/create-image-edit.mdx b/api-reference/inference-api/images/create-image-edit.mdx index af9f0996..d40901b9 100644 --- a/api-reference/inference-api/images/create-image-edit.mdx +++ b/api-reference/inference-api/images/create-image-edit.mdx @@ -2,3 +2,7 @@ title: Create Image Edit openapi: post /images/edits --- + + +Image edit requests use `multipart/form-data` and can include large binary files. Portkey does not rewrite provider-prefixed model aliases inside multipart payloads, so pass the upstream provider's model or deployment name directly in the `model` form field instead of values like `@provider/model-name`. + diff --git a/integrations/llms/azure-openai/azure-openai.mdx b/integrations/llms/azure-openai/azure-openai.mdx index 678eebf6..6f660e29 100644 --- a/integrations/llms/azure-openai/azure-openai.mdx +++ b/integrations/llms/azure-openai/azure-openai.mdx @@ -261,32 +261,6 @@ Log view for an image generation request on Azure OpenAI More information on image generation is available in the [API Reference](https://portkey.ai/docs/api-reference/completions-1#create-image). -## Image Editing - -Azure OpenAI image edit requests use `multipart/form-data` because the request can include binary image inputs. For these requests, keep using your Portkey provider or virtual key configuration for routing, but pass the Azure deployment/model name directly in the multipart `model` field. - -For example, use: - -```python -with open("image.png", "rb") as image_file: - image = portkey.images.edit( - model="gpt-image-2", - prompt="Add snow", - image=[("image.png", image_file.read(), "image/png")], - size="1024x1024", - ) -``` - -Do not pass the Portkey provider-prefixed alias in the multipart `model` field: - -```python -model="@azure/gpt-image-2" -``` - - -Portkey does not rewrite provider-prefixed model aliases inside multipart payloads. Multipart requests can contain large binary files, so the model value should already match the Azure deployment/model name expected by Azure OpenAI. - - --- ## Azure Government Cloud diff --git a/product/ai-gateway/multimodal-capabilities/image-generation.mdx b/product/ai-gateway/multimodal-capabilities/image-generation.mdx index 896c1a54..80953a4e 100644 --- a/product/ai-gateway/multimodal-capabilities/image-generation.mdx +++ b/product/ai-gateway/multimodal-capabilities/image-generation.mdx @@ -125,6 +125,32 @@ curl "https://api.portkey.ai/v1/images/generations" \ +## Image Editing + +Image edit requests to `/v1/images/edits` use `multipart/form-data` because the request can include binary image inputs. For these requests, keep using your Portkey provider or virtual key configuration for routing, but pass the provider-native model or deployment name directly in the multipart `model` field. + +For example, use: + +```python +with open("image.png", "rb") as image_file: + image = portkey.images.edit( + model="gpt-image-2", + prompt="Add snow", + image=[("image.png", image_file.read(), "image/png")], + size="1024x1024", + ) +``` + +Do not pass the Portkey provider-prefixed alias in the multipart `model` field: + +```python +model="@provider/gpt-image-2" +``` + + +Portkey does not rewrite provider-prefixed model aliases inside multipart payloads. Multipart requests can contain large binary files, so the model value should already match the model or deployment name expected by the upstream provider. + + ### API Reference [Create Image](/provider-endpoints/images/create-image) From 0bb946d776be931bc018694bb024a33e28d8b661 Mon Sep 17 00:00:00 2001 From: Akhil Menon Date: Wed, 29 Apr 2026 16:17:37 +0530 Subject: [PATCH 4/6] Update product/ai-gateway/multimodal-capabilities/image-generation.mdx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../ai-gateway/multimodal-capabilities/image-generation.mdx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/product/ai-gateway/multimodal-capabilities/image-generation.mdx b/product/ai-gateway/multimodal-capabilities/image-generation.mdx index 80953a4e..ce220202 100644 --- a/product/ai-gateway/multimodal-capabilities/image-generation.mdx +++ b/product/ai-gateway/multimodal-capabilities/image-generation.mdx @@ -132,6 +132,9 @@ Image edit requests to `/v1/images/edits` use `multipart/form-data` because the For example, use: ```python +from portkey_ai import Portkey + +portkey = Portkey(api_key="PORTKEY_API_KEY", provider="openai") with open("image.png", "rb") as image_file: image = portkey.images.edit( model="gpt-image-2", From e682f9e43120830eb977f6777fc435c6631e4db3 Mon Sep 17 00:00:00 2001 From: Akhil Menon Date: Wed, 29 Apr 2026 16:17:49 +0530 Subject: [PATCH 5/6] Update product/ai-gateway/multimodal-capabilities/image-generation.mdx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../ai-gateway/multimodal-capabilities/image-generation.mdx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/product/ai-gateway/multimodal-capabilities/image-generation.mdx b/product/ai-gateway/multimodal-capabilities/image-generation.mdx index ce220202..cc8dfff7 100644 --- a/product/ai-gateway/multimodal-capabilities/image-generation.mdx +++ b/product/ai-gateway/multimodal-capabilities/image-generation.mdx @@ -156,7 +156,8 @@ Portkey does not rewrite provider-prefixed model aliases inside multipart payloa ### API Reference -[Create Image](/provider-endpoints/images/create-image) +- [Create Image](/provider-endpoints/images/create-image) +- [Create Image Edit](/provider-endpoints/images/create-image-edit) ### OpenAI gpt-image-1 Parameters From 25385df8ed53e685fdecb73efc3412d46e7347c1 Mon Sep 17 00:00:00 2001 From: Akhil Menon Date: Fri, 15 May 2026 17:10:16 +0530 Subject: [PATCH 6/6] Modified the note for image edit in image-generation.mdx and create-image-edit.mdx --- .../images/create-image-edit.mdx | 2 +- .../image-generation.mdx | 27 +------------------ 2 files changed, 2 insertions(+), 27 deletions(-) diff --git a/api-reference/inference-api/images/create-image-edit.mdx b/api-reference/inference-api/images/create-image-edit.mdx index d40901b9..1638736f 100644 --- a/api-reference/inference-api/images/create-image-edit.mdx +++ b/api-reference/inference-api/images/create-image-edit.mdx @@ -4,5 +4,5 @@ openapi: post /images/edits --- -Image edit requests use `multipart/form-data` and can include large binary files. Portkey does not rewrite provider-prefixed model aliases inside multipart payloads, so pass the upstream provider's model or deployment name directly in the `model` form field instead of values like `@provider/model-name`. +Image edit requests use `multipart/form-data` and the provider-prefixed model aliases inside multipart payloads is not supported, so pass the upstream provider's model or deployment name directly in the `model` form field instead of values like `@provider/model-name`. diff --git a/product/ai-gateway/multimodal-capabilities/image-generation.mdx b/product/ai-gateway/multimodal-capabilities/image-generation.mdx index cc8dfff7..1c58fc60 100644 --- a/product/ai-gateway/multimodal-capabilities/image-generation.mdx +++ b/product/ai-gateway/multimodal-capabilities/image-generation.mdx @@ -125,33 +125,8 @@ curl "https://api.portkey.ai/v1/images/generations" \ -## Image Editing - -Image edit requests to `/v1/images/edits` use `multipart/form-data` because the request can include binary image inputs. For these requests, keep using your Portkey provider or virtual key configuration for routing, but pass the provider-native model or deployment name directly in the multipart `model` field. - -For example, use: - -```python -from portkey_ai import Portkey - -portkey = Portkey(api_key="PORTKEY_API_KEY", provider="openai") -with open("image.png", "rb") as image_file: - image = portkey.images.edit( - model="gpt-image-2", - prompt="Add snow", - image=[("image.png", image_file.read(), "image/png")], - size="1024x1024", - ) -``` - -Do not pass the Portkey provider-prefixed alias in the multipart `model` field: - -```python -model="@provider/gpt-image-2" -``` - -Portkey does not rewrite provider-prefixed model aliases inside multipart payloads. Multipart requests can contain large binary files, so the model value should already match the model or deployment name expected by the upstream provider. +For Image Edit requests, provider-prefixed model aliases inside multipart payloads are not supported. The `model` value should match the model or deployment name expected by the upstream provider. ### API Reference