-
Notifications
You must be signed in to change notification settings - Fork 342
Expose ImageGenerationTool for responses #702
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ShivangiReja
merged 5 commits into
openai:main
from
ShivangiReja:shreja/AddImageGenTool
Sep 24, 2025
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
cc598e8
Expose ImageGenerationTool for responses
ShivangiReja 971cf2e
Merge branch 'main' of https://github.com/openai/openai-dotnet into s…
ShivangiReja 3f439aa
Feedback
ShivangiReja 8ded201
Merge branch 'main' of https://github.com/openai/openai-dotnet into s…
ShivangiReja e4edc8e
Update ImageGenerationToolInputImageMask
ShivangiReja File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/Custom/Responses/Items/ImageGenerationTool/ImageGenerationCallResponseItem.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| namespace OpenAI.Responses; | ||
|
|
||
| // CUSTOM: Renamed. | ||
| [CodeGenType("ImageGenToolCallItemResource")] | ||
| public partial class ImageGenerationCallResponseItem | ||
| { | ||
| // CUSTOM: Made nullable since this is a read-only property. | ||
| [CodeGenMember("Status")] | ||
| public ImageGenerationCallStatus? Status { get; } | ||
| } |
14 changes: 14 additions & 0 deletions
14
src/Custom/Responses/Items/ImageGenerationTool/ImageGenerationCallStatus.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| using System.Diagnostics.CodeAnalysis; | ||
|
|
||
| namespace OpenAI.Responses; | ||
|
|
||
| // CUSTOM: Renamed. | ||
| [Experimental("OPENAI001")] | ||
| [CodeGenType("ImageGenToolCallItemResourceStatus")] | ||
| public enum ImageGenerationCallStatus | ||
| { | ||
| InProgress, | ||
| Completed, | ||
| Generating, | ||
| Failed | ||
| } |
7 changes: 7 additions & 0 deletions
7
src/Custom/Responses/Streaming/StreamingResponseImageGenerationCallCompletedUpdate.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| namespace OpenAI.Responses; | ||
|
|
||
| // CUSTOM: Renamed. | ||
| [CodeGenType("ResponseImageGenCallCompletedEvent")] | ||
| public partial class StreamingResponseImageGenerationCallCompletedUpdate | ||
| { | ||
| } | ||
7 changes: 7 additions & 0 deletions
7
src/Custom/Responses/Streaming/StreamingResponseImageGenerationCallGeneratingUpdate.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| namespace OpenAI.Responses; | ||
|
|
||
| // CUSTOM: Renamed. | ||
| [CodeGenType("ResponseImageGenCallGeneratingEvent")] | ||
| public partial class StreamingResponseImageGenerationCallGeneratingUpdate | ||
| { | ||
| } |
7 changes: 7 additions & 0 deletions
7
src/Custom/Responses/Streaming/StreamingResponseImageGenerationCallInProgressUpdate.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| namespace OpenAI.Responses; | ||
|
|
||
| // CUSTOM: Renamed. | ||
| [CodeGenType("ResponseImageGenCallInProgressEvent")] | ||
| public partial class StreamingResponseImageGenerationCallInProgressUpdate | ||
| { | ||
| } |
7 changes: 7 additions & 0 deletions
7
src/Custom/Responses/Streaming/StreamingResponseImageGenerationCallPartialImageUpdate.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| namespace OpenAI.Responses; | ||
|
|
||
| // CUSTOM: Renamed. | ||
| [CodeGenType("ResponseImageGenCallPartialImageEvent")] | ||
| public partial class StreamingResponseImageGenerationCallPartialImageUpdate | ||
| { | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| using System.Diagnostics.CodeAnalysis; | ||
|
|
||
| namespace OpenAI.Responses; | ||
|
|
||
| // CUSTOM: Renamed. | ||
| [CodeGenType("ImageGenTool")] | ||
| public partial class ImageGenerationTool | ||
| { | ||
| // CUSTOM:Renamed. | ||
| [CodeGenMember("OutputCompression")] | ||
| public int? OutputCompressionFactor { get; set; } | ||
|
|
||
| // CUSTOM: Renamed. | ||
| [CodeGenMember("OutputFormat")] | ||
| public ImageGenerationToolOutputFileFormat? OutputFileFormat { get; set; } | ||
|
|
||
| // CUSTOM: Renamed. | ||
| [CodeGenMember("Moderation")] | ||
| public ImageGenerationToolModerationLevel? ModerationLevel { get; set; } | ||
|
|
||
| // CUSTOM: Renamed. | ||
| [CodeGenMember("InputFidelity")] | ||
| public ImageGenerationToolInputFidelityLevel? InputFidelityLevel { get; set; } | ||
|
|
||
| // CUSTOM:Renamed. | ||
| [CodeGenMember("PartialImages")] | ||
| public int? PartialImageCount { get; set; } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| namespace OpenAI.Responses; | ||
|
|
||
| // CUSTOM: Renamed. | ||
| [CodeGenType("ImageGenToolBackground")] | ||
| public readonly partial struct ImageGenerationToolBackground | ||
| { | ||
| } |
41 changes: 41 additions & 0 deletions
41
src/Custom/Responses/Tools/ImageGenerationToolInputImageMask.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| using System; | ||
|
|
||
| namespace OpenAI.Responses; | ||
|
|
||
| // CUSTOM: Renamed. | ||
| [CodeGenType("ImageGenToolInputImageMask")] | ||
| public partial class ImageGenerationToolInputImageMask | ||
| { | ||
| internal ImageGenerationToolInputImageMask() { } | ||
|
|
||
| public ImageGenerationToolInputImageMask(string fileId) | ||
| { | ||
| Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); | ||
|
|
||
| FileId = fileId; | ||
| } | ||
|
|
||
| public ImageGenerationToolInputImageMask(BinaryData imageBytes, string imageBytesMediaType) | ||
| { | ||
| Argument.AssertNotNull(imageBytes, nameof(imageBytes)); | ||
| Argument.AssertNotNullOrEmpty(imageBytesMediaType, nameof(imageBytesMediaType)); | ||
|
|
||
| string base64EncodedData = Convert.ToBase64String(imageBytes.ToArray()); | ||
| ImageUrl = $"data:{imageBytesMediaType};base64,{base64EncodedData}"; | ||
| } | ||
|
|
||
| public ImageGenerationToolInputImageMask(Uri imageUri) | ||
| { | ||
| Argument.AssertNotNull(imageUri, nameof(imageUri)); | ||
|
|
||
| ImageUrl = imageUri?.AbsoluteUri; | ||
| } | ||
|
|
||
| // CUSTOM: Removed setter. | ||
| [CodeGenMember("ImageUrl")] | ||
| public string ImageUrl { get; } | ||
|
|
||
| // CUSTOM: Removed setter. | ||
| [CodeGenMember("FileId")] | ||
| public string FileId { get; } | ||
| } |
7 changes: 7 additions & 0 deletions
7
src/Custom/Responses/Tools/ImageGenerationToolInputfidelityLevel.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| namespace OpenAI.Responses; | ||
|
|
||
| // CUSTOM: Renamed. | ||
| [CodeGenType("ImageGenToolInputFidelity")] | ||
| public readonly partial struct ImageGenerationToolInputFidelityLevel | ||
| { | ||
| } |
7 changes: 7 additions & 0 deletions
7
src/Custom/Responses/Tools/ImageGenerationToolModerationLevel.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| namespace OpenAI.Responses; | ||
|
|
||
| // CUSTOM: Renamed. | ||
| [CodeGenType("ImageGenToolModeration")] | ||
| public readonly partial struct ImageGenerationToolModerationLevel | ||
| { | ||
| } |
7 changes: 7 additions & 0 deletions
7
src/Custom/Responses/Tools/ImageGenerationToolOutputFileFormat.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| namespace OpenAI.Responses; | ||
|
|
||
| // CUSTOM: Renamed. | ||
| [CodeGenType("ImageGenToolOutputFormat")] | ||
| public readonly partial struct ImageGenerationToolOutputFileFormat | ||
| { | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| namespace OpenAI.Responses; | ||
|
|
||
| // CUSTOM: Renamed. | ||
| [CodeGenType("ImageGenToolQuality")] | ||
| public readonly partial struct ImageGenerationToolQuality | ||
| { | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| using System; | ||
| using System.Diagnostics.CodeAnalysis; | ||
|
|
||
| namespace OpenAI.Responses; | ||
|
|
||
| // CUSTOM: Added custom struct in favor of the generated extensible enum. | ||
| /// <summary> The size of the image that will be generated. </summary> | ||
| [CodeGenType("ImageGenToolSize")] | ||
| [CodeGenSuppress("GeneratedImageSize", typeof(string))] | ||
| // CUSTOM: remove the implicit operator | ||
| [CodeGenSuppress("", typeof(string))] | ||
| public readonly partial struct ImageGenerationToolSize | ||
| { | ||
|
|
||
| /// <summary> Initializes a new instance of <see cref="ImageGenerationToolSize"/>. </summary> | ||
| /// <exception cref="ArgumentNullException"> <paramref name="value"/> is null. </exception> | ||
| internal ImageGenerationToolSize(string value) | ||
| { | ||
| _value = value ?? throw new ArgumentNullException(nameof(value)); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Creates a new instance of <see cref="ImageGenerationToolSize"/>. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// <b>Note:</b> arbitrary dimensions are not supported and a given model will only support a set of predefined | ||
| /// sizes. If supported dimensions are not known, try using one of the static properties like <see cref="W1024xH1024"/>. | ||
| /// </remarks> | ||
| /// <param name="width"> The desired width, in pixels, for an image. </param> | ||
| /// <param name="height"> The desired height, in pixels, for an image. </param> | ||
| public ImageGenerationToolSize(int width, int height) | ||
| { | ||
| _value = $"{width}x{height}"; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// A square image with 1024 pixels of both width and height. | ||
| /// <para> | ||
| /// <b>Supported</b> and <b>default</b> for both <c>dall-e-2</c> and <c>dall-e-3</c> models. | ||
| /// </para> | ||
| /// </summary> | ||
| [CodeGenMember("_1024x1024")] | ||
| public static readonly ImageGenerationToolSize W1024xH1024 = new ImageGenerationToolSize(1024, 1024); | ||
|
|
||
| /// <summary> | ||
| /// An extra tall image, 1024 pixels wide by 1536 pixels high. | ||
| /// <para> | ||
| /// Supported <b>only</b> for the <c>dall-e-3</c> model. | ||
| /// </para> | ||
| /// </summary> | ||
| [CodeGenMember("_1024x1536")] | ||
| public static readonly ImageGenerationToolSize W1024xH1536 = new(1024, 1536); | ||
|
|
||
| /// <summary> | ||
| /// An extra wide image, 1536 pixels wide by 1024 pixels high. | ||
| /// <para> | ||
| /// Supported <b>only</b> for the <c>dall-e-3</c> model. | ||
| /// </para> | ||
| /// </summary> | ||
| [CodeGenMember("_1536x1024")] | ||
| public static readonly ImageGenerationToolSize W1536xH1024 = new(1536, 1024); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.