From e61ebca9703cc72510970b2f70120ed1508fd260 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 6 May 2026 13:26:30 +0000 Subject: [PATCH] feat: Updated OpenAPI spec --- .../Ideogram.AutoSDKHttpResponse.g.cs | 121 + ...gram.BatchClient.GetMaybeBatchResults.g.cs | 64 +- .../Ideogram.BatchClient.PostBatch.g.cs | 69 +- .../Generated/Ideogram.BatchClient.g.cs | 8 +- ...Ideogram.DatasetsClient.CreateDataset.g.cs | 66 +- .../Ideogram.DatasetsClient.GetDataset.g.cs | 64 +- .../Ideogram.DatasetsClient.ListDatasets.g.cs | 61 +- ...gram.DatasetsClient.TrainDatasetModel.g.cs | 69 +- ...am.DatasetsClient.UploadDatasetAssets.g.cs | 1134 +++++++- .../Generated/Ideogram.DatasetsClient.g.cs | 8 +- ...Ideogram.GenerateClient.PostEditImage.g.cs | 1492 ++++++++++- ...eogram.GenerateClient.PostEditImageV3.g.cs | 837 ------ ...m.GenerateClient.PostGenerateDesignV3.g.cs | 2306 ++++++++++++++++- ...gram.GenerateClient.PostGenerateImage.g.cs | 67 +- ...am.GenerateClient.PostGenerateImageV3.g.cs | 1878 +++++++++++++- ...Client.PostGenerateImageV3Transparent.g.cs | 117 +- ...am.GenerateClient.PostGenerateImageV4.g.cs | 121 +- ...ram.GenerateClient.PostInpaintImageV3.g.cs | 1989 +++++++++++++- ...m.GenerateClient.PostLayerizeDesignV3.g.cs | 1837 ++++++++++++- ...ram.GenerateClient.PostLayerizeTextV3.g.cs | 1170 ++++++++- ...ogram.GenerateClient.PostReframeImage.g.cs | 1317 +++++++++- ...ram.GenerateClient.PostReframeImageV3.g.cs | 1506 ++++++++++- ...deogram.GenerateClient.PostRemixImage.g.cs | 1206 ++++++++- ...ogram.GenerateClient.PostRemixImageV3.g.cs | 2014 +++++++++++++- ...m.GenerateClient.PostRemoveBackground.g.cs | 1769 +++++++++++++ ...enerateClient.PostReplaceBackgroundV3.g.cs | 1582 ++++++++++- .../Ideogram.GenerateClient.PostTryOnV3.g.cs | 1559 ++++++++++- ...ogram.GenerateClient.PostUpscaleImage.g.cs | 1201 ++++++++- ...eogram.GenerateClient.PostV1EditImage.g.cs | 1613 +++++++++++- .../Generated/Ideogram.GenerateClient.g.cs | 8 +- ...ram.IBatchClient.GetMaybeBatchResults.g.cs | 12 + .../Ideogram.IBatchClient.PostBatch.g.cs | 16 +- ...deogram.IDatasetsClient.CreateDataset.g.cs | 13 + .../Ideogram.IDatasetsClient.GetDataset.g.cs | 12 + ...Ideogram.IDatasetsClient.ListDatasets.g.cs | 10 + ...ram.IDatasetsClient.TrainDatasetModel.g.cs | 15 + ...m.IDatasetsClient.UploadDatasetAssets.g.cs | 56 + ...deogram.IGenerateClient.PostEditImage.g.cs | 149 ++ ...ogram.IGenerateClient.PostEditImageV3.g.cs | 116 - ....IGenerateClient.PostGenerateDesignV3.g.cs | 314 +++ ...ram.IGenerateClient.PostGenerateImage.g.cs | 14 + ...m.IGenerateClient.PostGenerateImageV3.g.cs | 229 ++ ...Client.PostGenerateImageV3Transparent.g.cs | 27 + ...m.IGenerateClient.PostGenerateImageV4.g.cs | 28 + ...am.IGenerateClient.PostInpaintImageV3.g.cs | 237 ++ ....IGenerateClient.PostLayerizeDesignV3.g.cs | 191 ++ ...am.IGenerateClient.PostLayerizeTextV3.g.cs | 77 + ...gram.IGenerateClient.PostReframeImage.g.cs | 105 + ...am.IGenerateClient.PostReframeImageV3.g.cs | 137 + ...eogram.IGenerateClient.PostRemixImage.g.cs | 69 + ...gram.IGenerateClient.PostRemixImageV3.g.cs | 261 ++ ....IGenerateClient.PostRemoveBackground.g.cs | 109 + ...enerateClient.PostReplaceBackgroundV3.g.cs | 165 ++ .../Ideogram.IGenerateClient.PostTryOnV3.g.cs | 164 ++ ...gram.IGenerateClient.PostUpscaleImage.g.cs | 64 + ...ogram.IGenerateClient.PostV1EditImage.g.cs | 147 ++ ...rnalTestingClient.PostInternalTesting.g.cs | 118 + ....IManageClient.AddOrganizationMembers.g.cs | 14 + .../Ideogram.IManageClient.CreateApiKey.g.cs | 9 + ...Ideogram.IManageClient.CreateApiKeyV2.g.cs | 11 + ...geClient.DeactivateOrganizationApiKey.g.cs | 11 + ...gram.IManageClient.DeleteSingleApiKey.g.cs | 11 + .../Ideogram.IManageClient.GetApiKeys.g.cs | 9 + .../Ideogram.IManageClient.GetApiKeysV2.g.cs | 11 + ...ent.GetApiOrganizationUserSuggestions.g.cs | 17 + ...Ideogram.IManageClient.GetApiProfiles.g.cs | 9 + ...ManageClient.GetApiStripeSubscription.g.cs | 11 + ...gram.IManageClient.GetApiSubscription.g.cs | 9 + .../Ideogram.IManageClient.GetApiTerms.g.cs | 9 + ....IManageClient.GetOrganizationMembers.g.cs | 11 + .../Ideogram.IManageClient.GetUsageInfo.g.cs | 41 + ...Ideogram.IManageClient.GetUserCredits.g.cs | 15 + ....IManageClient.GetUserSpendCommitInfo.g.cs | 13 + ...ManageClient.ListOrganizationInvoices.g.cs | 11 + ...am.IManageClient.PostAddCreditsForApi.g.cs | 12 + ...ram.IManageClient.PostApiSubscription.g.cs | 12 + .../Ideogram.IManageClient.PostApiTerms.g.cs | 12 + ...nageClient.PromoteOrganizationMembers.g.cs | 14 + ....IManageClient.ReactivateSubscription.g.cs | 9 + ...anageClient.RemoveOrganizationMembers.g.cs | 14 + ...Ideogram.IModelsClient.GetCustomModel.g.cs | 12 + ...eogram.IModelsClient.ListCustomModels.g.cs | 14 + .../Ideogram.IModelsClient.TrainModelV3.g.cs | 13 + ...am.IModelsClient.TrainModelV3Advanced.g.cs | 13 + ...deogram.IPromptClient.PostMagicPrompt.g.cs | 114 + .../Ideogram.IVisionClient.PostDescribe.g.cs | 63 + .../Generated/Ideogram.IdeogramClient.g.cs | 24 +- ...rnalTestingClient.PostInternalTesting.g.cs | 1336 +++++++++- .../Ideogram.InternalTestingClient.g.cs | 8 +- ...sonConverters.TextItemV3TextTransform.g.cs | 53 + ...rters.TextItemV3TextTransformNullable.g.cs | 60 + ...onverters.TextItemV3VerticalAlignment.g.cs | 53 + ...s.TextItemV3VerticalAlignmentNullable.g.cs | 60 + .../Ideogram.JsonSerializerContext.g.cs | 40 +- .../Ideogram.JsonSerializerContextTypes.g.cs | 504 ++-- ...m.ManageClient.AddOrganizationMembers.g.cs | 72 +- .../Ideogram.ManageClient.CreateApiKey.g.cs | 60 +- .../Ideogram.ManageClient.CreateApiKeyV2.g.cs | 67 +- ...geClient.DeactivateOrganizationApiKey.g.cs | 57 +- ...ogram.ManageClient.DeleteSingleApiKey.g.cs | 53 +- .../Ideogram.ManageClient.GetApiKeys.g.cs | 60 +- .../Ideogram.ManageClient.GetApiKeysV2.g.cs | 67 +- ...ent.GetApiOrganizationUserSuggestions.g.cs | 75 +- .../Ideogram.ManageClient.GetApiProfiles.g.cs | 60 +- ...ManageClient.GetApiStripeSubscription.g.cs | 67 +- ...ogram.ManageClient.GetApiSubscription.g.cs | 60 +- .../Ideogram.ManageClient.GetApiTerms.g.cs | 60 +- ...m.ManageClient.GetOrganizationMembers.g.cs | 67 +- .../Ideogram.ManageClient.GetUsageInfo.g.cs | 105 +- .../Ideogram.ManageClient.GetUserCredits.g.cs | 73 +- ...m.ManageClient.GetUserSpendCommitInfo.g.cs | 70 +- ...ManageClient.ListOrganizationInvoices.g.cs | 67 +- ...ram.ManageClient.PostAddCreditsForApi.g.cs | 65 +- ...gram.ManageClient.PostApiSubscription.g.cs | 65 +- .../Ideogram.ManageClient.PostApiTerms.g.cs | 55 +- ...nageClient.PromoteOrganizationMembers.g.cs | 72 +- ...m.ManageClient.ReactivateSubscription.g.cs | 60 +- ...anageClient.RemoveOrganizationMembers.g.cs | 72 +- .../Generated/Ideogram.ManageClient.g.cs | 8 +- .../Ideogram.Models.EditImageRequest.g.cs | 11 + .../Ideogram.Models.EditImageRequestV3.g.cs | 11 + ...eogram.Models.GenerateDesignRequestV3.g.cs | 11 + ...ogram.Models.GenerateGraphicRequestV3.g.cs | 11 + ...deogram.Models.GenerateImageRequestV3.g.cs | 11 + ...deogram.Models.GenerateImageRequestV4.g.cs | 42 +- ...els.GenerateTransparentImageRequestV3.g.cs | 11 + .../Ideogram.Models.ImageLayerV3.g.cs | 2 +- .../Ideogram.Models.ImageRequest.g.cs | 11 + .../Ideogram.Models.InternalBatchRequest.g.cs | 8 +- ...am.Models.LayeredAssetTextShadow.Json.g.cs | 92 + ...deogram.Models.LayeredAssetTextShadow.g.cs | 80 + ...Models.LayeredImageGenerationObjectV3.g.cs | 2 +- ...dels.LayeredImageGenerationResponseV3.g.cs | 2 +- .../Ideogram.Models.ModelVersion.g.cs | 7 + .../Ideogram.Models.RemixImageRequestV3.g.cs | 11 + ...dels.RemoveBackgroundImageObject.Json.g.cs | 92 + ...am.Models.RemoveBackgroundImageObject.g.cs | 60 + ...m.Models.RemoveBackgroundRequest.Json.g.cs | 92 + ...eogram.Models.RemoveBackgroundRequest.g.cs | 58 + ....Models.RemoveBackgroundResponse.Json.g.cs | 92 + ...ogram.Models.RemoveBackgroundResponse.g.cs | 60 + ...ram.Models.ReplaceBackgroundRequestV3.g.cs | 11 + .../Ideogram.Models.ResolutionV4.g.cs | 126 + ...Ideogram.Models.SamplingRequestParams.g.cs | 13 +- .../Ideogram.Models.TextContainerV3.g.cs | 2 +- .../Generated/Ideogram.Models.TextItemV3.g.cs | 56 +- ...eogram.Models.TextItemV3TextTransform.g.cs | 57 + ...am.Models.TextItemV3VerticalAlignment.g.cs | 59 + .../Generated/Ideogram.Models.ToolUsage.g.cs | 2 + .../Ideogram.Models.TryOnRequestV3.g.cs | 11 + ...ram.Models.UpscaleInitialImageRequest.g.cs | 11 + .../Ideogram.Models.V1EditImagesRequest.g.cs | 11 + .../Ideogram.ModelsClient.GetCustomModel.g.cs | 64 +- ...deogram.ModelsClient.ListCustomModels.g.cs | 71 +- .../Ideogram.ModelsClient.TrainModelV3.g.cs | 66 +- ...ram.ModelsClient.TrainModelV3Advanced.g.cs | 66 +- .../Generated/Ideogram.ModelsClient.g.cs | 8 +- .../Generated/Ideogram.OptionsSupport.g.cs | 231 +- ...Ideogram.PromptClient.PostMagicPrompt.g.cs | 1349 +++++++++- .../Generated/Ideogram.PromptClient.g.cs | 8 +- .../Ideogram.VisionClient.PostDescribe.g.cs | 1145 +++++++- .../Generated/Ideogram.VisionClient.g.cs | 8 +- .../Generated/autosdk.generated-examples.json | 56 +- src/libs/Ideogram/openapi.json | 856 +++++- 164 files changed, 37369 insertions(+), 2002 deletions(-) create mode 100644 src/libs/Ideogram/Generated/Ideogram.AutoSDKHttpResponse.g.cs delete mode 100644 src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostEditImageV3.g.cs create mode 100644 src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostRemoveBackground.g.cs delete mode 100644 src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostEditImageV3.g.cs create mode 100644 src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostRemoveBackground.g.cs create mode 100644 src/libs/Ideogram/Generated/Ideogram.JsonConverters.TextItemV3TextTransform.g.cs create mode 100644 src/libs/Ideogram/Generated/Ideogram.JsonConverters.TextItemV3TextTransformNullable.g.cs create mode 100644 src/libs/Ideogram/Generated/Ideogram.JsonConverters.TextItemV3VerticalAlignment.g.cs create mode 100644 src/libs/Ideogram/Generated/Ideogram.JsonConverters.TextItemV3VerticalAlignmentNullable.g.cs create mode 100644 src/libs/Ideogram/Generated/Ideogram.Models.LayeredAssetTextShadow.Json.g.cs create mode 100644 src/libs/Ideogram/Generated/Ideogram.Models.LayeredAssetTextShadow.g.cs create mode 100644 src/libs/Ideogram/Generated/Ideogram.Models.RemoveBackgroundImageObject.Json.g.cs create mode 100644 src/libs/Ideogram/Generated/Ideogram.Models.RemoveBackgroundImageObject.g.cs create mode 100644 src/libs/Ideogram/Generated/Ideogram.Models.RemoveBackgroundRequest.Json.g.cs create mode 100644 src/libs/Ideogram/Generated/Ideogram.Models.RemoveBackgroundRequest.g.cs create mode 100644 src/libs/Ideogram/Generated/Ideogram.Models.RemoveBackgroundResponse.Json.g.cs create mode 100644 src/libs/Ideogram/Generated/Ideogram.Models.RemoveBackgroundResponse.g.cs create mode 100644 src/libs/Ideogram/Generated/Ideogram.Models.TextItemV3TextTransform.g.cs create mode 100644 src/libs/Ideogram/Generated/Ideogram.Models.TextItemV3VerticalAlignment.g.cs diff --git a/src/libs/Ideogram/Generated/Ideogram.AutoSDKHttpResponse.g.cs b/src/libs/Ideogram/Generated/Ideogram.AutoSDKHttpResponse.g.cs new file mode 100644 index 0000000..44faf45 --- /dev/null +++ b/src/libs/Ideogram/Generated/Ideogram.AutoSDKHttpResponse.g.cs @@ -0,0 +1,121 @@ + +#nullable enable + +namespace Ideogram +{ + /// + /// Represents a successful HTTP response with status code and headers. + /// + public partial class AutoSDKHttpResponse + { + /// + /// Initializes a new instance of the class. + /// + public AutoSDKHttpResponse( + global::System.Net.HttpStatusCode statusCode, + global::System.Collections.Generic.Dictionary> headers) + : this( + statusCode: statusCode, + headers: headers, + requestUri: null) + { + } + + /// + /// Initializes a new instance of the class. + /// + public AutoSDKHttpResponse( + global::System.Net.HttpStatusCode statusCode, + global::System.Collections.Generic.Dictionary> headers, + global::System.Uri? requestUri) + { + StatusCode = statusCode; + Headers = headers ?? throw new global::System.ArgumentNullException(nameof(headers)); + RequestUri = requestUri; + } + + /// + /// Gets the HTTP status code. + /// + public global::System.Net.HttpStatusCode StatusCode { get; } + /// + /// Gets the response headers. + /// + public global::System.Collections.Generic.Dictionary> Headers { get; } + /// + /// Gets the final request URI associated with the response. + /// + public global::System.Uri? RequestUri { get; } + + internal static global::System.Collections.Generic.Dictionary> CreateHeaders( + global::System.Net.Http.HttpResponseMessage response) + { + response = response ?? throw new global::System.ArgumentNullException(nameof(response)); + + var headers = global::System.Linq.Enumerable.ToDictionary( + response.Headers, + static header => header.Key, + static header => (global::System.Collections.Generic.IEnumerable)global::System.Linq.Enumerable.ToArray(header.Value), + global::System.StringComparer.OrdinalIgnoreCase); + + if (response.Content?.Headers == null) + { + return headers; + } + + foreach (var header in response.Content.Headers) + { + if (headers.TryGetValue(header.Key, out var existingValues)) + { + headers[header.Key] = global::System.Linq.Enumerable.ToArray( + global::System.Linq.Enumerable.Concat(existingValues, header.Value)); + } + else + { + headers[header.Key] = global::System.Linq.Enumerable.ToArray(header.Value); + } + } + + return headers; + } + } + + /// + /// Represents a successful HTTP response with status code, headers, and body. + /// + public partial class AutoSDKHttpResponse : AutoSDKHttpResponse + { + /// + /// Initializes a new instance of the class. + /// + public AutoSDKHttpResponse( + global::System.Net.HttpStatusCode statusCode, + global::System.Collections.Generic.Dictionary> headers, + T body) + : this( + statusCode: statusCode, + headers: headers, + requestUri: null, + body: body) + { + } + + /// + /// Initializes a new instance of the class. + /// + public AutoSDKHttpResponse( + global::System.Net.HttpStatusCode statusCode, + global::System.Collections.Generic.Dictionary> headers, + global::System.Uri? requestUri, + T body) + : base(statusCode, headers, requestUri) + { + Body = body; + } + + /// + /// Gets the response body. + /// + public T Body { get; } + } +} \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.BatchClient.GetMaybeBatchResults.g.cs b/src/libs/Ideogram/Generated/Ideogram.BatchClient.GetMaybeBatchResults.g.cs index ea616c2..41ae170 100644 --- a/src/libs/Ideogram/Generated/Ideogram.BatchClient.GetMaybeBatchResults.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.BatchClient.GetMaybeBatchResults.g.cs @@ -53,6 +53,27 @@ partial void ProcessGetMaybeBatchResultsResponseContent( string jobId, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetMaybeBatchResultsAsResponseAsync( + jobId: jobId, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Get Batch Magic Prompt Job Results if available.
+ /// Gets the results of a batch magic prompt job if available. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> GetMaybeBatchResultsAsResponseAsync( + string jobId, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( client: HttpClient); @@ -82,6 +103,7 @@ partial void ProcessGetMaybeBatchResultsResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: $"/internal/batch/get-maybe-batch-results/{jobId}", baseUri: HttpClient.BaseAddress); @@ -155,6 +177,8 @@ partial void ProcessGetMaybeBatchResultsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -165,6 +189,11 @@ partial void ProcessGetMaybeBatchResultsResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -182,6 +211,8 @@ partial void ProcessGetMaybeBatchResultsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -191,8 +222,7 @@ partial void ProcessGetMaybeBatchResultsResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -201,6 +231,11 @@ partial void ProcessGetMaybeBatchResultsResponseContent( __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -217,14 +252,15 @@ partial void ProcessGetMaybeBatchResultsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -264,6 +300,8 @@ partial void ProcessGetMaybeBatchResultsResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -284,6 +322,8 @@ partial void ProcessGetMaybeBatchResultsResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -440,9 +480,13 @@ partial void ProcessGetMaybeBatchResultsResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.InternalBatchResultsResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.InternalBatchResultsResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -470,9 +514,13 @@ partial void ProcessGetMaybeBatchResultsResponseContent( #endif ).ConfigureAwait(false); - return - await global::Ideogram.InternalBatchResultsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.InternalBatchResultsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/Ideogram/Generated/Ideogram.BatchClient.PostBatch.g.cs b/src/libs/Ideogram/Generated/Ideogram.BatchClient.PostBatch.g.cs index ec458d4..abe92c9 100644 --- a/src/libs/Ideogram/Generated/Ideogram.BatchClient.PostBatch.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.BatchClient.PostBatch.g.cs @@ -52,6 +52,30 @@ partial void ProcessPostBatchResponseContent( /// public async global::System.Threading.Tasks.Task PostBatchAsync( + global::Ideogram.InternalBatchRequest request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await PostBatchAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Initiate Batch Magic Prompt Evalution
+ /// Runs automated evaluation of multiple LLM models and system prompts for magic prompt generation.
+ /// Generates images using large batches of user prompt inputs. Internal use only (feature flagged). + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> PostBatchAsResponseAsync( + global::Ideogram.InternalBatchRequest request, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) @@ -86,6 +110,7 @@ partial void ProcessPostBatchResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/internal/batch", baseUri: HttpClient.BaseAddress); @@ -165,6 +190,8 @@ partial void ProcessPostBatchResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -175,6 +202,11 @@ partial void ProcessPostBatchResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -192,6 +224,8 @@ partial void ProcessPostBatchResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -201,8 +235,7 @@ partial void ProcessPostBatchResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -211,6 +244,11 @@ partial void ProcessPostBatchResponseContent( __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -227,14 +265,15 @@ partial void ProcessPostBatchResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -274,6 +313,8 @@ partial void ProcessPostBatchResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -294,6 +335,8 @@ partial void ProcessPostBatchResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -450,9 +493,13 @@ partial void ProcessPostBatchResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.InternalBatchResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.InternalBatchResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -480,9 +527,13 @@ partial void ProcessPostBatchResponseContent( #endif ).ConfigureAwait(false); - return - await global::Ideogram.InternalBatchResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.InternalBatchResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -534,7 +585,7 @@ partial void ProcessPostBatchResponseContent( /// Example: MAGIC_PROMPT_NO_TEXT /// /// - /// Example: {"aspect_ratio":"1x1","style_type":"GENERAL","magic_prompt_version":"V_0","seed":12345,"negative_prompt":"brush strokes, painting","magic_prompt_option":"ON","model":"V_2_TURBO","resolution":"1280x800","num_images":1,"color_palette":{"name":"PASTEL"}} + /// Example: {"magic_prompt_system_prompt_config_id":"magic_prompt_system_prompt_config_id","aspect_ratio":"1x1","style_type":"GENERAL","magic_prompt_version":"V_0","seed":12345,"negative_prompt":"brush strokes, painting","magic_prompt_option":"ON","model":"V_2_TURBO","resolution":"1280x800","num_images":1,"color_palette":{"name":"PASTEL"}} /// /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with diff --git a/src/libs/Ideogram/Generated/Ideogram.BatchClient.g.cs b/src/libs/Ideogram/Generated/Ideogram.BatchClient.g.cs index 4b1418e..ccb2505 100644 --- a/src/libs/Ideogram/Generated/Ideogram.BatchClient.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.BatchClient.g.cs @@ -72,10 +72,10 @@ public BatchClient( /// Client-wide request defaults such as headers, query parameters, retries, and timeout. /// Dispose the HttpClient when the instance is disposed. True by default. public BatchClient( - global::System.Net.Http.HttpClient? httpClient = null, - global::System.Uri? baseUri = null, - global::System.Collections.Generic.List? authorizations = null, - global::Ideogram.AutoSDKClientOptions? options = null, + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Ideogram.AutoSDKClientOptions? options, bool disposeHttpClient = true) { diff --git a/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.CreateDataset.g.cs b/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.CreateDataset.g.cs index 6fefee1..d7bf7c9 100644 --- a/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.CreateDataset.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.CreateDataset.g.cs @@ -51,6 +51,29 @@ partial void ProcessCreateDatasetResponseContent( /// public async global::System.Threading.Tasks.Task CreateDatasetAsync( + global::Ideogram.CreateDatasetRequest request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await CreateDatasetAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Create a new dataset
+ /// Creates a new dataset + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> CreateDatasetAsResponseAsync( + global::Ideogram.CreateDatasetRequest request, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) @@ -85,6 +108,7 @@ partial void ProcessCreateDatasetResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/datasets", baseUri: HttpClient.BaseAddress); @@ -164,6 +188,8 @@ partial void ProcessCreateDatasetResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -174,6 +200,11 @@ partial void ProcessCreateDatasetResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -191,6 +222,8 @@ partial void ProcessCreateDatasetResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -200,8 +233,7 @@ partial void ProcessCreateDatasetResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -210,6 +242,11 @@ partial void ProcessCreateDatasetResponseContent( __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -226,14 +263,15 @@ partial void ProcessCreateDatasetResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -273,6 +311,8 @@ partial void ProcessCreateDatasetResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -293,6 +333,8 @@ partial void ProcessCreateDatasetResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -383,9 +425,13 @@ partial void ProcessCreateDatasetResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.Dataset.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.Dataset.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -413,9 +459,13 @@ partial void ProcessCreateDatasetResponseContent( #endif ).ConfigureAwait(false); - return - await global::Ideogram.Dataset.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.Dataset.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.GetDataset.g.cs b/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.GetDataset.g.cs index d7d49fa..b787d45 100644 --- a/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.GetDataset.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.GetDataset.g.cs @@ -53,6 +53,27 @@ partial void ProcessGetDatasetResponseContent( string datasetId, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetDatasetAsResponseAsync( + datasetId: datasetId, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Get a dataset
+ /// Returns a dataset by ID, including the total number of files and a list of each file's name and size in bytes. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> GetDatasetAsResponseAsync( + string datasetId, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( client: HttpClient); @@ -82,6 +103,7 @@ partial void ProcessGetDatasetResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: $"/datasets/{datasetId}", baseUri: HttpClient.BaseAddress); @@ -155,6 +177,8 @@ partial void ProcessGetDatasetResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -165,6 +189,11 @@ partial void ProcessGetDatasetResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -182,6 +211,8 @@ partial void ProcessGetDatasetResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -191,8 +222,7 @@ partial void ProcessGetDatasetResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -201,6 +231,11 @@ partial void ProcessGetDatasetResponseContent( __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -217,14 +252,15 @@ partial void ProcessGetDatasetResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -264,6 +300,8 @@ partial void ProcessGetDatasetResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -284,6 +322,8 @@ partial void ProcessGetDatasetResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -374,9 +414,13 @@ partial void ProcessGetDatasetResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.GetDatasetResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.GetDatasetResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -404,9 +448,13 @@ partial void ProcessGetDatasetResponseContent( #endif ).ConfigureAwait(false); - return - await global::Ideogram.GetDatasetResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.GetDatasetResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.ListDatasets.g.cs b/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.ListDatasets.g.cs index 437f498..7ef711d 100644 --- a/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.ListDatasets.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.ListDatasets.g.cs @@ -49,6 +49,24 @@ partial void ProcessListDatasetsResponseContent( public async global::System.Threading.Tasks.Task ListDatasetsAsync( global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await ListDatasetsAsResponseAsync( + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// List datasets
+ /// Lists all datasets for the authenticated user + ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> ListDatasetsAsResponseAsync( + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( client: HttpClient); @@ -77,6 +95,7 @@ partial void ProcessListDatasetsResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/datasets", baseUri: HttpClient.BaseAddress); @@ -149,6 +168,8 @@ partial void ProcessListDatasetsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -159,6 +180,11 @@ partial void ProcessListDatasetsResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -176,6 +202,8 @@ partial void ProcessListDatasetsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -185,8 +213,7 @@ partial void ProcessListDatasetsResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -195,6 +222,11 @@ partial void ProcessListDatasetsResponseContent( __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -211,14 +243,15 @@ partial void ProcessListDatasetsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -258,6 +291,8 @@ partial void ProcessListDatasetsResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -278,6 +313,8 @@ partial void ProcessListDatasetsResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -335,9 +372,13 @@ partial void ProcessListDatasetsResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.ListDatasetsResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.ListDatasetsResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -365,9 +406,13 @@ partial void ProcessListDatasetsResponseContent( #endif ).ConfigureAwait(false); - return - await global::Ideogram.ListDatasetsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.ListDatasetsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.TrainDatasetModel.g.cs b/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.TrainDatasetModel.g.cs index da3f5e2..56a1c78 100644 --- a/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.TrainDatasetModel.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.TrainDatasetModel.g.cs @@ -55,6 +55,32 @@ partial void ProcessTrainDatasetModelResponseContent( public async global::System.Threading.Tasks.Task TrainDatasetModelAsync( string datasetId, + global::Ideogram.TrainDatasetModelRequest request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await TrainDatasetModelAsResponseAsync( + datasetId: datasetId, + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Train a model from a dataset
+ /// Start training a custom model from a dataset. The dataset must contain at least 15 images and a maximum of 100 images. Returns the model ID and training status. + ///
+ /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> TrainDatasetModelAsResponseAsync( + string datasetId, + global::Ideogram.TrainDatasetModelRequest request, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) @@ -90,6 +116,7 @@ partial void ProcessTrainDatasetModelResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: $"/datasets/{datasetId}/train_model", baseUri: HttpClient.BaseAddress); @@ -170,6 +197,8 @@ partial void ProcessTrainDatasetModelResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -180,6 +209,11 @@ partial void ProcessTrainDatasetModelResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -197,6 +231,8 @@ partial void ProcessTrainDatasetModelResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -206,8 +242,7 @@ partial void ProcessTrainDatasetModelResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -216,6 +251,11 @@ partial void ProcessTrainDatasetModelResponseContent( __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -232,14 +272,15 @@ partial void ProcessTrainDatasetModelResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -279,6 +320,8 @@ partial void ProcessTrainDatasetModelResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -299,6 +342,8 @@ partial void ProcessTrainDatasetModelResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -422,9 +467,13 @@ partial void ProcessTrainDatasetModelResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.TrainDatasetModelResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.TrainDatasetModelResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -452,9 +501,13 @@ partial void ProcessTrainDatasetModelResponseContent( #endif ).ConfigureAwait(false); - return - await global::Ideogram.TrainDatasetModelResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.TrainDatasetModelResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.UploadDatasetAssets.g.cs b/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.UploadDatasetAssets.g.cs index 80697f7..f132230 100644 --- a/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.UploadDatasetAssets.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.UploadDatasetAssets.g.cs @@ -55,6 +55,32 @@ partial void ProcessUploadDatasetAssetsResponseContent( public async global::System.Threading.Tasks.Task UploadDatasetAssetsAsync( string datasetId, + global::Ideogram.UploadDatasetAssetsRequest request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await UploadDatasetAssetsAsResponseAsync( + datasetId: datasetId, + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Upload assets to a dataset
+ /// Upload image assets to a dataset for model training. Accepts individual images (JPEG, PNG, WebP), optional .txt caption sidecar files, and/or ZIP archives containing images and captions. A dataset can contain up to 100 images. + ///
+ /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> UploadDatasetAssetsAsResponseAsync( + string datasetId, + global::Ideogram.UploadDatasetAssetsRequest request, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) @@ -86,10 +112,11 @@ partial void ProcessUploadDatasetAssetsResponseContent( var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: $"/datasets/{datasetId}/upload_assets", baseUri: HttpClient.BaseAddress); @@ -122,10 +149,12 @@ partial void ProcessUploadDatasetAssetsResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(datasetId ?? string.Empty), name: "\"dataset_id\""); + for (var __iFiles = 0; __iFiles < request.Files.Count; __iFiles++) { var __contentFiles = new global::System.Net.Http.ByteArrayContent(request.Files[__iFiles]); @@ -139,7 +168,9 @@ partial void ProcessUploadDatasetAssetsResponseContent( __contentFiles.Headers.ContentDisposition.FileNameStar = null; } } + __httpRequest.Content = __httpRequestContent; + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -182,6 +213,8 @@ partial void ProcessUploadDatasetAssetsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -192,6 +225,11 @@ partial void ProcessUploadDatasetAssetsResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -209,6 +247,8 @@ partial void ProcessUploadDatasetAssetsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -218,8 +258,7 @@ partial void ProcessUploadDatasetAssetsResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -228,6 +267,11 @@ partial void ProcessUploadDatasetAssetsResponseContent( __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -244,14 +288,15 @@ partial void ProcessUploadDatasetAssetsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -291,6 +336,8 @@ partial void ProcessUploadDatasetAssetsResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -311,6 +358,8 @@ partial void ProcessUploadDatasetAssetsResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -434,9 +483,13 @@ partial void ProcessUploadDatasetAssetsResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.UploadDatasetAssetsResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.UploadDatasetAssetsResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -464,9 +517,13 @@ partial void ProcessUploadDatasetAssetsResponseContent( #endif ).ConfigureAwait(false); - return - await global::Ideogram.UploadDatasetAssetsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.UploadDatasetAssetsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -532,5 +589,1064 @@ partial void ProcessUploadDatasetAssetsResponseContent( requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } + + /// + /// Upload assets to a dataset
+ /// Upload image assets to a dataset for model training. Accepts individual images (JPEG, PNG, WebP), optional .txt caption sidecar files, and/or ZIP archives containing images and captions. A dataset can contain up to 100 images. + ///
+ /// + /// + /// Image files (JPEG, PNG, WebP), .txt caption sidecar files, and/or ZIP archives containing images and captions. Caption .txt files are matched to images by filename stem (e.g. sunset.txt provides the caption for sunset.jpg). Captions are optional! + /// + /// + /// Optional file names to use for the multipart 'files' file parts. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task UploadDatasetAssetsAsync( + string datasetId, + global::System.Collections.Generic.IReadOnlyList files, + global::System.Collections.Generic.IReadOnlyList? filesFileNames = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + files = files ?? throw new global::System.ArgumentNullException(nameof(files)); + var request = new global::Ideogram.UploadDatasetAssetsRequest + { + Files = new global::System.Collections.Generic.List(), + }; + PrepareArguments( + client: HttpClient); + PrepareUploadDatasetAssetsArguments( + httpClient: HttpClient, + datasetId: ref datasetId, + request: request); + + + var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_UploadDatasetAssetsSecurityRequirements, + operationName: "UploadDatasetAssetsAsync"); + + using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Ideogram.PathBuilder( + path: $"/datasets/{datasetId}/upload_assets", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(datasetId ?? string.Empty), + name: "\"dataset_id\""); + + for (var __iFiles = 0; __iFiles < files.Count; __iFiles++) + { + var __fileNameFiles = filesFileNames != null && + __iFiles < filesFileNames.Count && + filesFileNames[__iFiles] != null + ? filesFileNames[__iFiles] + : $"file{__iFiles}.bin"; + var __contentFiles = new global::System.Net.Http.StreamContent(files[__iFiles]); + __contentFiles.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + __fileNameFiles is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(__fileNameFiles) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentFiles, + name: "\"files\"", + fileName: $"\"{__fileNameFiles}\""); + if (__contentFiles.Headers.ContentDisposition != null) + { + __contentFiles.Headers.ContentDisposition.FileNameStar = null; + } + } + + __httpRequest.Content = __httpRequestContent; + + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareUploadDatasetAssetsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + datasetId: datasetId!, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UploadDatasetAssets", + methodName: "UploadDatasetAssetsAsync", + pathTemplate: "$\"/datasets/{datasetId}/upload_assets\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UploadDatasetAssets", + methodName: "UploadDatasetAssetsAsync", + pathTemplate: "$\"/datasets/{datasetId}/upload_assets\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UploadDatasetAssets", + methodName: "UploadDatasetAssetsAsync", + pathTemplate: "$\"/datasets/{datasetId}/upload_assets\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUploadDatasetAssetsResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UploadDatasetAssets", + methodName: "UploadDatasetAssetsAsync", + pathTemplate: "$\"/datasets/{datasetId}/upload_assets\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UploadDatasetAssets", + methodName: "UploadDatasetAssetsAsync", + pathTemplate: "$\"/datasets/{datasetId}/upload_assets\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessUploadDatasetAssetsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Ideogram.UploadDatasetAssetsResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Ideogram.UploadDatasetAssetsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Upload assets to a dataset
+ /// Upload image assets to a dataset for model training. Accepts individual images (JPEG, PNG, WebP), optional .txt caption sidecar files, and/or ZIP archives containing images and captions. A dataset can contain up to 100 images. + ///
+ /// + /// + /// Image files (JPEG, PNG, WebP), .txt caption sidecar files, and/or ZIP archives containing images and captions. Caption .txt files are matched to images by filename stem (e.g. sunset.txt provides the caption for sunset.jpg). Captions are optional! + /// + /// + /// Optional file names to use for the multipart 'files' file parts. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> UploadDatasetAssetsAsResponseAsync( + string datasetId, + global::System.Collections.Generic.IReadOnlyList files, + global::System.Collections.Generic.IReadOnlyList? filesFileNames = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + files = files ?? throw new global::System.ArgumentNullException(nameof(files)); + var request = new global::Ideogram.UploadDatasetAssetsRequest + { + Files = new global::System.Collections.Generic.List(), + }; + PrepareArguments( + client: HttpClient); + PrepareUploadDatasetAssetsArguments( + httpClient: HttpClient, + datasetId: ref datasetId, + request: request); + + + var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_UploadDatasetAssetsSecurityRequirements, + operationName: "UploadDatasetAssetsAsync"); + + using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Ideogram.PathBuilder( + path: $"/datasets/{datasetId}/upload_assets", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(datasetId ?? string.Empty), + name: "\"dataset_id\""); + + for (var __iFiles = 0; __iFiles < files.Count; __iFiles++) + { + var __fileNameFiles = filesFileNames != null && + __iFiles < filesFileNames.Count && + filesFileNames[__iFiles] != null + ? filesFileNames[__iFiles] + : $"file{__iFiles}.bin"; + var __contentFiles = new global::System.Net.Http.StreamContent(files[__iFiles]); + __contentFiles.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + __fileNameFiles is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(__fileNameFiles) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentFiles, + name: "\"files\"", + fileName: $"\"{__fileNameFiles}\""); + if (__contentFiles.Headers.ContentDisposition != null) + { + __contentFiles.Headers.ContentDisposition.FileNameStar = null; + } + } + + __httpRequest.Content = __httpRequestContent; + + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareUploadDatasetAssetsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + datasetId: datasetId!, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UploadDatasetAssets", + methodName: "UploadDatasetAssetsAsync", + pathTemplate: "$\"/datasets/{datasetId}/upload_assets\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UploadDatasetAssets", + methodName: "UploadDatasetAssetsAsync", + pathTemplate: "$\"/datasets/{datasetId}/upload_assets\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UploadDatasetAssets", + methodName: "UploadDatasetAssetsAsync", + pathTemplate: "$\"/datasets/{datasetId}/upload_assets\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessUploadDatasetAssetsResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UploadDatasetAssets", + methodName: "UploadDatasetAssetsAsync", + pathTemplate: "$\"/datasets/{datasetId}/upload_assets\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UploadDatasetAssets", + methodName: "UploadDatasetAssetsAsync", + pathTemplate: "$\"/datasets/{datasetId}/upload_assets\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessUploadDatasetAssetsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Ideogram.UploadDatasetAssetsResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + var __value = await global::Ideogram.UploadDatasetAssetsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.g.cs b/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.g.cs index feacc49..0053fcf 100644 --- a/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.g.cs @@ -73,10 +73,10 @@ public DatasetsClient( /// Client-wide request defaults such as headers, query parameters, retries, and timeout. /// Dispose the HttpClient when the instance is disposed. True by default. public DatasetsClient( - global::System.Net.Http.HttpClient? httpClient = null, - global::System.Uri? baseUri = null, - global::System.Collections.Generic.List? authorizations = null, - global::Ideogram.AutoSDKClientOptions? options = null, + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Ideogram.AutoSDKClientOptions? options, bool disposeHttpClient = true) { diff --git a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostEditImage.g.cs b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostEditImage.g.cs index f934dff..621e55e 100644 --- a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostEditImage.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostEditImage.g.cs @@ -54,6 +54,32 @@ partial void ProcessPostEditImageResponseContent( /// public async global::System.Threading.Tasks.Task PostEditImageAsync( + global::Ideogram.EditImageRequest request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await PostEditImageAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Edit (legacy)
+ /// Edit a given image synchronously using the provided mask. The mask indicates which part of the image
+ /// should be edited, while the prompt and chosen style type can further guide the edit.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> PostEditImageAsResponseAsync( + global::Ideogram.EditImageRequest request, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) @@ -84,10 +110,11 @@ partial void ProcessPostEditImageResponseContent( var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/edit", baseUri: HttpClient.BaseAddress); @@ -120,6 +147,7 @@ partial void ProcessPostEditImageResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); var __contentImageFile = new global::System.Net.Http.ByteArrayContent(request.ImageFile ?? global::System.Array.Empty()); __contentImageFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( @@ -158,6 +186,7 @@ request.ImageFilename is null { __contentImageFile.Headers.ContentDisposition.FileNameStar = null; } + var __contentMask = new global::System.Net.Http.ByteArrayContent(request.Mask ?? global::System.Array.Empty()); __contentMask.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( request.Maskname is null @@ -195,41 +224,58 @@ request.Maskname is null { __contentMask.Headers.ContentDisposition.FileNameStar = null; } + __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), name: "\"prompt\""); + __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.Model.ToValueString()), name: "\"model\""); + if (request.MagicPromptOption != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.MagicPromptOption).HasValue ? (request.MagicPromptOption).GetValueOrDefault().ToValueString() : string.Empty), name: "\"magic_prompt_option\""); - } + + } + if (request.MagicPromptSystemPromptConfigId != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty), + name: "\"magic_prompt_system_prompt_config_id\""); + + } if (request.NumImages != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), name: "\"num_images\""); - } + + } if (request.Seed != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), name: "\"seed\""); - } + + } if (request.StyleType != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.StyleType).HasValue ? (request.StyleType).GetValueOrDefault().ToValueString() : string.Empty), name: "\"style_type\""); + } + __httpRequest.Content = __httpRequestContent; + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -271,6 +317,8 @@ request.Maskname is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -281,6 +329,11 @@ request.Maskname is null } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -298,6 +351,8 @@ request.Maskname is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -307,8 +362,7 @@ request.Maskname is null __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -317,6 +371,11 @@ request.Maskname is null __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -333,14 +392,15 @@ request.Maskname is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -380,6 +440,8 @@ request.Maskname is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -400,6 +462,8 @@ request.Maskname is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -561,9 +625,13 @@ request.Maskname is null { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -591,9 +659,13 @@ request.Maskname is null #endif ).ConfigureAwait(false); - return - await global::Ideogram.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -663,6 +735,9 @@ request.Maskname is null /// Determine if MagicPrompt should be used in generating the request or not.
/// Example: ON /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// /// /// The number of images to generate.
/// Default Value: 1 @@ -686,6 +761,7 @@ request.Maskname is null string prompt, global::Ideogram.ModelEnum model = global::Ideogram.ModelEnum.V2, global::Ideogram.MagicPromptOption? magicPromptOption = default, + string? magicPromptSystemPromptConfigId = default, int? numImages = default, int? seed = default, global::Ideogram.StyleType? styleType = default, @@ -701,6 +777,7 @@ request.Maskname is null Prompt = prompt, Model = model, MagicPromptOption = magicPromptOption, + MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId, NumImages = numImages, Seed = seed, StyleType = styleType, @@ -711,5 +788,1396 @@ request.Maskname is null requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } + + /// + /// Edit (legacy)
+ /// Edit a given image synchronously using the provided mask. The mask indicates which part of the image
+ /// should be edited, while the prompt and chosen style type can further guide the edit.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// A black and white image of the same size as the image being edited (max size 10MB). Black regions in the mask should match up with the regions of the image that you would like to edit; only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// A black and white image of the same size as the image being edited (max size 10MB). Black regions in the mask should match up with the regions of the image that you would like to edit; only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The prompt used to describe the edited result.
+ /// Example: A serene tropical beach scene. Dominating the foreground are tall palm trees with lush green leaves, standing tall against a backdrop of a sandy beach. The beach leads to the azure waters of the sea, which gently kisses the shoreline. In the distance, there is an island or landmass with a silhouette of what appears to be a lighthouse or tower. The sky above is painted with fluffy white clouds, some of which are tinged with hues of pink and orange, suggesting either a sunrise or sunset. + /// + /// + /// The model used to generate an image or edit one. /generate and /remix supports all model types, however, /edit is only supported for V_2 and V_2_TURBO.
+ /// Default Value: V_2
+ /// Example: V_2_TURBO + /// + /// + /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON + /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + /// + /// The number of images to generate.
+ /// Default Value: 1 + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// + /// The style type to generate with; this is only applicable for models V_2 and above and should not be specified for model versions V_1.
+ /// Example: REALISTIC + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task PostEditImageAsync( + global::System.IO.Stream imageFile, + string imageFilename, + global::System.IO.Stream mask, + string maskname, + string prompt, + global::Ideogram.ModelEnum model = global::Ideogram.ModelEnum.V2, + global::Ideogram.MagicPromptOption? magicPromptOption = default, + string? magicPromptSystemPromptConfigId = default, + int? numImages = default, + int? seed = default, + global::Ideogram.StyleType? styleType = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + imageFile = imageFile ?? throw new global::System.ArgumentNullException(nameof(imageFile)); + mask = mask ?? throw new global::System.ArgumentNullException(nameof(mask)); + var request = new global::Ideogram.EditImageRequest + { + ImageFile = global::System.Array.Empty(), + ImageFilename = imageFilename, + Mask = global::System.Array.Empty(), + Maskname = maskname, + Prompt = prompt, + Model = model, + MagicPromptOption = magicPromptOption, + MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId, + NumImages = numImages, + Seed = seed, + StyleType = styleType, + }; + PrepareArguments( + client: HttpClient); + PreparePostEditImageArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_PostEditImageSecurityRequirements, + operationName: "PostEditImageAsync"); + + using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Ideogram.PathBuilder( + path: "/edit", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + var __contentImageFile = new global::System.Net.Http.StreamContent(imageFile); + __contentImageFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.ImageFilename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.ImageFilename) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentImageFile, + name: "\"image_file\"", + fileName: request.ImageFilename != null ? $"\"{request.ImageFilename}\"" : string.Empty); + if (__contentImageFile.Headers.ContentDisposition != null) + { + __contentImageFile.Headers.ContentDisposition.FileNameStar = null; + } + + var __contentMask = new global::System.Net.Http.StreamContent(mask); + __contentMask.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.Maskname is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.Maskname) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentMask, + name: "\"mask\"", + fileName: request.Maskname != null ? $"\"{request.Maskname}\"" : string.Empty); + if (__contentMask.Headers.ContentDisposition != null) + { + __contentMask.Headers.ContentDisposition.FileNameStar = null; + } + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), + name: "\"prompt\""); + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Model.ToValueString()), + name: "\"model\""); + + if (request.MagicPromptOption != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.MagicPromptOption).HasValue ? (request.MagicPromptOption).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"magic_prompt_option\""); + + } + if (request.MagicPromptSystemPromptConfigId != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty), + name: "\"magic_prompt_system_prompt_config_id\""); + + } + if (request.NumImages != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"num_images\""); + + } + if (request.Seed != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"seed\""); + + } + if (request.StyleType != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.StyleType).HasValue ? (request.StyleType).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"style_type\""); + + } + + __httpRequest.Content = __httpRequestContent; + + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PreparePostEditImageRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostEditImage", + methodName: "PostEditImageAsync", + pathTemplate: "\"/edit\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostEditImage", + methodName: "PostEditImageAsync", + pathTemplate: "\"/edit\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostEditImage", + methodName: "PostEditImageAsync", + pathTemplate: "\"/edit\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessPostEditImageResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostEditImage", + methodName: "PostEditImageAsync", + pathTemplate: "\"/edit\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostEditImage", + methodName: "PostEditImageAsync", + pathTemplate: "\"/edit\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Prompt or Initial Image failed the safety checks. + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Ideogram.GenerateImageSafetyError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessPostEditImageResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Ideogram.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Ideogram.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Edit (legacy)
+ /// Edit a given image synchronously using the provided mask. The mask indicates which part of the image
+ /// should be edited, while the prompt and chosen style type can further guide the edit.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// A black and white image of the same size as the image being edited (max size 10MB). Black regions in the mask should match up with the regions of the image that you would like to edit; only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// A black and white image of the same size as the image being edited (max size 10MB). Black regions in the mask should match up with the regions of the image that you would like to edit; only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The prompt used to describe the edited result.
+ /// Example: A serene tropical beach scene. Dominating the foreground are tall palm trees with lush green leaves, standing tall against a backdrop of a sandy beach. The beach leads to the azure waters of the sea, which gently kisses the shoreline. In the distance, there is an island or landmass with a silhouette of what appears to be a lighthouse or tower. The sky above is painted with fluffy white clouds, some of which are tinged with hues of pink and orange, suggesting either a sunrise or sunset. + /// + /// + /// The model used to generate an image or edit one. /generate and /remix supports all model types, however, /edit is only supported for V_2 and V_2_TURBO.
+ /// Default Value: V_2
+ /// Example: V_2_TURBO + /// + /// + /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON + /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + /// + /// The number of images to generate.
+ /// Default Value: 1 + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// + /// The style type to generate with; this is only applicable for models V_2 and above and should not be specified for model versions V_1.
+ /// Example: REALISTIC + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> PostEditImageAsResponseAsync( + global::System.IO.Stream imageFile, + string imageFilename, + global::System.IO.Stream mask, + string maskname, + string prompt, + global::Ideogram.ModelEnum model = global::Ideogram.ModelEnum.V2, + global::Ideogram.MagicPromptOption? magicPromptOption = default, + string? magicPromptSystemPromptConfigId = default, + int? numImages = default, + int? seed = default, + global::Ideogram.StyleType? styleType = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + imageFile = imageFile ?? throw new global::System.ArgumentNullException(nameof(imageFile)); + mask = mask ?? throw new global::System.ArgumentNullException(nameof(mask)); + var request = new global::Ideogram.EditImageRequest + { + ImageFile = global::System.Array.Empty(), + ImageFilename = imageFilename, + Mask = global::System.Array.Empty(), + Maskname = maskname, + Prompt = prompt, + Model = model, + MagicPromptOption = magicPromptOption, + MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId, + NumImages = numImages, + Seed = seed, + StyleType = styleType, + }; + PrepareArguments( + client: HttpClient); + PreparePostEditImageArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_PostEditImageSecurityRequirements, + operationName: "PostEditImageAsync"); + + using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Ideogram.PathBuilder( + path: "/edit", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + var __contentImageFile = new global::System.Net.Http.StreamContent(imageFile); + __contentImageFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.ImageFilename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.ImageFilename) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentImageFile, + name: "\"image_file\"", + fileName: request.ImageFilename != null ? $"\"{request.ImageFilename}\"" : string.Empty); + if (__contentImageFile.Headers.ContentDisposition != null) + { + __contentImageFile.Headers.ContentDisposition.FileNameStar = null; + } + + var __contentMask = new global::System.Net.Http.StreamContent(mask); + __contentMask.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.Maskname is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.Maskname) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentMask, + name: "\"mask\"", + fileName: request.Maskname != null ? $"\"{request.Maskname}\"" : string.Empty); + if (__contentMask.Headers.ContentDisposition != null) + { + __contentMask.Headers.ContentDisposition.FileNameStar = null; + } + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), + name: "\"prompt\""); + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Model.ToValueString()), + name: "\"model\""); + + if (request.MagicPromptOption != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.MagicPromptOption).HasValue ? (request.MagicPromptOption).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"magic_prompt_option\""); + + } + if (request.MagicPromptSystemPromptConfigId != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty), + name: "\"magic_prompt_system_prompt_config_id\""); + + } + if (request.NumImages != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"num_images\""); + + } + if (request.Seed != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"seed\""); + + } + if (request.StyleType != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.StyleType).HasValue ? (request.StyleType).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"style_type\""); + + } + + __httpRequest.Content = __httpRequestContent; + + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PreparePostEditImageRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostEditImage", + methodName: "PostEditImageAsync", + pathTemplate: "\"/edit\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostEditImage", + methodName: "PostEditImageAsync", + pathTemplate: "\"/edit\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostEditImage", + methodName: "PostEditImageAsync", + pathTemplate: "\"/edit\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessPostEditImageResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostEditImage", + methodName: "PostEditImageAsync", + pathTemplate: "\"/edit\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostEditImage", + methodName: "PostEditImageAsync", + pathTemplate: "\"/edit\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Prompt or Initial Image failed the safety checks. + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Ideogram.GenerateImageSafetyError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessPostEditImageResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Ideogram.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + var __value = await global::Ideogram.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostEditImageV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostEditImageV3.g.cs deleted file mode 100644 index 517be4f..0000000 --- a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostEditImageV3.g.cs +++ /dev/null @@ -1,837 +0,0 @@ - -#nullable enable - -namespace Ideogram -{ - public partial class GenerateClient - { - - - private static readonly global::Ideogram.EndPointSecurityRequirement s_PostEditImageV3SecurityRequirement0 = - new global::Ideogram.EndPointSecurityRequirement - { - Authorizations = new global::Ideogram.EndPointAuthorizationRequirement[] - { new global::Ideogram.EndPointAuthorizationRequirement - { - Type = "Http", - SchemeId = "HttpBearer", - Location = "Header", - Name = "Bearer", - FriendlyName = "Bearer", - }, - }, - }; - private static readonly global::Ideogram.EndPointSecurityRequirement[] s_PostEditImageV3SecurityRequirements = - new global::Ideogram.EndPointSecurityRequirement[] - { s_PostEditImageV3SecurityRequirement0, - }; - partial void PreparePostEditImageV3Arguments( - global::System.Net.Http.HttpClient httpClient, - global::Ideogram.EditImageRequestV3 request); - partial void PreparePostEditImageV3Request( - global::System.Net.Http.HttpClient httpClient, - global::System.Net.Http.HttpRequestMessage httpRequestMessage, - global::Ideogram.EditImageRequestV3 request); - partial void ProcessPostEditImageV3Response( - global::System.Net.Http.HttpClient httpClient, - global::System.Net.Http.HttpResponseMessage httpResponseMessage); - - partial void ProcessPostEditImageV3ResponseContent( - global::System.Net.Http.HttpClient httpClient, - global::System.Net.Http.HttpResponseMessage httpResponseMessage, - ref string content); - - /// - /// Edit with Ideogram 3.0
- /// Edit a given image synchronously using the provided mask with Ideogram 3.0. The mask indicates which part of the image
- /// should be edited, while the prompt and chosen style can further guide the edit.
- /// Supported image formats include JPEG, PNG, and WebP.
- /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. - ///
- /// - /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. - /// The token to cancel the operation with - /// - public async global::System.Threading.Tasks.Task PostEditImageV3Async( - - global::Ideogram.EditImageRequestV3 request, - global::Ideogram.AutoSDKRequestOptions? requestOptions = default, - global::System.Threading.CancellationToken cancellationToken = default) - { - request = request ?? throw new global::System.ArgumentNullException(nameof(request)); - - PrepareArguments( - client: HttpClient); - PreparePostEditImageV3Arguments( - httpClient: HttpClient, - request: request); - - - var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations( - availableAuthorizations: Authorizations, - securityRequirements: s_PostEditImageV3SecurityRequirements, - operationName: "PostEditImageV3Async"); - - using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( - clientOptions: Options, - requestOptions: requestOptions, - cancellationToken: cancellationToken); - var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; - var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString( - clientOptions: Options, - requestOptions: requestOptions, - fallbackValue: ReadResponseAsString); - var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( - clientOptions: Options, - requestOptions: requestOptions, - supportsRetry: true); - - global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() - { - var __pathBuilder = new global::Ideogram.PathBuilder( - path: "/v1/ideogram-v3/edit", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( - path: __path, - clientParameters: Options.QueryParameters, - requestParameters: requestOptions?.QueryParameters); - var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Post, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); -#if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; -#endif - - foreach (var __authorization in __authorizations) - { - if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2" || - __authorization.Type == "OpenIdConnect") - { - __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( - scheme: __authorization.Name, - parameter: __authorization.Value); - } - else if (__authorization.Type == "ApiKey" && - __authorization.Location == "Header") - { - __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } - } - var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); - var __contentImage = new global::System.Net.Http.ByteArrayContent(request.Image ?? global::System.Array.Empty()); - __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( - request.Imagename is null - ? "application/octet-stream" - : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch - { - ".aac" => "audio/aac", - ".flac" => "audio/flac", - ".gif" => "image/gif", - ".jpeg" => "image/jpeg", - ".jpg" => "image/jpeg", - ".json" => "application/json", - ".m4a" => "audio/mp4", - ".mp3" => "audio/mpeg", - ".mp4" => "video/mp4", - ".mpeg" => "audio/mpeg", - ".mpga" => "audio/mpeg", - ".oga" => "audio/ogg", - ".ogg" => "audio/ogg", - ".opus" => "audio/ogg", - ".pdf" => "application/pdf", - ".png" => "image/png", - ".txt" => "text/plain", - ".wav" => "audio/wav", - ".weba" => "audio/webm", - ".webm" => "video/webm", - ".webp" => "image/webp", - _ => "application/octet-stream", - }); - __httpRequestContent.Add( - content: __contentImage, - name: "\"image\"", - fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty); - if (__contentImage.Headers.ContentDisposition != null) - { - __contentImage.Headers.ContentDisposition.FileNameStar = null; - } - var __contentMask = new global::System.Net.Http.ByteArrayContent(request.Mask ?? global::System.Array.Empty()); - __contentMask.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( - request.Maskname is null - ? "application/octet-stream" - : (global::System.IO.Path.GetExtension(request.Maskname) ?? string.Empty).ToLowerInvariant() switch - { - ".aac" => "audio/aac", - ".flac" => "audio/flac", - ".gif" => "image/gif", - ".jpeg" => "image/jpeg", - ".jpg" => "image/jpeg", - ".json" => "application/json", - ".m4a" => "audio/mp4", - ".mp3" => "audio/mpeg", - ".mp4" => "video/mp4", - ".mpeg" => "audio/mpeg", - ".mpga" => "audio/mpeg", - ".oga" => "audio/ogg", - ".ogg" => "audio/ogg", - ".opus" => "audio/ogg", - ".pdf" => "application/pdf", - ".png" => "image/png", - ".txt" => "text/plain", - ".wav" => "audio/wav", - ".weba" => "audio/webm", - ".webm" => "video/webm", - ".webp" => "image/webp", - _ => "application/octet-stream", - }); - __httpRequestContent.Add( - content: __contentMask, - name: "\"mask\"", - fileName: request.Maskname != null ? $"\"{request.Maskname}\"" : string.Empty); - if (__contentMask.Headers.ContentDisposition != null) - { - __contentMask.Headers.ContentDisposition.FileNameStar = null; - } - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), - name: "\"prompt\""); - if (request.MagicPrompt != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent((request.MagicPrompt).HasValue ? (request.MagicPrompt).GetValueOrDefault().ToValueString() : string.Empty), - name: "\"magic_prompt\""); - } - if (request.NumImages != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), - name: "\"num_images\""); - } - if (request.Seed != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), - name: "\"seed\""); - } - if (request.RenderingSpeed != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty), - name: "\"rendering_speed\""); - } - if (request.StyleType != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent((request.StyleType).HasValue ? (request.StyleType).GetValueOrDefault().ToValueString() : string.Empty), - name: "\"style_type\""); - } - if (request.StylePreset != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent((request.StylePreset).HasValue ? (request.StylePreset).GetValueOrDefault().ToValueString() : string.Empty), - name: "\"style_preset\""); - } - if (request.CustomModelUri != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.CustomModelUri ?? string.Empty), - name: "\"custom_model_uri\""); - } - if (request.ColorPalette != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.ColorPalette.ToString() ?? string.Empty), - name: "\"color_palette\""); - } - if (request.StyleCodes != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.StyleCodes, x => x))}]"), - name: "\"style_codes\""); - } - if (request.StyleReferenceImages != default) - { - - for (var __iStyleReferenceImages = 0; __iStyleReferenceImages < request.StyleReferenceImages.Count; __iStyleReferenceImages++) - { - var __contentStyleReferenceImages = new global::System.Net.Http.ByteArrayContent(request.StyleReferenceImages[__iStyleReferenceImages]); - __contentStyleReferenceImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue("application/octet-stream"); - __httpRequestContent.Add( - content: __contentStyleReferenceImages, - name: "\"style_reference_images\"", - fileName: $"\"file{__iStyleReferenceImages}.bin\""); - if (__contentStyleReferenceImages.Headers.ContentDisposition != null) - { - __contentStyleReferenceImages.Headers.ContentDisposition.FileNameStar = null; - } - } - } - if (request.CharacterReferenceImages != default) - { - - for (var __iCharacterReferenceImages = 0; __iCharacterReferenceImages < request.CharacterReferenceImages.Count; __iCharacterReferenceImages++) - { - var __contentCharacterReferenceImages = new global::System.Net.Http.ByteArrayContent(request.CharacterReferenceImages[__iCharacterReferenceImages]); - __contentCharacterReferenceImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue("application/octet-stream"); - __httpRequestContent.Add( - content: __contentCharacterReferenceImages, - name: "\"character_reference_images\"", - fileName: $"\"file{__iCharacterReferenceImages}.bin\""); - if (__contentCharacterReferenceImages.Headers.ContentDisposition != null) - { - __contentCharacterReferenceImages.Headers.ContentDisposition.FileNameStar = null; - } - } - } - if (request.CharacterReferenceImagesMask != default) - { - - for (var __iCharacterReferenceImagesMask = 0; __iCharacterReferenceImagesMask < request.CharacterReferenceImagesMask.Count; __iCharacterReferenceImagesMask++) - { - var __contentCharacterReferenceImagesMask = new global::System.Net.Http.ByteArrayContent(request.CharacterReferenceImagesMask[__iCharacterReferenceImagesMask]); - __contentCharacterReferenceImagesMask.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue("application/octet-stream"); - __httpRequestContent.Add( - content: __contentCharacterReferenceImagesMask, - name: "\"character_reference_images_mask\"", - fileName: $"\"file{__iCharacterReferenceImagesMask}.bin\""); - if (__contentCharacterReferenceImagesMask.Headers.ContentDisposition != null) - { - __contentCharacterReferenceImagesMask.Headers.ContentDisposition.FileNameStar = null; - } - } - } - __httpRequest.Content = __httpRequestContent; - global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( - request: __httpRequest, - clientHeaders: Options.Headers, - requestHeaders: requestOptions?.Headers); - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PreparePostEditImageV3Request( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); - - return __httpRequest; - } - - global::System.Net.Http.HttpRequestMessage? __httpRequest = null; - global::System.Net.Http.HttpResponseMessage? __response = null; - var __attemptNumber = 0; - try - { - for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) - { - __attemptNumber = __attempt; - __httpRequest = __CreateHttpRequest(); - await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( - clientOptions: Options, - context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "PostEditImageV3", - methodName: "PostEditImageV3Async", - pathTemplate: "\"/v1/ideogram-v3/edit\"", - httpMethod: "POST", - baseUri: BaseUri, - request: __httpRequest!, - response: null, - exception: null, - clientOptions: Options, - requestOptions: requestOptions, - attempt: __attempt, - maxAttempts: __maxAttempts, - willRetry: false, - cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); - try - { - __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); - } - catch (global::System.Net.Http.HttpRequestException __exception) - { - var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; - await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "PostEditImageV3", - methodName: "PostEditImageV3Async", - pathTemplate: "\"/v1/ideogram-v3/edit\"", - httpMethod: "POST", - baseUri: BaseUri, - request: __httpRequest!, - response: null, - exception: __exception, - clientOptions: Options, - requestOptions: requestOptions, - attempt: __attempt, - maxAttempts: __maxAttempts, - willRetry: __willRetry, - cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); - if (!__willRetry) - { - throw; - } - - __httpRequest.Dispose(); - __httpRequest = null; - await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, - cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); - continue; - } - - if (__response != null && - __attempt < __maxAttempts && - global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) - { - await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "PostEditImageV3", - methodName: "PostEditImageV3Async", - pathTemplate: "\"/v1/ideogram-v3/edit\"", - httpMethod: "POST", - baseUri: BaseUri, - request: __httpRequest!, - response: __response, - exception: null, - clientOptions: Options, - requestOptions: requestOptions, - attempt: __attempt, - maxAttempts: __maxAttempts, - willRetry: true, - cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); - __response.Dispose(); - __response = null; - __httpRequest.Dispose(); - __httpRequest = null; - await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, - cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); - continue; - } - - break; - } - - if (__response == null) - { - throw new global::System.InvalidOperationException("No response received."); - } - - using (__response) - { - - ProcessResponse( - client: HttpClient, - response: __response); - ProcessPostEditImageV3Response( - httpClient: HttpClient, - httpResponseMessage: __response); - if (__response.IsSuccessStatusCode) - { - await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( - clientOptions: Options, - context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "PostEditImageV3", - methodName: "PostEditImageV3Async", - pathTemplate: "\"/v1/ideogram-v3/edit\"", - httpMethod: "POST", - baseUri: BaseUri, - request: __httpRequest!, - response: __response, - exception: null, - clientOptions: Options, - requestOptions: requestOptions, - attempt: __attemptNumber, - maxAttempts: __maxAttempts, - willRetry: false, - cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); - } - else - { - await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "PostEditImageV3", - methodName: "PostEditImageV3Async", - pathTemplate: "\"/v1/ideogram-v3/edit\"", - httpMethod: "POST", - baseUri: BaseUri, - request: __httpRequest!, - response: __response, - exception: null, - clientOptions: Options, - requestOptions: requestOptions, - attempt: __attemptNumber, - maxAttempts: __maxAttempts, - willRetry: false, - cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); - } - // - if ((int)__response.StatusCode == 400) - { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - try - { - if (__effectiveReadResponseAsString) - { - __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - } - else - { - __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - } - } - catch (global::System.Exception __ex) - { - __exception_400 = __ex; - } - - throw new global::Ideogram.ApiException( - message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_400, - statusCode: __response.StatusCode) - { - ResponseBody = __content_400, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // - if ((int)__response.StatusCode == 401) - { - string? __content_401 = null; - global::System.Exception? __exception_401 = null; - try - { - if (__effectiveReadResponseAsString) - { - __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - } - else - { - __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - } - } - catch (global::System.Exception __ex) - { - __exception_401 = __ex; - } - - throw new global::Ideogram.ApiException( - message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_401, - statusCode: __response.StatusCode) - { - ResponseBody = __content_401, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Prompt or Initial Image failed the safety checks. - if ((int)__response.StatusCode == 422) - { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Ideogram.GenerateImageSafetyError? __value_422 = null; - try - { - if (__effectiveReadResponseAsString) - { - __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); - } - else - { - __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - - __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_422 = __ex; - } - - throw new global::Ideogram.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) - { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // - if ((int)__response.StatusCode == 429) - { - string? __content_429 = null; - global::System.Exception? __exception_429 = null; - try - { - if (__effectiveReadResponseAsString) - { - __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - } - else - { - __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - } - } - catch (global::System.Exception __ex) - { - __exception_429 = __ex; - } - - throw new global::Ideogram.ApiException( - message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_429, - statusCode: __response.StatusCode) - { - ResponseBody = __content_429, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (__effectiveReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( - #if NET5_0_OR_GREATER - __effectiveCancellationToken - #endif - ).ConfigureAwait(false); - - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessPostEditImageV3ResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try - { - __response.EnsureSuccessStatusCode(); - - return - global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); - } - catch (global::System.Exception __ex) - { - throw new global::Ideogram.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( - #if NET5_0_OR_GREATER - __effectiveCancellationToken - #endif - ).ConfigureAwait(false); - - return - await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( - #if NET5_0_OR_GREATER - __effectiveCancellationToken - #endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } - - throw new global::Ideogram.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - } - - } - } - finally - { - __httpRequest?.Dispose(); - } - } - /// - /// Edit with Ideogram 3.0
- /// Edit a given image synchronously using the provided mask with Ideogram 3.0. The mask indicates which part of the image
- /// should be edited, while the prompt and chosen style can further guide the edit.
- /// Supported image formats include JPEG, PNG, and WebP.
- /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. - ///
- /// - /// The image being edited (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. - /// - /// - /// The image being edited (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. - /// - /// - /// A black and white image of the same size as the image being edited (max size 10MB). Black regions in the mask should match up with the regions of the image that you would like to edit; only JPEG, WebP and PNG formats are supported at this time. - /// - /// - /// A black and white image of the same size as the image being edited (max size 10MB). Black regions in the mask should match up with the regions of the image that you would like to edit; only JPEG, WebP and PNG formats are supported at this time. - /// - /// - /// The prompt used to describe the edited result.
- /// Example: A photo of a cat. - /// - /// - /// Determine if MagicPrompt should be used in generating the request or not.
- /// Example: ON - /// - /// - /// The number of images to generate.
- /// Default Value: 1 - /// - /// - /// Random seed. Set for reproducible generation.
- /// Example: 12345 - /// - /// - /// The rendering speed to use.
- /// Default Value: DEFAULT - /// - /// - /// The style type to generate with.
- /// Default Value: GENERAL
- /// Example: GENERAL - /// - /// - /// A predefined style preset that applies a specific artistic style to the generated image.
- /// Example: BRIGHT_ART - /// - /// - /// A custom model URI in the format model/<model_name>/version/<version_name>.
- /// When provided, the model version and style will be resolved from this URI, and style_type is not required.
- /// Example: model/my-custom-model/version/1 - /// - /// - /// A color palette for generation, must EITHER be specified via one of the presets (name) or explicitly via hexadecimal representations of the color with optional weights (members). Not supported by V_1, V_1_TURBO, V_2A and V_2A_TURBO models. - /// - /// - /// A list of 8 character hexadecimal codes representing the style of the image. Cannot be used in conjunction with style_reference_images or style_type.
- /// Example: [AAFF5733, 0133FF57, DE3357FF] - /// - /// - /// A set of images to use as style references (maximum total size 10MB across all style references). The images should be in JPEG, PNG or WebP format. - /// - /// - /// Generations with character reference are subject to the character reference pricing. A set of images to use as character references (maximum total size 10MB across all character references), currently only supports 1 character reference image. The images should be in JPEG, PNG or WebP format. - /// - /// - /// Optional masks for character reference images. When provided, must match the number of character_reference_images. Each mask should be a grayscale image of the same dimensions as the corresponding character reference image. The images should be in JPEG, PNG or WebP format. - /// - /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. - /// The token to cancel the operation with - /// - public async global::System.Threading.Tasks.Task PostEditImageV3Async( - byte[] image, - string imagename, - byte[] mask, - string maskname, - string prompt, - global::Ideogram.MagicPromptOption? magicPrompt = default, - int? numImages = default, - int? seed = default, - global::Ideogram.RenderingSpeed? renderingSpeed = default, - global::Ideogram.StyleTypeV3? styleType = default, - global::Ideogram.StylePresetV3? stylePreset = default, - string? customModelUri = default, - global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette = default, - global::System.Collections.Generic.IList? styleCodes = default, - global::System.Collections.Generic.IList? styleReferenceImages = default, - global::System.Collections.Generic.IList? characterReferenceImages = default, - global::System.Collections.Generic.IList? characterReferenceImagesMask = default, - global::Ideogram.AutoSDKRequestOptions? requestOptions = default, - global::System.Threading.CancellationToken cancellationToken = default) - { - var __request = new global::Ideogram.EditImageRequestV3 - { - Image = image, - Imagename = imagename, - Mask = mask, - Maskname = maskname, - Prompt = prompt, - MagicPrompt = magicPrompt, - NumImages = numImages, - Seed = seed, - RenderingSpeed = renderingSpeed, - StyleType = styleType, - StylePreset = stylePreset, - CustomModelUri = customModelUri, - ColorPalette = colorPalette, - StyleCodes = styleCodes, - StyleReferenceImages = styleReferenceImages, - CharacterReferenceImages = characterReferenceImages, - CharacterReferenceImagesMask = characterReferenceImagesMask, - }; - - return await PostEditImageV3Async( - request: __request, - requestOptions: requestOptions, - cancellationToken: cancellationToken).ConfigureAwait(false); - } - } -} \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateDesignV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateDesignV3.g.cs index 90a5817..eafea41 100644 --- a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateDesignV3.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateDesignV3.g.cs @@ -53,6 +53,31 @@ partial void ProcessPostGenerateDesignV3ResponseContent( /// public async global::System.Threading.Tasks.Task PostGenerateDesignV3Async( + global::Ideogram.GenerateDesignRequestV3 request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await PostGenerateDesignV3AsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Generate a design from a text prompt with text detection and correction
+ /// Generates a design synchronously from a text prompt using the Ideogram 3.0 model, then detects and corrects text layers within the generated image.
+ /// The response includes the generated image URL along with detected text layers (with font, size, color, position) and image asset layers.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> PostGenerateDesignV3AsResponseAsync( + global::Ideogram.GenerateDesignRequestV3 request, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) @@ -83,10 +108,11 @@ partial void ProcessPostGenerateDesignV3ResponseContent( var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/v1/ideogram-v3/generate-design", baseUri: HttpClient.BaseAddress); @@ -119,94 +145,116 @@ partial void ProcessPostGenerateDesignV3ResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), name: "\"prompt\""); + if (request.Seed != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), name: "\"seed\""); - } + + } if (request.Resolution != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.Resolution).HasValue ? (request.Resolution).GetValueOrDefault().ToValueString() : string.Empty), name: "\"resolution\""); - } + + } if (request.AspectRatio != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.AspectRatio).HasValue ? (request.AspectRatio).GetValueOrDefault().ToValueString() : string.Empty), name: "\"aspect_ratio\""); - } + + } if (request.RenderingSpeed != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty), name: "\"rendering_speed\""); - } + + } if (request.MagicPrompt != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.MagicPrompt).HasValue ? (request.MagicPrompt).GetValueOrDefault().ToValueString() : string.Empty), name: "\"magic_prompt\""); - } + + } + if (request.MagicPromptSystemPromptConfigId != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty), + name: "\"magic_prompt_system_prompt_config_id\""); + + } if (request.NegativePrompt != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.NegativePrompt ?? string.Empty), name: "\"negative_prompt\""); - } + + } if (request.NumImages != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), name: "\"num_images\""); - } + + } if (request.ColorPalette != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.ColorPalette.ToString() ?? string.Empty), name: "\"color_palette\""); - } + + } if (request.StyleCodes != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.StyleCodes, x => x))}]"), name: "\"style_codes\""); - } + + } if (request.StyleType != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.StyleType).HasValue ? (request.StyleType).GetValueOrDefault().ToValueString() : string.Empty), name: "\"style_type\""); - } + + } if (request.StylePreset != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.StylePreset).HasValue ? (request.StylePreset).GetValueOrDefault().ToValueString() : string.Empty), name: "\"style_preset\""); - } + + } if (request.CustomModelUri != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.CustomModelUri ?? string.Empty), name: "\"custom_model_uri\""); - } + + } if (request.FontFileH1 != default) { @@ -247,14 +295,16 @@ request.FontFileH1name is null { __contentFontFileH1.Headers.ContentDisposition.FileNameStar = null; } - } + + } if (request.FontNameH1 != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.FontNameH1 ?? string.Empty), name: "\"font_name_h1\""); - } + + } if (request.FontFileH2 != default) { @@ -295,14 +345,16 @@ request.FontFileH2name is null { __contentFontFileH2.Headers.ContentDisposition.FileNameStar = null; } - } + + } if (request.FontNameH2 != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.FontNameH2 ?? string.Empty), name: "\"font_name_h2\""); - } + + } if (request.FontFileBody != default) { @@ -343,14 +395,16 @@ request.FontFileBodyname is null { __contentFontFileBody.Headers.ContentDisposition.FileNameStar = null; } - } + + } if (request.FontNameBody != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.FontNameBody ?? string.Empty), name: "\"font_name_body\""); - } + + } if (request.FontFileSmall != default) { @@ -391,14 +445,16 @@ request.FontFileSmallname is null { __contentFontFileSmall.Headers.ContentDisposition.FileNameStar = null; } - } + + } if (request.FontNameSmall != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.FontNameSmall ?? string.Empty), name: "\"font_name_small\""); - } + + } if (request.StyleReferenceImages != default) { @@ -415,7 +471,8 @@ request.FontFileSmallname is null __contentStyleReferenceImages.Headers.ContentDisposition.FileNameStar = null; } } - } + + } if (request.ReferenceAssetImages != default) { @@ -432,8 +489,11 @@ request.FontFileSmallname is null __contentReferenceAssetImages.Headers.ContentDisposition.FileNameStar = null; } } + } + __httpRequest.Content = __httpRequestContent; + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -475,6 +535,8 @@ request.FontFileSmallname is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -485,6 +547,11 @@ request.FontFileSmallname is null } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -502,6 +569,8 @@ request.FontFileSmallname is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -511,8 +580,7 @@ request.FontFileSmallname is null __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -521,6 +589,11 @@ request.FontFileSmallname is null __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -537,14 +610,15 @@ request.FontFileSmallname is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -584,6 +658,8 @@ request.FontFileSmallname is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -604,6 +680,8 @@ request.FontFileSmallname is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -765,9 +843,13 @@ request.FontFileSmallname is null { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.LayeredImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.LayeredImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -795,9 +877,13 @@ request.FontFileSmallname is null #endif ).ConfigureAwait(false); - return - await global::Ideogram.LayeredImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.LayeredImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -864,6 +950,9 @@ request.FontFileSmallname is null /// Determine if MagicPrompt should be used in generating the request or not.
/// Example: ON /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// /// /// Description of what to exclude from a design. Descriptions in the prompt take precedence
/// to descriptions in the negative prompt.
@@ -947,6 +1036,7 @@ request.FontFileSmallname is null global::Ideogram.AspectRatioV3? aspectRatio = default, global::Ideogram.RenderingSpeed? renderingSpeed = default, global::Ideogram.MagicPromptOption? magicPrompt = default, + string? magicPromptSystemPromptConfigId = default, string? negativePrompt = default, int? numImages = default, global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette = default, @@ -979,6 +1069,7 @@ request.FontFileSmallname is null AspectRatio = aspectRatio, RenderingSpeed = renderingSpeed, MagicPrompt = magicPrompt, + MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId, NegativePrompt = negativePrompt, NumImages = numImages, ColorPalette = colorPalette, @@ -1007,5 +1098,2160 @@ request.FontFileSmallname is null requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } + + /// + /// Generate a design from a text prompt with text detection and correction
+ /// Generates a design synchronously from a text prompt using the Ideogram 3.0 model, then detects and corrects text layers within the generated image.
+ /// The response includes the generated image URL along with detected text layers (with font, size, color, position) and image asset layers.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// The prompt to use to generate the design.
+ /// Example: A birthday card saying 'Happy Birthday' + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// + /// The resolutions supported for Ideogram 3.0.
+ /// Example: 1280x800 + /// + /// + /// The aspect ratio to use for image generation, which determines the image's resolution. Cannot be used in conjunction with resolution. Defaults to 1x1. + /// + /// + /// The rendering speed to use.
+ /// Default Value: DEFAULT + /// + /// + /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON + /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + /// + /// Description of what to exclude from a design. Descriptions in the prompt take precedence
+ /// to descriptions in the negative prompt.
+ /// Example: brush strokes, painting + /// + /// + /// Number of designs to generate.
+ /// Default Value: 1 + /// + /// + /// A color palette for generation, must EITHER be specified via one of the presets (name) or explicitly via hexadecimal representations of the color with optional weights (members). Not supported by V_1, V_1_TURBO, V_2A and V_2A_TURBO models. + /// + /// + /// A list of 8 character hexadecimal codes representing the style of the image. Cannot be used in conjunction with style_reference_images or style_type.
+ /// Example: [AAFF5733, 0133FF57, DE3357FF] + /// + /// + /// The style type to generate with.
+ /// Default Value: GENERAL
+ /// Example: GENERAL + /// + /// + /// A predefined style preset that applies a specific artistic style to the generated image.
+ /// Example: BRIGHT_ART + /// + /// + /// A custom model URI in the format model/<model_name>/version/<version_name>.
+ /// When provided, the model version and style will be resolved from this URI, and style_type is not required.
+ /// Example: model/my-custom-model/version/1 + /// + /// + /// Custom font file for H1 (heading) text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_h1. + /// + /// + /// Custom font file for H1 (heading) text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_h1. + /// + /// + /// Font name from the available font library for H1 text. Ignored if font_file_h1 is provided.
+ /// Example: Ubuntu-Bold.ttf + /// + /// + /// Custom font file for H2 (subheading) text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_h2. + /// + /// + /// Custom font file for H2 (subheading) text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_h2. + /// + /// + /// Font name from the available font library for H2 text. Ignored if font_file_h2 is provided. + /// + /// + /// Custom font file for body text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_body. + /// + /// + /// Custom font file for body text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_body. + /// + /// + /// Font name from the available font library for body text. Ignored if font_file_body is provided. + /// + /// + /// Custom font file for small/caption text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_small. + /// + /// + /// Custom font file for small/caption text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_small. + /// + /// + /// Font name from the available font library for small text. Ignored if font_file_small is provided. + /// + /// + /// A set of images to use as style references (maximum total size 10MB across all style references). The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'style_reference_images' file parts. + /// + /// + /// A set of asset images (e.g., logos, icons) to use as references for detection and replacement (maximum 10 images). The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'reference_asset_images' file parts. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task PostGenerateDesignV3Async( + string prompt, + int? seed = default, + global::Ideogram.ResolutionV3? resolution = default, + global::Ideogram.AspectRatioV3? aspectRatio = default, + global::Ideogram.RenderingSpeed? renderingSpeed = default, + global::Ideogram.MagicPromptOption? magicPrompt = default, + string? magicPromptSystemPromptConfigId = default, + string? negativePrompt = default, + int? numImages = default, + global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette = default, + global::System.Collections.Generic.IList? styleCodes = default, + global::Ideogram.StyleTypeV3? styleType = default, + global::Ideogram.StylePresetV3? stylePreset = default, + string? customModelUri = default, + global::System.IO.Stream? fontFileH1 = default, + string? fontFileH1name = default, + string? fontNameH1 = default, + global::System.IO.Stream? fontFileH2 = default, + string? fontFileH2name = default, + string? fontNameH2 = default, + global::System.IO.Stream? fontFileBody = default, + string? fontFileBodyname = default, + string? fontNameBody = default, + global::System.IO.Stream? fontFileSmall = default, + string? fontFileSmallname = default, + string? fontNameSmall = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImages = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImagesFileNames = default, + global::System.Collections.Generic.IReadOnlyList? referenceAssetImages = default, + global::System.Collections.Generic.IReadOnlyList? referenceAssetImagesFileNames = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + var request = new global::Ideogram.GenerateDesignRequestV3 + { + Prompt = prompt, + Seed = seed, + Resolution = resolution, + AspectRatio = aspectRatio, + RenderingSpeed = renderingSpeed, + MagicPrompt = magicPrompt, + MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId, + NegativePrompt = negativePrompt, + NumImages = numImages, + ColorPalette = colorPalette, + StyleCodes = styleCodes, + StyleType = styleType, + StylePreset = stylePreset, + CustomModelUri = customModelUri, + FontFileH1 = global::System.Array.Empty(), + FontFileH1name = fontFileH1name, + FontNameH1 = fontNameH1, + FontFileH2 = global::System.Array.Empty(), + FontFileH2name = fontFileH2name, + FontNameH2 = fontNameH2, + FontFileBody = global::System.Array.Empty(), + FontFileBodyname = fontFileBodyname, + FontNameBody = fontNameBody, + FontFileSmall = global::System.Array.Empty(), + FontFileSmallname = fontFileSmallname, + FontNameSmall = fontNameSmall, + StyleReferenceImages = new global::System.Collections.Generic.List(), + ReferenceAssetImages = new global::System.Collections.Generic.List(), + }; + PrepareArguments( + client: HttpClient); + PreparePostGenerateDesignV3Arguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_PostGenerateDesignV3SecurityRequirements, + operationName: "PostGenerateDesignV3Async"); + + using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Ideogram.PathBuilder( + path: "/v1/ideogram-v3/generate-design", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), + name: "\"prompt\""); + + if (request.Seed != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"seed\""); + + } + if (request.Resolution != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.Resolution).HasValue ? (request.Resolution).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"resolution\""); + + } + if (request.AspectRatio != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.AspectRatio).HasValue ? (request.AspectRatio).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"aspect_ratio\""); + + } + if (request.RenderingSpeed != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"rendering_speed\""); + + } + if (request.MagicPrompt != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.MagicPrompt).HasValue ? (request.MagicPrompt).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"magic_prompt\""); + + } + if (request.MagicPromptSystemPromptConfigId != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty), + name: "\"magic_prompt_system_prompt_config_id\""); + + } + if (request.NegativePrompt != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.NegativePrompt ?? string.Empty), + name: "\"negative_prompt\""); + + } + if (request.NumImages != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"num_images\""); + + } + if (request.ColorPalette != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.ColorPalette.ToString() ?? string.Empty), + name: "\"color_palette\""); + + } + if (request.StyleCodes != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.StyleCodes, x => x))}]"), + name: "\"style_codes\""); + + } + if (request.StyleType != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.StyleType).HasValue ? (request.StyleType).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"style_type\""); + + } + if (request.StylePreset != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.StylePreset).HasValue ? (request.StylePreset).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"style_preset\""); + + } + if (request.CustomModelUri != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.CustomModelUri ?? string.Empty), + name: "\"custom_model_uri\""); + + } + if (fontFileH1 != default) + { + + var __contentFontFileH1 = new global::System.Net.Http.StreamContent(fontFileH1); + __contentFontFileH1.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.FontFileH1name is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.FontFileH1name) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentFontFileH1, + name: "\"font_file_h1\"", + fileName: request.FontFileH1name != null ? $"\"{request.FontFileH1name}\"" : string.Empty); + if (__contentFontFileH1.Headers.ContentDisposition != null) + { + __contentFontFileH1.Headers.ContentDisposition.FileNameStar = null; + } + + } + if (request.FontNameH1 != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.FontNameH1 ?? string.Empty), + name: "\"font_name_h1\""); + + } + if (fontFileH2 != default) + { + + var __contentFontFileH2 = new global::System.Net.Http.StreamContent(fontFileH2); + __contentFontFileH2.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.FontFileH2name is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.FontFileH2name) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentFontFileH2, + name: "\"font_file_h2\"", + fileName: request.FontFileH2name != null ? $"\"{request.FontFileH2name}\"" : string.Empty); + if (__contentFontFileH2.Headers.ContentDisposition != null) + { + __contentFontFileH2.Headers.ContentDisposition.FileNameStar = null; + } + + } + if (request.FontNameH2 != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.FontNameH2 ?? string.Empty), + name: "\"font_name_h2\""); + + } + if (fontFileBody != default) + { + + var __contentFontFileBody = new global::System.Net.Http.StreamContent(fontFileBody); + __contentFontFileBody.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.FontFileBodyname is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.FontFileBodyname) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentFontFileBody, + name: "\"font_file_body\"", + fileName: request.FontFileBodyname != null ? $"\"{request.FontFileBodyname}\"" : string.Empty); + if (__contentFontFileBody.Headers.ContentDisposition != null) + { + __contentFontFileBody.Headers.ContentDisposition.FileNameStar = null; + } + + } + if (request.FontNameBody != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.FontNameBody ?? string.Empty), + name: "\"font_name_body\""); + + } + if (fontFileSmall != default) + { + + var __contentFontFileSmall = new global::System.Net.Http.StreamContent(fontFileSmall); + __contentFontFileSmall.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.FontFileSmallname is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.FontFileSmallname) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentFontFileSmall, + name: "\"font_file_small\"", + fileName: request.FontFileSmallname != null ? $"\"{request.FontFileSmallname}\"" : string.Empty); + if (__contentFontFileSmall.Headers.ContentDisposition != null) + { + __contentFontFileSmall.Headers.ContentDisposition.FileNameStar = null; + } + + } + if (request.FontNameSmall != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.FontNameSmall ?? string.Empty), + name: "\"font_name_small\""); + + } + if (styleReferenceImages != default) + { + + for (var __iStyleReferenceImages = 0; __iStyleReferenceImages < styleReferenceImages.Count; __iStyleReferenceImages++) + { + var __fileNameStyleReferenceImages = styleReferenceImagesFileNames != null && + __iStyleReferenceImages < styleReferenceImagesFileNames.Count && + styleReferenceImagesFileNames[__iStyleReferenceImages] != null + ? styleReferenceImagesFileNames[__iStyleReferenceImages] + : $"file{__iStyleReferenceImages}.bin"; + var __contentStyleReferenceImages = new global::System.Net.Http.StreamContent(styleReferenceImages[__iStyleReferenceImages]); + __contentStyleReferenceImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + __fileNameStyleReferenceImages is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(__fileNameStyleReferenceImages) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentStyleReferenceImages, + name: "\"style_reference_images\"", + fileName: $"\"{__fileNameStyleReferenceImages}\""); + if (__contentStyleReferenceImages.Headers.ContentDisposition != null) + { + __contentStyleReferenceImages.Headers.ContentDisposition.FileNameStar = null; + } + } + + } + if (referenceAssetImages != default) + { + + for (var __iReferenceAssetImages = 0; __iReferenceAssetImages < referenceAssetImages.Count; __iReferenceAssetImages++) + { + var __fileNameReferenceAssetImages = referenceAssetImagesFileNames != null && + __iReferenceAssetImages < referenceAssetImagesFileNames.Count && + referenceAssetImagesFileNames[__iReferenceAssetImages] != null + ? referenceAssetImagesFileNames[__iReferenceAssetImages] + : $"file{__iReferenceAssetImages}.bin"; + var __contentReferenceAssetImages = new global::System.Net.Http.StreamContent(referenceAssetImages[__iReferenceAssetImages]); + __contentReferenceAssetImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + __fileNameReferenceAssetImages is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(__fileNameReferenceAssetImages) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentReferenceAssetImages, + name: "\"reference_asset_images\"", + fileName: $"\"{__fileNameReferenceAssetImages}\""); + if (__contentReferenceAssetImages.Headers.ContentDisposition != null) + { + __contentReferenceAssetImages.Headers.ContentDisposition.FileNameStar = null; + } + } + + } + + __httpRequest.Content = __httpRequestContent; + + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PreparePostGenerateDesignV3Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostGenerateDesignV3", + methodName: "PostGenerateDesignV3Async", + pathTemplate: "\"/v1/ideogram-v3/generate-design\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostGenerateDesignV3", + methodName: "PostGenerateDesignV3Async", + pathTemplate: "\"/v1/ideogram-v3/generate-design\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostGenerateDesignV3", + methodName: "PostGenerateDesignV3Async", + pathTemplate: "\"/v1/ideogram-v3/generate-design\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessPostGenerateDesignV3Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostGenerateDesignV3", + methodName: "PostGenerateDesignV3Async", + pathTemplate: "\"/v1/ideogram-v3/generate-design\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostGenerateDesignV3", + methodName: "PostGenerateDesignV3Async", + pathTemplate: "\"/v1/ideogram-v3/generate-design\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Prompt failed the safety check. + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Ideogram.GenerateImageSafetyError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessPostGenerateDesignV3ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Ideogram.LayeredImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Ideogram.LayeredImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Generate a design from a text prompt with text detection and correction
+ /// Generates a design synchronously from a text prompt using the Ideogram 3.0 model, then detects and corrects text layers within the generated image.
+ /// The response includes the generated image URL along with detected text layers (with font, size, color, position) and image asset layers.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// The prompt to use to generate the design.
+ /// Example: A birthday card saying 'Happy Birthday' + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// + /// The resolutions supported for Ideogram 3.0.
+ /// Example: 1280x800 + /// + /// + /// The aspect ratio to use for image generation, which determines the image's resolution. Cannot be used in conjunction with resolution. Defaults to 1x1. + /// + /// + /// The rendering speed to use.
+ /// Default Value: DEFAULT + /// + /// + /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON + /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + /// + /// Description of what to exclude from a design. Descriptions in the prompt take precedence
+ /// to descriptions in the negative prompt.
+ /// Example: brush strokes, painting + /// + /// + /// Number of designs to generate.
+ /// Default Value: 1 + /// + /// + /// A color palette for generation, must EITHER be specified via one of the presets (name) or explicitly via hexadecimal representations of the color with optional weights (members). Not supported by V_1, V_1_TURBO, V_2A and V_2A_TURBO models. + /// + /// + /// A list of 8 character hexadecimal codes representing the style of the image. Cannot be used in conjunction with style_reference_images or style_type.
+ /// Example: [AAFF5733, 0133FF57, DE3357FF] + /// + /// + /// The style type to generate with.
+ /// Default Value: GENERAL
+ /// Example: GENERAL + /// + /// + /// A predefined style preset that applies a specific artistic style to the generated image.
+ /// Example: BRIGHT_ART + /// + /// + /// A custom model URI in the format model/<model_name>/version/<version_name>.
+ /// When provided, the model version and style will be resolved from this URI, and style_type is not required.
+ /// Example: model/my-custom-model/version/1 + /// + /// + /// Custom font file for H1 (heading) text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_h1. + /// + /// + /// Custom font file for H1 (heading) text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_h1. + /// + /// + /// Font name from the available font library for H1 text. Ignored if font_file_h1 is provided.
+ /// Example: Ubuntu-Bold.ttf + /// + /// + /// Custom font file for H2 (subheading) text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_h2. + /// + /// + /// Custom font file for H2 (subheading) text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_h2. + /// + /// + /// Font name from the available font library for H2 text. Ignored if font_file_h2 is provided. + /// + /// + /// Custom font file for body text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_body. + /// + /// + /// Custom font file for body text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_body. + /// + /// + /// Font name from the available font library for body text. Ignored if font_file_body is provided. + /// + /// + /// Custom font file for small/caption text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_small. + /// + /// + /// Custom font file for small/caption text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_small. + /// + /// + /// Font name from the available font library for small text. Ignored if font_file_small is provided. + /// + /// + /// A set of images to use as style references (maximum total size 10MB across all style references). The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'style_reference_images' file parts. + /// + /// + /// A set of asset images (e.g., logos, icons) to use as references for detection and replacement (maximum 10 images). The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'reference_asset_images' file parts. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> PostGenerateDesignV3AsResponseAsync( + string prompt, + int? seed = default, + global::Ideogram.ResolutionV3? resolution = default, + global::Ideogram.AspectRatioV3? aspectRatio = default, + global::Ideogram.RenderingSpeed? renderingSpeed = default, + global::Ideogram.MagicPromptOption? magicPrompt = default, + string? magicPromptSystemPromptConfigId = default, + string? negativePrompt = default, + int? numImages = default, + global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette = default, + global::System.Collections.Generic.IList? styleCodes = default, + global::Ideogram.StyleTypeV3? styleType = default, + global::Ideogram.StylePresetV3? stylePreset = default, + string? customModelUri = default, + global::System.IO.Stream? fontFileH1 = default, + string? fontFileH1name = default, + string? fontNameH1 = default, + global::System.IO.Stream? fontFileH2 = default, + string? fontFileH2name = default, + string? fontNameH2 = default, + global::System.IO.Stream? fontFileBody = default, + string? fontFileBodyname = default, + string? fontNameBody = default, + global::System.IO.Stream? fontFileSmall = default, + string? fontFileSmallname = default, + string? fontNameSmall = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImages = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImagesFileNames = default, + global::System.Collections.Generic.IReadOnlyList? referenceAssetImages = default, + global::System.Collections.Generic.IReadOnlyList? referenceAssetImagesFileNames = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + var request = new global::Ideogram.GenerateDesignRequestV3 + { + Prompt = prompt, + Seed = seed, + Resolution = resolution, + AspectRatio = aspectRatio, + RenderingSpeed = renderingSpeed, + MagicPrompt = magicPrompt, + MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId, + NegativePrompt = negativePrompt, + NumImages = numImages, + ColorPalette = colorPalette, + StyleCodes = styleCodes, + StyleType = styleType, + StylePreset = stylePreset, + CustomModelUri = customModelUri, + FontFileH1 = global::System.Array.Empty(), + FontFileH1name = fontFileH1name, + FontNameH1 = fontNameH1, + FontFileH2 = global::System.Array.Empty(), + FontFileH2name = fontFileH2name, + FontNameH2 = fontNameH2, + FontFileBody = global::System.Array.Empty(), + FontFileBodyname = fontFileBodyname, + FontNameBody = fontNameBody, + FontFileSmall = global::System.Array.Empty(), + FontFileSmallname = fontFileSmallname, + FontNameSmall = fontNameSmall, + StyleReferenceImages = new global::System.Collections.Generic.List(), + ReferenceAssetImages = new global::System.Collections.Generic.List(), + }; + PrepareArguments( + client: HttpClient); + PreparePostGenerateDesignV3Arguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_PostGenerateDesignV3SecurityRequirements, + operationName: "PostGenerateDesignV3Async"); + + using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Ideogram.PathBuilder( + path: "/v1/ideogram-v3/generate-design", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), + name: "\"prompt\""); + + if (request.Seed != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"seed\""); + + } + if (request.Resolution != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.Resolution).HasValue ? (request.Resolution).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"resolution\""); + + } + if (request.AspectRatio != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.AspectRatio).HasValue ? (request.AspectRatio).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"aspect_ratio\""); + + } + if (request.RenderingSpeed != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"rendering_speed\""); + + } + if (request.MagicPrompt != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.MagicPrompt).HasValue ? (request.MagicPrompt).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"magic_prompt\""); + + } + if (request.MagicPromptSystemPromptConfigId != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty), + name: "\"magic_prompt_system_prompt_config_id\""); + + } + if (request.NegativePrompt != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.NegativePrompt ?? string.Empty), + name: "\"negative_prompt\""); + + } + if (request.NumImages != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"num_images\""); + + } + if (request.ColorPalette != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.ColorPalette.ToString() ?? string.Empty), + name: "\"color_palette\""); + + } + if (request.StyleCodes != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.StyleCodes, x => x))}]"), + name: "\"style_codes\""); + + } + if (request.StyleType != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.StyleType).HasValue ? (request.StyleType).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"style_type\""); + + } + if (request.StylePreset != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.StylePreset).HasValue ? (request.StylePreset).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"style_preset\""); + + } + if (request.CustomModelUri != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.CustomModelUri ?? string.Empty), + name: "\"custom_model_uri\""); + + } + if (fontFileH1 != default) + { + + var __contentFontFileH1 = new global::System.Net.Http.StreamContent(fontFileH1); + __contentFontFileH1.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.FontFileH1name is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.FontFileH1name) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentFontFileH1, + name: "\"font_file_h1\"", + fileName: request.FontFileH1name != null ? $"\"{request.FontFileH1name}\"" : string.Empty); + if (__contentFontFileH1.Headers.ContentDisposition != null) + { + __contentFontFileH1.Headers.ContentDisposition.FileNameStar = null; + } + + } + if (request.FontNameH1 != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.FontNameH1 ?? string.Empty), + name: "\"font_name_h1\""); + + } + if (fontFileH2 != default) + { + + var __contentFontFileH2 = new global::System.Net.Http.StreamContent(fontFileH2); + __contentFontFileH2.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.FontFileH2name is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.FontFileH2name) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentFontFileH2, + name: "\"font_file_h2\"", + fileName: request.FontFileH2name != null ? $"\"{request.FontFileH2name}\"" : string.Empty); + if (__contentFontFileH2.Headers.ContentDisposition != null) + { + __contentFontFileH2.Headers.ContentDisposition.FileNameStar = null; + } + + } + if (request.FontNameH2 != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.FontNameH2 ?? string.Empty), + name: "\"font_name_h2\""); + + } + if (fontFileBody != default) + { + + var __contentFontFileBody = new global::System.Net.Http.StreamContent(fontFileBody); + __contentFontFileBody.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.FontFileBodyname is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.FontFileBodyname) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentFontFileBody, + name: "\"font_file_body\"", + fileName: request.FontFileBodyname != null ? $"\"{request.FontFileBodyname}\"" : string.Empty); + if (__contentFontFileBody.Headers.ContentDisposition != null) + { + __contentFontFileBody.Headers.ContentDisposition.FileNameStar = null; + } + + } + if (request.FontNameBody != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.FontNameBody ?? string.Empty), + name: "\"font_name_body\""); + + } + if (fontFileSmall != default) + { + + var __contentFontFileSmall = new global::System.Net.Http.StreamContent(fontFileSmall); + __contentFontFileSmall.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.FontFileSmallname is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.FontFileSmallname) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentFontFileSmall, + name: "\"font_file_small\"", + fileName: request.FontFileSmallname != null ? $"\"{request.FontFileSmallname}\"" : string.Empty); + if (__contentFontFileSmall.Headers.ContentDisposition != null) + { + __contentFontFileSmall.Headers.ContentDisposition.FileNameStar = null; + } + + } + if (request.FontNameSmall != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.FontNameSmall ?? string.Empty), + name: "\"font_name_small\""); + + } + if (styleReferenceImages != default) + { + + for (var __iStyleReferenceImages = 0; __iStyleReferenceImages < styleReferenceImages.Count; __iStyleReferenceImages++) + { + var __fileNameStyleReferenceImages = styleReferenceImagesFileNames != null && + __iStyleReferenceImages < styleReferenceImagesFileNames.Count && + styleReferenceImagesFileNames[__iStyleReferenceImages] != null + ? styleReferenceImagesFileNames[__iStyleReferenceImages] + : $"file{__iStyleReferenceImages}.bin"; + var __contentStyleReferenceImages = new global::System.Net.Http.StreamContent(styleReferenceImages[__iStyleReferenceImages]); + __contentStyleReferenceImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + __fileNameStyleReferenceImages is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(__fileNameStyleReferenceImages) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentStyleReferenceImages, + name: "\"style_reference_images\"", + fileName: $"\"{__fileNameStyleReferenceImages}\""); + if (__contentStyleReferenceImages.Headers.ContentDisposition != null) + { + __contentStyleReferenceImages.Headers.ContentDisposition.FileNameStar = null; + } + } + + } + if (referenceAssetImages != default) + { + + for (var __iReferenceAssetImages = 0; __iReferenceAssetImages < referenceAssetImages.Count; __iReferenceAssetImages++) + { + var __fileNameReferenceAssetImages = referenceAssetImagesFileNames != null && + __iReferenceAssetImages < referenceAssetImagesFileNames.Count && + referenceAssetImagesFileNames[__iReferenceAssetImages] != null + ? referenceAssetImagesFileNames[__iReferenceAssetImages] + : $"file{__iReferenceAssetImages}.bin"; + var __contentReferenceAssetImages = new global::System.Net.Http.StreamContent(referenceAssetImages[__iReferenceAssetImages]); + __contentReferenceAssetImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + __fileNameReferenceAssetImages is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(__fileNameReferenceAssetImages) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentReferenceAssetImages, + name: "\"reference_asset_images\"", + fileName: $"\"{__fileNameReferenceAssetImages}\""); + if (__contentReferenceAssetImages.Headers.ContentDisposition != null) + { + __contentReferenceAssetImages.Headers.ContentDisposition.FileNameStar = null; + } + } + + } + + __httpRequest.Content = __httpRequestContent; + + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PreparePostGenerateDesignV3Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostGenerateDesignV3", + methodName: "PostGenerateDesignV3Async", + pathTemplate: "\"/v1/ideogram-v3/generate-design\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostGenerateDesignV3", + methodName: "PostGenerateDesignV3Async", + pathTemplate: "\"/v1/ideogram-v3/generate-design\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostGenerateDesignV3", + methodName: "PostGenerateDesignV3Async", + pathTemplate: "\"/v1/ideogram-v3/generate-design\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessPostGenerateDesignV3Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostGenerateDesignV3", + methodName: "PostGenerateDesignV3Async", + pathTemplate: "\"/v1/ideogram-v3/generate-design\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostGenerateDesignV3", + methodName: "PostGenerateDesignV3Async", + pathTemplate: "\"/v1/ideogram-v3/generate-design\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Prompt failed the safety check. + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Ideogram.GenerateImageSafetyError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessPostGenerateDesignV3ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Ideogram.LayeredImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + var __value = await global::Ideogram.LayeredImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateImage.g.cs b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateImage.g.cs index 4220d0a..5b4c040 100644 --- a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateImage.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateImage.g.cs @@ -52,6 +52,30 @@ partial void ProcessPostGenerateImageResponseContent( /// public async global::System.Threading.Tasks.Task PostGenerateImageAsync( + global::Ideogram.GenerateImageRequest request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await PostGenerateImageAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Generate (legacy)
+ /// Generates images synchronously based on a given prompt and optional parameters.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> PostGenerateImageAsResponseAsync( + global::Ideogram.GenerateImageRequest request, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) @@ -86,6 +110,7 @@ partial void ProcessPostGenerateImageResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/generate", baseUri: HttpClient.BaseAddress); @@ -165,6 +190,8 @@ partial void ProcessPostGenerateImageResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -175,6 +202,11 @@ partial void ProcessPostGenerateImageResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -192,6 +224,8 @@ partial void ProcessPostGenerateImageResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -201,8 +235,7 @@ partial void ProcessPostGenerateImageResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -211,6 +244,11 @@ partial void ProcessPostGenerateImageResponseContent( __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -227,14 +265,15 @@ partial void ProcessPostGenerateImageResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -274,6 +313,8 @@ partial void ProcessPostGenerateImageResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -294,6 +335,8 @@ partial void ProcessPostGenerateImageResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -455,9 +498,13 @@ partial void ProcessPostGenerateImageResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -485,9 +532,13 @@ partial void ProcessPostGenerateImageResponseContent( #endif ).ConfigureAwait(false); - return - await global::Ideogram.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateImageV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateImageV3.g.cs index d8b9e2a..80394dd 100644 --- a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateImageV3.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateImageV3.g.cs @@ -52,6 +52,30 @@ partial void ProcessPostGenerateImageV3ResponseContent( /// public async global::System.Threading.Tasks.Task PostGenerateImageV3Async( + global::Ideogram.GenerateImageRequestV3 request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await PostGenerateImageV3AsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Generate with Ideogram 3.0
+ /// Generates images synchronously based on a given prompt and optional parameters using the Ideogram 3.0 model.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> PostGenerateImageV3AsResponseAsync( + global::Ideogram.GenerateImageRequestV3 request, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) @@ -82,10 +106,11 @@ partial void ProcessPostGenerateImageV3ResponseContent( var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/v1/ideogram-v3/generate", baseUri: HttpClient.BaseAddress); @@ -118,94 +143,116 @@ partial void ProcessPostGenerateImageV3ResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), name: "\"prompt\""); + if (request.Seed != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), name: "\"seed\""); - } + + } if (request.Resolution != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.Resolution).HasValue ? (request.Resolution).GetValueOrDefault().ToValueString() : string.Empty), name: "\"resolution\""); - } + + } if (request.AspectRatio != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.AspectRatio).HasValue ? (request.AspectRatio).GetValueOrDefault().ToValueString() : string.Empty), name: "\"aspect_ratio\""); - } + + } if (request.RenderingSpeed != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty), name: "\"rendering_speed\""); - } + + } if (request.MagicPrompt != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.MagicPrompt).HasValue ? (request.MagicPrompt).GetValueOrDefault().ToValueString() : string.Empty), name: "\"magic_prompt\""); - } + + } + if (request.MagicPromptSystemPromptConfigId != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty), + name: "\"magic_prompt_system_prompt_config_id\""); + + } if (request.NegativePrompt != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.NegativePrompt ?? string.Empty), name: "\"negative_prompt\""); - } + + } if (request.NumImages != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), name: "\"num_images\""); - } + + } if (request.ColorPalette != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.ColorPalette.ToString() ?? string.Empty), name: "\"color_palette\""); - } + + } if (request.StyleCodes != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.StyleCodes, x => x))}]"), name: "\"style_codes\""); - } + + } if (request.StyleType != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.StyleType).HasValue ? (request.StyleType).GetValueOrDefault().ToValueString() : string.Empty), name: "\"style_type\""); - } + + } if (request.StylePreset != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.StylePreset).HasValue ? (request.StylePreset).GetValueOrDefault().ToValueString() : string.Empty), name: "\"style_preset\""); - } + + } if (request.CustomModelUri != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.CustomModelUri ?? string.Empty), name: "\"custom_model_uri\""); - } + + } if (request.StyleReferenceImages != default) { @@ -222,7 +269,8 @@ partial void ProcessPostGenerateImageV3ResponseContent( __contentStyleReferenceImages.Headers.ContentDisposition.FileNameStar = null; } } - } + + } if (request.CharacterReferenceImages != default) { @@ -239,7 +287,8 @@ partial void ProcessPostGenerateImageV3ResponseContent( __contentCharacterReferenceImages.Headers.ContentDisposition.FileNameStar = null; } } - } + + } if (request.CharacterReferenceImagesMask != default) { @@ -256,8 +305,11 @@ partial void ProcessPostGenerateImageV3ResponseContent( __contentCharacterReferenceImagesMask.Headers.ContentDisposition.FileNameStar = null; } } + } + __httpRequest.Content = __httpRequestContent; + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -299,6 +351,8 @@ partial void ProcessPostGenerateImageV3ResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -309,6 +363,11 @@ partial void ProcessPostGenerateImageV3ResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -326,6 +385,8 @@ partial void ProcessPostGenerateImageV3ResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -335,8 +396,7 @@ partial void ProcessPostGenerateImageV3ResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -345,6 +405,11 @@ partial void ProcessPostGenerateImageV3ResponseContent( __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -361,14 +426,15 @@ partial void ProcessPostGenerateImageV3ResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -408,6 +474,8 @@ partial void ProcessPostGenerateImageV3ResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -428,6 +496,8 @@ partial void ProcessPostGenerateImageV3ResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -589,9 +659,13 @@ partial void ProcessPostGenerateImageV3ResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -619,9 +693,13 @@ partial void ProcessPostGenerateImageV3ResponseContent( #endif ).ConfigureAwait(false); - return - await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -687,6 +765,9 @@ partial void ProcessPostGenerateImageV3ResponseContent( /// Determine if MagicPrompt should be used in generating the request or not.
/// Example: ON /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// /// /// Description of what to exclude from an image. Descriptions in the prompt take precedence
/// to descriptions in the negative prompt.
@@ -736,6 +817,7 @@ partial void ProcessPostGenerateImageV3ResponseContent( global::Ideogram.AspectRatioV3? aspectRatio = default, global::Ideogram.RenderingSpeed? renderingSpeed = default, global::Ideogram.MagicPromptOption? magicPrompt = default, + string? magicPromptSystemPromptConfigId = default, string? negativePrompt = default, int? numImages = default, global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette = default, @@ -757,6 +839,7 @@ partial void ProcessPostGenerateImageV3ResponseContent( AspectRatio = aspectRatio, RenderingSpeed = renderingSpeed, MagicPrompt = magicPrompt, + MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId, NegativePrompt = negativePrompt, NumImages = numImages, ColorPalette = colorPalette, @@ -774,5 +857,1754 @@ partial void ProcessPostGenerateImageV3ResponseContent( requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } + + /// + /// Generate with Ideogram 3.0
+ /// Generates images synchronously based on a given prompt and optional parameters using the Ideogram 3.0 model.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// The prompt to use to generate the image.
+ /// Example: A photo of a cat + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// + /// The resolutions supported for Ideogram 3.0.
+ /// Example: 1280x800 + /// + /// + /// The aspect ratio to use for image generation, which determines the image's resolution. Cannot be used in conjunction with resolution. Defaults to 1x1. + /// + /// + /// The rendering speed to use.
+ /// Default Value: DEFAULT + /// + /// + /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON + /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + /// + /// Description of what to exclude from an image. Descriptions in the prompt take precedence
+ /// to descriptions in the negative prompt.
+ /// Example: brush strokes, painting + /// + /// + /// Number of images to generate.
+ /// Default Value: 1 + /// + /// + /// A color palette for generation, must EITHER be specified via one of the presets (name) or explicitly via hexadecimal representations of the color with optional weights (members). Not supported by V_1, V_1_TURBO, V_2A and V_2A_TURBO models. + /// + /// + /// A list of 8 character hexadecimal codes representing the style of the image. Cannot be used in conjunction with style_reference_images or style_type.
+ /// Example: [AAFF5733, 0133FF57, DE3357FF] + /// + /// + /// The style type to generate with.
+ /// Default Value: GENERAL
+ /// Example: GENERAL + /// + /// + /// A predefined style preset that applies a specific artistic style to the generated image.
+ /// Example: BRIGHT_ART + /// + /// + /// A custom model URI in the format model/<model_name>/version/<version_name>.
+ /// When provided, the model version and style will be resolved from this URI, and style_type is not required.
+ /// Example: model/my-custom-model/version/1 + /// + /// + /// A set of images to use as style references (maximum total size 10MB across all style references). The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'style_reference_images' file parts. + /// + /// + /// Generations with character reference are subject to the character reference pricing. A set of images to use as character references (maximum total size 10MB across all character references), currently only supports 1 character reference image. The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'character_reference_images' file parts. + /// + /// + /// Optional masks for character reference images. When provided, must match the number of character_reference_images. Each mask should be a grayscale image of the same dimensions as the corresponding character reference image. The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'character_reference_images_mask' file parts. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task PostGenerateImageV3Async( + string prompt, + int? seed = default, + global::Ideogram.ResolutionV3? resolution = default, + global::Ideogram.AspectRatioV3? aspectRatio = default, + global::Ideogram.RenderingSpeed? renderingSpeed = default, + global::Ideogram.MagicPromptOption? magicPrompt = default, + string? magicPromptSystemPromptConfigId = default, + string? negativePrompt = default, + int? numImages = default, + global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette = default, + global::System.Collections.Generic.IList? styleCodes = default, + global::Ideogram.StyleTypeV3? styleType = default, + global::Ideogram.StylePresetV3? stylePreset = default, + string? customModelUri = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImages = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImagesFileNames = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImages = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesFileNames = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesMask = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesMaskFileNames = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + var request = new global::Ideogram.GenerateImageRequestV3 + { + Prompt = prompt, + Seed = seed, + Resolution = resolution, + AspectRatio = aspectRatio, + RenderingSpeed = renderingSpeed, + MagicPrompt = magicPrompt, + MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId, + NegativePrompt = negativePrompt, + NumImages = numImages, + ColorPalette = colorPalette, + StyleCodes = styleCodes, + StyleType = styleType, + StylePreset = stylePreset, + CustomModelUri = customModelUri, + StyleReferenceImages = new global::System.Collections.Generic.List(), + CharacterReferenceImages = new global::System.Collections.Generic.List(), + CharacterReferenceImagesMask = new global::System.Collections.Generic.List(), + }; + PrepareArguments( + client: HttpClient); + PreparePostGenerateImageV3Arguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_PostGenerateImageV3SecurityRequirements, + operationName: "PostGenerateImageV3Async"); + + using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Ideogram.PathBuilder( + path: "/v1/ideogram-v3/generate", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), + name: "\"prompt\""); + + if (request.Seed != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"seed\""); + + } + if (request.Resolution != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.Resolution).HasValue ? (request.Resolution).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"resolution\""); + + } + if (request.AspectRatio != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.AspectRatio).HasValue ? (request.AspectRatio).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"aspect_ratio\""); + + } + if (request.RenderingSpeed != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"rendering_speed\""); + + } + if (request.MagicPrompt != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.MagicPrompt).HasValue ? (request.MagicPrompt).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"magic_prompt\""); + + } + if (request.MagicPromptSystemPromptConfigId != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty), + name: "\"magic_prompt_system_prompt_config_id\""); + + } + if (request.NegativePrompt != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.NegativePrompt ?? string.Empty), + name: "\"negative_prompt\""); + + } + if (request.NumImages != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"num_images\""); + + } + if (request.ColorPalette != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.ColorPalette.ToString() ?? string.Empty), + name: "\"color_palette\""); + + } + if (request.StyleCodes != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.StyleCodes, x => x))}]"), + name: "\"style_codes\""); + + } + if (request.StyleType != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.StyleType).HasValue ? (request.StyleType).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"style_type\""); + + } + if (request.StylePreset != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.StylePreset).HasValue ? (request.StylePreset).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"style_preset\""); + + } + if (request.CustomModelUri != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.CustomModelUri ?? string.Empty), + name: "\"custom_model_uri\""); + + } + if (styleReferenceImages != default) + { + + for (var __iStyleReferenceImages = 0; __iStyleReferenceImages < styleReferenceImages.Count; __iStyleReferenceImages++) + { + var __fileNameStyleReferenceImages = styleReferenceImagesFileNames != null && + __iStyleReferenceImages < styleReferenceImagesFileNames.Count && + styleReferenceImagesFileNames[__iStyleReferenceImages] != null + ? styleReferenceImagesFileNames[__iStyleReferenceImages] + : $"file{__iStyleReferenceImages}.bin"; + var __contentStyleReferenceImages = new global::System.Net.Http.StreamContent(styleReferenceImages[__iStyleReferenceImages]); + __contentStyleReferenceImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + __fileNameStyleReferenceImages is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(__fileNameStyleReferenceImages) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentStyleReferenceImages, + name: "\"style_reference_images\"", + fileName: $"\"{__fileNameStyleReferenceImages}\""); + if (__contentStyleReferenceImages.Headers.ContentDisposition != null) + { + __contentStyleReferenceImages.Headers.ContentDisposition.FileNameStar = null; + } + } + + } + if (characterReferenceImages != default) + { + + for (var __iCharacterReferenceImages = 0; __iCharacterReferenceImages < characterReferenceImages.Count; __iCharacterReferenceImages++) + { + var __fileNameCharacterReferenceImages = characterReferenceImagesFileNames != null && + __iCharacterReferenceImages < characterReferenceImagesFileNames.Count && + characterReferenceImagesFileNames[__iCharacterReferenceImages] != null + ? characterReferenceImagesFileNames[__iCharacterReferenceImages] + : $"file{__iCharacterReferenceImages}.bin"; + var __contentCharacterReferenceImages = new global::System.Net.Http.StreamContent(characterReferenceImages[__iCharacterReferenceImages]); + __contentCharacterReferenceImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + __fileNameCharacterReferenceImages is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(__fileNameCharacterReferenceImages) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentCharacterReferenceImages, + name: "\"character_reference_images\"", + fileName: $"\"{__fileNameCharacterReferenceImages}\""); + if (__contentCharacterReferenceImages.Headers.ContentDisposition != null) + { + __contentCharacterReferenceImages.Headers.ContentDisposition.FileNameStar = null; + } + } + + } + if (characterReferenceImagesMask != default) + { + + for (var __iCharacterReferenceImagesMask = 0; __iCharacterReferenceImagesMask < characterReferenceImagesMask.Count; __iCharacterReferenceImagesMask++) + { + var __fileNameCharacterReferenceImagesMask = characterReferenceImagesMaskFileNames != null && + __iCharacterReferenceImagesMask < characterReferenceImagesMaskFileNames.Count && + characterReferenceImagesMaskFileNames[__iCharacterReferenceImagesMask] != null + ? characterReferenceImagesMaskFileNames[__iCharacterReferenceImagesMask] + : $"file{__iCharacterReferenceImagesMask}.bin"; + var __contentCharacterReferenceImagesMask = new global::System.Net.Http.StreamContent(characterReferenceImagesMask[__iCharacterReferenceImagesMask]); + __contentCharacterReferenceImagesMask.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + __fileNameCharacterReferenceImagesMask is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(__fileNameCharacterReferenceImagesMask) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentCharacterReferenceImagesMask, + name: "\"character_reference_images_mask\"", + fileName: $"\"{__fileNameCharacterReferenceImagesMask}\""); + if (__contentCharacterReferenceImagesMask.Headers.ContentDisposition != null) + { + __contentCharacterReferenceImagesMask.Headers.ContentDisposition.FileNameStar = null; + } + } + + } + + __httpRequest.Content = __httpRequestContent; + + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PreparePostGenerateImageV3Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostGenerateImageV3", + methodName: "PostGenerateImageV3Async", + pathTemplate: "\"/v1/ideogram-v3/generate\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostGenerateImageV3", + methodName: "PostGenerateImageV3Async", + pathTemplate: "\"/v1/ideogram-v3/generate\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostGenerateImageV3", + methodName: "PostGenerateImageV3Async", + pathTemplate: "\"/v1/ideogram-v3/generate\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessPostGenerateImageV3Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostGenerateImageV3", + methodName: "PostGenerateImageV3Async", + pathTemplate: "\"/v1/ideogram-v3/generate\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostGenerateImageV3", + methodName: "PostGenerateImageV3Async", + pathTemplate: "\"/v1/ideogram-v3/generate\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Prompt failed the safety check. + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Ideogram.GenerateImageSafetyError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessPostGenerateImageV3ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Generate with Ideogram 3.0
+ /// Generates images synchronously based on a given prompt and optional parameters using the Ideogram 3.0 model.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// The prompt to use to generate the image.
+ /// Example: A photo of a cat + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// + /// The resolutions supported for Ideogram 3.0.
+ /// Example: 1280x800 + /// + /// + /// The aspect ratio to use for image generation, which determines the image's resolution. Cannot be used in conjunction with resolution. Defaults to 1x1. + /// + /// + /// The rendering speed to use.
+ /// Default Value: DEFAULT + /// + /// + /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON + /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + /// + /// Description of what to exclude from an image. Descriptions in the prompt take precedence
+ /// to descriptions in the negative prompt.
+ /// Example: brush strokes, painting + /// + /// + /// Number of images to generate.
+ /// Default Value: 1 + /// + /// + /// A color palette for generation, must EITHER be specified via one of the presets (name) or explicitly via hexadecimal representations of the color with optional weights (members). Not supported by V_1, V_1_TURBO, V_2A and V_2A_TURBO models. + /// + /// + /// A list of 8 character hexadecimal codes representing the style of the image. Cannot be used in conjunction with style_reference_images or style_type.
+ /// Example: [AAFF5733, 0133FF57, DE3357FF] + /// + /// + /// The style type to generate with.
+ /// Default Value: GENERAL
+ /// Example: GENERAL + /// + /// + /// A predefined style preset that applies a specific artistic style to the generated image.
+ /// Example: BRIGHT_ART + /// + /// + /// A custom model URI in the format model/<model_name>/version/<version_name>.
+ /// When provided, the model version and style will be resolved from this URI, and style_type is not required.
+ /// Example: model/my-custom-model/version/1 + /// + /// + /// A set of images to use as style references (maximum total size 10MB across all style references). The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'style_reference_images' file parts. + /// + /// + /// Generations with character reference are subject to the character reference pricing. A set of images to use as character references (maximum total size 10MB across all character references), currently only supports 1 character reference image. The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'character_reference_images' file parts. + /// + /// + /// Optional masks for character reference images. When provided, must match the number of character_reference_images. Each mask should be a grayscale image of the same dimensions as the corresponding character reference image. The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'character_reference_images_mask' file parts. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> PostGenerateImageV3AsResponseAsync( + string prompt, + int? seed = default, + global::Ideogram.ResolutionV3? resolution = default, + global::Ideogram.AspectRatioV3? aspectRatio = default, + global::Ideogram.RenderingSpeed? renderingSpeed = default, + global::Ideogram.MagicPromptOption? magicPrompt = default, + string? magicPromptSystemPromptConfigId = default, + string? negativePrompt = default, + int? numImages = default, + global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette = default, + global::System.Collections.Generic.IList? styleCodes = default, + global::Ideogram.StyleTypeV3? styleType = default, + global::Ideogram.StylePresetV3? stylePreset = default, + string? customModelUri = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImages = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImagesFileNames = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImages = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesFileNames = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesMask = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesMaskFileNames = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + var request = new global::Ideogram.GenerateImageRequestV3 + { + Prompt = prompt, + Seed = seed, + Resolution = resolution, + AspectRatio = aspectRatio, + RenderingSpeed = renderingSpeed, + MagicPrompt = magicPrompt, + MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId, + NegativePrompt = negativePrompt, + NumImages = numImages, + ColorPalette = colorPalette, + StyleCodes = styleCodes, + StyleType = styleType, + StylePreset = stylePreset, + CustomModelUri = customModelUri, + StyleReferenceImages = new global::System.Collections.Generic.List(), + CharacterReferenceImages = new global::System.Collections.Generic.List(), + CharacterReferenceImagesMask = new global::System.Collections.Generic.List(), + }; + PrepareArguments( + client: HttpClient); + PreparePostGenerateImageV3Arguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_PostGenerateImageV3SecurityRequirements, + operationName: "PostGenerateImageV3Async"); + + using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Ideogram.PathBuilder( + path: "/v1/ideogram-v3/generate", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), + name: "\"prompt\""); + + if (request.Seed != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"seed\""); + + } + if (request.Resolution != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.Resolution).HasValue ? (request.Resolution).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"resolution\""); + + } + if (request.AspectRatio != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.AspectRatio).HasValue ? (request.AspectRatio).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"aspect_ratio\""); + + } + if (request.RenderingSpeed != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"rendering_speed\""); + + } + if (request.MagicPrompt != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.MagicPrompt).HasValue ? (request.MagicPrompt).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"magic_prompt\""); + + } + if (request.MagicPromptSystemPromptConfigId != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty), + name: "\"magic_prompt_system_prompt_config_id\""); + + } + if (request.NegativePrompt != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.NegativePrompt ?? string.Empty), + name: "\"negative_prompt\""); + + } + if (request.NumImages != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"num_images\""); + + } + if (request.ColorPalette != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.ColorPalette.ToString() ?? string.Empty), + name: "\"color_palette\""); + + } + if (request.StyleCodes != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.StyleCodes, x => x))}]"), + name: "\"style_codes\""); + + } + if (request.StyleType != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.StyleType).HasValue ? (request.StyleType).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"style_type\""); + + } + if (request.StylePreset != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.StylePreset).HasValue ? (request.StylePreset).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"style_preset\""); + + } + if (request.CustomModelUri != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.CustomModelUri ?? string.Empty), + name: "\"custom_model_uri\""); + + } + if (styleReferenceImages != default) + { + + for (var __iStyleReferenceImages = 0; __iStyleReferenceImages < styleReferenceImages.Count; __iStyleReferenceImages++) + { + var __fileNameStyleReferenceImages = styleReferenceImagesFileNames != null && + __iStyleReferenceImages < styleReferenceImagesFileNames.Count && + styleReferenceImagesFileNames[__iStyleReferenceImages] != null + ? styleReferenceImagesFileNames[__iStyleReferenceImages] + : $"file{__iStyleReferenceImages}.bin"; + var __contentStyleReferenceImages = new global::System.Net.Http.StreamContent(styleReferenceImages[__iStyleReferenceImages]); + __contentStyleReferenceImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + __fileNameStyleReferenceImages is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(__fileNameStyleReferenceImages) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentStyleReferenceImages, + name: "\"style_reference_images\"", + fileName: $"\"{__fileNameStyleReferenceImages}\""); + if (__contentStyleReferenceImages.Headers.ContentDisposition != null) + { + __contentStyleReferenceImages.Headers.ContentDisposition.FileNameStar = null; + } + } + + } + if (characterReferenceImages != default) + { + + for (var __iCharacterReferenceImages = 0; __iCharacterReferenceImages < characterReferenceImages.Count; __iCharacterReferenceImages++) + { + var __fileNameCharacterReferenceImages = characterReferenceImagesFileNames != null && + __iCharacterReferenceImages < characterReferenceImagesFileNames.Count && + characterReferenceImagesFileNames[__iCharacterReferenceImages] != null + ? characterReferenceImagesFileNames[__iCharacterReferenceImages] + : $"file{__iCharacterReferenceImages}.bin"; + var __contentCharacterReferenceImages = new global::System.Net.Http.StreamContent(characterReferenceImages[__iCharacterReferenceImages]); + __contentCharacterReferenceImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + __fileNameCharacterReferenceImages is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(__fileNameCharacterReferenceImages) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentCharacterReferenceImages, + name: "\"character_reference_images\"", + fileName: $"\"{__fileNameCharacterReferenceImages}\""); + if (__contentCharacterReferenceImages.Headers.ContentDisposition != null) + { + __contentCharacterReferenceImages.Headers.ContentDisposition.FileNameStar = null; + } + } + + } + if (characterReferenceImagesMask != default) + { + + for (var __iCharacterReferenceImagesMask = 0; __iCharacterReferenceImagesMask < characterReferenceImagesMask.Count; __iCharacterReferenceImagesMask++) + { + var __fileNameCharacterReferenceImagesMask = characterReferenceImagesMaskFileNames != null && + __iCharacterReferenceImagesMask < characterReferenceImagesMaskFileNames.Count && + characterReferenceImagesMaskFileNames[__iCharacterReferenceImagesMask] != null + ? characterReferenceImagesMaskFileNames[__iCharacterReferenceImagesMask] + : $"file{__iCharacterReferenceImagesMask}.bin"; + var __contentCharacterReferenceImagesMask = new global::System.Net.Http.StreamContent(characterReferenceImagesMask[__iCharacterReferenceImagesMask]); + __contentCharacterReferenceImagesMask.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + __fileNameCharacterReferenceImagesMask is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(__fileNameCharacterReferenceImagesMask) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentCharacterReferenceImagesMask, + name: "\"character_reference_images_mask\"", + fileName: $"\"{__fileNameCharacterReferenceImagesMask}\""); + if (__contentCharacterReferenceImagesMask.Headers.ContentDisposition != null) + { + __contentCharacterReferenceImagesMask.Headers.ContentDisposition.FileNameStar = null; + } + } + + } + + __httpRequest.Content = __httpRequestContent; + + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PreparePostGenerateImageV3Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostGenerateImageV3", + methodName: "PostGenerateImageV3Async", + pathTemplate: "\"/v1/ideogram-v3/generate\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostGenerateImageV3", + methodName: "PostGenerateImageV3Async", + pathTemplate: "\"/v1/ideogram-v3/generate\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostGenerateImageV3", + methodName: "PostGenerateImageV3Async", + pathTemplate: "\"/v1/ideogram-v3/generate\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessPostGenerateImageV3Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostGenerateImageV3", + methodName: "PostGenerateImageV3Async", + pathTemplate: "\"/v1/ideogram-v3/generate\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostGenerateImageV3", + methodName: "PostGenerateImageV3Async", + pathTemplate: "\"/v1/ideogram-v3/generate\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Prompt failed the safety check. + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Ideogram.GenerateImageSafetyError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessPostGenerateImageV3ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + var __value = await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateImageV3Transparent.g.cs b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateImageV3Transparent.g.cs index c66170c..dc5218b 100644 --- a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateImageV3Transparent.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateImageV3Transparent.g.cs @@ -47,6 +47,8 @@ partial void ProcessPostGenerateImageV3TransparentResponseContent( /// the Ideogram 3.0 model. Images will be generated using maximum supported resolution at the specified aspect ratio
/// to allow best results with upscaler. The selected resolution is written to the response, not the upscaled final
/// resolution.
+ /// `rendering_speed=FLASH` is not supported for transparent-background generation; the request will return a 400.
+ /// Use `TURBO`, `DEFAULT`, or `QUALITY` instead.
/// Images links are available for a limited period of time; if you would like to keep the image, you must download it. /// /// @@ -55,6 +57,35 @@ partial void ProcessPostGenerateImageV3TransparentResponseContent( /// public async global::System.Threading.Tasks.Task PostGenerateImageV3TransparentAsync( + global::Ideogram.GenerateTransparentImageRequestV3 request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await PostGenerateImageV3TransparentAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Generate with Ideogram 3.0 (Transparent Background)
+ /// Generates images with transparent background synchronously based on a given prompt and optional parameters using
+ /// the Ideogram 3.0 model. Images will be generated using maximum supported resolution at the specified aspect ratio
+ /// to allow best results with upscaler. The selected resolution is written to the response, not the upscaled final
+ /// resolution.
+ /// `rendering_speed=FLASH` is not supported for transparent-background generation; the request will return a 400.
+ /// Use `TURBO`, `DEFAULT`, or `QUALITY` instead.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> PostGenerateImageV3TransparentAsResponseAsync( + global::Ideogram.GenerateTransparentImageRequestV3 request, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) @@ -85,10 +116,11 @@ partial void ProcessPostGenerateImageV3TransparentResponseContent( var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/v1/ideogram-v3/generate-transparent", baseUri: HttpClient.BaseAddress); @@ -121,67 +153,87 @@ partial void ProcessPostGenerateImageV3TransparentResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), name: "\"prompt\""); + if (request.Seed != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), name: "\"seed\""); - } + + } if (request.UpscaleFactor != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.UpscaleFactor).HasValue ? (request.UpscaleFactor).GetValueOrDefault().ToValueString() : string.Empty), name: "\"upscale_factor\""); - } + + } if (request.AspectRatio != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.AspectRatio).HasValue ? (request.AspectRatio).GetValueOrDefault().ToValueString() : string.Empty), name: "\"aspect_ratio\""); - } + + } if (request.RenderingSpeed != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty), name: "\"rendering_speed\""); - } + + } if (request.MagicPrompt != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.MagicPrompt).HasValue ? (request.MagicPrompt).GetValueOrDefault().ToValueString() : string.Empty), name: "\"magic_prompt\""); - } + + } + if (request.MagicPromptSystemPromptConfigId != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty), + name: "\"magic_prompt_system_prompt_config_id\""); + + } if (request.NegativePrompt != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.NegativePrompt ?? string.Empty), name: "\"negative_prompt\""); - } + + } if (request.NumImages != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), name: "\"num_images\""); - } + + } if (request.CustomModelUri != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.CustomModelUri ?? string.Empty), name: "\"custom_model_uri\""); + } + __httpRequest.Content = __httpRequestContent; + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -223,6 +275,8 @@ partial void ProcessPostGenerateImageV3TransparentResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -233,6 +287,11 @@ partial void ProcessPostGenerateImageV3TransparentResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -250,6 +309,8 @@ partial void ProcessPostGenerateImageV3TransparentResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -259,8 +320,7 @@ partial void ProcessPostGenerateImageV3TransparentResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -269,6 +329,11 @@ partial void ProcessPostGenerateImageV3TransparentResponseContent( __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -285,14 +350,15 @@ partial void ProcessPostGenerateImageV3TransparentResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -332,6 +398,8 @@ partial void ProcessPostGenerateImageV3TransparentResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -352,6 +420,8 @@ partial void ProcessPostGenerateImageV3TransparentResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -513,9 +583,13 @@ partial void ProcessPostGenerateImageV3TransparentResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -543,9 +617,13 @@ partial void ProcessPostGenerateImageV3TransparentResponseContent( #endif ).ConfigureAwait(false); - return - await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -589,6 +667,8 @@ partial void ProcessPostGenerateImageV3TransparentResponseContent( /// the Ideogram 3.0 model. Images will be generated using maximum supported resolution at the specified aspect ratio
/// to allow best results with upscaler. The selected resolution is written to the response, not the upscaled final
/// resolution.
+ /// `rendering_speed=FLASH` is not supported for transparent-background generation; the request will return a 400.
+ /// Use `TURBO`, `DEFAULT`, or `QUALITY` instead.
/// Images links are available for a limited period of time; if you would like to keep the image, you must download it. /// /// @@ -615,6 +695,9 @@ partial void ProcessPostGenerateImageV3TransparentResponseContent( /// Determine if MagicPrompt should be used in generating the request or not.
/// Example: ON /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// /// /// Description of what to exclude from an image. Descriptions in the prompt take precedence
/// to descriptions in the negative prompt.
@@ -640,6 +723,7 @@ partial void ProcessPostGenerateImageV3TransparentResponseContent( global::Ideogram.AspectRatioV3? aspectRatio = default, global::Ideogram.RenderingSpeed? renderingSpeed = default, global::Ideogram.MagicPromptOption? magicPrompt = default, + string? magicPromptSystemPromptConfigId = default, string? negativePrompt = default, int? numImages = default, string? customModelUri = default, @@ -654,6 +738,7 @@ partial void ProcessPostGenerateImageV3TransparentResponseContent( AspectRatio = aspectRatio, RenderingSpeed = renderingSpeed, MagicPrompt = magicPrompt, + MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId, NegativePrompt = negativePrompt, NumImages = numImages, CustomModelUri = customModelUri, diff --git a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateImageV4.g.cs b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateImageV4.g.cs index 222fc4e..3b115ea 100644 --- a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateImageV4.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateImageV4.g.cs @@ -52,6 +52,30 @@ partial void ProcessPostGenerateImageV4ResponseContent( /// public async global::System.Threading.Tasks.Task PostGenerateImageV4Async( + global::Ideogram.GenerateImageRequestV4 request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await PostGenerateImageV4AsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Generate with Ideogram 4.0
+ /// Generates images synchronously using the Ideogram 4.0 model.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> PostGenerateImageV4AsResponseAsync( + global::Ideogram.GenerateImageRequestV4 request, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) @@ -82,10 +106,11 @@ partial void ProcessPostGenerateImageV4ResponseContent( var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/v1/ideogram-v4/generate", baseUri: HttpClient.BaseAddress); @@ -118,32 +143,63 @@ partial void ProcessPostGenerateImageV4ResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), name: "\"prompt\""); + if (request.Seed != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), name: "\"seed\""); - } + + } if (request.MagicPromptOption != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.MagicPromptOption).HasValue ? (request.MagicPromptOption).GetValueOrDefault().ToValueString() : string.Empty), name: "\"magic_prompt_option\""); - } + + } + if (request.MagicPromptSystemPromptConfigId != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty), + name: "\"magic_prompt_system_prompt_config_id\""); + + } if (request.CustomModelUri != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.CustomModelUri ?? string.Empty), name: "\"custom_model_uri\""); + + } + if (request.Resolution != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.Resolution).HasValue ? (request.Resolution).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"resolution\""); + + } + if (request.RenderingSpeed != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"rendering_speed\""); + } + __httpRequest.Content = __httpRequestContent; + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -185,6 +241,8 @@ partial void ProcessPostGenerateImageV4ResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -195,6 +253,11 @@ partial void ProcessPostGenerateImageV4ResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -212,6 +275,8 @@ partial void ProcessPostGenerateImageV4ResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -221,8 +286,7 @@ partial void ProcessPostGenerateImageV4ResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -231,6 +295,11 @@ partial void ProcessPostGenerateImageV4ResponseContent( __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -247,14 +316,15 @@ partial void ProcessPostGenerateImageV4ResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -294,6 +364,8 @@ partial void ProcessPostGenerateImageV4ResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -314,6 +386,8 @@ partial void ProcessPostGenerateImageV4ResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -475,9 +549,13 @@ partial void ProcessPostGenerateImageV4ResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.ImageGenerationResponseV4.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.ImageGenerationResponseV4.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -505,9 +583,13 @@ partial void ProcessPostGenerateImageV4ResponseContent( #endif ).ConfigureAwait(false); - return - await global::Ideogram.ImageGenerationResponseV4.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.ImageGenerationResponseV4.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -560,11 +642,22 @@ partial void ProcessPostGenerateImageV4ResponseContent( /// Determine if MagicPrompt should be used in generating the request or not.
/// Example: ON /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// /// /// A custom model URI in the format model/<model_name>/version/<version_name>.
/// When provided, the model version and style will be resolved from this URI.
/// Example: model/my-custom-model/version/0 /// + /// + /// The resolutions supported for Ideogram 4.0.
+ /// Example: 1280x800 + /// + /// + /// The rendering speed to use.
+ /// Default Value: DEFAULT + /// /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// @@ -572,7 +665,10 @@ partial void ProcessPostGenerateImageV4ResponseContent( string prompt, int? seed = default, global::Ideogram.MagicPromptOption? magicPromptOption = default, + string? magicPromptSystemPromptConfigId = default, string? customModelUri = default, + global::Ideogram.ResolutionV4? resolution = default, + global::Ideogram.RenderingSpeed? renderingSpeed = default, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { @@ -581,7 +677,10 @@ partial void ProcessPostGenerateImageV4ResponseContent( Prompt = prompt, Seed = seed, MagicPromptOption = magicPromptOption, + MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId, CustomModelUri = customModelUri, + Resolution = resolution, + RenderingSpeed = renderingSpeed, }; return await PostGenerateImageV4Async( diff --git a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostInpaintImageV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostInpaintImageV3.g.cs index c527a47..879ca23 100644 --- a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostInpaintImageV3.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostInpaintImageV3.g.cs @@ -54,6 +54,32 @@ partial void ProcessPostInpaintImageV3ResponseContent( /// public async global::System.Threading.Tasks.Task PostInpaintImageV3Async( + global::Ideogram.EditImageRequestV3 request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await PostInpaintImageV3AsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Inpaint with Ideogram 3.0
+ /// Inpaint a given image synchronously using the provided mask with Ideogram 3.0. The mask indicates which part of the image
+ /// should be edited, while the prompt and chosen style can further guide the edit.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> PostInpaintImageV3AsResponseAsync( + global::Ideogram.EditImageRequestV3 request, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) @@ -84,10 +110,11 @@ partial void ProcessPostInpaintImageV3ResponseContent( var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/v1/ideogram-v3/inpaint", baseUri: HttpClient.BaseAddress); @@ -120,6 +147,7 @@ partial void ProcessPostInpaintImageV3ResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); var __contentImage = new global::System.Net.Http.ByteArrayContent(request.Image ?? global::System.Array.Empty()); __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( @@ -158,6 +186,7 @@ request.Imagename is null { __contentImage.Headers.ContentDisposition.FileNameStar = null; } + var __contentMask = new global::System.Net.Http.ByteArrayContent(request.Mask ?? global::System.Array.Empty()); __contentMask.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( request.Maskname is null @@ -195,72 +224,91 @@ request.Maskname is null { __contentMask.Headers.ContentDisposition.FileNameStar = null; } + __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), name: "\"prompt\""); + if (request.MagicPrompt != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.MagicPrompt).HasValue ? (request.MagicPrompt).GetValueOrDefault().ToValueString() : string.Empty), name: "\"magic_prompt\""); - } + + } + if (request.MagicPromptSystemPromptConfigId != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty), + name: "\"magic_prompt_system_prompt_config_id\""); + + } if (request.NumImages != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), name: "\"num_images\""); - } + + } if (request.Seed != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), name: "\"seed\""); - } + + } if (request.RenderingSpeed != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty), name: "\"rendering_speed\""); - } + + } if (request.StyleType != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.StyleType).HasValue ? (request.StyleType).GetValueOrDefault().ToValueString() : string.Empty), name: "\"style_type\""); - } + + } if (request.StylePreset != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.StylePreset).HasValue ? (request.StylePreset).GetValueOrDefault().ToValueString() : string.Empty), name: "\"style_preset\""); - } + + } if (request.CustomModelUri != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.CustomModelUri ?? string.Empty), name: "\"custom_model_uri\""); - } + + } if (request.ColorPalette != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.ColorPalette.ToString() ?? string.Empty), name: "\"color_palette\""); - } + + } if (request.StyleCodes != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.StyleCodes, x => x))}]"), name: "\"style_codes\""); - } + + } if (request.StyleReferenceImages != default) { @@ -277,7 +325,8 @@ request.Maskname is null __contentStyleReferenceImages.Headers.ContentDisposition.FileNameStar = null; } } - } + + } if (request.CharacterReferenceImages != default) { @@ -294,7 +343,8 @@ request.Maskname is null __contentCharacterReferenceImages.Headers.ContentDisposition.FileNameStar = null; } } - } + + } if (request.CharacterReferenceImagesMask != default) { @@ -311,8 +361,11 @@ request.Maskname is null __contentCharacterReferenceImagesMask.Headers.ContentDisposition.FileNameStar = null; } } + } + __httpRequest.Content = __httpRequestContent; + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -354,6 +407,8 @@ request.Maskname is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -364,6 +419,11 @@ request.Maskname is null } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -381,6 +441,8 @@ request.Maskname is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -390,8 +452,7 @@ request.Maskname is null __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -400,6 +461,11 @@ request.Maskname is null __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -416,14 +482,15 @@ request.Maskname is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -463,6 +530,8 @@ request.Maskname is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -483,6 +552,8 @@ request.Maskname is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -644,9 +715,13 @@ request.Maskname is null { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -674,9 +749,13 @@ request.Maskname is null #endif ).ConfigureAwait(false); - return - await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -741,6 +820,9 @@ request.Maskname is null /// Determine if MagicPrompt should be used in generating the request or not.
/// Example: ON /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// /// /// The number of images to generate.
/// Default Value: 1 @@ -793,6 +875,7 @@ request.Maskname is null string maskname, string prompt, global::Ideogram.MagicPromptOption? magicPrompt = default, + string? magicPromptSystemPromptConfigId = default, int? numImages = default, int? seed = default, global::Ideogram.RenderingSpeed? renderingSpeed = default, @@ -815,6 +898,7 @@ request.Maskname is null Maskname = maskname, Prompt = prompt, MagicPrompt = magicPrompt, + MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId, NumImages = numImages, Seed = seed, RenderingSpeed = renderingSpeed, @@ -833,5 +917,1870 @@ request.Maskname is null requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } + + /// + /// Inpaint with Ideogram 3.0
+ /// Inpaint a given image synchronously using the provided mask with Ideogram 3.0. The mask indicates which part of the image
+ /// should be edited, while the prompt and chosen style can further guide the edit.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// The image being edited (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The image being edited (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// A black and white image of the same size as the image being edited (max size 10MB). Black regions in the mask should match up with the regions of the image that you would like to edit; only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// A black and white image of the same size as the image being edited (max size 10MB). Black regions in the mask should match up with the regions of the image that you would like to edit; only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The prompt used to describe the edited result.
+ /// Example: A photo of a cat. + /// + /// + /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON + /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + /// + /// The number of images to generate.
+ /// Default Value: 1 + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// + /// The rendering speed to use.
+ /// Default Value: DEFAULT + /// + /// + /// The style type to generate with.
+ /// Default Value: GENERAL
+ /// Example: GENERAL + /// + /// + /// A predefined style preset that applies a specific artistic style to the generated image.
+ /// Example: BRIGHT_ART + /// + /// + /// A custom model URI in the format model/<model_name>/version/<version_name>.
+ /// When provided, the model version and style will be resolved from this URI, and style_type is not required.
+ /// Example: model/my-custom-model/version/1 + /// + /// + /// A color palette for generation, must EITHER be specified via one of the presets (name) or explicitly via hexadecimal representations of the color with optional weights (members). Not supported by V_1, V_1_TURBO, V_2A and V_2A_TURBO models. + /// + /// + /// A list of 8 character hexadecimal codes representing the style of the image. Cannot be used in conjunction with style_reference_images or style_type.
+ /// Example: [AAFF5733, 0133FF57, DE3357FF] + /// + /// + /// A set of images to use as style references (maximum total size 10MB across all style references). The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'style_reference_images' file parts. + /// + /// + /// Generations with character reference are subject to the character reference pricing. A set of images to use as character references (maximum total size 10MB across all character references), currently only supports 1 character reference image. The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'character_reference_images' file parts. + /// + /// + /// Optional masks for character reference images. When provided, must match the number of character_reference_images. Each mask should be a grayscale image of the same dimensions as the corresponding character reference image. The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'character_reference_images_mask' file parts. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task PostInpaintImageV3Async( + global::System.IO.Stream image, + string imagename, + global::System.IO.Stream mask, + string maskname, + string prompt, + global::Ideogram.MagicPromptOption? magicPrompt = default, + string? magicPromptSystemPromptConfigId = default, + int? numImages = default, + int? seed = default, + global::Ideogram.RenderingSpeed? renderingSpeed = default, + global::Ideogram.StyleTypeV3? styleType = default, + global::Ideogram.StylePresetV3? stylePreset = default, + string? customModelUri = default, + global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette = default, + global::System.Collections.Generic.IList? styleCodes = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImages = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImagesFileNames = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImages = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesFileNames = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesMask = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesMaskFileNames = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + image = image ?? throw new global::System.ArgumentNullException(nameof(image)); + mask = mask ?? throw new global::System.ArgumentNullException(nameof(mask)); + var request = new global::Ideogram.EditImageRequestV3 + { + Image = global::System.Array.Empty(), + Imagename = imagename, + Mask = global::System.Array.Empty(), + Maskname = maskname, + Prompt = prompt, + MagicPrompt = magicPrompt, + MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId, + NumImages = numImages, + Seed = seed, + RenderingSpeed = renderingSpeed, + StyleType = styleType, + StylePreset = stylePreset, + CustomModelUri = customModelUri, + ColorPalette = colorPalette, + StyleCodes = styleCodes, + StyleReferenceImages = new global::System.Collections.Generic.List(), + CharacterReferenceImages = new global::System.Collections.Generic.List(), + CharacterReferenceImagesMask = new global::System.Collections.Generic.List(), + }; + PrepareArguments( + client: HttpClient); + PreparePostInpaintImageV3Arguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_PostInpaintImageV3SecurityRequirements, + operationName: "PostInpaintImageV3Async"); + + using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Ideogram.PathBuilder( + path: "/v1/ideogram-v3/inpaint", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + var __contentImage = new global::System.Net.Http.StreamContent(image); + __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.Imagename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentImage, + name: "\"image\"", + fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty); + if (__contentImage.Headers.ContentDisposition != null) + { + __contentImage.Headers.ContentDisposition.FileNameStar = null; + } + + var __contentMask = new global::System.Net.Http.StreamContent(mask); + __contentMask.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.Maskname is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.Maskname) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentMask, + name: "\"mask\"", + fileName: request.Maskname != null ? $"\"{request.Maskname}\"" : string.Empty); + if (__contentMask.Headers.ContentDisposition != null) + { + __contentMask.Headers.ContentDisposition.FileNameStar = null; + } + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), + name: "\"prompt\""); + + if (request.MagicPrompt != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.MagicPrompt).HasValue ? (request.MagicPrompt).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"magic_prompt\""); + + } + if (request.MagicPromptSystemPromptConfigId != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty), + name: "\"magic_prompt_system_prompt_config_id\""); + + } + if (request.NumImages != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"num_images\""); + + } + if (request.Seed != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"seed\""); + + } + if (request.RenderingSpeed != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"rendering_speed\""); + + } + if (request.StyleType != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.StyleType).HasValue ? (request.StyleType).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"style_type\""); + + } + if (request.StylePreset != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.StylePreset).HasValue ? (request.StylePreset).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"style_preset\""); + + } + if (request.CustomModelUri != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.CustomModelUri ?? string.Empty), + name: "\"custom_model_uri\""); + + } + if (request.ColorPalette != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.ColorPalette.ToString() ?? string.Empty), + name: "\"color_palette\""); + + } + if (request.StyleCodes != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.StyleCodes, x => x))}]"), + name: "\"style_codes\""); + + } + if (styleReferenceImages != default) + { + + for (var __iStyleReferenceImages = 0; __iStyleReferenceImages < styleReferenceImages.Count; __iStyleReferenceImages++) + { + var __fileNameStyleReferenceImages = styleReferenceImagesFileNames != null && + __iStyleReferenceImages < styleReferenceImagesFileNames.Count && + styleReferenceImagesFileNames[__iStyleReferenceImages] != null + ? styleReferenceImagesFileNames[__iStyleReferenceImages] + : $"file{__iStyleReferenceImages}.bin"; + var __contentStyleReferenceImages = new global::System.Net.Http.StreamContent(styleReferenceImages[__iStyleReferenceImages]); + __contentStyleReferenceImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + __fileNameStyleReferenceImages is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(__fileNameStyleReferenceImages) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentStyleReferenceImages, + name: "\"style_reference_images\"", + fileName: $"\"{__fileNameStyleReferenceImages}\""); + if (__contentStyleReferenceImages.Headers.ContentDisposition != null) + { + __contentStyleReferenceImages.Headers.ContentDisposition.FileNameStar = null; + } + } + + } + if (characterReferenceImages != default) + { + + for (var __iCharacterReferenceImages = 0; __iCharacterReferenceImages < characterReferenceImages.Count; __iCharacterReferenceImages++) + { + var __fileNameCharacterReferenceImages = characterReferenceImagesFileNames != null && + __iCharacterReferenceImages < characterReferenceImagesFileNames.Count && + characterReferenceImagesFileNames[__iCharacterReferenceImages] != null + ? characterReferenceImagesFileNames[__iCharacterReferenceImages] + : $"file{__iCharacterReferenceImages}.bin"; + var __contentCharacterReferenceImages = new global::System.Net.Http.StreamContent(characterReferenceImages[__iCharacterReferenceImages]); + __contentCharacterReferenceImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + __fileNameCharacterReferenceImages is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(__fileNameCharacterReferenceImages) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentCharacterReferenceImages, + name: "\"character_reference_images\"", + fileName: $"\"{__fileNameCharacterReferenceImages}\""); + if (__contentCharacterReferenceImages.Headers.ContentDisposition != null) + { + __contentCharacterReferenceImages.Headers.ContentDisposition.FileNameStar = null; + } + } + + } + if (characterReferenceImagesMask != default) + { + + for (var __iCharacterReferenceImagesMask = 0; __iCharacterReferenceImagesMask < characterReferenceImagesMask.Count; __iCharacterReferenceImagesMask++) + { + var __fileNameCharacterReferenceImagesMask = characterReferenceImagesMaskFileNames != null && + __iCharacterReferenceImagesMask < characterReferenceImagesMaskFileNames.Count && + characterReferenceImagesMaskFileNames[__iCharacterReferenceImagesMask] != null + ? characterReferenceImagesMaskFileNames[__iCharacterReferenceImagesMask] + : $"file{__iCharacterReferenceImagesMask}.bin"; + var __contentCharacterReferenceImagesMask = new global::System.Net.Http.StreamContent(characterReferenceImagesMask[__iCharacterReferenceImagesMask]); + __contentCharacterReferenceImagesMask.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + __fileNameCharacterReferenceImagesMask is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(__fileNameCharacterReferenceImagesMask) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentCharacterReferenceImagesMask, + name: "\"character_reference_images_mask\"", + fileName: $"\"{__fileNameCharacterReferenceImagesMask}\""); + if (__contentCharacterReferenceImagesMask.Headers.ContentDisposition != null) + { + __contentCharacterReferenceImagesMask.Headers.ContentDisposition.FileNameStar = null; + } + } + + } + + __httpRequest.Content = __httpRequestContent; + + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PreparePostInpaintImageV3Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostInpaintImageV3", + methodName: "PostInpaintImageV3Async", + pathTemplate: "\"/v1/ideogram-v3/inpaint\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostInpaintImageV3", + methodName: "PostInpaintImageV3Async", + pathTemplate: "\"/v1/ideogram-v3/inpaint\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostInpaintImageV3", + methodName: "PostInpaintImageV3Async", + pathTemplate: "\"/v1/ideogram-v3/inpaint\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessPostInpaintImageV3Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostInpaintImageV3", + methodName: "PostInpaintImageV3Async", + pathTemplate: "\"/v1/ideogram-v3/inpaint\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostInpaintImageV3", + methodName: "PostInpaintImageV3Async", + pathTemplate: "\"/v1/ideogram-v3/inpaint\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Prompt or Initial Image failed the safety checks. + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Ideogram.GenerateImageSafetyError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessPostInpaintImageV3ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Inpaint with Ideogram 3.0
+ /// Inpaint a given image synchronously using the provided mask with Ideogram 3.0. The mask indicates which part of the image
+ /// should be edited, while the prompt and chosen style can further guide the edit.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// The image being edited (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The image being edited (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// A black and white image of the same size as the image being edited (max size 10MB). Black regions in the mask should match up with the regions of the image that you would like to edit; only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// A black and white image of the same size as the image being edited (max size 10MB). Black regions in the mask should match up with the regions of the image that you would like to edit; only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The prompt used to describe the edited result.
+ /// Example: A photo of a cat. + /// + /// + /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON + /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + /// + /// The number of images to generate.
+ /// Default Value: 1 + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// + /// The rendering speed to use.
+ /// Default Value: DEFAULT + /// + /// + /// The style type to generate with.
+ /// Default Value: GENERAL
+ /// Example: GENERAL + /// + /// + /// A predefined style preset that applies a specific artistic style to the generated image.
+ /// Example: BRIGHT_ART + /// + /// + /// A custom model URI in the format model/<model_name>/version/<version_name>.
+ /// When provided, the model version and style will be resolved from this URI, and style_type is not required.
+ /// Example: model/my-custom-model/version/1 + /// + /// + /// A color palette for generation, must EITHER be specified via one of the presets (name) or explicitly via hexadecimal representations of the color with optional weights (members). Not supported by V_1, V_1_TURBO, V_2A and V_2A_TURBO models. + /// + /// + /// A list of 8 character hexadecimal codes representing the style of the image. Cannot be used in conjunction with style_reference_images or style_type.
+ /// Example: [AAFF5733, 0133FF57, DE3357FF] + /// + /// + /// A set of images to use as style references (maximum total size 10MB across all style references). The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'style_reference_images' file parts. + /// + /// + /// Generations with character reference are subject to the character reference pricing. A set of images to use as character references (maximum total size 10MB across all character references), currently only supports 1 character reference image. The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'character_reference_images' file parts. + /// + /// + /// Optional masks for character reference images. When provided, must match the number of character_reference_images. Each mask should be a grayscale image of the same dimensions as the corresponding character reference image. The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'character_reference_images_mask' file parts. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> PostInpaintImageV3AsResponseAsync( + global::System.IO.Stream image, + string imagename, + global::System.IO.Stream mask, + string maskname, + string prompt, + global::Ideogram.MagicPromptOption? magicPrompt = default, + string? magicPromptSystemPromptConfigId = default, + int? numImages = default, + int? seed = default, + global::Ideogram.RenderingSpeed? renderingSpeed = default, + global::Ideogram.StyleTypeV3? styleType = default, + global::Ideogram.StylePresetV3? stylePreset = default, + string? customModelUri = default, + global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette = default, + global::System.Collections.Generic.IList? styleCodes = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImages = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImagesFileNames = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImages = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesFileNames = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesMask = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesMaskFileNames = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + image = image ?? throw new global::System.ArgumentNullException(nameof(image)); + mask = mask ?? throw new global::System.ArgumentNullException(nameof(mask)); + var request = new global::Ideogram.EditImageRequestV3 + { + Image = global::System.Array.Empty(), + Imagename = imagename, + Mask = global::System.Array.Empty(), + Maskname = maskname, + Prompt = prompt, + MagicPrompt = magicPrompt, + MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId, + NumImages = numImages, + Seed = seed, + RenderingSpeed = renderingSpeed, + StyleType = styleType, + StylePreset = stylePreset, + CustomModelUri = customModelUri, + ColorPalette = colorPalette, + StyleCodes = styleCodes, + StyleReferenceImages = new global::System.Collections.Generic.List(), + CharacterReferenceImages = new global::System.Collections.Generic.List(), + CharacterReferenceImagesMask = new global::System.Collections.Generic.List(), + }; + PrepareArguments( + client: HttpClient); + PreparePostInpaintImageV3Arguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_PostInpaintImageV3SecurityRequirements, + operationName: "PostInpaintImageV3Async"); + + using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Ideogram.PathBuilder( + path: "/v1/ideogram-v3/inpaint", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + var __contentImage = new global::System.Net.Http.StreamContent(image); + __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.Imagename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentImage, + name: "\"image\"", + fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty); + if (__contentImage.Headers.ContentDisposition != null) + { + __contentImage.Headers.ContentDisposition.FileNameStar = null; + } + + var __contentMask = new global::System.Net.Http.StreamContent(mask); + __contentMask.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.Maskname is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.Maskname) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentMask, + name: "\"mask\"", + fileName: request.Maskname != null ? $"\"{request.Maskname}\"" : string.Empty); + if (__contentMask.Headers.ContentDisposition != null) + { + __contentMask.Headers.ContentDisposition.FileNameStar = null; + } + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), + name: "\"prompt\""); + + if (request.MagicPrompt != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.MagicPrompt).HasValue ? (request.MagicPrompt).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"magic_prompt\""); + + } + if (request.MagicPromptSystemPromptConfigId != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty), + name: "\"magic_prompt_system_prompt_config_id\""); + + } + if (request.NumImages != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"num_images\""); + + } + if (request.Seed != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"seed\""); + + } + if (request.RenderingSpeed != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"rendering_speed\""); + + } + if (request.StyleType != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.StyleType).HasValue ? (request.StyleType).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"style_type\""); + + } + if (request.StylePreset != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.StylePreset).HasValue ? (request.StylePreset).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"style_preset\""); + + } + if (request.CustomModelUri != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.CustomModelUri ?? string.Empty), + name: "\"custom_model_uri\""); + + } + if (request.ColorPalette != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.ColorPalette.ToString() ?? string.Empty), + name: "\"color_palette\""); + + } + if (request.StyleCodes != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.StyleCodes, x => x))}]"), + name: "\"style_codes\""); + + } + if (styleReferenceImages != default) + { + + for (var __iStyleReferenceImages = 0; __iStyleReferenceImages < styleReferenceImages.Count; __iStyleReferenceImages++) + { + var __fileNameStyleReferenceImages = styleReferenceImagesFileNames != null && + __iStyleReferenceImages < styleReferenceImagesFileNames.Count && + styleReferenceImagesFileNames[__iStyleReferenceImages] != null + ? styleReferenceImagesFileNames[__iStyleReferenceImages] + : $"file{__iStyleReferenceImages}.bin"; + var __contentStyleReferenceImages = new global::System.Net.Http.StreamContent(styleReferenceImages[__iStyleReferenceImages]); + __contentStyleReferenceImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + __fileNameStyleReferenceImages is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(__fileNameStyleReferenceImages) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentStyleReferenceImages, + name: "\"style_reference_images\"", + fileName: $"\"{__fileNameStyleReferenceImages}\""); + if (__contentStyleReferenceImages.Headers.ContentDisposition != null) + { + __contentStyleReferenceImages.Headers.ContentDisposition.FileNameStar = null; + } + } + + } + if (characterReferenceImages != default) + { + + for (var __iCharacterReferenceImages = 0; __iCharacterReferenceImages < characterReferenceImages.Count; __iCharacterReferenceImages++) + { + var __fileNameCharacterReferenceImages = characterReferenceImagesFileNames != null && + __iCharacterReferenceImages < characterReferenceImagesFileNames.Count && + characterReferenceImagesFileNames[__iCharacterReferenceImages] != null + ? characterReferenceImagesFileNames[__iCharacterReferenceImages] + : $"file{__iCharacterReferenceImages}.bin"; + var __contentCharacterReferenceImages = new global::System.Net.Http.StreamContent(characterReferenceImages[__iCharacterReferenceImages]); + __contentCharacterReferenceImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + __fileNameCharacterReferenceImages is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(__fileNameCharacterReferenceImages) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentCharacterReferenceImages, + name: "\"character_reference_images\"", + fileName: $"\"{__fileNameCharacterReferenceImages}\""); + if (__contentCharacterReferenceImages.Headers.ContentDisposition != null) + { + __contentCharacterReferenceImages.Headers.ContentDisposition.FileNameStar = null; + } + } + + } + if (characterReferenceImagesMask != default) + { + + for (var __iCharacterReferenceImagesMask = 0; __iCharacterReferenceImagesMask < characterReferenceImagesMask.Count; __iCharacterReferenceImagesMask++) + { + var __fileNameCharacterReferenceImagesMask = characterReferenceImagesMaskFileNames != null && + __iCharacterReferenceImagesMask < characterReferenceImagesMaskFileNames.Count && + characterReferenceImagesMaskFileNames[__iCharacterReferenceImagesMask] != null + ? characterReferenceImagesMaskFileNames[__iCharacterReferenceImagesMask] + : $"file{__iCharacterReferenceImagesMask}.bin"; + var __contentCharacterReferenceImagesMask = new global::System.Net.Http.StreamContent(characterReferenceImagesMask[__iCharacterReferenceImagesMask]); + __contentCharacterReferenceImagesMask.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + __fileNameCharacterReferenceImagesMask is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(__fileNameCharacterReferenceImagesMask) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentCharacterReferenceImagesMask, + name: "\"character_reference_images_mask\"", + fileName: $"\"{__fileNameCharacterReferenceImagesMask}\""); + if (__contentCharacterReferenceImagesMask.Headers.ContentDisposition != null) + { + __contentCharacterReferenceImagesMask.Headers.ContentDisposition.FileNameStar = null; + } + } + + } + + __httpRequest.Content = __httpRequestContent; + + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PreparePostInpaintImageV3Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostInpaintImageV3", + methodName: "PostInpaintImageV3Async", + pathTemplate: "\"/v1/ideogram-v3/inpaint\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostInpaintImageV3", + methodName: "PostInpaintImageV3Async", + pathTemplate: "\"/v1/ideogram-v3/inpaint\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostInpaintImageV3", + methodName: "PostInpaintImageV3Async", + pathTemplate: "\"/v1/ideogram-v3/inpaint\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessPostInpaintImageV3Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostInpaintImageV3", + methodName: "PostInpaintImageV3Async", + pathTemplate: "\"/v1/ideogram-v3/inpaint\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostInpaintImageV3", + methodName: "PostInpaintImageV3Async", + pathTemplate: "\"/v1/ideogram-v3/inpaint\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Prompt or Initial Image failed the safety checks. + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Ideogram.GenerateImageSafetyError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessPostInpaintImageV3ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + var __value = await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostLayerizeDesignV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostLayerizeDesignV3.g.cs index 02f4868..a980a39 100644 --- a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostLayerizeDesignV3.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostLayerizeDesignV3.g.cs @@ -54,6 +54,32 @@ partial void ProcessPostLayerizeDesignV3ResponseContent( /// public async global::System.Threading.Tasks.Task PostLayerizeDesignV3Async( + global::Ideogram.LayerizeDesignRequestV3 request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await PostLayerizeDesignV3AsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Layerize an existing flat graphic image with text detection and correction
+ /// Processes an existing flat graphic image to detect and correct text layers without generating a new image from scratch.
+ /// The uploaded image is analyzed for text content, which is then removed and returned as structured text layers with font matching, sizing, and color information.
+ /// Supported image formats include JPEG, PNG, and WebP (max size 10MB).
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> PostLayerizeDesignV3AsResponseAsync( + global::Ideogram.LayerizeDesignRequestV3 request, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) @@ -84,10 +110,11 @@ partial void ProcessPostLayerizeDesignV3ResponseContent( var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/v1/ideogram-v3/layerize-design", baseUri: HttpClient.BaseAddress); @@ -120,6 +147,7 @@ partial void ProcessPostLayerizeDesignV3ResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); var __contentFlatGraphicImage = new global::System.Net.Http.ByteArrayContent(request.FlatGraphicImage ?? global::System.Array.Empty()); __contentFlatGraphicImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( @@ -158,20 +186,23 @@ request.FlatGraphicImagename is null { __contentFlatGraphicImage.Headers.ContentDisposition.FileNameStar = null; } + if (request.Prompt != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), name: "\"prompt\""); - } + + } if (request.Seed != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), name: "\"seed\""); - } + + } if (request.FontFileH1 != default) { @@ -212,14 +243,16 @@ request.FontFileH1name is null { __contentFontFileH1.Headers.ContentDisposition.FileNameStar = null; } - } + + } if (request.FontNameH1 != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.FontNameH1 ?? string.Empty), name: "\"font_name_h1\""); - } + + } if (request.FontFileH2 != default) { @@ -260,14 +293,16 @@ request.FontFileH2name is null { __contentFontFileH2.Headers.ContentDisposition.FileNameStar = null; } - } + + } if (request.FontNameH2 != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.FontNameH2 ?? string.Empty), name: "\"font_name_h2\""); - } + + } if (request.FontFileBody != default) { @@ -308,14 +343,16 @@ request.FontFileBodyname is null { __contentFontFileBody.Headers.ContentDisposition.FileNameStar = null; } - } + + } if (request.FontNameBody != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.FontNameBody ?? string.Empty), name: "\"font_name_body\""); - } + + } if (request.FontFileSmall != default) { @@ -356,14 +393,16 @@ request.FontFileSmallname is null { __contentFontFileSmall.Headers.ContentDisposition.FileNameStar = null; } - } + + } if (request.FontNameSmall != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.FontNameSmall ?? string.Empty), name: "\"font_name_small\""); - } + + } if (request.ReferenceAssetImages != default) { @@ -380,8 +419,11 @@ request.FontFileSmallname is null __contentReferenceAssetImages.Headers.ContentDisposition.FileNameStar = null; } } + } + __httpRequest.Content = __httpRequestContent; + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -423,6 +465,8 @@ request.FontFileSmallname is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -433,6 +477,11 @@ request.FontFileSmallname is null } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -450,6 +499,8 @@ request.FontFileSmallname is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -459,8 +510,7 @@ request.FontFileSmallname is null __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -469,6 +519,11 @@ request.FontFileSmallname is null __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -485,14 +540,15 @@ request.FontFileSmallname is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -532,6 +588,8 @@ request.FontFileSmallname is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -552,6 +610,8 @@ request.FontFileSmallname is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -675,9 +735,13 @@ request.FontFileSmallname is null { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.LayeredImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.LayeredImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -705,9 +769,13 @@ request.FontFileSmallname is null #endif ).ConfigureAwait(false); - return - await global::Ideogram.LayeredImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.LayeredImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -855,5 +923,1736 @@ request.FontFileSmallname is null requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } + + /// + /// Layerize an existing flat graphic image with text detection and correction
+ /// Processes an existing flat graphic image to detect and correct text layers without generating a new image from scratch.
+ /// The uploaded image is analyzed for text content, which is then removed and returned as structured text layers with font matching, sizing, and color information.
+ /// Supported image formats include JPEG, PNG, and WebP (max size 10MB).
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// The flat graphic image to process for text detection and correction. The image should be in JPEG, PNG or WebP format (max size 10MB). + /// + /// + /// The flat graphic image to process for text detection and correction. The image should be in JPEG, PNG or WebP format (max size 10MB). + /// + /// + /// An optional prompt to describe the image. If not provided, a prompt will be auto-generated from the image via captioning. + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// + /// Custom font file for H1 (heading) text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_h1. + /// + /// + /// Custom font file for H1 (heading) text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_h1. + /// + /// + /// Font name from the available font library for H1 text. Ignored if font_file_h1 is provided.
+ /// Example: Ubuntu-Bold.ttf + /// + /// + /// Custom font file for H2 (subheading) text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_h2. + /// + /// + /// Custom font file for H2 (subheading) text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_h2. + /// + /// + /// Font name from the available font library for H2 text. Ignored if font_file_h2 is provided. + /// + /// + /// Custom font file for body text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_body. + /// + /// + /// Custom font file for body text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_body. + /// + /// + /// Font name from the available font library for body text. Ignored if font_file_body is provided. + /// + /// + /// Custom font file for small/caption text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_small. + /// + /// + /// Custom font file for small/caption text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_small. + /// + /// + /// Font name from the available font library for small text. Ignored if font_file_small is provided. + /// + /// + /// A set of asset images (e.g., logos, icons) to use as references for detection and replacement (maximum 10 images). The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'reference_asset_images' file parts. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task PostLayerizeDesignV3Async( + global::System.IO.Stream flatGraphicImage, + string flatGraphicImagename, + string? prompt = default, + int? seed = default, + global::System.IO.Stream? fontFileH1 = default, + string? fontFileH1name = default, + string? fontNameH1 = default, + global::System.IO.Stream? fontFileH2 = default, + string? fontFileH2name = default, + string? fontNameH2 = default, + global::System.IO.Stream? fontFileBody = default, + string? fontFileBodyname = default, + string? fontNameBody = default, + global::System.IO.Stream? fontFileSmall = default, + string? fontFileSmallname = default, + string? fontNameSmall = default, + global::System.Collections.Generic.IReadOnlyList? referenceAssetImages = default, + global::System.Collections.Generic.IReadOnlyList? referenceAssetImagesFileNames = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + flatGraphicImage = flatGraphicImage ?? throw new global::System.ArgumentNullException(nameof(flatGraphicImage)); + var request = new global::Ideogram.LayerizeDesignRequestV3 + { + FlatGraphicImage = global::System.Array.Empty(), + FlatGraphicImagename = flatGraphicImagename, + Prompt = prompt, + Seed = seed, + FontFileH1 = global::System.Array.Empty(), + FontFileH1name = fontFileH1name, + FontNameH1 = fontNameH1, + FontFileH2 = global::System.Array.Empty(), + FontFileH2name = fontFileH2name, + FontNameH2 = fontNameH2, + FontFileBody = global::System.Array.Empty(), + FontFileBodyname = fontFileBodyname, + FontNameBody = fontNameBody, + FontFileSmall = global::System.Array.Empty(), + FontFileSmallname = fontFileSmallname, + FontNameSmall = fontNameSmall, + ReferenceAssetImages = new global::System.Collections.Generic.List(), + }; + PrepareArguments( + client: HttpClient); + PreparePostLayerizeDesignV3Arguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_PostLayerizeDesignV3SecurityRequirements, + operationName: "PostLayerizeDesignV3Async"); + + using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Ideogram.PathBuilder( + path: "/v1/ideogram-v3/layerize-design", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + var __contentFlatGraphicImage = new global::System.Net.Http.StreamContent(flatGraphicImage); + __contentFlatGraphicImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.FlatGraphicImagename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.FlatGraphicImagename) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentFlatGraphicImage, + name: "\"flat_graphic_image\"", + fileName: request.FlatGraphicImagename != null ? $"\"{request.FlatGraphicImagename}\"" : string.Empty); + if (__contentFlatGraphicImage.Headers.ContentDisposition != null) + { + __contentFlatGraphicImage.Headers.ContentDisposition.FileNameStar = null; + } + + if (request.Prompt != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), + name: "\"prompt\""); + + } + if (request.Seed != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"seed\""); + + } + if (fontFileH1 != default) + { + + var __contentFontFileH1 = new global::System.Net.Http.StreamContent(fontFileH1); + __contentFontFileH1.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.FontFileH1name is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.FontFileH1name) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentFontFileH1, + name: "\"font_file_h1\"", + fileName: request.FontFileH1name != null ? $"\"{request.FontFileH1name}\"" : string.Empty); + if (__contentFontFileH1.Headers.ContentDisposition != null) + { + __contentFontFileH1.Headers.ContentDisposition.FileNameStar = null; + } + + } + if (request.FontNameH1 != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.FontNameH1 ?? string.Empty), + name: "\"font_name_h1\""); + + } + if (fontFileH2 != default) + { + + var __contentFontFileH2 = new global::System.Net.Http.StreamContent(fontFileH2); + __contentFontFileH2.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.FontFileH2name is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.FontFileH2name) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentFontFileH2, + name: "\"font_file_h2\"", + fileName: request.FontFileH2name != null ? $"\"{request.FontFileH2name}\"" : string.Empty); + if (__contentFontFileH2.Headers.ContentDisposition != null) + { + __contentFontFileH2.Headers.ContentDisposition.FileNameStar = null; + } + + } + if (request.FontNameH2 != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.FontNameH2 ?? string.Empty), + name: "\"font_name_h2\""); + + } + if (fontFileBody != default) + { + + var __contentFontFileBody = new global::System.Net.Http.StreamContent(fontFileBody); + __contentFontFileBody.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.FontFileBodyname is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.FontFileBodyname) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentFontFileBody, + name: "\"font_file_body\"", + fileName: request.FontFileBodyname != null ? $"\"{request.FontFileBodyname}\"" : string.Empty); + if (__contentFontFileBody.Headers.ContentDisposition != null) + { + __contentFontFileBody.Headers.ContentDisposition.FileNameStar = null; + } + + } + if (request.FontNameBody != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.FontNameBody ?? string.Empty), + name: "\"font_name_body\""); + + } + if (fontFileSmall != default) + { + + var __contentFontFileSmall = new global::System.Net.Http.StreamContent(fontFileSmall); + __contentFontFileSmall.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.FontFileSmallname is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.FontFileSmallname) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentFontFileSmall, + name: "\"font_file_small\"", + fileName: request.FontFileSmallname != null ? $"\"{request.FontFileSmallname}\"" : string.Empty); + if (__contentFontFileSmall.Headers.ContentDisposition != null) + { + __contentFontFileSmall.Headers.ContentDisposition.FileNameStar = null; + } + + } + if (request.FontNameSmall != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.FontNameSmall ?? string.Empty), + name: "\"font_name_small\""); + + } + if (referenceAssetImages != default) + { + + for (var __iReferenceAssetImages = 0; __iReferenceAssetImages < referenceAssetImages.Count; __iReferenceAssetImages++) + { + var __fileNameReferenceAssetImages = referenceAssetImagesFileNames != null && + __iReferenceAssetImages < referenceAssetImagesFileNames.Count && + referenceAssetImagesFileNames[__iReferenceAssetImages] != null + ? referenceAssetImagesFileNames[__iReferenceAssetImages] + : $"file{__iReferenceAssetImages}.bin"; + var __contentReferenceAssetImages = new global::System.Net.Http.StreamContent(referenceAssetImages[__iReferenceAssetImages]); + __contentReferenceAssetImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + __fileNameReferenceAssetImages is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(__fileNameReferenceAssetImages) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentReferenceAssetImages, + name: "\"reference_asset_images\"", + fileName: $"\"{__fileNameReferenceAssetImages}\""); + if (__contentReferenceAssetImages.Headers.ContentDisposition != null) + { + __contentReferenceAssetImages.Headers.ContentDisposition.FileNameStar = null; + } + } + + } + + __httpRequest.Content = __httpRequestContent; + + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PreparePostLayerizeDesignV3Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostLayerizeDesignV3", + methodName: "PostLayerizeDesignV3Async", + pathTemplate: "\"/v1/ideogram-v3/layerize-design\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostLayerizeDesignV3", + methodName: "PostLayerizeDesignV3Async", + pathTemplate: "\"/v1/ideogram-v3/layerize-design\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostLayerizeDesignV3", + methodName: "PostLayerizeDesignV3Async", + pathTemplate: "\"/v1/ideogram-v3/layerize-design\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessPostLayerizeDesignV3Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostLayerizeDesignV3", + methodName: "PostLayerizeDesignV3Async", + pathTemplate: "\"/v1/ideogram-v3/layerize-design\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostLayerizeDesignV3", + methodName: "PostLayerizeDesignV3Async", + pathTemplate: "\"/v1/ideogram-v3/layerize-design\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessPostLayerizeDesignV3ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Ideogram.LayeredImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Ideogram.LayeredImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Layerize an existing flat graphic image with text detection and correction
+ /// Processes an existing flat graphic image to detect and correct text layers without generating a new image from scratch.
+ /// The uploaded image is analyzed for text content, which is then removed and returned as structured text layers with font matching, sizing, and color information.
+ /// Supported image formats include JPEG, PNG, and WebP (max size 10MB).
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// The flat graphic image to process for text detection and correction. The image should be in JPEG, PNG or WebP format (max size 10MB). + /// + /// + /// The flat graphic image to process for text detection and correction. The image should be in JPEG, PNG or WebP format (max size 10MB). + /// + /// + /// An optional prompt to describe the image. If not provided, a prompt will be auto-generated from the image via captioning. + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// + /// Custom font file for H1 (heading) text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_h1. + /// + /// + /// Custom font file for H1 (heading) text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_h1. + /// + /// + /// Font name from the available font library for H1 text. Ignored if font_file_h1 is provided.
+ /// Example: Ubuntu-Bold.ttf + /// + /// + /// Custom font file for H2 (subheading) text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_h2. + /// + /// + /// Custom font file for H2 (subheading) text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_h2. + /// + /// + /// Font name from the available font library for H2 text. Ignored if font_file_h2 is provided. + /// + /// + /// Custom font file for body text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_body. + /// + /// + /// Custom font file for body text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_body. + /// + /// + /// Font name from the available font library for body text. Ignored if font_file_body is provided. + /// + /// + /// Custom font file for small/caption text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_small. + /// + /// + /// Custom font file for small/caption text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_small. + /// + /// + /// Font name from the available font library for small text. Ignored if font_file_small is provided. + /// + /// + /// A set of asset images (e.g., logos, icons) to use as references for detection and replacement (maximum 10 images). The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'reference_asset_images' file parts. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> PostLayerizeDesignV3AsResponseAsync( + global::System.IO.Stream flatGraphicImage, + string flatGraphicImagename, + string? prompt = default, + int? seed = default, + global::System.IO.Stream? fontFileH1 = default, + string? fontFileH1name = default, + string? fontNameH1 = default, + global::System.IO.Stream? fontFileH2 = default, + string? fontFileH2name = default, + string? fontNameH2 = default, + global::System.IO.Stream? fontFileBody = default, + string? fontFileBodyname = default, + string? fontNameBody = default, + global::System.IO.Stream? fontFileSmall = default, + string? fontFileSmallname = default, + string? fontNameSmall = default, + global::System.Collections.Generic.IReadOnlyList? referenceAssetImages = default, + global::System.Collections.Generic.IReadOnlyList? referenceAssetImagesFileNames = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + flatGraphicImage = flatGraphicImage ?? throw new global::System.ArgumentNullException(nameof(flatGraphicImage)); + var request = new global::Ideogram.LayerizeDesignRequestV3 + { + FlatGraphicImage = global::System.Array.Empty(), + FlatGraphicImagename = flatGraphicImagename, + Prompt = prompt, + Seed = seed, + FontFileH1 = global::System.Array.Empty(), + FontFileH1name = fontFileH1name, + FontNameH1 = fontNameH1, + FontFileH2 = global::System.Array.Empty(), + FontFileH2name = fontFileH2name, + FontNameH2 = fontNameH2, + FontFileBody = global::System.Array.Empty(), + FontFileBodyname = fontFileBodyname, + FontNameBody = fontNameBody, + FontFileSmall = global::System.Array.Empty(), + FontFileSmallname = fontFileSmallname, + FontNameSmall = fontNameSmall, + ReferenceAssetImages = new global::System.Collections.Generic.List(), + }; + PrepareArguments( + client: HttpClient); + PreparePostLayerizeDesignV3Arguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_PostLayerizeDesignV3SecurityRequirements, + operationName: "PostLayerizeDesignV3Async"); + + using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Ideogram.PathBuilder( + path: "/v1/ideogram-v3/layerize-design", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + var __contentFlatGraphicImage = new global::System.Net.Http.StreamContent(flatGraphicImage); + __contentFlatGraphicImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.FlatGraphicImagename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.FlatGraphicImagename) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentFlatGraphicImage, + name: "\"flat_graphic_image\"", + fileName: request.FlatGraphicImagename != null ? $"\"{request.FlatGraphicImagename}\"" : string.Empty); + if (__contentFlatGraphicImage.Headers.ContentDisposition != null) + { + __contentFlatGraphicImage.Headers.ContentDisposition.FileNameStar = null; + } + + if (request.Prompt != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), + name: "\"prompt\""); + + } + if (request.Seed != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"seed\""); + + } + if (fontFileH1 != default) + { + + var __contentFontFileH1 = new global::System.Net.Http.StreamContent(fontFileH1); + __contentFontFileH1.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.FontFileH1name is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.FontFileH1name) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentFontFileH1, + name: "\"font_file_h1\"", + fileName: request.FontFileH1name != null ? $"\"{request.FontFileH1name}\"" : string.Empty); + if (__contentFontFileH1.Headers.ContentDisposition != null) + { + __contentFontFileH1.Headers.ContentDisposition.FileNameStar = null; + } + + } + if (request.FontNameH1 != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.FontNameH1 ?? string.Empty), + name: "\"font_name_h1\""); + + } + if (fontFileH2 != default) + { + + var __contentFontFileH2 = new global::System.Net.Http.StreamContent(fontFileH2); + __contentFontFileH2.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.FontFileH2name is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.FontFileH2name) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentFontFileH2, + name: "\"font_file_h2\"", + fileName: request.FontFileH2name != null ? $"\"{request.FontFileH2name}\"" : string.Empty); + if (__contentFontFileH2.Headers.ContentDisposition != null) + { + __contentFontFileH2.Headers.ContentDisposition.FileNameStar = null; + } + + } + if (request.FontNameH2 != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.FontNameH2 ?? string.Empty), + name: "\"font_name_h2\""); + + } + if (fontFileBody != default) + { + + var __contentFontFileBody = new global::System.Net.Http.StreamContent(fontFileBody); + __contentFontFileBody.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.FontFileBodyname is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.FontFileBodyname) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentFontFileBody, + name: "\"font_file_body\"", + fileName: request.FontFileBodyname != null ? $"\"{request.FontFileBodyname}\"" : string.Empty); + if (__contentFontFileBody.Headers.ContentDisposition != null) + { + __contentFontFileBody.Headers.ContentDisposition.FileNameStar = null; + } + + } + if (request.FontNameBody != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.FontNameBody ?? string.Empty), + name: "\"font_name_body\""); + + } + if (fontFileSmall != default) + { + + var __contentFontFileSmall = new global::System.Net.Http.StreamContent(fontFileSmall); + __contentFontFileSmall.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.FontFileSmallname is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.FontFileSmallname) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentFontFileSmall, + name: "\"font_file_small\"", + fileName: request.FontFileSmallname != null ? $"\"{request.FontFileSmallname}\"" : string.Empty); + if (__contentFontFileSmall.Headers.ContentDisposition != null) + { + __contentFontFileSmall.Headers.ContentDisposition.FileNameStar = null; + } + + } + if (request.FontNameSmall != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.FontNameSmall ?? string.Empty), + name: "\"font_name_small\""); + + } + if (referenceAssetImages != default) + { + + for (var __iReferenceAssetImages = 0; __iReferenceAssetImages < referenceAssetImages.Count; __iReferenceAssetImages++) + { + var __fileNameReferenceAssetImages = referenceAssetImagesFileNames != null && + __iReferenceAssetImages < referenceAssetImagesFileNames.Count && + referenceAssetImagesFileNames[__iReferenceAssetImages] != null + ? referenceAssetImagesFileNames[__iReferenceAssetImages] + : $"file{__iReferenceAssetImages}.bin"; + var __contentReferenceAssetImages = new global::System.Net.Http.StreamContent(referenceAssetImages[__iReferenceAssetImages]); + __contentReferenceAssetImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + __fileNameReferenceAssetImages is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(__fileNameReferenceAssetImages) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentReferenceAssetImages, + name: "\"reference_asset_images\"", + fileName: $"\"{__fileNameReferenceAssetImages}\""); + if (__contentReferenceAssetImages.Headers.ContentDisposition != null) + { + __contentReferenceAssetImages.Headers.ContentDisposition.FileNameStar = null; + } + } + + } + + __httpRequest.Content = __httpRequestContent; + + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PreparePostLayerizeDesignV3Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostLayerizeDesignV3", + methodName: "PostLayerizeDesignV3Async", + pathTemplate: "\"/v1/ideogram-v3/layerize-design\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostLayerizeDesignV3", + methodName: "PostLayerizeDesignV3Async", + pathTemplate: "\"/v1/ideogram-v3/layerize-design\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostLayerizeDesignV3", + methodName: "PostLayerizeDesignV3Async", + pathTemplate: "\"/v1/ideogram-v3/layerize-design\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessPostLayerizeDesignV3Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostLayerizeDesignV3", + methodName: "PostLayerizeDesignV3Async", + pathTemplate: "\"/v1/ideogram-v3/layerize-design\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostLayerizeDesignV3", + methodName: "PostLayerizeDesignV3Async", + pathTemplate: "\"/v1/ideogram-v3/layerize-design\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessPostLayerizeDesignV3ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Ideogram.LayeredImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + var __value = await global::Ideogram.LayeredImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostLayerizeTextV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostLayerizeTextV3.g.cs index 43359a9..5b79ba3 100644 --- a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostLayerizeTextV3.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostLayerizeTextV3.g.cs @@ -54,6 +54,32 @@ partial void ProcessPostLayerizeTextV3ResponseContent( /// public async global::System.Threading.Tasks.Task PostLayerizeTextV3Async( + global::Ideogram.LayerizeTextRequest request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await PostLayerizeTextV3AsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Layerize Text
+ /// Analyzes an image to detect text regions, then returns each detected text block with its position, content, font information, and styling.
+ /// The response includes a text-erased base image (background with all text removed) and a flat list of detected text blocks.
+ /// Supported image formats include JPEG, PNG, and WebP (max size 10MB).
+ /// Image links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> PostLayerizeTextV3AsResponseAsync( + global::Ideogram.LayerizeTextRequest request, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) @@ -84,10 +110,11 @@ partial void ProcessPostLayerizeTextV3ResponseContent( var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/v1/ideogram-v3/layerize-text", baseUri: HttpClient.BaseAddress); @@ -120,6 +147,7 @@ partial void ProcessPostLayerizeTextV3ResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); var __contentImage = new global::System.Net.Http.ByteArrayContent(request.Image ?? global::System.Array.Empty()); __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( @@ -158,21 +186,26 @@ request.Imagename is null { __contentImage.Headers.ContentDisposition.FileNameStar = null; } + if (request.Prompt != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), name: "\"prompt\""); - } + + } if (request.Seed != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), name: "\"seed\""); + } + __httpRequest.Content = __httpRequestContent; + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -214,6 +247,8 @@ request.Imagename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -224,6 +259,11 @@ request.Imagename is null } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -241,6 +281,8 @@ request.Imagename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -250,8 +292,7 @@ request.Imagename is null __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -260,6 +301,11 @@ request.Imagename is null __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -276,14 +322,15 @@ request.Imagename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -323,6 +370,8 @@ request.Imagename is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -343,6 +392,8 @@ request.Imagename is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -466,9 +517,13 @@ request.Imagename is null { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.LayerizeTextResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.LayerizeTextResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -496,9 +551,13 @@ request.Imagename is null #endif ).ConfigureAwait(false); - return - await global::Ideogram.LayerizeTextResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.LayerizeTextResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -580,5 +639,1096 @@ request.Imagename is null requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } + + /// + /// Layerize Text
+ /// Analyzes an image to detect text regions, then returns each detected text block with its position, content, font information, and styling.
+ /// The response includes a text-erased base image (background with all text removed) and a flat list of detected text blocks.
+ /// Supported image formats include JPEG, PNG, and WebP (max size 10MB).
+ /// Image links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// The image to analyze for text detection. The image should be in JPEG, PNG, or WebP format (max size 10MB). + /// + /// + /// The image to analyze for text detection. The image should be in JPEG, PNG, or WebP format (max size 10MB). + /// + /// + /// An optional text description of the image. If not provided, a description will be auto-generated from the image. + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task PostLayerizeTextV3Async( + global::System.IO.Stream image, + string imagename, + string? prompt = default, + int? seed = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + image = image ?? throw new global::System.ArgumentNullException(nameof(image)); + var request = new global::Ideogram.LayerizeTextRequest + { + Image = global::System.Array.Empty(), + Imagename = imagename, + Prompt = prompt, + Seed = seed, + }; + PrepareArguments( + client: HttpClient); + PreparePostLayerizeTextV3Arguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_PostLayerizeTextV3SecurityRequirements, + operationName: "PostLayerizeTextV3Async"); + + using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Ideogram.PathBuilder( + path: "/v1/ideogram-v3/layerize-text", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + var __contentImage = new global::System.Net.Http.StreamContent(image); + __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.Imagename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentImage, + name: "\"image\"", + fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty); + if (__contentImage.Headers.ContentDisposition != null) + { + __contentImage.Headers.ContentDisposition.FileNameStar = null; + } + + if (request.Prompt != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), + name: "\"prompt\""); + + } + if (request.Seed != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"seed\""); + + } + + __httpRequest.Content = __httpRequestContent; + + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PreparePostLayerizeTextV3Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostLayerizeTextV3", + methodName: "PostLayerizeTextV3Async", + pathTemplate: "\"/v1/ideogram-v3/layerize-text\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostLayerizeTextV3", + methodName: "PostLayerizeTextV3Async", + pathTemplate: "\"/v1/ideogram-v3/layerize-text\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostLayerizeTextV3", + methodName: "PostLayerizeTextV3Async", + pathTemplate: "\"/v1/ideogram-v3/layerize-text\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessPostLayerizeTextV3Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostLayerizeTextV3", + methodName: "PostLayerizeTextV3Async", + pathTemplate: "\"/v1/ideogram-v3/layerize-text\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostLayerizeTextV3", + methodName: "PostLayerizeTextV3Async", + pathTemplate: "\"/v1/ideogram-v3/layerize-text\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessPostLayerizeTextV3ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Ideogram.LayerizeTextResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Ideogram.LayerizeTextResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Layerize Text
+ /// Analyzes an image to detect text regions, then returns each detected text block with its position, content, font information, and styling.
+ /// The response includes a text-erased base image (background with all text removed) and a flat list of detected text blocks.
+ /// Supported image formats include JPEG, PNG, and WebP (max size 10MB).
+ /// Image links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// The image to analyze for text detection. The image should be in JPEG, PNG, or WebP format (max size 10MB). + /// + /// + /// The image to analyze for text detection. The image should be in JPEG, PNG, or WebP format (max size 10MB). + /// + /// + /// An optional text description of the image. If not provided, a description will be auto-generated from the image. + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> PostLayerizeTextV3AsResponseAsync( + global::System.IO.Stream image, + string imagename, + string? prompt = default, + int? seed = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + image = image ?? throw new global::System.ArgumentNullException(nameof(image)); + var request = new global::Ideogram.LayerizeTextRequest + { + Image = global::System.Array.Empty(), + Imagename = imagename, + Prompt = prompt, + Seed = seed, + }; + PrepareArguments( + client: HttpClient); + PreparePostLayerizeTextV3Arguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_PostLayerizeTextV3SecurityRequirements, + operationName: "PostLayerizeTextV3Async"); + + using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Ideogram.PathBuilder( + path: "/v1/ideogram-v3/layerize-text", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + var __contentImage = new global::System.Net.Http.StreamContent(image); + __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.Imagename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentImage, + name: "\"image\"", + fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty); + if (__contentImage.Headers.ContentDisposition != null) + { + __contentImage.Headers.ContentDisposition.FileNameStar = null; + } + + if (request.Prompt != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), + name: "\"prompt\""); + + } + if (request.Seed != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"seed\""); + + } + + __httpRequest.Content = __httpRequestContent; + + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PreparePostLayerizeTextV3Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostLayerizeTextV3", + methodName: "PostLayerizeTextV3Async", + pathTemplate: "\"/v1/ideogram-v3/layerize-text\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostLayerizeTextV3", + methodName: "PostLayerizeTextV3Async", + pathTemplate: "\"/v1/ideogram-v3/layerize-text\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostLayerizeTextV3", + methodName: "PostLayerizeTextV3Async", + pathTemplate: "\"/v1/ideogram-v3/layerize-text\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessPostLayerizeTextV3Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostLayerizeTextV3", + methodName: "PostLayerizeTextV3Async", + pathTemplate: "\"/v1/ideogram-v3/layerize-text\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostLayerizeTextV3", + methodName: "PostLayerizeTextV3Async", + pathTemplate: "\"/v1/ideogram-v3/layerize-text\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessPostLayerizeTextV3ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Ideogram.LayerizeTextResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + var __value = await global::Ideogram.LayerizeTextResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostReframeImage.g.cs b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostReframeImage.g.cs index 41aeea2..04378c3 100644 --- a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostReframeImage.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostReframeImage.g.cs @@ -52,6 +52,30 @@ partial void ProcessPostReframeImageResponseContent( /// public async global::System.Threading.Tasks.Task PostReframeImageAsync( + global::Ideogram.ReframeImageRequest request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await PostReframeImageAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Reframe (legacy)
+ /// Reframe a square image to a chosen resolution. The supported image formats include JPEG, PNG, and WebP.
+ /// Image links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> PostReframeImageAsResponseAsync( + global::Ideogram.ReframeImageRequest request, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) @@ -82,10 +106,11 @@ partial void ProcessPostReframeImageResponseContent( var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/reframe", baseUri: HttpClient.BaseAddress); @@ -118,6 +143,7 @@ partial void ProcessPostReframeImageResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); var __contentImageFile = new global::System.Net.Http.ByteArrayContent(request.ImageFile ?? global::System.Array.Empty()); __contentImageFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( @@ -156,34 +182,42 @@ request.ImageFilename is null { __contentImageFile.Headers.ContentDisposition.FileNameStar = null; } + __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.Resolution.ToValueString()), name: "\"resolution\""); + __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.Model.ToValueString()), name: "\"model\""); + if (request.NumImages != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), name: "\"num_images\""); - } + + } if (request.Seed != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), name: "\"seed\""); - } + + } if (request.StyleType != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.StyleType).HasValue ? (request.StyleType).GetValueOrDefault().ToValueString() : string.Empty), name: "\"style_type\""); + } + __httpRequest.Content = __httpRequestContent; + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -225,6 +259,8 @@ request.ImageFilename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -235,6 +271,11 @@ request.ImageFilename is null } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -252,6 +293,8 @@ request.ImageFilename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -261,8 +304,7 @@ request.ImageFilename is null __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -271,6 +313,11 @@ request.ImageFilename is null __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -287,14 +334,15 @@ request.ImageFilename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -334,6 +382,8 @@ request.ImageFilename is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -354,6 +404,8 @@ request.ImageFilename is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -515,9 +567,13 @@ request.ImageFilename is null { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -545,9 +601,13 @@ request.ImageFilename is null #endif ).ConfigureAwait(false); - return - await global::Ideogram.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -647,5 +707,1240 @@ request.ImageFilename is null requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } + + /// + /// Reframe (legacy)
+ /// Reframe a square image to a chosen resolution. The supported image formats include JPEG, PNG, and WebP.
+ /// Image links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// The image being reframed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The image being reframed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// (For model_version for 2.0 only, cannot be used in conjunction with aspect_ratio) The resolution to use for image generation, represented in width x height. If not specified, defaults to using aspect_ratio.
+ /// Example: RESOLUTION_1024_1024 + /// + /// + /// The model used to generate an image or edit one. /generate and /remix supports all model types, however, /edit is only supported for V_2 and V_2_TURBO.
+ /// Default Value: V_2
+ /// Example: V_2_TURBO + /// + /// + /// The number of images to generate.
+ /// Default Value: 1 + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// + /// The style type to generate with; this is only applicable for models V_2 and above and should not be specified for model versions V_1.
+ /// Example: REALISTIC + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task PostReframeImageAsync( + global::System.IO.Stream imageFile, + string imageFilename, + global::Ideogram.Resolution resolution, + global::Ideogram.ModelEnum model = global::Ideogram.ModelEnum.V2, + int? numImages = default, + int? seed = default, + global::Ideogram.StyleType? styleType = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + imageFile = imageFile ?? throw new global::System.ArgumentNullException(nameof(imageFile)); + var request = new global::Ideogram.ReframeImageRequest + { + ImageFile = global::System.Array.Empty(), + ImageFilename = imageFilename, + Resolution = resolution, + Model = model, + NumImages = numImages, + Seed = seed, + StyleType = styleType, + }; + PrepareArguments( + client: HttpClient); + PreparePostReframeImageArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_PostReframeImageSecurityRequirements, + operationName: "PostReframeImageAsync"); + + using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Ideogram.PathBuilder( + path: "/reframe", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + var __contentImageFile = new global::System.Net.Http.StreamContent(imageFile); + __contentImageFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.ImageFilename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.ImageFilename) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentImageFile, + name: "\"image_file\"", + fileName: request.ImageFilename != null ? $"\"{request.ImageFilename}\"" : string.Empty); + if (__contentImageFile.Headers.ContentDisposition != null) + { + __contentImageFile.Headers.ContentDisposition.FileNameStar = null; + } + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Resolution.ToValueString()), + name: "\"resolution\""); + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Model.ToValueString()), + name: "\"model\""); + + if (request.NumImages != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"num_images\""); + + } + if (request.Seed != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"seed\""); + + } + if (request.StyleType != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.StyleType).HasValue ? (request.StyleType).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"style_type\""); + + } + + __httpRequest.Content = __httpRequestContent; + + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PreparePostReframeImageRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostReframeImage", + methodName: "PostReframeImageAsync", + pathTemplate: "\"/reframe\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostReframeImage", + methodName: "PostReframeImageAsync", + pathTemplate: "\"/reframe\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostReframeImage", + methodName: "PostReframeImageAsync", + pathTemplate: "\"/reframe\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessPostReframeImageResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostReframeImage", + methodName: "PostReframeImageAsync", + pathTemplate: "\"/reframe\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostReframeImage", + methodName: "PostReframeImageAsync", + pathTemplate: "\"/reframe\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Prompt or Image failed the safety checks. + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Ideogram.GenerateImageSafetyError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessPostReframeImageResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Ideogram.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Ideogram.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Reframe (legacy)
+ /// Reframe a square image to a chosen resolution. The supported image formats include JPEG, PNG, and WebP.
+ /// Image links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// The image being reframed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The image being reframed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// (For model_version for 2.0 only, cannot be used in conjunction with aspect_ratio) The resolution to use for image generation, represented in width x height. If not specified, defaults to using aspect_ratio.
+ /// Example: RESOLUTION_1024_1024 + /// + /// + /// The model used to generate an image or edit one. /generate and /remix supports all model types, however, /edit is only supported for V_2 and V_2_TURBO.
+ /// Default Value: V_2
+ /// Example: V_2_TURBO + /// + /// + /// The number of images to generate.
+ /// Default Value: 1 + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// + /// The style type to generate with; this is only applicable for models V_2 and above and should not be specified for model versions V_1.
+ /// Example: REALISTIC + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> PostReframeImageAsResponseAsync( + global::System.IO.Stream imageFile, + string imageFilename, + global::Ideogram.Resolution resolution, + global::Ideogram.ModelEnum model = global::Ideogram.ModelEnum.V2, + int? numImages = default, + int? seed = default, + global::Ideogram.StyleType? styleType = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + imageFile = imageFile ?? throw new global::System.ArgumentNullException(nameof(imageFile)); + var request = new global::Ideogram.ReframeImageRequest + { + ImageFile = global::System.Array.Empty(), + ImageFilename = imageFilename, + Resolution = resolution, + Model = model, + NumImages = numImages, + Seed = seed, + StyleType = styleType, + }; + PrepareArguments( + client: HttpClient); + PreparePostReframeImageArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_PostReframeImageSecurityRequirements, + operationName: "PostReframeImageAsync"); + + using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Ideogram.PathBuilder( + path: "/reframe", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + var __contentImageFile = new global::System.Net.Http.StreamContent(imageFile); + __contentImageFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.ImageFilename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.ImageFilename) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentImageFile, + name: "\"image_file\"", + fileName: request.ImageFilename != null ? $"\"{request.ImageFilename}\"" : string.Empty); + if (__contentImageFile.Headers.ContentDisposition != null) + { + __contentImageFile.Headers.ContentDisposition.FileNameStar = null; + } + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Resolution.ToValueString()), + name: "\"resolution\""); + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Model.ToValueString()), + name: "\"model\""); + + if (request.NumImages != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"num_images\""); + + } + if (request.Seed != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"seed\""); + + } + if (request.StyleType != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.StyleType).HasValue ? (request.StyleType).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"style_type\""); + + } + + __httpRequest.Content = __httpRequestContent; + + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PreparePostReframeImageRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostReframeImage", + methodName: "PostReframeImageAsync", + pathTemplate: "\"/reframe\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostReframeImage", + methodName: "PostReframeImageAsync", + pathTemplate: "\"/reframe\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostReframeImage", + methodName: "PostReframeImageAsync", + pathTemplate: "\"/reframe\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessPostReframeImageResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostReframeImage", + methodName: "PostReframeImageAsync", + pathTemplate: "\"/reframe\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostReframeImage", + methodName: "PostReframeImageAsync", + pathTemplate: "\"/reframe\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Prompt or Image failed the safety checks. + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Ideogram.GenerateImageSafetyError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessPostReframeImageResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Ideogram.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + var __value = await global::Ideogram.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostReframeImageV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostReframeImageV3.g.cs index eb523a9..29a338b 100644 --- a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostReframeImageV3.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostReframeImageV3.g.cs @@ -52,6 +52,30 @@ partial void ProcessPostReframeImageV3ResponseContent( /// public async global::System.Threading.Tasks.Task PostReframeImageV3Async( + global::Ideogram.ReframeImageRequestV3 request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await PostReframeImageV3AsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Reframe with Ideogram 3.0
+ /// Reframe a square image to a chosen resolution with Ideogram 3.0. The supported image formats include JPEG, PNG, and WebP.
+ /// Image links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> PostReframeImageV3AsResponseAsync( + global::Ideogram.ReframeImageRequestV3 request, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) @@ -82,10 +106,11 @@ partial void ProcessPostReframeImageV3ResponseContent( var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/v1/ideogram-v3/reframe", baseUri: HttpClient.BaseAddress); @@ -118,6 +143,7 @@ partial void ProcessPostReframeImageV3ResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); var __contentImage = new global::System.Net.Http.ByteArrayContent(request.Image ?? global::System.Array.Empty()); __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( @@ -156,51 +182,59 @@ request.Imagename is null { __contentImage.Headers.ContentDisposition.FileNameStar = null; } + __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.Resolution.ToValueString()), name: "\"resolution\""); + if (request.NumImages != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), name: "\"num_images\""); - } + + } if (request.Seed != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), name: "\"seed\""); - } + + } if (request.RenderingSpeed != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty), name: "\"rendering_speed\""); - } + + } if (request.StylePreset != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.StylePreset).HasValue ? (request.StylePreset).GetValueOrDefault().ToValueString() : string.Empty), name: "\"style_preset\""); - } + + } if (request.ColorPalette != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.ColorPalette.ToString() ?? string.Empty), name: "\"color_palette\""); - } + + } if (request.StyleCodes != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.StyleCodes, x => x))}]"), name: "\"style_codes\""); - } + + } if (request.StyleReferenceImages != default) { @@ -217,8 +251,11 @@ request.Imagename is null __contentStyleReferenceImages.Headers.ContentDisposition.FileNameStar = null; } } + } + __httpRequest.Content = __httpRequestContent; + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -260,6 +297,8 @@ request.Imagename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -270,6 +309,11 @@ request.Imagename is null } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -287,6 +331,8 @@ request.Imagename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -296,8 +342,7 @@ request.Imagename is null __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -306,6 +351,11 @@ request.Imagename is null __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -322,14 +372,15 @@ request.Imagename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -369,6 +420,8 @@ request.Imagename is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -389,6 +442,8 @@ request.Imagename is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -550,9 +605,13 @@ request.Imagename is null { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -580,9 +639,13 @@ request.Imagename is null #endif ).ConfigureAwait(false); - return - await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -697,5 +760,1418 @@ request.Imagename is null requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } + + /// + /// Reframe with Ideogram 3.0
+ /// Reframe a square image to a chosen resolution with Ideogram 3.0. The supported image formats include JPEG, PNG, and WebP.
+ /// Image links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// The image being reframed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The image being reframed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The resolutions supported for Ideogram 3.0.
+ /// Example: 1280x800 + /// + /// + /// The number of images to generate.
+ /// Default Value: 1 + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// + /// The rendering speed to use.
+ /// Default Value: DEFAULT + /// + /// + /// A predefined style preset that applies a specific artistic style to the generated image.
+ /// Example: BRIGHT_ART + /// + /// + /// A color palette for generation, must EITHER be specified via one of the presets (name) or explicitly via hexadecimal representations of the color with optional weights (members). Not supported by V_1, V_1_TURBO, V_2A and V_2A_TURBO models. + /// + /// + /// A list of 8 character hexadecimal codes representing the style of the image. Cannot be used in conjunction with style_reference_images or style_type.
+ /// Example: [AAFF5733, 0133FF57, DE3357FF] + /// + /// + /// A set of images to use as style references (maximum total size 10MB across all style references). The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'style_reference_images' file parts. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task PostReframeImageV3Async( + global::System.IO.Stream image, + string imagename, + global::Ideogram.ResolutionV3 resolution, + int? numImages = default, + int? seed = default, + global::Ideogram.RenderingSpeed? renderingSpeed = default, + global::Ideogram.StylePresetV3? stylePreset = default, + global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette = default, + global::System.Collections.Generic.IList? styleCodes = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImages = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImagesFileNames = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + image = image ?? throw new global::System.ArgumentNullException(nameof(image)); + var request = new global::Ideogram.ReframeImageRequestV3 + { + Image = global::System.Array.Empty(), + Imagename = imagename, + Resolution = resolution, + NumImages = numImages, + Seed = seed, + RenderingSpeed = renderingSpeed, + StylePreset = stylePreset, + ColorPalette = colorPalette, + StyleCodes = styleCodes, + StyleReferenceImages = new global::System.Collections.Generic.List(), + }; + PrepareArguments( + client: HttpClient); + PreparePostReframeImageV3Arguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_PostReframeImageV3SecurityRequirements, + operationName: "PostReframeImageV3Async"); + + using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Ideogram.PathBuilder( + path: "/v1/ideogram-v3/reframe", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + var __contentImage = new global::System.Net.Http.StreamContent(image); + __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.Imagename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentImage, + name: "\"image\"", + fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty); + if (__contentImage.Headers.ContentDisposition != null) + { + __contentImage.Headers.ContentDisposition.FileNameStar = null; + } + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Resolution.ToValueString()), + name: "\"resolution\""); + + if (request.NumImages != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"num_images\""); + + } + if (request.Seed != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"seed\""); + + } + if (request.RenderingSpeed != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"rendering_speed\""); + + } + if (request.StylePreset != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.StylePreset).HasValue ? (request.StylePreset).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"style_preset\""); + + } + if (request.ColorPalette != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.ColorPalette.ToString() ?? string.Empty), + name: "\"color_palette\""); + + } + if (request.StyleCodes != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.StyleCodes, x => x))}]"), + name: "\"style_codes\""); + + } + if (styleReferenceImages != default) + { + + for (var __iStyleReferenceImages = 0; __iStyleReferenceImages < styleReferenceImages.Count; __iStyleReferenceImages++) + { + var __fileNameStyleReferenceImages = styleReferenceImagesFileNames != null && + __iStyleReferenceImages < styleReferenceImagesFileNames.Count && + styleReferenceImagesFileNames[__iStyleReferenceImages] != null + ? styleReferenceImagesFileNames[__iStyleReferenceImages] + : $"file{__iStyleReferenceImages}.bin"; + var __contentStyleReferenceImages = new global::System.Net.Http.StreamContent(styleReferenceImages[__iStyleReferenceImages]); + __contentStyleReferenceImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + __fileNameStyleReferenceImages is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(__fileNameStyleReferenceImages) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentStyleReferenceImages, + name: "\"style_reference_images\"", + fileName: $"\"{__fileNameStyleReferenceImages}\""); + if (__contentStyleReferenceImages.Headers.ContentDisposition != null) + { + __contentStyleReferenceImages.Headers.ContentDisposition.FileNameStar = null; + } + } + + } + + __httpRequest.Content = __httpRequestContent; + + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PreparePostReframeImageV3Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostReframeImageV3", + methodName: "PostReframeImageV3Async", + pathTemplate: "\"/v1/ideogram-v3/reframe\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostReframeImageV3", + methodName: "PostReframeImageV3Async", + pathTemplate: "\"/v1/ideogram-v3/reframe\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostReframeImageV3", + methodName: "PostReframeImageV3Async", + pathTemplate: "\"/v1/ideogram-v3/reframe\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessPostReframeImageV3Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostReframeImageV3", + methodName: "PostReframeImageV3Async", + pathTemplate: "\"/v1/ideogram-v3/reframe\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostReframeImageV3", + methodName: "PostReframeImageV3Async", + pathTemplate: "\"/v1/ideogram-v3/reframe\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Prompt or Image failed the safety checks. + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Ideogram.GenerateImageSafetyError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessPostReframeImageV3ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Reframe with Ideogram 3.0
+ /// Reframe a square image to a chosen resolution with Ideogram 3.0. The supported image formats include JPEG, PNG, and WebP.
+ /// Image links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// The image being reframed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The image being reframed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The resolutions supported for Ideogram 3.0.
+ /// Example: 1280x800 + /// + /// + /// The number of images to generate.
+ /// Default Value: 1 + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// + /// The rendering speed to use.
+ /// Default Value: DEFAULT + /// + /// + /// A predefined style preset that applies a specific artistic style to the generated image.
+ /// Example: BRIGHT_ART + /// + /// + /// A color palette for generation, must EITHER be specified via one of the presets (name) or explicitly via hexadecimal representations of the color with optional weights (members). Not supported by V_1, V_1_TURBO, V_2A and V_2A_TURBO models. + /// + /// + /// A list of 8 character hexadecimal codes representing the style of the image. Cannot be used in conjunction with style_reference_images or style_type.
+ /// Example: [AAFF5733, 0133FF57, DE3357FF] + /// + /// + /// A set of images to use as style references (maximum total size 10MB across all style references). The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'style_reference_images' file parts. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> PostReframeImageV3AsResponseAsync( + global::System.IO.Stream image, + string imagename, + global::Ideogram.ResolutionV3 resolution, + int? numImages = default, + int? seed = default, + global::Ideogram.RenderingSpeed? renderingSpeed = default, + global::Ideogram.StylePresetV3? stylePreset = default, + global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette = default, + global::System.Collections.Generic.IList? styleCodes = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImages = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImagesFileNames = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + image = image ?? throw new global::System.ArgumentNullException(nameof(image)); + var request = new global::Ideogram.ReframeImageRequestV3 + { + Image = global::System.Array.Empty(), + Imagename = imagename, + Resolution = resolution, + NumImages = numImages, + Seed = seed, + RenderingSpeed = renderingSpeed, + StylePreset = stylePreset, + ColorPalette = colorPalette, + StyleCodes = styleCodes, + StyleReferenceImages = new global::System.Collections.Generic.List(), + }; + PrepareArguments( + client: HttpClient); + PreparePostReframeImageV3Arguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_PostReframeImageV3SecurityRequirements, + operationName: "PostReframeImageV3Async"); + + using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Ideogram.PathBuilder( + path: "/v1/ideogram-v3/reframe", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + var __contentImage = new global::System.Net.Http.StreamContent(image); + __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.Imagename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentImage, + name: "\"image\"", + fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty); + if (__contentImage.Headers.ContentDisposition != null) + { + __contentImage.Headers.ContentDisposition.FileNameStar = null; + } + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Resolution.ToValueString()), + name: "\"resolution\""); + + if (request.NumImages != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"num_images\""); + + } + if (request.Seed != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"seed\""); + + } + if (request.RenderingSpeed != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"rendering_speed\""); + + } + if (request.StylePreset != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.StylePreset).HasValue ? (request.StylePreset).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"style_preset\""); + + } + if (request.ColorPalette != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.ColorPalette.ToString() ?? string.Empty), + name: "\"color_palette\""); + + } + if (request.StyleCodes != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.StyleCodes, x => x))}]"), + name: "\"style_codes\""); + + } + if (styleReferenceImages != default) + { + + for (var __iStyleReferenceImages = 0; __iStyleReferenceImages < styleReferenceImages.Count; __iStyleReferenceImages++) + { + var __fileNameStyleReferenceImages = styleReferenceImagesFileNames != null && + __iStyleReferenceImages < styleReferenceImagesFileNames.Count && + styleReferenceImagesFileNames[__iStyleReferenceImages] != null + ? styleReferenceImagesFileNames[__iStyleReferenceImages] + : $"file{__iStyleReferenceImages}.bin"; + var __contentStyleReferenceImages = new global::System.Net.Http.StreamContent(styleReferenceImages[__iStyleReferenceImages]); + __contentStyleReferenceImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + __fileNameStyleReferenceImages is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(__fileNameStyleReferenceImages) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentStyleReferenceImages, + name: "\"style_reference_images\"", + fileName: $"\"{__fileNameStyleReferenceImages}\""); + if (__contentStyleReferenceImages.Headers.ContentDisposition != null) + { + __contentStyleReferenceImages.Headers.ContentDisposition.FileNameStar = null; + } + } + + } + + __httpRequest.Content = __httpRequestContent; + + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PreparePostReframeImageV3Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostReframeImageV3", + methodName: "PostReframeImageV3Async", + pathTemplate: "\"/v1/ideogram-v3/reframe\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostReframeImageV3", + methodName: "PostReframeImageV3Async", + pathTemplate: "\"/v1/ideogram-v3/reframe\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostReframeImageV3", + methodName: "PostReframeImageV3Async", + pathTemplate: "\"/v1/ideogram-v3/reframe\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessPostReframeImageV3Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostReframeImageV3", + methodName: "PostReframeImageV3Async", + pathTemplate: "\"/v1/ideogram-v3/reframe\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostReframeImageV3", + methodName: "PostReframeImageV3Async", + pathTemplate: "\"/v1/ideogram-v3/reframe\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Prompt or Image failed the safety checks. + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Ideogram.GenerateImageSafetyError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessPostReframeImageV3ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + var __value = await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostRemixImage.g.cs b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostRemixImage.g.cs index 6bd933f..d3e3055 100644 --- a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostRemixImage.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostRemixImage.g.cs @@ -54,6 +54,32 @@ partial void ProcessPostRemixImageResponseContent( /// public async global::System.Threading.Tasks.Task PostRemixImageAsync( + global::Ideogram.RemixImageRequest request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await PostRemixImageAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Remix (legacy)
+ /// Remix provided images synchronously based on a given prompt and optional parameters.
+ /// Input images are cropped to the chosen aspect ratio before being remixed.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> PostRemixImageAsResponseAsync( + global::Ideogram.RemixImageRequest request, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) @@ -84,10 +110,11 @@ partial void ProcessPostRemixImageResponseContent( var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/remix", baseUri: HttpClient.BaseAddress); @@ -120,10 +147,12 @@ partial void ProcessPostRemixImageResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.ImageRequest.ToJson(JsonSerializerContext)), name: "\"image_request\""); + var __contentImageFile = new global::System.Net.Http.ByteArrayContent(request.ImageFile ?? global::System.Array.Empty()); __contentImageFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( request.ImageFilename is null @@ -161,7 +190,9 @@ request.ImageFilename is null { __contentImageFile.Headers.ContentDisposition.FileNameStar = null; } + __httpRequest.Content = __httpRequestContent; + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -203,6 +234,8 @@ request.ImageFilename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -213,6 +246,11 @@ request.ImageFilename is null } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -230,6 +268,8 @@ request.ImageFilename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -239,8 +279,7 @@ request.ImageFilename is null __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -249,6 +288,11 @@ request.ImageFilename is null __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -265,14 +309,15 @@ request.ImageFilename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -312,6 +357,8 @@ request.ImageFilename is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -332,6 +379,8 @@ request.ImageFilename is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -493,9 +542,13 @@ request.ImageFilename is null { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -523,9 +576,13 @@ request.ImageFilename is null #endif ).ConfigureAwait(false); - return - await global::Ideogram.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -602,5 +659,1136 @@ request.ImageFilename is null requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } + + /// + /// Remix (legacy)
+ /// Remix provided images synchronously based on a given prompt and optional parameters.
+ /// Input images are cropped to the chosen aspect ratio before being remixed.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// A request to generate a new image using a provided image and a prompt.
+ /// Example: {"aspect_ratio":"ASPECT_10_16","magic_prompt_option":"ON","model":"V_2","prompt":"A serene tropical beach scene. Dominating the foreground are tall palm trees with lush green leaves, standing tall against a backdrop of a sandy beach. The beach leads to the azure waters of the sea, which gently kisses the shoreline. In the distance, there is an island or landmass with a silhouette of what appears to be a lighthouse or tower. The sky above is painted with fluffy white clouds, some of which are tinged with hues of pink and orange, suggesting either a sunrise or sunset.","image_weight":50} + /// + /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task PostRemixImageAsync( + global::Ideogram.InitialImageRequest imageRequest, + global::System.IO.Stream imageFile, + string imageFilename, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + imageFile = imageFile ?? throw new global::System.ArgumentNullException(nameof(imageFile)); + var request = new global::Ideogram.RemixImageRequest + { + ImageRequest = imageRequest, + ImageFile = global::System.Array.Empty(), + ImageFilename = imageFilename, + }; + PrepareArguments( + client: HttpClient); + PreparePostRemixImageArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_PostRemixImageSecurityRequirements, + operationName: "PostRemixImageAsync"); + + using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Ideogram.PathBuilder( + path: "/remix", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.ImageRequest.ToJson(JsonSerializerContext)), + name: "\"image_request\""); + + var __contentImageFile = new global::System.Net.Http.StreamContent(imageFile); + __contentImageFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.ImageFilename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.ImageFilename) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentImageFile, + name: "\"image_file\"", + fileName: request.ImageFilename != null ? $"\"{request.ImageFilename}\"" : string.Empty); + if (__contentImageFile.Headers.ContentDisposition != null) + { + __contentImageFile.Headers.ContentDisposition.FileNameStar = null; + } + + __httpRequest.Content = __httpRequestContent; + + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PreparePostRemixImageRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostRemixImage", + methodName: "PostRemixImageAsync", + pathTemplate: "\"/remix\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostRemixImage", + methodName: "PostRemixImageAsync", + pathTemplate: "\"/remix\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostRemixImage", + methodName: "PostRemixImageAsync", + pathTemplate: "\"/remix\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessPostRemixImageResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostRemixImage", + methodName: "PostRemixImageAsync", + pathTemplate: "\"/remix\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostRemixImage", + methodName: "PostRemixImageAsync", + pathTemplate: "\"/remix\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Prompt or provided image failed safety check. + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Ideogram.GenerateImageSafetyError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessPostRemixImageResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Ideogram.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Ideogram.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Remix (legacy)
+ /// Remix provided images synchronously based on a given prompt and optional parameters.
+ /// Input images are cropped to the chosen aspect ratio before being remixed.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// A request to generate a new image using a provided image and a prompt.
+ /// Example: {"aspect_ratio":"ASPECT_10_16","magic_prompt_option":"ON","model":"V_2","prompt":"A serene tropical beach scene. Dominating the foreground are tall palm trees with lush green leaves, standing tall against a backdrop of a sandy beach. The beach leads to the azure waters of the sea, which gently kisses the shoreline. In the distance, there is an island or landmass with a silhouette of what appears to be a lighthouse or tower. The sky above is painted with fluffy white clouds, some of which are tinged with hues of pink and orange, suggesting either a sunrise or sunset.","image_weight":50} + /// + /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> PostRemixImageAsResponseAsync( + global::Ideogram.InitialImageRequest imageRequest, + global::System.IO.Stream imageFile, + string imageFilename, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + imageFile = imageFile ?? throw new global::System.ArgumentNullException(nameof(imageFile)); + var request = new global::Ideogram.RemixImageRequest + { + ImageRequest = imageRequest, + ImageFile = global::System.Array.Empty(), + ImageFilename = imageFilename, + }; + PrepareArguments( + client: HttpClient); + PreparePostRemixImageArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_PostRemixImageSecurityRequirements, + operationName: "PostRemixImageAsync"); + + using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Ideogram.PathBuilder( + path: "/remix", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.ImageRequest.ToJson(JsonSerializerContext)), + name: "\"image_request\""); + + var __contentImageFile = new global::System.Net.Http.StreamContent(imageFile); + __contentImageFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.ImageFilename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.ImageFilename) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentImageFile, + name: "\"image_file\"", + fileName: request.ImageFilename != null ? $"\"{request.ImageFilename}\"" : string.Empty); + if (__contentImageFile.Headers.ContentDisposition != null) + { + __contentImageFile.Headers.ContentDisposition.FileNameStar = null; + } + + __httpRequest.Content = __httpRequestContent; + + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PreparePostRemixImageRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostRemixImage", + methodName: "PostRemixImageAsync", + pathTemplate: "\"/remix\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostRemixImage", + methodName: "PostRemixImageAsync", + pathTemplate: "\"/remix\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostRemixImage", + methodName: "PostRemixImageAsync", + pathTemplate: "\"/remix\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessPostRemixImageResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostRemixImage", + methodName: "PostRemixImageAsync", + pathTemplate: "\"/remix\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostRemixImage", + methodName: "PostRemixImageAsync", + pathTemplate: "\"/remix\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Prompt or provided image failed safety check. + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Ideogram.GenerateImageSafetyError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessPostRemixImageResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Ideogram.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + var __value = await global::Ideogram.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostRemixImageV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostRemixImageV3.g.cs index 2dc9bdf..1c16f12 100644 --- a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostRemixImageV3.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostRemixImageV3.g.cs @@ -54,6 +54,32 @@ partial void ProcessPostRemixImageV3ResponseContent( /// public async global::System.Threading.Tasks.Task PostRemixImageV3Async( + global::Ideogram.RemixImageRequestV3 request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await PostRemixImageV3AsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Remix with Ideogram 3.0
+ /// Remix provided images synchronously based on a given prompt and optional parameters with the Ideogram 3.0 model.
+ /// Input images are cropped to the chosen aspect ratio before being remixed.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> PostRemixImageV3AsResponseAsync( + global::Ideogram.RemixImageRequestV3 request, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) @@ -84,10 +110,11 @@ partial void ProcessPostRemixImageV3ResponseContent( var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/v1/ideogram-v3/remix", baseUri: HttpClient.BaseAddress); @@ -120,6 +147,7 @@ partial void ProcessPostRemixImageV3ResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); var __contentImage = new global::System.Net.Http.ByteArrayContent(request.Image ?? global::System.Array.Empty()); __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( @@ -158,100 +186,123 @@ request.Imagename is null { __contentImage.Headers.ContentDisposition.FileNameStar = null; } + __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), name: "\"prompt\""); + if (request.ImageWeight != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.ImageWeight, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), name: "\"image_weight\""); - } + + } if (request.Seed != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), name: "\"seed\""); - } + + } if (request.Resolution != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.Resolution).HasValue ? (request.Resolution).GetValueOrDefault().ToValueString() : string.Empty), name: "\"resolution\""); - } + + } if (request.AspectRatio != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.AspectRatio).HasValue ? (request.AspectRatio).GetValueOrDefault().ToValueString() : string.Empty), name: "\"aspect_ratio\""); - } + + } if (request.RenderingSpeed != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty), name: "\"rendering_speed\""); - } + + } if (request.MagicPrompt != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.MagicPrompt).HasValue ? (request.MagicPrompt).GetValueOrDefault().ToValueString() : string.Empty), name: "\"magic_prompt\""); - } + + } + if (request.MagicPromptSystemPromptConfigId != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty), + name: "\"magic_prompt_system_prompt_config_id\""); + + } if (request.NegativePrompt != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.NegativePrompt ?? string.Empty), name: "\"negative_prompt\""); - } + + } if (request.NumImages != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), name: "\"num_images\""); - } + + } if (request.ColorPalette != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.ColorPalette.ToString() ?? string.Empty), name: "\"color_palette\""); - } + + } if (request.StyleCodes != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.StyleCodes, x => x))}]"), name: "\"style_codes\""); - } + + } if (request.StyleType != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.StyleType).HasValue ? (request.StyleType).GetValueOrDefault().ToValueString() : string.Empty), name: "\"style_type\""); - } + + } if (request.StylePreset != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.StylePreset).HasValue ? (request.StylePreset).GetValueOrDefault().ToValueString() : string.Empty), name: "\"style_preset\""); - } + + } if (request.CustomModelUri != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.CustomModelUri ?? string.Empty), name: "\"custom_model_uri\""); - } + + } if (request.StyleReferenceImages != default) { @@ -268,7 +319,8 @@ request.Imagename is null __contentStyleReferenceImages.Headers.ContentDisposition.FileNameStar = null; } } - } + + } if (request.CharacterReferenceImages != default) { @@ -285,7 +337,8 @@ request.Imagename is null __contentCharacterReferenceImages.Headers.ContentDisposition.FileNameStar = null; } } - } + + } if (request.CharacterReferenceImagesMask != default) { @@ -302,8 +355,11 @@ request.Imagename is null __contentCharacterReferenceImagesMask.Headers.ContentDisposition.FileNameStar = null; } } + } + __httpRequest.Content = __httpRequestContent; + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -345,6 +401,8 @@ request.Imagename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -355,6 +413,11 @@ request.Imagename is null } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -372,6 +435,8 @@ request.Imagename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -381,8 +446,7 @@ request.Imagename is null __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -391,6 +455,11 @@ request.Imagename is null __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -407,14 +476,15 @@ request.Imagename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -454,6 +524,8 @@ request.Imagename is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -474,6 +546,8 @@ request.Imagename is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -635,9 +709,13 @@ request.Imagename is null { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -665,9 +743,13 @@ request.Imagename is null #endif ).ConfigureAwait(false); - return - await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -745,6 +827,9 @@ request.Imagename is null /// Determine if MagicPrompt should be used in generating the request or not.
/// Example: ON /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// /// /// Description of what to exclude from an image. Descriptions in the prompt take precedence
/// to descriptions in the negative prompt.
@@ -797,6 +882,7 @@ request.Imagename is null global::Ideogram.AspectRatioV3? aspectRatio = default, global::Ideogram.RenderingSpeed? renderingSpeed = default, global::Ideogram.MagicPromptOption? magicPrompt = default, + string? magicPromptSystemPromptConfigId = default, string? negativePrompt = default, int? numImages = default, global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette = default, @@ -821,6 +907,7 @@ request.Imagename is null AspectRatio = aspectRatio, RenderingSpeed = renderingSpeed, MagicPrompt = magicPrompt, + MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId, NegativePrompt = negativePrompt, NumImages = numImages, ColorPalette = colorPalette, @@ -838,5 +925,1884 @@ request.Imagename is null requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } + + /// + /// Remix with Ideogram 3.0
+ /// Remix provided images synchronously based on a given prompt and optional parameters with the Ideogram 3.0 model.
+ /// Input images are cropped to the chosen aspect ratio before being remixed.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// The image to remix binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The image to remix binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The prompt to use to generate the image.
+ /// Example: A photo of a cat + /// + /// + /// Default Value: 50
+ /// Example: 50 + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// + /// The resolutions supported for Ideogram 3.0.
+ /// Example: 1280x800 + /// + /// + /// The aspect ratio to use for image generation, which determines the image's resolution. Cannot be used in conjunction with resolution. Defaults to 1x1. + /// + /// + /// The rendering speed to use.
+ /// Default Value: DEFAULT + /// + /// + /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON + /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + /// + /// Description of what to exclude from an image. Descriptions in the prompt take precedence
+ /// to descriptions in the negative prompt.
+ /// Example: brush strokes, painting + /// + /// + /// Number of images to generate.
+ /// Default Value: 1 + /// + /// + /// A color palette for generation, must EITHER be specified via one of the presets (name) or explicitly via hexadecimal representations of the color with optional weights (members). Not supported by V_1, V_1_TURBO, V_2A and V_2A_TURBO models. + /// + /// + /// A list of 8 character hexadecimal codes representing the style of the image. Cannot be used in conjunction with style_reference_images or style_type.
+ /// Example: [AAFF5733, 0133FF57, DE3357FF] + /// + /// + /// The style type to generate with.
+ /// Default Value: GENERAL
+ /// Example: GENERAL + /// + /// + /// A predefined style preset that applies a specific artistic style to the generated image.
+ /// Example: BRIGHT_ART + /// + /// + /// A custom model URI in the format model/<model_name>/version/<version_name>.
+ /// When provided, the model version and style will be resolved from this URI, and style_type is not required.
+ /// Example: model/my-custom-model/version/1 + /// + /// + /// A set of images to use as style references (maximum total size 10MB across all style references). The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'style_reference_images' file parts. + /// + /// + /// Generations with character reference are subject to the character reference pricing. A set of images to use as character references (maximum total size 10MB across all character references), currently only supports 1 character reference image. The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'character_reference_images' file parts. + /// + /// + /// Optional masks for character reference images. When provided, must match the number of character_reference_images. Each mask should be a grayscale image of the same dimensions as the corresponding character reference image. The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'character_reference_images_mask' file parts. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task PostRemixImageV3Async( + global::System.IO.Stream image, + string imagename, + string prompt, + int? imageWeight = default, + int? seed = default, + global::Ideogram.ResolutionV3? resolution = default, + global::Ideogram.AspectRatioV3? aspectRatio = default, + global::Ideogram.RenderingSpeed? renderingSpeed = default, + global::Ideogram.MagicPromptOption? magicPrompt = default, + string? magicPromptSystemPromptConfigId = default, + string? negativePrompt = default, + int? numImages = default, + global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette = default, + global::System.Collections.Generic.IList? styleCodes = default, + global::Ideogram.StyleTypeV3? styleType = default, + global::Ideogram.StylePresetV3? stylePreset = default, + string? customModelUri = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImages = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImagesFileNames = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImages = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesFileNames = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesMask = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesMaskFileNames = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + image = image ?? throw new global::System.ArgumentNullException(nameof(image)); + var request = new global::Ideogram.RemixImageRequestV3 + { + Image = global::System.Array.Empty(), + Imagename = imagename, + Prompt = prompt, + ImageWeight = imageWeight, + Seed = seed, + Resolution = resolution, + AspectRatio = aspectRatio, + RenderingSpeed = renderingSpeed, + MagicPrompt = magicPrompt, + MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId, + NegativePrompt = negativePrompt, + NumImages = numImages, + ColorPalette = colorPalette, + StyleCodes = styleCodes, + StyleType = styleType, + StylePreset = stylePreset, + CustomModelUri = customModelUri, + StyleReferenceImages = new global::System.Collections.Generic.List(), + CharacterReferenceImages = new global::System.Collections.Generic.List(), + CharacterReferenceImagesMask = new global::System.Collections.Generic.List(), + }; + PrepareArguments( + client: HttpClient); + PreparePostRemixImageV3Arguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_PostRemixImageV3SecurityRequirements, + operationName: "PostRemixImageV3Async"); + + using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Ideogram.PathBuilder( + path: "/v1/ideogram-v3/remix", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + var __contentImage = new global::System.Net.Http.StreamContent(image); + __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.Imagename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentImage, + name: "\"image\"", + fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty); + if (__contentImage.Headers.ContentDisposition != null) + { + __contentImage.Headers.ContentDisposition.FileNameStar = null; + } + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), + name: "\"prompt\""); + + if (request.ImageWeight != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.ImageWeight, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"image_weight\""); + + } + if (request.Seed != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"seed\""); + + } + if (request.Resolution != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.Resolution).HasValue ? (request.Resolution).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"resolution\""); + + } + if (request.AspectRatio != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.AspectRatio).HasValue ? (request.AspectRatio).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"aspect_ratio\""); + + } + if (request.RenderingSpeed != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"rendering_speed\""); + + } + if (request.MagicPrompt != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.MagicPrompt).HasValue ? (request.MagicPrompt).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"magic_prompt\""); + + } + if (request.MagicPromptSystemPromptConfigId != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty), + name: "\"magic_prompt_system_prompt_config_id\""); + + } + if (request.NegativePrompt != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.NegativePrompt ?? string.Empty), + name: "\"negative_prompt\""); + + } + if (request.NumImages != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"num_images\""); + + } + if (request.ColorPalette != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.ColorPalette.ToString() ?? string.Empty), + name: "\"color_palette\""); + + } + if (request.StyleCodes != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.StyleCodes, x => x))}]"), + name: "\"style_codes\""); + + } + if (request.StyleType != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.StyleType).HasValue ? (request.StyleType).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"style_type\""); + + } + if (request.StylePreset != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.StylePreset).HasValue ? (request.StylePreset).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"style_preset\""); + + } + if (request.CustomModelUri != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.CustomModelUri ?? string.Empty), + name: "\"custom_model_uri\""); + + } + if (styleReferenceImages != default) + { + + for (var __iStyleReferenceImages = 0; __iStyleReferenceImages < styleReferenceImages.Count; __iStyleReferenceImages++) + { + var __fileNameStyleReferenceImages = styleReferenceImagesFileNames != null && + __iStyleReferenceImages < styleReferenceImagesFileNames.Count && + styleReferenceImagesFileNames[__iStyleReferenceImages] != null + ? styleReferenceImagesFileNames[__iStyleReferenceImages] + : $"file{__iStyleReferenceImages}.bin"; + var __contentStyleReferenceImages = new global::System.Net.Http.StreamContent(styleReferenceImages[__iStyleReferenceImages]); + __contentStyleReferenceImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + __fileNameStyleReferenceImages is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(__fileNameStyleReferenceImages) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentStyleReferenceImages, + name: "\"style_reference_images\"", + fileName: $"\"{__fileNameStyleReferenceImages}\""); + if (__contentStyleReferenceImages.Headers.ContentDisposition != null) + { + __contentStyleReferenceImages.Headers.ContentDisposition.FileNameStar = null; + } + } + + } + if (characterReferenceImages != default) + { + + for (var __iCharacterReferenceImages = 0; __iCharacterReferenceImages < characterReferenceImages.Count; __iCharacterReferenceImages++) + { + var __fileNameCharacterReferenceImages = characterReferenceImagesFileNames != null && + __iCharacterReferenceImages < characterReferenceImagesFileNames.Count && + characterReferenceImagesFileNames[__iCharacterReferenceImages] != null + ? characterReferenceImagesFileNames[__iCharacterReferenceImages] + : $"file{__iCharacterReferenceImages}.bin"; + var __contentCharacterReferenceImages = new global::System.Net.Http.StreamContent(characterReferenceImages[__iCharacterReferenceImages]); + __contentCharacterReferenceImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + __fileNameCharacterReferenceImages is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(__fileNameCharacterReferenceImages) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentCharacterReferenceImages, + name: "\"character_reference_images\"", + fileName: $"\"{__fileNameCharacterReferenceImages}\""); + if (__contentCharacterReferenceImages.Headers.ContentDisposition != null) + { + __contentCharacterReferenceImages.Headers.ContentDisposition.FileNameStar = null; + } + } + + } + if (characterReferenceImagesMask != default) + { + + for (var __iCharacterReferenceImagesMask = 0; __iCharacterReferenceImagesMask < characterReferenceImagesMask.Count; __iCharacterReferenceImagesMask++) + { + var __fileNameCharacterReferenceImagesMask = characterReferenceImagesMaskFileNames != null && + __iCharacterReferenceImagesMask < characterReferenceImagesMaskFileNames.Count && + characterReferenceImagesMaskFileNames[__iCharacterReferenceImagesMask] != null + ? characterReferenceImagesMaskFileNames[__iCharacterReferenceImagesMask] + : $"file{__iCharacterReferenceImagesMask}.bin"; + var __contentCharacterReferenceImagesMask = new global::System.Net.Http.StreamContent(characterReferenceImagesMask[__iCharacterReferenceImagesMask]); + __contentCharacterReferenceImagesMask.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + __fileNameCharacterReferenceImagesMask is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(__fileNameCharacterReferenceImagesMask) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentCharacterReferenceImagesMask, + name: "\"character_reference_images_mask\"", + fileName: $"\"{__fileNameCharacterReferenceImagesMask}\""); + if (__contentCharacterReferenceImagesMask.Headers.ContentDisposition != null) + { + __contentCharacterReferenceImagesMask.Headers.ContentDisposition.FileNameStar = null; + } + } + + } + + __httpRequest.Content = __httpRequestContent; + + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PreparePostRemixImageV3Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostRemixImageV3", + methodName: "PostRemixImageV3Async", + pathTemplate: "\"/v1/ideogram-v3/remix\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostRemixImageV3", + methodName: "PostRemixImageV3Async", + pathTemplate: "\"/v1/ideogram-v3/remix\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostRemixImageV3", + methodName: "PostRemixImageV3Async", + pathTemplate: "\"/v1/ideogram-v3/remix\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessPostRemixImageV3Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostRemixImageV3", + methodName: "PostRemixImageV3Async", + pathTemplate: "\"/v1/ideogram-v3/remix\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostRemixImageV3", + methodName: "PostRemixImageV3Async", + pathTemplate: "\"/v1/ideogram-v3/remix\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Prompt or provided image failed safety check. + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Ideogram.GenerateImageSafetyError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessPostRemixImageV3ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Remix with Ideogram 3.0
+ /// Remix provided images synchronously based on a given prompt and optional parameters with the Ideogram 3.0 model.
+ /// Input images are cropped to the chosen aspect ratio before being remixed.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// The image to remix binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The image to remix binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The prompt to use to generate the image.
+ /// Example: A photo of a cat + /// + /// + /// Default Value: 50
+ /// Example: 50 + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// + /// The resolutions supported for Ideogram 3.0.
+ /// Example: 1280x800 + /// + /// + /// The aspect ratio to use for image generation, which determines the image's resolution. Cannot be used in conjunction with resolution. Defaults to 1x1. + /// + /// + /// The rendering speed to use.
+ /// Default Value: DEFAULT + /// + /// + /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON + /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + /// + /// Description of what to exclude from an image. Descriptions in the prompt take precedence
+ /// to descriptions in the negative prompt.
+ /// Example: brush strokes, painting + /// + /// + /// Number of images to generate.
+ /// Default Value: 1 + /// + /// + /// A color palette for generation, must EITHER be specified via one of the presets (name) or explicitly via hexadecimal representations of the color with optional weights (members). Not supported by V_1, V_1_TURBO, V_2A and V_2A_TURBO models. + /// + /// + /// A list of 8 character hexadecimal codes representing the style of the image. Cannot be used in conjunction with style_reference_images or style_type.
+ /// Example: [AAFF5733, 0133FF57, DE3357FF] + /// + /// + /// The style type to generate with.
+ /// Default Value: GENERAL
+ /// Example: GENERAL + /// + /// + /// A predefined style preset that applies a specific artistic style to the generated image.
+ /// Example: BRIGHT_ART + /// + /// + /// A custom model URI in the format model/<model_name>/version/<version_name>.
+ /// When provided, the model version and style will be resolved from this URI, and style_type is not required.
+ /// Example: model/my-custom-model/version/1 + /// + /// + /// A set of images to use as style references (maximum total size 10MB across all style references). The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'style_reference_images' file parts. + /// + /// + /// Generations with character reference are subject to the character reference pricing. A set of images to use as character references (maximum total size 10MB across all character references), currently only supports 1 character reference image. The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'character_reference_images' file parts. + /// + /// + /// Optional masks for character reference images. When provided, must match the number of character_reference_images. Each mask should be a grayscale image of the same dimensions as the corresponding character reference image. The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'character_reference_images_mask' file parts. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> PostRemixImageV3AsResponseAsync( + global::System.IO.Stream image, + string imagename, + string prompt, + int? imageWeight = default, + int? seed = default, + global::Ideogram.ResolutionV3? resolution = default, + global::Ideogram.AspectRatioV3? aspectRatio = default, + global::Ideogram.RenderingSpeed? renderingSpeed = default, + global::Ideogram.MagicPromptOption? magicPrompt = default, + string? magicPromptSystemPromptConfigId = default, + string? negativePrompt = default, + int? numImages = default, + global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette = default, + global::System.Collections.Generic.IList? styleCodes = default, + global::Ideogram.StyleTypeV3? styleType = default, + global::Ideogram.StylePresetV3? stylePreset = default, + string? customModelUri = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImages = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImagesFileNames = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImages = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesFileNames = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesMask = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesMaskFileNames = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + image = image ?? throw new global::System.ArgumentNullException(nameof(image)); + var request = new global::Ideogram.RemixImageRequestV3 + { + Image = global::System.Array.Empty(), + Imagename = imagename, + Prompt = prompt, + ImageWeight = imageWeight, + Seed = seed, + Resolution = resolution, + AspectRatio = aspectRatio, + RenderingSpeed = renderingSpeed, + MagicPrompt = magicPrompt, + MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId, + NegativePrompt = negativePrompt, + NumImages = numImages, + ColorPalette = colorPalette, + StyleCodes = styleCodes, + StyleType = styleType, + StylePreset = stylePreset, + CustomModelUri = customModelUri, + StyleReferenceImages = new global::System.Collections.Generic.List(), + CharacterReferenceImages = new global::System.Collections.Generic.List(), + CharacterReferenceImagesMask = new global::System.Collections.Generic.List(), + }; + PrepareArguments( + client: HttpClient); + PreparePostRemixImageV3Arguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_PostRemixImageV3SecurityRequirements, + operationName: "PostRemixImageV3Async"); + + using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Ideogram.PathBuilder( + path: "/v1/ideogram-v3/remix", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + var __contentImage = new global::System.Net.Http.StreamContent(image); + __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.Imagename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentImage, + name: "\"image\"", + fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty); + if (__contentImage.Headers.ContentDisposition != null) + { + __contentImage.Headers.ContentDisposition.FileNameStar = null; + } + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), + name: "\"prompt\""); + + if (request.ImageWeight != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.ImageWeight, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"image_weight\""); + + } + if (request.Seed != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"seed\""); + + } + if (request.Resolution != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.Resolution).HasValue ? (request.Resolution).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"resolution\""); + + } + if (request.AspectRatio != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.AspectRatio).HasValue ? (request.AspectRatio).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"aspect_ratio\""); + + } + if (request.RenderingSpeed != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"rendering_speed\""); + + } + if (request.MagicPrompt != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.MagicPrompt).HasValue ? (request.MagicPrompt).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"magic_prompt\""); + + } + if (request.MagicPromptSystemPromptConfigId != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty), + name: "\"magic_prompt_system_prompt_config_id\""); + + } + if (request.NegativePrompt != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.NegativePrompt ?? string.Empty), + name: "\"negative_prompt\""); + + } + if (request.NumImages != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"num_images\""); + + } + if (request.ColorPalette != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.ColorPalette.ToString() ?? string.Empty), + name: "\"color_palette\""); + + } + if (request.StyleCodes != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.StyleCodes, x => x))}]"), + name: "\"style_codes\""); + + } + if (request.StyleType != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.StyleType).HasValue ? (request.StyleType).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"style_type\""); + + } + if (request.StylePreset != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.StylePreset).HasValue ? (request.StylePreset).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"style_preset\""); + + } + if (request.CustomModelUri != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.CustomModelUri ?? string.Empty), + name: "\"custom_model_uri\""); + + } + if (styleReferenceImages != default) + { + + for (var __iStyleReferenceImages = 0; __iStyleReferenceImages < styleReferenceImages.Count; __iStyleReferenceImages++) + { + var __fileNameStyleReferenceImages = styleReferenceImagesFileNames != null && + __iStyleReferenceImages < styleReferenceImagesFileNames.Count && + styleReferenceImagesFileNames[__iStyleReferenceImages] != null + ? styleReferenceImagesFileNames[__iStyleReferenceImages] + : $"file{__iStyleReferenceImages}.bin"; + var __contentStyleReferenceImages = new global::System.Net.Http.StreamContent(styleReferenceImages[__iStyleReferenceImages]); + __contentStyleReferenceImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + __fileNameStyleReferenceImages is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(__fileNameStyleReferenceImages) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentStyleReferenceImages, + name: "\"style_reference_images\"", + fileName: $"\"{__fileNameStyleReferenceImages}\""); + if (__contentStyleReferenceImages.Headers.ContentDisposition != null) + { + __contentStyleReferenceImages.Headers.ContentDisposition.FileNameStar = null; + } + } + + } + if (characterReferenceImages != default) + { + + for (var __iCharacterReferenceImages = 0; __iCharacterReferenceImages < characterReferenceImages.Count; __iCharacterReferenceImages++) + { + var __fileNameCharacterReferenceImages = characterReferenceImagesFileNames != null && + __iCharacterReferenceImages < characterReferenceImagesFileNames.Count && + characterReferenceImagesFileNames[__iCharacterReferenceImages] != null + ? characterReferenceImagesFileNames[__iCharacterReferenceImages] + : $"file{__iCharacterReferenceImages}.bin"; + var __contentCharacterReferenceImages = new global::System.Net.Http.StreamContent(characterReferenceImages[__iCharacterReferenceImages]); + __contentCharacterReferenceImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + __fileNameCharacterReferenceImages is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(__fileNameCharacterReferenceImages) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentCharacterReferenceImages, + name: "\"character_reference_images\"", + fileName: $"\"{__fileNameCharacterReferenceImages}\""); + if (__contentCharacterReferenceImages.Headers.ContentDisposition != null) + { + __contentCharacterReferenceImages.Headers.ContentDisposition.FileNameStar = null; + } + } + + } + if (characterReferenceImagesMask != default) + { + + for (var __iCharacterReferenceImagesMask = 0; __iCharacterReferenceImagesMask < characterReferenceImagesMask.Count; __iCharacterReferenceImagesMask++) + { + var __fileNameCharacterReferenceImagesMask = characterReferenceImagesMaskFileNames != null && + __iCharacterReferenceImagesMask < characterReferenceImagesMaskFileNames.Count && + characterReferenceImagesMaskFileNames[__iCharacterReferenceImagesMask] != null + ? characterReferenceImagesMaskFileNames[__iCharacterReferenceImagesMask] + : $"file{__iCharacterReferenceImagesMask}.bin"; + var __contentCharacterReferenceImagesMask = new global::System.Net.Http.StreamContent(characterReferenceImagesMask[__iCharacterReferenceImagesMask]); + __contentCharacterReferenceImagesMask.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + __fileNameCharacterReferenceImagesMask is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(__fileNameCharacterReferenceImagesMask) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentCharacterReferenceImagesMask, + name: "\"character_reference_images_mask\"", + fileName: $"\"{__fileNameCharacterReferenceImagesMask}\""); + if (__contentCharacterReferenceImagesMask.Headers.ContentDisposition != null) + { + __contentCharacterReferenceImagesMask.Headers.ContentDisposition.FileNameStar = null; + } + } + + } + + __httpRequest.Content = __httpRequestContent; + + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PreparePostRemixImageV3Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostRemixImageV3", + methodName: "PostRemixImageV3Async", + pathTemplate: "\"/v1/ideogram-v3/remix\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostRemixImageV3", + methodName: "PostRemixImageV3Async", + pathTemplate: "\"/v1/ideogram-v3/remix\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostRemixImageV3", + methodName: "PostRemixImageV3Async", + pathTemplate: "\"/v1/ideogram-v3/remix\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessPostRemixImageV3Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostRemixImageV3", + methodName: "PostRemixImageV3Async", + pathTemplate: "\"/v1/ideogram-v3/remix\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostRemixImageV3", + methodName: "PostRemixImageV3Async", + pathTemplate: "\"/v1/ideogram-v3/remix\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Prompt or provided image failed safety check. + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Ideogram.GenerateImageSafetyError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessPostRemixImageV3ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + var __value = await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostRemoveBackground.g.cs b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostRemoveBackground.g.cs new file mode 100644 index 0000000..3ef9043 --- /dev/null +++ b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostRemoveBackground.g.cs @@ -0,0 +1,1769 @@ + +#nullable enable + +namespace Ideogram +{ + public partial class GenerateClient + { + + + private static readonly global::Ideogram.EndPointSecurityRequirement s_PostRemoveBackgroundSecurityRequirement0 = + new global::Ideogram.EndPointSecurityRequirement + { + Authorizations = new global::Ideogram.EndPointAuthorizationRequirement[] + { new global::Ideogram.EndPointAuthorizationRequirement + { + Type = "Http", + SchemeId = "HttpBearer", + Location = "Header", + Name = "Bearer", + FriendlyName = "Bearer", + }, + }, + }; + private static readonly global::Ideogram.EndPointSecurityRequirement[] s_PostRemoveBackgroundSecurityRequirements = + new global::Ideogram.EndPointSecurityRequirement[] + { s_PostRemoveBackgroundSecurityRequirement0, + }; + partial void PreparePostRemoveBackgroundArguments( + global::System.Net.Http.HttpClient httpClient, + global::Ideogram.RemoveBackgroundRequest request); + partial void PreparePostRemoveBackgroundRequest( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpRequestMessage httpRequestMessage, + global::Ideogram.RemoveBackgroundRequest request); + partial void ProcessPostRemoveBackgroundResponse( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpResponseMessage httpResponseMessage); + + partial void ProcessPostRemoveBackgroundResponseContent( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpResponseMessage httpResponseMessage, + ref string content); + + /// + /// Remove Background
+ /// Remove the background of a given image synchronously. The foreground subject
+ /// is identified and returned on a transparent background. Supported image formats include JPEG,
+ /// PNG, and WebP.
+ /// Image links are available for a limited period of time; if you would like to keep the image,
+ /// you must download it. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task PostRemoveBackgroundAsync( + + global::Ideogram.RemoveBackgroundRequest request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await PostRemoveBackgroundAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Remove Background
+ /// Remove the background of a given image synchronously. The foreground subject
+ /// is identified and returned on a transparent background. Supported image formats include JPEG,
+ /// PNG, and WebP.
+ /// Image links are available for a limited period of time; if you would like to keep the image,
+ /// you must download it. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> PostRemoveBackgroundAsResponseAsync( + + global::Ideogram.RemoveBackgroundRequest request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + request = request ?? throw new global::System.ArgumentNullException(nameof(request)); + + PrepareArguments( + client: HttpClient); + PreparePostRemoveBackgroundArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_PostRemoveBackgroundSecurityRequirements, + operationName: "PostRemoveBackgroundAsync"); + + using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Ideogram.PathBuilder( + path: "/v1/remove-background", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + var __contentImage = new global::System.Net.Http.ByteArrayContent(request.Image ?? global::System.Array.Empty()); + __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.Imagename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentImage, + name: "\"image\"", + fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty); + if (__contentImage.Headers.ContentDisposition != null) + { + __contentImage.Headers.ContentDisposition.FileNameStar = null; + } + + __httpRequest.Content = __httpRequestContent; + + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PreparePostRemoveBackgroundRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostRemoveBackground", + methodName: "PostRemoveBackgroundAsync", + pathTemplate: "\"/v1/remove-background\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostRemoveBackground", + methodName: "PostRemoveBackgroundAsync", + pathTemplate: "\"/v1/remove-background\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostRemoveBackground", + methodName: "PostRemoveBackgroundAsync", + pathTemplate: "\"/v1/remove-background\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessPostRemoveBackgroundResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostRemoveBackground", + methodName: "PostRemoveBackgroundAsync", + pathTemplate: "\"/v1/remove-background\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostRemoveBackground", + methodName: "PostRemoveBackgroundAsync", + pathTemplate: "\"/v1/remove-background\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Initial image failed the safety checks. + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Ideogram.GenerateImageSafetyError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessPostRemoveBackgroundResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Ideogram.RemoveBackgroundResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + var __value = await global::Ideogram.RemoveBackgroundResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Remove Background
+ /// Remove the background of a given image synchronously. The foreground subject
+ /// is identified and returned on a transparent background. Supported image formats include JPEG,
+ /// PNG, and WebP.
+ /// Image links are available for a limited period of time; if you would like to keep the image,
+ /// you must download it. + ///
+ /// + /// The image whose background is being removed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The image whose background is being removed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task PostRemoveBackgroundAsync( + byte[] image, + string imagename, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __request = new global::Ideogram.RemoveBackgroundRequest + { + Image = image, + Imagename = imagename, + }; + + return await PostRemoveBackgroundAsync( + request: __request, + requestOptions: requestOptions, + cancellationToken: cancellationToken).ConfigureAwait(false); + } + + /// + /// Remove Background
+ /// Remove the background of a given image synchronously. The foreground subject
+ /// is identified and returned on a transparent background. Supported image formats include JPEG,
+ /// PNG, and WebP.
+ /// Image links are available for a limited period of time; if you would like to keep the image,
+ /// you must download it. + ///
+ /// + /// The image whose background is being removed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The image whose background is being removed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task PostRemoveBackgroundAsync( + global::System.IO.Stream image, + string imagename, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + image = image ?? throw new global::System.ArgumentNullException(nameof(image)); + var request = new global::Ideogram.RemoveBackgroundRequest + { + Image = global::System.Array.Empty(), + Imagename = imagename, + }; + PrepareArguments( + client: HttpClient); + PreparePostRemoveBackgroundArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_PostRemoveBackgroundSecurityRequirements, + operationName: "PostRemoveBackgroundAsync"); + + using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Ideogram.PathBuilder( + path: "/v1/remove-background", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + var __contentImage = new global::System.Net.Http.StreamContent(image); + __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.Imagename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentImage, + name: "\"image\"", + fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty); + if (__contentImage.Headers.ContentDisposition != null) + { + __contentImage.Headers.ContentDisposition.FileNameStar = null; + } + + __httpRequest.Content = __httpRequestContent; + + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PreparePostRemoveBackgroundRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostRemoveBackground", + methodName: "PostRemoveBackgroundAsync", + pathTemplate: "\"/v1/remove-background\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostRemoveBackground", + methodName: "PostRemoveBackgroundAsync", + pathTemplate: "\"/v1/remove-background\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostRemoveBackground", + methodName: "PostRemoveBackgroundAsync", + pathTemplate: "\"/v1/remove-background\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessPostRemoveBackgroundResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostRemoveBackground", + methodName: "PostRemoveBackgroundAsync", + pathTemplate: "\"/v1/remove-background\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostRemoveBackground", + methodName: "PostRemoveBackgroundAsync", + pathTemplate: "\"/v1/remove-background\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Initial image failed the safety checks. + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Ideogram.GenerateImageSafetyError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessPostRemoveBackgroundResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Ideogram.RemoveBackgroundResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Ideogram.RemoveBackgroundResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Remove Background
+ /// Remove the background of a given image synchronously. The foreground subject
+ /// is identified and returned on a transparent background. Supported image formats include JPEG,
+ /// PNG, and WebP.
+ /// Image links are available for a limited period of time; if you would like to keep the image,
+ /// you must download it. + ///
+ /// + /// The image whose background is being removed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The image whose background is being removed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> PostRemoveBackgroundAsResponseAsync( + global::System.IO.Stream image, + string imagename, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + image = image ?? throw new global::System.ArgumentNullException(nameof(image)); + var request = new global::Ideogram.RemoveBackgroundRequest + { + Image = global::System.Array.Empty(), + Imagename = imagename, + }; + PrepareArguments( + client: HttpClient); + PreparePostRemoveBackgroundArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_PostRemoveBackgroundSecurityRequirements, + operationName: "PostRemoveBackgroundAsync"); + + using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Ideogram.PathBuilder( + path: "/v1/remove-background", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + var __contentImage = new global::System.Net.Http.StreamContent(image); + __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.Imagename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentImage, + name: "\"image\"", + fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty); + if (__contentImage.Headers.ContentDisposition != null) + { + __contentImage.Headers.ContentDisposition.FileNameStar = null; + } + + __httpRequest.Content = __httpRequestContent; + + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PreparePostRemoveBackgroundRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostRemoveBackground", + methodName: "PostRemoveBackgroundAsync", + pathTemplate: "\"/v1/remove-background\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostRemoveBackground", + methodName: "PostRemoveBackgroundAsync", + pathTemplate: "\"/v1/remove-background\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostRemoveBackground", + methodName: "PostRemoveBackgroundAsync", + pathTemplate: "\"/v1/remove-background\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessPostRemoveBackgroundResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostRemoveBackground", + methodName: "PostRemoveBackgroundAsync", + pathTemplate: "\"/v1/remove-background\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostRemoveBackground", + methodName: "PostRemoveBackgroundAsync", + pathTemplate: "\"/v1/remove-background\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Initial image failed the safety checks. + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Ideogram.GenerateImageSafetyError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessPostRemoveBackgroundResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Ideogram.RemoveBackgroundResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + var __value = await global::Ideogram.RemoveBackgroundResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } + } +} \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostReplaceBackgroundV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostReplaceBackgroundV3.g.cs index 1cb24fd..a4442da 100644 --- a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostReplaceBackgroundV3.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostReplaceBackgroundV3.g.cs @@ -54,6 +54,32 @@ partial void ProcessPostReplaceBackgroundV3ResponseContent( /// public async global::System.Threading.Tasks.Task PostReplaceBackgroundV3Async( + global::Ideogram.ReplaceBackgroundRequestV3 request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await PostReplaceBackgroundV3AsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Replace Background with Ideogram 3.0
+ /// Replace the background of a given image synchronously using a prompt with Ideogram 3.0. The foreground subject
+ /// will be identified and kept, while the background is replaced based on the prompt and chosen style.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> PostReplaceBackgroundV3AsResponseAsync( + global::Ideogram.ReplaceBackgroundRequestV3 request, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) @@ -84,10 +110,11 @@ partial void ProcessPostReplaceBackgroundV3ResponseContent( var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/v1/ideogram-v3/replace-background", baseUri: HttpClient.BaseAddress); @@ -120,6 +147,7 @@ partial void ProcessPostReplaceBackgroundV3ResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); var __contentImage = new global::System.Net.Http.ByteArrayContent(request.Image ?? global::System.Array.Empty()); __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( @@ -158,58 +186,75 @@ request.Imagename is null { __contentImage.Headers.ContentDisposition.FileNameStar = null; } + __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), name: "\"prompt\""); + if (request.MagicPrompt != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.MagicPrompt).HasValue ? (request.MagicPrompt).GetValueOrDefault().ToValueString() : string.Empty), name: "\"magic_prompt\""); - } + + } + if (request.MagicPromptSystemPromptConfigId != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty), + name: "\"magic_prompt_system_prompt_config_id\""); + + } if (request.NumImages != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), name: "\"num_images\""); - } + + } if (request.Seed != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), name: "\"seed\""); - } + + } if (request.RenderingSpeed != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty), name: "\"rendering_speed\""); - } + + } if (request.StylePreset != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.StylePreset).HasValue ? (request.StylePreset).GetValueOrDefault().ToValueString() : string.Empty), name: "\"style_preset\""); - } + + } if (request.ColorPalette != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.ColorPalette.ToString() ?? string.Empty), name: "\"color_palette\""); - } + + } if (request.StyleCodes != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.StyleCodes, x => x))}]"), name: "\"style_codes\""); - } + + } if (request.StyleReferenceImages != default) { @@ -226,8 +271,11 @@ request.Imagename is null __contentStyleReferenceImages.Headers.ContentDisposition.FileNameStar = null; } } + } + __httpRequest.Content = __httpRequestContent; + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -269,6 +317,8 @@ request.Imagename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -279,6 +329,11 @@ request.Imagename is null } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -296,6 +351,8 @@ request.Imagename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -305,8 +362,7 @@ request.Imagename is null __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -315,6 +371,11 @@ request.Imagename is null __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -331,14 +392,15 @@ request.Imagename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -378,6 +440,8 @@ request.Imagename is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -398,6 +462,8 @@ request.Imagename is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -559,9 +625,13 @@ request.Imagename is null { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -589,9 +659,13 @@ request.Imagename is null #endif ).ConfigureAwait(false); - return - await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -650,6 +724,9 @@ request.Imagename is null /// Determine if MagicPrompt should be used in generating the request or not.
/// Example: ON /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// /// /// The number of images to generate.
/// Default Value: 1 @@ -684,6 +761,7 @@ request.Imagename is null string imagename, string prompt, global::Ideogram.MagicPromptOption? magicPrompt = default, + string? magicPromptSystemPromptConfigId = default, int? numImages = default, int? seed = default, global::Ideogram.RenderingSpeed? renderingSpeed = default, @@ -700,6 +778,7 @@ request.Imagename is null Imagename = imagename, Prompt = prompt, MagicPrompt = magicPrompt, + MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId, NumImages = numImages, Seed = seed, RenderingSpeed = renderingSpeed, @@ -714,5 +793,1476 @@ request.Imagename is null requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } + + /// + /// Replace Background with Ideogram 3.0
+ /// Replace the background of a given image synchronously using a prompt with Ideogram 3.0. The foreground subject
+ /// will be identified and kept, while the background is replaced based on the prompt and chosen style.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// The image whose background is being replaced (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The image whose background is being replaced (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The prompt describing the desired new background.
+ /// Example: A vibrant cityscape at night. + /// + /// + /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON + /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + /// + /// The number of images to generate.
+ /// Default Value: 1 + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// + /// The rendering speed to use.
+ /// Default Value: DEFAULT + /// + /// + /// A predefined style preset that applies a specific artistic style to the generated image.
+ /// Example: BRIGHT_ART + /// + /// + /// A color palette for generation, must EITHER be specified via one of the presets (name) or explicitly via hexadecimal representations of the color with optional weights (members). Not supported by V_1, V_1_TURBO, V_2A and V_2A_TURBO models. + /// + /// + /// A list of 8 character hexadecimal codes representing the style of the image. Cannot be used in conjunction with style_reference_images or style_type.
+ /// Example: [AAFF5733, 0133FF57, DE3357FF] + /// + /// + /// A set of images to use as style references (maximum total size 10MB across all style references). The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'style_reference_images' file parts. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task PostReplaceBackgroundV3Async( + global::System.IO.Stream image, + string imagename, + string prompt, + global::Ideogram.MagicPromptOption? magicPrompt = default, + string? magicPromptSystemPromptConfigId = default, + int? numImages = default, + int? seed = default, + global::Ideogram.RenderingSpeed? renderingSpeed = default, + global::Ideogram.StylePresetV3? stylePreset = default, + global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette = default, + global::System.Collections.Generic.IList? styleCodes = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImages = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImagesFileNames = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + image = image ?? throw new global::System.ArgumentNullException(nameof(image)); + var request = new global::Ideogram.ReplaceBackgroundRequestV3 + { + Image = global::System.Array.Empty(), + Imagename = imagename, + Prompt = prompt, + MagicPrompt = magicPrompt, + MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId, + NumImages = numImages, + Seed = seed, + RenderingSpeed = renderingSpeed, + StylePreset = stylePreset, + ColorPalette = colorPalette, + StyleCodes = styleCodes, + StyleReferenceImages = new global::System.Collections.Generic.List(), + }; + PrepareArguments( + client: HttpClient); + PreparePostReplaceBackgroundV3Arguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_PostReplaceBackgroundV3SecurityRequirements, + operationName: "PostReplaceBackgroundV3Async"); + + using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Ideogram.PathBuilder( + path: "/v1/ideogram-v3/replace-background", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + var __contentImage = new global::System.Net.Http.StreamContent(image); + __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.Imagename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentImage, + name: "\"image\"", + fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty); + if (__contentImage.Headers.ContentDisposition != null) + { + __contentImage.Headers.ContentDisposition.FileNameStar = null; + } + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), + name: "\"prompt\""); + + if (request.MagicPrompt != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.MagicPrompt).HasValue ? (request.MagicPrompt).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"magic_prompt\""); + + } + if (request.MagicPromptSystemPromptConfigId != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty), + name: "\"magic_prompt_system_prompt_config_id\""); + + } + if (request.NumImages != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"num_images\""); + + } + if (request.Seed != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"seed\""); + + } + if (request.RenderingSpeed != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"rendering_speed\""); + + } + if (request.StylePreset != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.StylePreset).HasValue ? (request.StylePreset).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"style_preset\""); + + } + if (request.ColorPalette != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.ColorPalette.ToString() ?? string.Empty), + name: "\"color_palette\""); + + } + if (request.StyleCodes != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.StyleCodes, x => x))}]"), + name: "\"style_codes\""); + + } + if (styleReferenceImages != default) + { + + for (var __iStyleReferenceImages = 0; __iStyleReferenceImages < styleReferenceImages.Count; __iStyleReferenceImages++) + { + var __fileNameStyleReferenceImages = styleReferenceImagesFileNames != null && + __iStyleReferenceImages < styleReferenceImagesFileNames.Count && + styleReferenceImagesFileNames[__iStyleReferenceImages] != null + ? styleReferenceImagesFileNames[__iStyleReferenceImages] + : $"file{__iStyleReferenceImages}.bin"; + var __contentStyleReferenceImages = new global::System.Net.Http.StreamContent(styleReferenceImages[__iStyleReferenceImages]); + __contentStyleReferenceImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + __fileNameStyleReferenceImages is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(__fileNameStyleReferenceImages) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentStyleReferenceImages, + name: "\"style_reference_images\"", + fileName: $"\"{__fileNameStyleReferenceImages}\""); + if (__contentStyleReferenceImages.Headers.ContentDisposition != null) + { + __contentStyleReferenceImages.Headers.ContentDisposition.FileNameStar = null; + } + } + + } + + __httpRequest.Content = __httpRequestContent; + + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PreparePostReplaceBackgroundV3Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostReplaceBackgroundV3", + methodName: "PostReplaceBackgroundV3Async", + pathTemplate: "\"/v1/ideogram-v3/replace-background\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostReplaceBackgroundV3", + methodName: "PostReplaceBackgroundV3Async", + pathTemplate: "\"/v1/ideogram-v3/replace-background\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostReplaceBackgroundV3", + methodName: "PostReplaceBackgroundV3Async", + pathTemplate: "\"/v1/ideogram-v3/replace-background\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessPostReplaceBackgroundV3Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostReplaceBackgroundV3", + methodName: "PostReplaceBackgroundV3Async", + pathTemplate: "\"/v1/ideogram-v3/replace-background\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostReplaceBackgroundV3", + methodName: "PostReplaceBackgroundV3Async", + pathTemplate: "\"/v1/ideogram-v3/replace-background\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Prompt or Initial Image failed the safety checks. + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Ideogram.GenerateImageSafetyError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessPostReplaceBackgroundV3ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Replace Background with Ideogram 3.0
+ /// Replace the background of a given image synchronously using a prompt with Ideogram 3.0. The foreground subject
+ /// will be identified and kept, while the background is replaced based on the prompt and chosen style.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// The image whose background is being replaced (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The image whose background is being replaced (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The prompt describing the desired new background.
+ /// Example: A vibrant cityscape at night. + /// + /// + /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON + /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + /// + /// The number of images to generate.
+ /// Default Value: 1 + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// + /// The rendering speed to use.
+ /// Default Value: DEFAULT + /// + /// + /// A predefined style preset that applies a specific artistic style to the generated image.
+ /// Example: BRIGHT_ART + /// + /// + /// A color palette for generation, must EITHER be specified via one of the presets (name) or explicitly via hexadecimal representations of the color with optional weights (members). Not supported by V_1, V_1_TURBO, V_2A and V_2A_TURBO models. + /// + /// + /// A list of 8 character hexadecimal codes representing the style of the image. Cannot be used in conjunction with style_reference_images or style_type.
+ /// Example: [AAFF5733, 0133FF57, DE3357FF] + /// + /// + /// A set of images to use as style references (maximum total size 10MB across all style references). The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'style_reference_images' file parts. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> PostReplaceBackgroundV3AsResponseAsync( + global::System.IO.Stream image, + string imagename, + string prompt, + global::Ideogram.MagicPromptOption? magicPrompt = default, + string? magicPromptSystemPromptConfigId = default, + int? numImages = default, + int? seed = default, + global::Ideogram.RenderingSpeed? renderingSpeed = default, + global::Ideogram.StylePresetV3? stylePreset = default, + global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette = default, + global::System.Collections.Generic.IList? styleCodes = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImages = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImagesFileNames = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + image = image ?? throw new global::System.ArgumentNullException(nameof(image)); + var request = new global::Ideogram.ReplaceBackgroundRequestV3 + { + Image = global::System.Array.Empty(), + Imagename = imagename, + Prompt = prompt, + MagicPrompt = magicPrompt, + MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId, + NumImages = numImages, + Seed = seed, + RenderingSpeed = renderingSpeed, + StylePreset = stylePreset, + ColorPalette = colorPalette, + StyleCodes = styleCodes, + StyleReferenceImages = new global::System.Collections.Generic.List(), + }; + PrepareArguments( + client: HttpClient); + PreparePostReplaceBackgroundV3Arguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_PostReplaceBackgroundV3SecurityRequirements, + operationName: "PostReplaceBackgroundV3Async"); + + using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Ideogram.PathBuilder( + path: "/v1/ideogram-v3/replace-background", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + var __contentImage = new global::System.Net.Http.StreamContent(image); + __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.Imagename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentImage, + name: "\"image\"", + fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty); + if (__contentImage.Headers.ContentDisposition != null) + { + __contentImage.Headers.ContentDisposition.FileNameStar = null; + } + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), + name: "\"prompt\""); + + if (request.MagicPrompt != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.MagicPrompt).HasValue ? (request.MagicPrompt).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"magic_prompt\""); + + } + if (request.MagicPromptSystemPromptConfigId != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty), + name: "\"magic_prompt_system_prompt_config_id\""); + + } + if (request.NumImages != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"num_images\""); + + } + if (request.Seed != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"seed\""); + + } + if (request.RenderingSpeed != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"rendering_speed\""); + + } + if (request.StylePreset != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.StylePreset).HasValue ? (request.StylePreset).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"style_preset\""); + + } + if (request.ColorPalette != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.ColorPalette.ToString() ?? string.Empty), + name: "\"color_palette\""); + + } + if (request.StyleCodes != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.StyleCodes, x => x))}]"), + name: "\"style_codes\""); + + } + if (styleReferenceImages != default) + { + + for (var __iStyleReferenceImages = 0; __iStyleReferenceImages < styleReferenceImages.Count; __iStyleReferenceImages++) + { + var __fileNameStyleReferenceImages = styleReferenceImagesFileNames != null && + __iStyleReferenceImages < styleReferenceImagesFileNames.Count && + styleReferenceImagesFileNames[__iStyleReferenceImages] != null + ? styleReferenceImagesFileNames[__iStyleReferenceImages] + : $"file{__iStyleReferenceImages}.bin"; + var __contentStyleReferenceImages = new global::System.Net.Http.StreamContent(styleReferenceImages[__iStyleReferenceImages]); + __contentStyleReferenceImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + __fileNameStyleReferenceImages is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(__fileNameStyleReferenceImages) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentStyleReferenceImages, + name: "\"style_reference_images\"", + fileName: $"\"{__fileNameStyleReferenceImages}\""); + if (__contentStyleReferenceImages.Headers.ContentDisposition != null) + { + __contentStyleReferenceImages.Headers.ContentDisposition.FileNameStar = null; + } + } + + } + + __httpRequest.Content = __httpRequestContent; + + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PreparePostReplaceBackgroundV3Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostReplaceBackgroundV3", + methodName: "PostReplaceBackgroundV3Async", + pathTemplate: "\"/v1/ideogram-v3/replace-background\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostReplaceBackgroundV3", + methodName: "PostReplaceBackgroundV3Async", + pathTemplate: "\"/v1/ideogram-v3/replace-background\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostReplaceBackgroundV3", + methodName: "PostReplaceBackgroundV3Async", + pathTemplate: "\"/v1/ideogram-v3/replace-background\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessPostReplaceBackgroundV3Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostReplaceBackgroundV3", + methodName: "PostReplaceBackgroundV3Async", + pathTemplate: "\"/v1/ideogram-v3/replace-background\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostReplaceBackgroundV3", + methodName: "PostReplaceBackgroundV3Async", + pathTemplate: "\"/v1/ideogram-v3/replace-background\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Prompt or Initial Image failed the safety checks. + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Ideogram.GenerateImageSafetyError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessPostReplaceBackgroundV3ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + var __value = await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostTryOnV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostTryOnV3.g.cs index 554a4e8..b02d878 100644 --- a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostTryOnV3.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostTryOnV3.g.cs @@ -55,6 +55,33 @@ partial void ProcessPostTryOnV3ResponseContent( /// public async global::System.Threading.Tasks.Task PostTryOnV3Async( + global::Ideogram.TryOnRequestV3 request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await PostTryOnV3AsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Virtual Try-On with Ideogram 3.0
+ /// Performs virtual clothing try-on by automatically segmenting the clothing in the provided image
+ /// and replacing it based on the prompt. The user provides an image and an optional prompt describing
+ /// the desired clothing change (e.g., "change his shirt to a pink shirt").
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> PostTryOnV3AsResponseAsync( + global::Ideogram.TryOnRequestV3 request, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) @@ -85,10 +112,11 @@ partial void ProcessPostTryOnV3ResponseContent( var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/v1/ideogram-v3/try-on", baseUri: HttpClient.BaseAddress); @@ -121,6 +149,7 @@ partial void ProcessPostTryOnV3ResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); var __contentImage = new global::System.Net.Http.ByteArrayContent(request.Image ?? global::System.Array.Empty()); __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( @@ -159,54 +188,70 @@ request.Imagename is null { __contentImage.Headers.ContentDisposition.FileNameStar = null; } + if (request.Prompt != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), name: "\"prompt\""); - } + + } if (request.MagicPrompt != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.MagicPrompt).HasValue ? (request.MagicPrompt).GetValueOrDefault().ToValueString() : string.Empty), name: "\"magic_prompt\""); - } + + } + if (request.MagicPromptSystemPromptConfigId != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty), + name: "\"magic_prompt_system_prompt_config_id\""); + + } if (request.NumImages != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), name: "\"num_images\""); - } + + } if (request.Seed != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), name: "\"seed\""); - } + + } if (request.RenderingSpeed != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty), name: "\"rendering_speed\""); - } + + } if (request.StyleType != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.StyleType).HasValue ? (request.StyleType).GetValueOrDefault().ToValueString() : string.Empty), name: "\"style_type\""); - } + + } if (request.StylePreset != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.StylePreset).HasValue ? (request.StylePreset).GetValueOrDefault().ToValueString() : string.Empty), name: "\"style_preset\""); + } for (var __iProductReferenceImages = 0; __iProductReferenceImages < request.ProductReferenceImages.Count; __iProductReferenceImages++) { @@ -221,7 +266,9 @@ request.Imagename is null __contentProductReferenceImages.Headers.ContentDisposition.FileNameStar = null; } } + __httpRequest.Content = __httpRequestContent; + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -263,6 +310,8 @@ request.Imagename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -273,6 +322,11 @@ request.Imagename is null } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -290,6 +344,8 @@ request.Imagename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -299,8 +355,7 @@ request.Imagename is null __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -309,6 +364,11 @@ request.Imagename is null __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -325,14 +385,15 @@ request.Imagename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -372,6 +433,8 @@ request.Imagename is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -392,6 +455,8 @@ request.Imagename is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -553,9 +618,13 @@ request.Imagename is null { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -583,9 +652,13 @@ request.Imagename is null #endif ).ConfigureAwait(false); - return - await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -646,6 +719,9 @@ request.Imagename is null /// Determine if MagicPrompt should be used in generating the request or not.
/// Example: ON /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// /// /// The number of images to generate.
/// Default Value: 1 @@ -679,6 +755,7 @@ request.Imagename is null global::System.Collections.Generic.IList productReferenceImages, string? prompt = default, global::Ideogram.MagicPromptOption? magicPrompt = default, + string? magicPromptSystemPromptConfigId = default, int? numImages = default, int? seed = default, global::Ideogram.RenderingSpeed? renderingSpeed = default, @@ -693,6 +770,7 @@ request.Imagename is null Imagename = imagename, Prompt = prompt, MagicPrompt = magicPrompt, + MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId, NumImages = numImages, Seed = seed, RenderingSpeed = renderingSpeed, @@ -706,5 +784,1456 @@ request.Imagename is null requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } + + /// + /// Virtual Try-On with Ideogram 3.0
+ /// Performs virtual clothing try-on by automatically segmenting the clothing in the provided image
+ /// and replacing it based on the prompt. The user provides an image and an optional prompt describing
+ /// the desired clothing change (e.g., "change his shirt to a pink shirt").
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// The image containing a person wearing clothing to be modified (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The image containing a person wearing clothing to be modified (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The prompt describing the desired clothing change. Defaults to "Person wearing this piece of clothing" if omitted or empty.
+ /// Default Value: Person wearing this piece of clothing
+ /// Example: Change his shirt to a pink shirt + /// + /// + /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON + /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + /// + /// The number of images to generate.
+ /// Default Value: 1 + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// + /// The rendering speed to use.
+ /// Default Value: DEFAULT + /// + /// + /// The style type to generate with.
+ /// Default Value: GENERAL
+ /// Example: GENERAL + /// + /// + /// A predefined style preset that applies a specific artistic style to the generated image.
+ /// Example: BRIGHT_ART + /// + /// + /// An image to use as the product reference for the try-on (exactly 1 image required). The image should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'product_reference_images' file parts. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task PostTryOnV3Async( + global::System.IO.Stream image, + string imagename, + global::System.Collections.Generic.IReadOnlyList productReferenceImages, + string? prompt = default, + global::Ideogram.MagicPromptOption? magicPrompt = default, + string? magicPromptSystemPromptConfigId = default, + int? numImages = default, + int? seed = default, + global::Ideogram.RenderingSpeed? renderingSpeed = default, + global::Ideogram.StyleTypeV3? styleType = default, + global::Ideogram.StylePresetV3? stylePreset = default, + global::System.Collections.Generic.IReadOnlyList? productReferenceImagesFileNames = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + image = image ?? throw new global::System.ArgumentNullException(nameof(image)); + productReferenceImages = productReferenceImages ?? throw new global::System.ArgumentNullException(nameof(productReferenceImages)); + var request = new global::Ideogram.TryOnRequestV3 + { + Image = global::System.Array.Empty(), + Imagename = imagename, + Prompt = prompt, + MagicPrompt = magicPrompt, + MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId, + NumImages = numImages, + Seed = seed, + RenderingSpeed = renderingSpeed, + StyleType = styleType, + StylePreset = stylePreset, + ProductReferenceImages = new global::System.Collections.Generic.List(), + }; + PrepareArguments( + client: HttpClient); + PreparePostTryOnV3Arguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_PostTryOnV3SecurityRequirements, + operationName: "PostTryOnV3Async"); + + using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Ideogram.PathBuilder( + path: "/v1/ideogram-v3/try-on", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + var __contentImage = new global::System.Net.Http.StreamContent(image); + __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.Imagename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentImage, + name: "\"image\"", + fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty); + if (__contentImage.Headers.ContentDisposition != null) + { + __contentImage.Headers.ContentDisposition.FileNameStar = null; + } + + if (request.Prompt != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), + name: "\"prompt\""); + + } + if (request.MagicPrompt != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.MagicPrompt).HasValue ? (request.MagicPrompt).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"magic_prompt\""); + + } + if (request.MagicPromptSystemPromptConfigId != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty), + name: "\"magic_prompt_system_prompt_config_id\""); + + } + if (request.NumImages != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"num_images\""); + + } + if (request.Seed != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"seed\""); + + } + if (request.RenderingSpeed != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"rendering_speed\""); + + } + if (request.StyleType != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.StyleType).HasValue ? (request.StyleType).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"style_type\""); + + } + if (request.StylePreset != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.StylePreset).HasValue ? (request.StylePreset).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"style_preset\""); + + } + for (var __iProductReferenceImages = 0; __iProductReferenceImages < productReferenceImages.Count; __iProductReferenceImages++) + { + var __fileNameProductReferenceImages = productReferenceImagesFileNames != null && + __iProductReferenceImages < productReferenceImagesFileNames.Count && + productReferenceImagesFileNames[__iProductReferenceImages] != null + ? productReferenceImagesFileNames[__iProductReferenceImages] + : $"file{__iProductReferenceImages}.bin"; + var __contentProductReferenceImages = new global::System.Net.Http.StreamContent(productReferenceImages[__iProductReferenceImages]); + __contentProductReferenceImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + __fileNameProductReferenceImages is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(__fileNameProductReferenceImages) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentProductReferenceImages, + name: "\"product_reference_images\"", + fileName: $"\"{__fileNameProductReferenceImages}\""); + if (__contentProductReferenceImages.Headers.ContentDisposition != null) + { + __contentProductReferenceImages.Headers.ContentDisposition.FileNameStar = null; + } + } + + __httpRequest.Content = __httpRequestContent; + + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PreparePostTryOnV3Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostTryOnV3", + methodName: "PostTryOnV3Async", + pathTemplate: "\"/v1/ideogram-v3/try-on\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostTryOnV3", + methodName: "PostTryOnV3Async", + pathTemplate: "\"/v1/ideogram-v3/try-on\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostTryOnV3", + methodName: "PostTryOnV3Async", + pathTemplate: "\"/v1/ideogram-v3/try-on\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessPostTryOnV3Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostTryOnV3", + methodName: "PostTryOnV3Async", + pathTemplate: "\"/v1/ideogram-v3/try-on\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostTryOnV3", + methodName: "PostTryOnV3Async", + pathTemplate: "\"/v1/ideogram-v3/try-on\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Prompt or provided image failed safety check, or clothing segmentation failed. + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Ideogram.GenerateImageSafetyError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessPostTryOnV3ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Virtual Try-On with Ideogram 3.0
+ /// Performs virtual clothing try-on by automatically segmenting the clothing in the provided image
+ /// and replacing it based on the prompt. The user provides an image and an optional prompt describing
+ /// the desired clothing change (e.g., "change his shirt to a pink shirt").
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// The image containing a person wearing clothing to be modified (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The image containing a person wearing clothing to be modified (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The prompt describing the desired clothing change. Defaults to "Person wearing this piece of clothing" if omitted or empty.
+ /// Default Value: Person wearing this piece of clothing
+ /// Example: Change his shirt to a pink shirt + /// + /// + /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON + /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + /// + /// The number of images to generate.
+ /// Default Value: 1 + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// + /// The rendering speed to use.
+ /// Default Value: DEFAULT + /// + /// + /// The style type to generate with.
+ /// Default Value: GENERAL
+ /// Example: GENERAL + /// + /// + /// A predefined style preset that applies a specific artistic style to the generated image.
+ /// Example: BRIGHT_ART + /// + /// + /// An image to use as the product reference for the try-on (exactly 1 image required). The image should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'product_reference_images' file parts. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> PostTryOnV3AsResponseAsync( + global::System.IO.Stream image, + string imagename, + global::System.Collections.Generic.IReadOnlyList productReferenceImages, + string? prompt = default, + global::Ideogram.MagicPromptOption? magicPrompt = default, + string? magicPromptSystemPromptConfigId = default, + int? numImages = default, + int? seed = default, + global::Ideogram.RenderingSpeed? renderingSpeed = default, + global::Ideogram.StyleTypeV3? styleType = default, + global::Ideogram.StylePresetV3? stylePreset = default, + global::System.Collections.Generic.IReadOnlyList? productReferenceImagesFileNames = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + image = image ?? throw new global::System.ArgumentNullException(nameof(image)); + productReferenceImages = productReferenceImages ?? throw new global::System.ArgumentNullException(nameof(productReferenceImages)); + var request = new global::Ideogram.TryOnRequestV3 + { + Image = global::System.Array.Empty(), + Imagename = imagename, + Prompt = prompt, + MagicPrompt = magicPrompt, + MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId, + NumImages = numImages, + Seed = seed, + RenderingSpeed = renderingSpeed, + StyleType = styleType, + StylePreset = stylePreset, + ProductReferenceImages = new global::System.Collections.Generic.List(), + }; + PrepareArguments( + client: HttpClient); + PreparePostTryOnV3Arguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_PostTryOnV3SecurityRequirements, + operationName: "PostTryOnV3Async"); + + using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Ideogram.PathBuilder( + path: "/v1/ideogram-v3/try-on", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + var __contentImage = new global::System.Net.Http.StreamContent(image); + __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.Imagename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentImage, + name: "\"image\"", + fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty); + if (__contentImage.Headers.ContentDisposition != null) + { + __contentImage.Headers.ContentDisposition.FileNameStar = null; + } + + if (request.Prompt != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), + name: "\"prompt\""); + + } + if (request.MagicPrompt != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.MagicPrompt).HasValue ? (request.MagicPrompt).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"magic_prompt\""); + + } + if (request.MagicPromptSystemPromptConfigId != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty), + name: "\"magic_prompt_system_prompt_config_id\""); + + } + if (request.NumImages != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"num_images\""); + + } + if (request.Seed != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"seed\""); + + } + if (request.RenderingSpeed != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"rendering_speed\""); + + } + if (request.StyleType != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.StyleType).HasValue ? (request.StyleType).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"style_type\""); + + } + if (request.StylePreset != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.StylePreset).HasValue ? (request.StylePreset).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"style_preset\""); + + } + for (var __iProductReferenceImages = 0; __iProductReferenceImages < productReferenceImages.Count; __iProductReferenceImages++) + { + var __fileNameProductReferenceImages = productReferenceImagesFileNames != null && + __iProductReferenceImages < productReferenceImagesFileNames.Count && + productReferenceImagesFileNames[__iProductReferenceImages] != null + ? productReferenceImagesFileNames[__iProductReferenceImages] + : $"file{__iProductReferenceImages}.bin"; + var __contentProductReferenceImages = new global::System.Net.Http.StreamContent(productReferenceImages[__iProductReferenceImages]); + __contentProductReferenceImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + __fileNameProductReferenceImages is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(__fileNameProductReferenceImages) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentProductReferenceImages, + name: "\"product_reference_images\"", + fileName: $"\"{__fileNameProductReferenceImages}\""); + if (__contentProductReferenceImages.Headers.ContentDisposition != null) + { + __contentProductReferenceImages.Headers.ContentDisposition.FileNameStar = null; + } + } + + __httpRequest.Content = __httpRequestContent; + + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PreparePostTryOnV3Request( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostTryOnV3", + methodName: "PostTryOnV3Async", + pathTemplate: "\"/v1/ideogram-v3/try-on\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostTryOnV3", + methodName: "PostTryOnV3Async", + pathTemplate: "\"/v1/ideogram-v3/try-on\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostTryOnV3", + methodName: "PostTryOnV3Async", + pathTemplate: "\"/v1/ideogram-v3/try-on\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessPostTryOnV3Response( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostTryOnV3", + methodName: "PostTryOnV3Async", + pathTemplate: "\"/v1/ideogram-v3/try-on\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostTryOnV3", + methodName: "PostTryOnV3Async", + pathTemplate: "\"/v1/ideogram-v3/try-on\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Prompt or provided image failed safety check, or clothing segmentation failed. + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Ideogram.GenerateImageSafetyError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessPostTryOnV3ResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + var __value = await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostUpscaleImage.g.cs b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostUpscaleImage.g.cs index ddd4349..0355765 100644 --- a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostUpscaleImage.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostUpscaleImage.g.cs @@ -53,6 +53,31 @@ partial void ProcessPostUpscaleImageResponseContent( /// public async global::System.Threading.Tasks.Task PostUpscaleImageAsync( + global::Ideogram.UpscaleImageRequest request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await PostUpscaleImageAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Upscale
+ /// Upscale provided images synchronously with an optional prompt.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> PostUpscaleImageAsResponseAsync( + global::Ideogram.UpscaleImageRequest request, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) @@ -83,10 +108,11 @@ partial void ProcessPostUpscaleImageResponseContent( var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/upscale", baseUri: HttpClient.BaseAddress); @@ -119,10 +145,12 @@ partial void ProcessPostUpscaleImageResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.ImageRequest.ToJson(JsonSerializerContext)), name: "\"image_request\""); + var __contentImageFile = new global::System.Net.Http.ByteArrayContent(request.ImageFile ?? global::System.Array.Empty()); __contentImageFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( request.ImageFilename is null @@ -160,7 +188,9 @@ request.ImageFilename is null { __contentImageFile.Headers.ContentDisposition.FileNameStar = null; } + __httpRequest.Content = __httpRequestContent; + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -202,6 +232,8 @@ request.ImageFilename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -212,6 +244,11 @@ request.ImageFilename is null } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -229,6 +266,8 @@ request.ImageFilename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -238,8 +277,7 @@ request.ImageFilename is null __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -248,6 +286,11 @@ request.ImageFilename is null __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -264,14 +307,15 @@ request.ImageFilename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -311,6 +355,8 @@ request.ImageFilename is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -331,6 +377,8 @@ request.ImageFilename is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -492,9 +540,13 @@ request.ImageFilename is null { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -522,9 +574,13 @@ request.ImageFilename is null #endif ).ConfigureAwait(false); - return - await global::Ideogram.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -599,5 +655,1132 @@ request.ImageFilename is null requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } + + /// + /// Upscale
+ /// Upscale provided images synchronously with an optional prompt.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// A request to upscale a provided image with the help of an optional prompt. + /// + /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task PostUpscaleImageAsync( + global::Ideogram.UpscaleInitialImageRequest imageRequest, + global::System.IO.Stream imageFile, + string imageFilename, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + imageFile = imageFile ?? throw new global::System.ArgumentNullException(nameof(imageFile)); + var request = new global::Ideogram.UpscaleImageRequest + { + ImageRequest = imageRequest, + ImageFile = global::System.Array.Empty(), + ImageFilename = imageFilename, + }; + PrepareArguments( + client: HttpClient); + PreparePostUpscaleImageArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_PostUpscaleImageSecurityRequirements, + operationName: "PostUpscaleImageAsync"); + + using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Ideogram.PathBuilder( + path: "/upscale", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.ImageRequest.ToJson(JsonSerializerContext)), + name: "\"image_request\""); + + var __contentImageFile = new global::System.Net.Http.StreamContent(imageFile); + __contentImageFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.ImageFilename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.ImageFilename) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentImageFile, + name: "\"image_file\"", + fileName: request.ImageFilename != null ? $"\"{request.ImageFilename}\"" : string.Empty); + if (__contentImageFile.Headers.ContentDisposition != null) + { + __contentImageFile.Headers.ContentDisposition.FileNameStar = null; + } + + __httpRequest.Content = __httpRequestContent; + + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PreparePostUpscaleImageRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostUpscaleImage", + methodName: "PostUpscaleImageAsync", + pathTemplate: "\"/upscale\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostUpscaleImage", + methodName: "PostUpscaleImageAsync", + pathTemplate: "\"/upscale\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostUpscaleImage", + methodName: "PostUpscaleImageAsync", + pathTemplate: "\"/upscale\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessPostUpscaleImageResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostUpscaleImage", + methodName: "PostUpscaleImageAsync", + pathTemplate: "\"/upscale\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostUpscaleImage", + methodName: "PostUpscaleImageAsync", + pathTemplate: "\"/upscale\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Prompt or provided image failed safety check. + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Ideogram.GenerateImageSafetyError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessPostUpscaleImageResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Ideogram.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Ideogram.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Upscale
+ /// Upscale provided images synchronously with an optional prompt.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// A request to upscale a provided image with the help of an optional prompt. + /// + /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> PostUpscaleImageAsResponseAsync( + global::Ideogram.UpscaleInitialImageRequest imageRequest, + global::System.IO.Stream imageFile, + string imageFilename, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + imageFile = imageFile ?? throw new global::System.ArgumentNullException(nameof(imageFile)); + var request = new global::Ideogram.UpscaleImageRequest + { + ImageRequest = imageRequest, + ImageFile = global::System.Array.Empty(), + ImageFilename = imageFilename, + }; + PrepareArguments( + client: HttpClient); + PreparePostUpscaleImageArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_PostUpscaleImageSecurityRequirements, + operationName: "PostUpscaleImageAsync"); + + using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Ideogram.PathBuilder( + path: "/upscale", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.ImageRequest.ToJson(JsonSerializerContext)), + name: "\"image_request\""); + + var __contentImageFile = new global::System.Net.Http.StreamContent(imageFile); + __contentImageFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.ImageFilename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.ImageFilename) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentImageFile, + name: "\"image_file\"", + fileName: request.ImageFilename != null ? $"\"{request.ImageFilename}\"" : string.Empty); + if (__contentImageFile.Headers.ContentDisposition != null) + { + __contentImageFile.Headers.ContentDisposition.FileNameStar = null; + } + + __httpRequest.Content = __httpRequestContent; + + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PreparePostUpscaleImageRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostUpscaleImage", + methodName: "PostUpscaleImageAsync", + pathTemplate: "\"/upscale\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostUpscaleImage", + methodName: "PostUpscaleImageAsync", + pathTemplate: "\"/upscale\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostUpscaleImage", + methodName: "PostUpscaleImageAsync", + pathTemplate: "\"/upscale\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessPostUpscaleImageResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostUpscaleImage", + methodName: "PostUpscaleImageAsync", + pathTemplate: "\"/upscale\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostUpscaleImage", + methodName: "PostUpscaleImageAsync", + pathTemplate: "\"/upscale\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 403) + { + string? __content_403 = null; + global::System.Exception? __exception_403 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_403 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_403 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_403, + statusCode: __response.StatusCode) + { + ResponseBody = __content_403, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Prompt or provided image failed safety check. + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Ideogram.GenerateImageSafetyError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessPostUpscaleImageResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Ideogram.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + var __value = await global::Ideogram.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostV1EditImage.g.cs b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostV1EditImage.g.cs index d2c2301..df10a0f 100644 --- a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostV1EditImage.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostV1EditImage.g.cs @@ -54,6 +54,32 @@ partial void ProcessPostV1EditImageResponseContent( /// public async global::System.Threading.Tasks.Task PostV1EditImageAsync( + global::Ideogram.V1EditImagesRequest request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await PostV1EditImageAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Edit images with a prompt
+ /// Edit one or more images using a text prompt. Provide images via file upload
+ /// or Ideogram image URLs, and describe the desired edit in your prompt.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> PostV1EditImageAsResponseAsync( + global::Ideogram.V1EditImagesRequest request, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) @@ -84,10 +110,11 @@ partial void ProcessPostV1EditImageResponseContent( var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/v1/edit", baseUri: HttpClient.BaseAddress); @@ -120,10 +147,12 @@ partial void ProcessPostV1EditImageResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), name: "\"prompt\""); + if (request.Images != default) { @@ -140,57 +169,75 @@ partial void ProcessPostV1EditImageResponseContent( __contentImages.Headers.ContentDisposition.FileNameStar = null; } } - } + + } if (request.ImageUrls != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.ImageUrls, x => x))}]"), name: "\"image_urls\""); - } + + } if (request.NumImages != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), name: "\"num_images\""); - } + + } if (request.Seed != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), name: "\"seed\""); - } + + } if (request.MagicPrompt != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.MagicPrompt).HasValue ? (request.MagicPrompt).GetValueOrDefault().ToValueString() : string.Empty), name: "\"magic_prompt\""); - } + + } + if (request.MagicPromptSystemPromptConfigId != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty), + name: "\"magic_prompt_system_prompt_config_id\""); + + } if (request.Resolution != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.Resolution).HasValue ? (request.Resolution).GetValueOrDefault().ToValueString() : string.Empty), name: "\"resolution\""); - } + + } if (request.AspectRatio != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.AspectRatio).HasValue ? (request.AspectRatio).GetValueOrDefault().ToValueString() : string.Empty), name: "\"aspect_ratio\""); - } + + } if (request.TransparentBackground != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.TransparentBackground, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()), name: "\"transparent_background\""); + } + __httpRequest.Content = __httpRequestContent; + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -232,6 +279,8 @@ partial void ProcessPostV1EditImageResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -242,6 +291,11 @@ partial void ProcessPostV1EditImageResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -259,6 +313,8 @@ partial void ProcessPostV1EditImageResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -268,8 +324,7 @@ partial void ProcessPostV1EditImageResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -278,6 +333,11 @@ partial void ProcessPostV1EditImageResponseContent( __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -294,14 +354,15 @@ partial void ProcessPostV1EditImageResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -341,6 +402,8 @@ partial void ProcessPostV1EditImageResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -361,6 +424,8 @@ partial void ProcessPostV1EditImageResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -588,9 +653,13 @@ partial void ProcessPostV1EditImageResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.V1EditImagesResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.V1EditImagesResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -618,9 +687,13 @@ partial void ProcessPostV1EditImageResponseContent( #endif ).ConfigureAwait(false); - return - await global::Ideogram.V1EditImagesResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.V1EditImagesResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -687,6 +760,9 @@ partial void ProcessPostV1EditImageResponseContent( /// Determine if MagicPrompt should be used in generating the request or not.
/// Example: ON /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// /// /// The resolutions supported for Ideogram 3.0.
/// Example: 1280x800 @@ -708,6 +784,7 @@ partial void ProcessPostV1EditImageResponseContent( int? numImages = default, int? seed = default, global::Ideogram.MagicPromptOption? magicPrompt = default, + string? magicPromptSystemPromptConfigId = default, global::Ideogram.ResolutionV3? resolution = default, global::Ideogram.AspectRatioV3? aspectRatio = default, bool? transparentBackground = default, @@ -722,6 +799,7 @@ partial void ProcessPostV1EditImageResponseContent( NumImages = numImages, Seed = seed, MagicPrompt = magicPrompt, + MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId, Resolution = resolution, AspectRatio = aspectRatio, TransparentBackground = transparentBackground, @@ -732,5 +810,1508 @@ partial void ProcessPostV1EditImageResponseContent( requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } + + /// + /// Edit images with a prompt
+ /// Edit one or more images using a text prompt. Provide images via file upload
+ /// or Ideogram image URLs, and describe the desired edit in your prompt.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// The prompt describing the desired edit.
+ /// Example: Change the background to a beach sunset. + /// + /// + /// Images to edit (max 10 images, max size 10MB each); JPEG, WebP and PNG formats are supported. + /// + /// + /// Optional file names to use for the multipart 'images' file parts. + /// + /// + /// URLs to Ideogram images to use as references (max 10). Supports URLs from generation responses and image uploads. Alternative to uploading via the images field. + /// + /// + /// The number of images to generate.
+ /// Default Value: 1 + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// + /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON + /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + /// + /// The resolutions supported for Ideogram 3.0.
+ /// Example: 1280x800 + /// + /// + /// The aspect ratio to use for image generation, which determines the image's resolution. Cannot be used in conjunction with resolution. Defaults to 1x1. + /// + /// + /// Whether the output should have a transparent background. Default false.
+ /// Default Value: false + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task PostV1EditImageAsync( + string prompt, + global::System.Collections.Generic.IReadOnlyList? images = default, + global::System.Collections.Generic.IReadOnlyList? imagesFileNames = default, + global::System.Collections.Generic.IList? imageUrls = default, + int? numImages = default, + int? seed = default, + global::Ideogram.MagicPromptOption? magicPrompt = default, + string? magicPromptSystemPromptConfigId = default, + global::Ideogram.ResolutionV3? resolution = default, + global::Ideogram.AspectRatioV3? aspectRatio = default, + bool? transparentBackground = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + var request = new global::Ideogram.V1EditImagesRequest + { + Prompt = prompt, + Images = new global::System.Collections.Generic.List(), + ImageUrls = imageUrls, + NumImages = numImages, + Seed = seed, + MagicPrompt = magicPrompt, + MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId, + Resolution = resolution, + AspectRatio = aspectRatio, + TransparentBackground = transparentBackground, + }; + PrepareArguments( + client: HttpClient); + PreparePostV1EditImageArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_PostV1EditImageSecurityRequirements, + operationName: "PostV1EditImageAsync"); + + using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Ideogram.PathBuilder( + path: "/v1/edit", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), + name: "\"prompt\""); + + if (images != default) + { + + for (var __iImages = 0; __iImages < images.Count; __iImages++) + { + var __fileNameImages = imagesFileNames != null && + __iImages < imagesFileNames.Count && + imagesFileNames[__iImages] != null + ? imagesFileNames[__iImages] + : $"file{__iImages}.bin"; + var __contentImages = new global::System.Net.Http.StreamContent(images[__iImages]); + __contentImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + __fileNameImages is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(__fileNameImages) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentImages, + name: "\"images\"", + fileName: $"\"{__fileNameImages}\""); + if (__contentImages.Headers.ContentDisposition != null) + { + __contentImages.Headers.ContentDisposition.FileNameStar = null; + } + } + + } + if (request.ImageUrls != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.ImageUrls, x => x))}]"), + name: "\"image_urls\""); + + } + if (request.NumImages != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"num_images\""); + + } + if (request.Seed != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"seed\""); + + } + if (request.MagicPrompt != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.MagicPrompt).HasValue ? (request.MagicPrompt).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"magic_prompt\""); + + } + if (request.MagicPromptSystemPromptConfigId != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty), + name: "\"magic_prompt_system_prompt_config_id\""); + + } + if (request.Resolution != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.Resolution).HasValue ? (request.Resolution).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"resolution\""); + + } + if (request.AspectRatio != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.AspectRatio).HasValue ? (request.AspectRatio).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"aspect_ratio\""); + + } + if (request.TransparentBackground != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.TransparentBackground, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()), + name: "\"transparent_background\""); + + } + + __httpRequest.Content = __httpRequestContent; + + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PreparePostV1EditImageRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostV1EditImage", + methodName: "PostV1EditImageAsync", + pathTemplate: "\"/v1/edit\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostV1EditImage", + methodName: "PostV1EditImageAsync", + pathTemplate: "\"/v1/edit\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostV1EditImage", + methodName: "PostV1EditImageAsync", + pathTemplate: "\"/v1/edit\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessPostV1EditImageResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostV1EditImage", + methodName: "PostV1EditImageAsync", + pathTemplate: "\"/v1/edit\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostV1EditImage", + methodName: "PostV1EditImageAsync", + pathTemplate: "\"/v1/edit\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 402) + { + string? __content_402 = null; + global::System.Exception? __exception_402 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_402 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_402 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_402, + statusCode: __response.StatusCode) + { + ResponseBody = __content_402, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Prompt or provided image failed safety checks. + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Ideogram.GenerateImageSafetyError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 503) + { + string? __content_503 = null; + global::System.Exception? __exception_503 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_503 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_503 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_503, + statusCode: __response.StatusCode) + { + ResponseBody = __content_503, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessPostV1EditImageResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Ideogram.V1EditImagesResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Ideogram.V1EditImagesResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Edit images with a prompt
+ /// Edit one or more images using a text prompt. Provide images via file upload
+ /// or Ideogram image URLs, and describe the desired edit in your prompt.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// The prompt describing the desired edit.
+ /// Example: Change the background to a beach sunset. + /// + /// + /// Images to edit (max 10 images, max size 10MB each); JPEG, WebP and PNG formats are supported. + /// + /// + /// Optional file names to use for the multipart 'images' file parts. + /// + /// + /// URLs to Ideogram images to use as references (max 10). Supports URLs from generation responses and image uploads. Alternative to uploading via the images field. + /// + /// + /// The number of images to generate.
+ /// Default Value: 1 + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// + /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON + /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + /// + /// The resolutions supported for Ideogram 3.0.
+ /// Example: 1280x800 + /// + /// + /// The aspect ratio to use for image generation, which determines the image's resolution. Cannot be used in conjunction with resolution. Defaults to 1x1. + /// + /// + /// Whether the output should have a transparent background. Default false.
+ /// Default Value: false + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> PostV1EditImageAsResponseAsync( + string prompt, + global::System.Collections.Generic.IReadOnlyList? images = default, + global::System.Collections.Generic.IReadOnlyList? imagesFileNames = default, + global::System.Collections.Generic.IList? imageUrls = default, + int? numImages = default, + int? seed = default, + global::Ideogram.MagicPromptOption? magicPrompt = default, + string? magicPromptSystemPromptConfigId = default, + global::Ideogram.ResolutionV3? resolution = default, + global::Ideogram.AspectRatioV3? aspectRatio = default, + bool? transparentBackground = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + var request = new global::Ideogram.V1EditImagesRequest + { + Prompt = prompt, + Images = new global::System.Collections.Generic.List(), + ImageUrls = imageUrls, + NumImages = numImages, + Seed = seed, + MagicPrompt = magicPrompt, + MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId, + Resolution = resolution, + AspectRatio = aspectRatio, + TransparentBackground = transparentBackground, + }; + PrepareArguments( + client: HttpClient); + PreparePostV1EditImageArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_PostV1EditImageSecurityRequirements, + operationName: "PostV1EditImageAsync"); + + using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Ideogram.PathBuilder( + path: "/v1/edit", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), + name: "\"prompt\""); + + if (images != default) + { + + for (var __iImages = 0; __iImages < images.Count; __iImages++) + { + var __fileNameImages = imagesFileNames != null && + __iImages < imagesFileNames.Count && + imagesFileNames[__iImages] != null + ? imagesFileNames[__iImages] + : $"file{__iImages}.bin"; + var __contentImages = new global::System.Net.Http.StreamContent(images[__iImages]); + __contentImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + __fileNameImages is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(__fileNameImages) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentImages, + name: "\"images\"", + fileName: $"\"{__fileNameImages}\""); + if (__contentImages.Headers.ContentDisposition != null) + { + __contentImages.Headers.ContentDisposition.FileNameStar = null; + } + } + + } + if (request.ImageUrls != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.ImageUrls, x => x))}]"), + name: "\"image_urls\""); + + } + if (request.NumImages != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"num_images\""); + + } + if (request.Seed != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"seed\""); + + } + if (request.MagicPrompt != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.MagicPrompt).HasValue ? (request.MagicPrompt).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"magic_prompt\""); + + } + if (request.MagicPromptSystemPromptConfigId != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty), + name: "\"magic_prompt_system_prompt_config_id\""); + + } + if (request.Resolution != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.Resolution).HasValue ? (request.Resolution).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"resolution\""); + + } + if (request.AspectRatio != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.AspectRatio).HasValue ? (request.AspectRatio).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"aspect_ratio\""); + + } + if (request.TransparentBackground != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.TransparentBackground, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()), + name: "\"transparent_background\""); + + } + + __httpRequest.Content = __httpRequestContent; + + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PreparePostV1EditImageRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostV1EditImage", + methodName: "PostV1EditImageAsync", + pathTemplate: "\"/v1/edit\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostV1EditImage", + methodName: "PostV1EditImageAsync", + pathTemplate: "\"/v1/edit\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostV1EditImage", + methodName: "PostV1EditImageAsync", + pathTemplate: "\"/v1/edit\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessPostV1EditImageResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostV1EditImage", + methodName: "PostV1EditImageAsync", + pathTemplate: "\"/v1/edit\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostV1EditImage", + methodName: "PostV1EditImageAsync", + pathTemplate: "\"/v1/edit\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 402) + { + string? __content_402 = null; + global::System.Exception? __exception_402 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_402 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_402 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_402 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_402, + statusCode: __response.StatusCode) + { + ResponseBody = __content_402, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Prompt or provided image failed safety checks. + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Ideogram.GenerateImageSafetyError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 503) + { + string? __content_503 = null; + global::System.Exception? __exception_503 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_503 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_503 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_503 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_503, + statusCode: __response.StatusCode) + { + ResponseBody = __content_503, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessPostV1EditImageResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Ideogram.V1EditImagesResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + var __value = await global::Ideogram.V1EditImagesResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.g.cs b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.g.cs index 6a99377..1c2decd 100644 --- a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.g.cs @@ -73,10 +73,10 @@ public GenerateClient( /// Client-wide request defaults such as headers, query parameters, retries, and timeout. /// Dispose the HttpClient when the instance is disposed. True by default. public GenerateClient( - global::System.Net.Http.HttpClient? httpClient = null, - global::System.Uri? baseUri = null, - global::System.Collections.Generic.List? authorizations = null, - global::Ideogram.AutoSDKClientOptions? options = null, + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Ideogram.AutoSDKClientOptions? options, bool disposeHttpClient = true) { diff --git a/src/libs/Ideogram/Generated/Ideogram.IBatchClient.GetMaybeBatchResults.g.cs b/src/libs/Ideogram/Generated/Ideogram.IBatchClient.GetMaybeBatchResults.g.cs index 91af1fc..6df74be 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IBatchClient.GetMaybeBatchResults.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IBatchClient.GetMaybeBatchResults.g.cs @@ -16,5 +16,17 @@ public partial interface IBatchClient string jobId, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get Batch Magic Prompt Job Results if available.
+ /// Gets the results of a batch magic prompt job if available. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> GetMaybeBatchResultsAsResponseAsync( + string jobId, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.IBatchClient.PostBatch.g.cs b/src/libs/Ideogram/Generated/Ideogram.IBatchClient.PostBatch.g.cs index 4b211a8..26096eb 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IBatchClient.PostBatch.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IBatchClient.PostBatch.g.cs @@ -23,6 +23,20 @@ public partial interface IBatchClient /// Runs automated evaluation of multiple LLM models and system prompts for magic prompt generation.
/// Generates images using large batches of user prompt inputs. Internal use only (feature flagged). /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> PostBatchAsResponseAsync( + + global::Ideogram.InternalBatchRequest request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Initiate Batch Magic Prompt Evalution
+ /// Runs automated evaluation of multiple LLM models and system prompts for magic prompt generation.
+ /// Generates images using large batches of user prompt inputs. Internal use only (feature flagged). + ///
/// /// The prompts to enhance with a magic prompt.
/// Example: [a cat, a dog] @@ -32,7 +46,7 @@ public partial interface IBatchClient /// Example: MAGIC_PROMPT_NO_TEXT /// /// - /// Example: {"aspect_ratio":"1x1","style_type":"GENERAL","magic_prompt_version":"V_0","seed":12345,"negative_prompt":"brush strokes, painting","magic_prompt_option":"ON","model":"V_2_TURBO","resolution":"1280x800","num_images":1,"color_palette":{"name":"PASTEL"}} + /// Example: {"magic_prompt_system_prompt_config_id":"magic_prompt_system_prompt_config_id","aspect_ratio":"1x1","style_type":"GENERAL","magic_prompt_version":"V_0","seed":12345,"negative_prompt":"brush strokes, painting","magic_prompt_option":"ON","model":"V_2_TURBO","resolution":"1280x800","num_images":1,"color_palette":{"name":"PASTEL"}} /// /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with diff --git a/src/libs/Ideogram/Generated/Ideogram.IDatasetsClient.CreateDataset.g.cs b/src/libs/Ideogram/Generated/Ideogram.IDatasetsClient.CreateDataset.g.cs index 740c181..69ab609 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IDatasetsClient.CreateDataset.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IDatasetsClient.CreateDataset.g.cs @@ -21,6 +21,19 @@ public partial interface IDatasetsClient /// Create a new dataset
/// Creates a new dataset /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> CreateDatasetAsResponseAsync( + + global::Ideogram.CreateDatasetRequest request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Create a new dataset
+ /// Creates a new dataset + ///
/// /// Name of the dataset. /// diff --git a/src/libs/Ideogram/Generated/Ideogram.IDatasetsClient.GetDataset.g.cs b/src/libs/Ideogram/Generated/Ideogram.IDatasetsClient.GetDataset.g.cs index 45d893e..f15d31c 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IDatasetsClient.GetDataset.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IDatasetsClient.GetDataset.g.cs @@ -16,5 +16,17 @@ public partial interface IDatasetsClient string datasetId, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get a dataset
+ /// Returns a dataset by ID, including the total number of files and a list of each file's name and size in bytes. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> GetDatasetAsResponseAsync( + string datasetId, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.IDatasetsClient.ListDatasets.g.cs b/src/libs/Ideogram/Generated/Ideogram.IDatasetsClient.ListDatasets.g.cs index 6c3f221..3a78f7d 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IDatasetsClient.ListDatasets.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IDatasetsClient.ListDatasets.g.cs @@ -14,5 +14,15 @@ public partial interface IDatasetsClient global::System.Threading.Tasks.Task ListDatasetsAsync( global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + /// + /// List datasets
+ /// Lists all datasets for the authenticated user + ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> ListDatasetsAsResponseAsync( + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.IDatasetsClient.TrainDatasetModel.g.cs b/src/libs/Ideogram/Generated/Ideogram.IDatasetsClient.TrainDatasetModel.g.cs index d66ddee..96fad43 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IDatasetsClient.TrainDatasetModel.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IDatasetsClient.TrainDatasetModel.g.cs @@ -24,6 +24,21 @@ public partial interface IDatasetsClient /// Start training a custom model from a dataset. The dataset must contain at least 15 images and a maximum of 100 images. Returns the model ID and training status. /// /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> TrainDatasetModelAsResponseAsync( + string datasetId, + + global::Ideogram.TrainDatasetModelRequest request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Train a model from a dataset
+ /// Start training a custom model from a dataset. The dataset must contain at least 15 images and a maximum of 100 images. Returns the model ID and training status. + ///
+ /// /// /// Name for the trained model. Must be 5-30 characters, alphanumeric with spaces and hyphens allowed.
/// Example: my-custom-model diff --git a/src/libs/Ideogram/Generated/Ideogram.IDatasetsClient.UploadDatasetAssets.g.cs b/src/libs/Ideogram/Generated/Ideogram.IDatasetsClient.UploadDatasetAssets.g.cs index bfcdb84..2bf18c9 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IDatasetsClient.UploadDatasetAssets.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IDatasetsClient.UploadDatasetAssets.g.cs @@ -24,6 +24,21 @@ public partial interface IDatasetsClient /// Upload image assets to a dataset for model training. Accepts individual images (JPEG, PNG, WebP), optional .txt caption sidecar files, and/or ZIP archives containing images and captions. A dataset can contain up to 100 images. /// /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> UploadDatasetAssetsAsResponseAsync( + string datasetId, + + global::Ideogram.UploadDatasetAssetsRequest request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Upload assets to a dataset
+ /// Upload image assets to a dataset for model training. Accepts individual images (JPEG, PNG, WebP), optional .txt caption sidecar files, and/or ZIP archives containing images and captions. A dataset can contain up to 100 images. + ///
+ /// /// /// Image files (JPEG, PNG, WebP), .txt caption sidecar files, and/or ZIP archives containing images and captions. Caption .txt files are matched to images by filename stem (e.g. sunset.txt provides the caption for sunset.jpg). Captions are optional! /// @@ -35,5 +50,46 @@ public partial interface IDatasetsClient global::System.Collections.Generic.IList files, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + + /// + /// Upload assets to a dataset
+ /// Upload image assets to a dataset for model training. Accepts individual images (JPEG, PNG, WebP), optional .txt caption sidecar files, and/or ZIP archives containing images and captions. A dataset can contain up to 100 images. + ///
+ /// + /// + /// Image files (JPEG, PNG, WebP), .txt caption sidecar files, and/or ZIP archives containing images and captions. Caption .txt files are matched to images by filename stem (e.g. sunset.txt provides the caption for sunset.jpg). Captions are optional! + /// + /// + /// Optional file names to use for the multipart 'files' file parts. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task UploadDatasetAssetsAsync( + string datasetId, + global::System.Collections.Generic.IReadOnlyList files, + global::System.Collections.Generic.IReadOnlyList? filesFileNames = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Upload assets to a dataset
+ /// Upload image assets to a dataset for model training. Accepts individual images (JPEG, PNG, WebP), optional .txt caption sidecar files, and/or ZIP archives containing images and captions. A dataset can contain up to 100 images. + ///
+ /// + /// + /// Image files (JPEG, PNG, WebP), .txt caption sidecar files, and/or ZIP archives containing images and captions. Caption .txt files are matched to images by filename stem (e.g. sunset.txt provides the caption for sunset.jpg). Captions are optional! + /// + /// + /// Optional file names to use for the multipart 'files' file parts. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> UploadDatasetAssetsAsResponseAsync( + string datasetId, + global::System.Collections.Generic.IReadOnlyList files, + global::System.Collections.Generic.IReadOnlyList? filesFileNames = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostEditImage.g.cs b/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostEditImage.g.cs index 04264b8..9fc6e68 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostEditImage.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostEditImage.g.cs @@ -27,6 +27,22 @@ public partial interface IGenerateClient /// Supported image formats include JPEG, PNG, and WebP.
/// Images links are available for a limited period of time; if you would like to keep the image, you must download it. /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> PostEditImageAsResponseAsync( + + global::Ideogram.EditImageRequest request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Edit (legacy)
+ /// Edit a given image synchronously using the provided mask. The mask indicates which part of the image
+ /// should be edited, while the prompt and chosen style type can further guide the edit.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
/// /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. /// @@ -52,6 +68,9 @@ public partial interface IGenerateClient /// Determine if MagicPrompt should be used in generating the request or not.
/// Example: ON /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// /// /// The number of images to generate.
/// Default Value: 1 @@ -75,6 +94,136 @@ public partial interface IGenerateClient string prompt, global::Ideogram.ModelEnum model = global::Ideogram.ModelEnum.V2, global::Ideogram.MagicPromptOption? magicPromptOption = default, + string? magicPromptSystemPromptConfigId = default, + int? numImages = default, + int? seed = default, + global::Ideogram.StyleType? styleType = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + + /// + /// Edit (legacy)
+ /// Edit a given image synchronously using the provided mask. The mask indicates which part of the image
+ /// should be edited, while the prompt and chosen style type can further guide the edit.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// A black and white image of the same size as the image being edited (max size 10MB). Black regions in the mask should match up with the regions of the image that you would like to edit; only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// A black and white image of the same size as the image being edited (max size 10MB). Black regions in the mask should match up with the regions of the image that you would like to edit; only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The prompt used to describe the edited result.
+ /// Example: A serene tropical beach scene. Dominating the foreground are tall palm trees with lush green leaves, standing tall against a backdrop of a sandy beach. The beach leads to the azure waters of the sea, which gently kisses the shoreline. In the distance, there is an island or landmass with a silhouette of what appears to be a lighthouse or tower. The sky above is painted with fluffy white clouds, some of which are tinged with hues of pink and orange, suggesting either a sunrise or sunset. + /// + /// + /// The model used to generate an image or edit one. /generate and /remix supports all model types, however, /edit is only supported for V_2 and V_2_TURBO.
+ /// Default Value: V_2
+ /// Example: V_2_TURBO + /// + /// + /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON + /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + /// + /// The number of images to generate.
+ /// Default Value: 1 + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// + /// The style type to generate with; this is only applicable for models V_2 and above and should not be specified for model versions V_1.
+ /// Example: REALISTIC + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task PostEditImageAsync( + global::System.IO.Stream imageFile, + string imageFilename, + global::System.IO.Stream mask, + string maskname, + string prompt, + global::Ideogram.ModelEnum model = global::Ideogram.ModelEnum.V2, + global::Ideogram.MagicPromptOption? magicPromptOption = default, + string? magicPromptSystemPromptConfigId = default, + int? numImages = default, + int? seed = default, + global::Ideogram.StyleType? styleType = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Edit (legacy)
+ /// Edit a given image synchronously using the provided mask. The mask indicates which part of the image
+ /// should be edited, while the prompt and chosen style type can further guide the edit.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// A black and white image of the same size as the image being edited (max size 10MB). Black regions in the mask should match up with the regions of the image that you would like to edit; only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// A black and white image of the same size as the image being edited (max size 10MB). Black regions in the mask should match up with the regions of the image that you would like to edit; only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The prompt used to describe the edited result.
+ /// Example: A serene tropical beach scene. Dominating the foreground are tall palm trees with lush green leaves, standing tall against a backdrop of a sandy beach. The beach leads to the azure waters of the sea, which gently kisses the shoreline. In the distance, there is an island or landmass with a silhouette of what appears to be a lighthouse or tower. The sky above is painted with fluffy white clouds, some of which are tinged with hues of pink and orange, suggesting either a sunrise or sunset. + /// + /// + /// The model used to generate an image or edit one. /generate and /remix supports all model types, however, /edit is only supported for V_2 and V_2_TURBO.
+ /// Default Value: V_2
+ /// Example: V_2_TURBO + /// + /// + /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON + /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + /// + /// The number of images to generate.
+ /// Default Value: 1 + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// + /// The style type to generate with; this is only applicable for models V_2 and above and should not be specified for model versions V_1.
+ /// Example: REALISTIC + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> PostEditImageAsResponseAsync( + global::System.IO.Stream imageFile, + string imageFilename, + global::System.IO.Stream mask, + string maskname, + string prompt, + global::Ideogram.ModelEnum model = global::Ideogram.ModelEnum.V2, + global::Ideogram.MagicPromptOption? magicPromptOption = default, + string? magicPromptSystemPromptConfigId = default, int? numImages = default, int? seed = default, global::Ideogram.StyleType? styleType = default, diff --git a/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostEditImageV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostEditImageV3.g.cs deleted file mode 100644 index 04369d8..0000000 --- a/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostEditImageV3.g.cs +++ /dev/null @@ -1,116 +0,0 @@ -#nullable enable - -namespace Ideogram -{ - public partial interface IGenerateClient - { - /// - /// Edit with Ideogram 3.0
- /// Edit a given image synchronously using the provided mask with Ideogram 3.0. The mask indicates which part of the image
- /// should be edited, while the prompt and chosen style can further guide the edit.
- /// Supported image formats include JPEG, PNG, and WebP.
- /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. - ///
- /// - /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. - /// The token to cancel the operation with - /// - global::System.Threading.Tasks.Task PostEditImageV3Async( - - global::Ideogram.EditImageRequestV3 request, - global::Ideogram.AutoSDKRequestOptions? requestOptions = default, - global::System.Threading.CancellationToken cancellationToken = default); - /// - /// Edit with Ideogram 3.0
- /// Edit a given image synchronously using the provided mask with Ideogram 3.0. The mask indicates which part of the image
- /// should be edited, while the prompt and chosen style can further guide the edit.
- /// Supported image formats include JPEG, PNG, and WebP.
- /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. - ///
- /// - /// The image being edited (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. - /// - /// - /// The image being edited (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. - /// - /// - /// A black and white image of the same size as the image being edited (max size 10MB). Black regions in the mask should match up with the regions of the image that you would like to edit; only JPEG, WebP and PNG formats are supported at this time. - /// - /// - /// A black and white image of the same size as the image being edited (max size 10MB). Black regions in the mask should match up with the regions of the image that you would like to edit; only JPEG, WebP and PNG formats are supported at this time. - /// - /// - /// The prompt used to describe the edited result.
- /// Example: A photo of a cat. - /// - /// - /// Determine if MagicPrompt should be used in generating the request or not.
- /// Example: ON - /// - /// - /// The number of images to generate.
- /// Default Value: 1 - /// - /// - /// Random seed. Set for reproducible generation.
- /// Example: 12345 - /// - /// - /// The rendering speed to use.
- /// Default Value: DEFAULT - /// - /// - /// The style type to generate with.
- /// Default Value: GENERAL
- /// Example: GENERAL - /// - /// - /// A predefined style preset that applies a specific artistic style to the generated image.
- /// Example: BRIGHT_ART - /// - /// - /// A custom model URI in the format model/<model_name>/version/<version_name>.
- /// When provided, the model version and style will be resolved from this URI, and style_type is not required.
- /// Example: model/my-custom-model/version/1 - /// - /// - /// A color palette for generation, must EITHER be specified via one of the presets (name) or explicitly via hexadecimal representations of the color with optional weights (members). Not supported by V_1, V_1_TURBO, V_2A and V_2A_TURBO models. - /// - /// - /// A list of 8 character hexadecimal codes representing the style of the image. Cannot be used in conjunction with style_reference_images or style_type.
- /// Example: [AAFF5733, 0133FF57, DE3357FF] - /// - /// - /// A set of images to use as style references (maximum total size 10MB across all style references). The images should be in JPEG, PNG or WebP format. - /// - /// - /// Generations with character reference are subject to the character reference pricing. A set of images to use as character references (maximum total size 10MB across all character references), currently only supports 1 character reference image. The images should be in JPEG, PNG or WebP format. - /// - /// - /// Optional masks for character reference images. When provided, must match the number of character_reference_images. Each mask should be a grayscale image of the same dimensions as the corresponding character reference image. The images should be in JPEG, PNG or WebP format. - /// - /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. - /// The token to cancel the operation with - /// - global::System.Threading.Tasks.Task PostEditImageV3Async( - byte[] image, - string imagename, - byte[] mask, - string maskname, - string prompt, - global::Ideogram.MagicPromptOption? magicPrompt = default, - int? numImages = default, - int? seed = default, - global::Ideogram.RenderingSpeed? renderingSpeed = default, - global::Ideogram.StyleTypeV3? styleType = default, - global::Ideogram.StylePresetV3? stylePreset = default, - string? customModelUri = default, - global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette = default, - global::System.Collections.Generic.IList? styleCodes = default, - global::System.Collections.Generic.IList? styleReferenceImages = default, - global::System.Collections.Generic.IList? characterReferenceImages = default, - global::System.Collections.Generic.IList? characterReferenceImagesMask = default, - global::Ideogram.AutoSDKRequestOptions? requestOptions = default, - global::System.Threading.CancellationToken cancellationToken = default); - } -} \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostGenerateDesignV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostGenerateDesignV3.g.cs index 2e84a7d..7e69d59 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostGenerateDesignV3.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostGenerateDesignV3.g.cs @@ -25,6 +25,21 @@ public partial interface IGenerateClient /// The response includes the generated image URL along with detected text layers (with font, size, color, position) and image asset layers.
/// Images links are available for a limited period of time; if you would like to keep the image, you must download it. /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> PostGenerateDesignV3AsResponseAsync( + + global::Ideogram.GenerateDesignRequestV3 request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Generate a design from a text prompt with text detection and correction
+ /// Generates a design synchronously from a text prompt using the Ideogram 3.0 model, then detects and corrects text layers within the generated image.
+ /// The response includes the generated image URL along with detected text layers (with font, size, color, position) and image asset layers.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
/// /// The prompt to use to generate the design.
/// Example: A birthday card saying 'Happy Birthday' @@ -48,6 +63,9 @@ public partial interface IGenerateClient /// Determine if MagicPrompt should be used in generating the request or not.
/// Example: ON /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// /// /// Description of what to exclude from a design. Descriptions in the prompt take precedence
/// to descriptions in the negative prompt.
@@ -131,6 +149,7 @@ public partial interface IGenerateClient global::Ideogram.AspectRatioV3? aspectRatio = default, global::Ideogram.RenderingSpeed? renderingSpeed = default, global::Ideogram.MagicPromptOption? magicPrompt = default, + string? magicPromptSystemPromptConfigId = default, string? negativePrompt = default, int? numImages = default, global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette = default, @@ -154,5 +173,300 @@ public partial interface IGenerateClient global::System.Collections.Generic.IList? referenceAssetImages = default, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + + /// + /// Generate a design from a text prompt with text detection and correction
+ /// Generates a design synchronously from a text prompt using the Ideogram 3.0 model, then detects and corrects text layers within the generated image.
+ /// The response includes the generated image URL along with detected text layers (with font, size, color, position) and image asset layers.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// The prompt to use to generate the design.
+ /// Example: A birthday card saying 'Happy Birthday' + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// + /// The resolutions supported for Ideogram 3.0.
+ /// Example: 1280x800 + /// + /// + /// The aspect ratio to use for image generation, which determines the image's resolution. Cannot be used in conjunction with resolution. Defaults to 1x1. + /// + /// + /// The rendering speed to use.
+ /// Default Value: DEFAULT + /// + /// + /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON + /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + /// + /// Description of what to exclude from a design. Descriptions in the prompt take precedence
+ /// to descriptions in the negative prompt.
+ /// Example: brush strokes, painting + /// + /// + /// Number of designs to generate.
+ /// Default Value: 1 + /// + /// + /// A color palette for generation, must EITHER be specified via one of the presets (name) or explicitly via hexadecimal representations of the color with optional weights (members). Not supported by V_1, V_1_TURBO, V_2A and V_2A_TURBO models. + /// + /// + /// A list of 8 character hexadecimal codes representing the style of the image. Cannot be used in conjunction with style_reference_images or style_type.
+ /// Example: [AAFF5733, 0133FF57, DE3357FF] + /// + /// + /// The style type to generate with.
+ /// Default Value: GENERAL
+ /// Example: GENERAL + /// + /// + /// A predefined style preset that applies a specific artistic style to the generated image.
+ /// Example: BRIGHT_ART + /// + /// + /// A custom model URI in the format model/<model_name>/version/<version_name>.
+ /// When provided, the model version and style will be resolved from this URI, and style_type is not required.
+ /// Example: model/my-custom-model/version/1 + /// + /// + /// Custom font file for H1 (heading) text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_h1. + /// + /// + /// Custom font file for H1 (heading) text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_h1. + /// + /// + /// Font name from the available font library for H1 text. Ignored if font_file_h1 is provided.
+ /// Example: Ubuntu-Bold.ttf + /// + /// + /// Custom font file for H2 (subheading) text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_h2. + /// + /// + /// Custom font file for H2 (subheading) text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_h2. + /// + /// + /// Font name from the available font library for H2 text. Ignored if font_file_h2 is provided. + /// + /// + /// Custom font file for body text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_body. + /// + /// + /// Custom font file for body text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_body. + /// + /// + /// Font name from the available font library for body text. Ignored if font_file_body is provided. + /// + /// + /// Custom font file for small/caption text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_small. + /// + /// + /// Custom font file for small/caption text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_small. + /// + /// + /// Font name from the available font library for small text. Ignored if font_file_small is provided. + /// + /// + /// A set of images to use as style references (maximum total size 10MB across all style references). The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'style_reference_images' file parts. + /// + /// + /// A set of asset images (e.g., logos, icons) to use as references for detection and replacement (maximum 10 images). The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'reference_asset_images' file parts. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task PostGenerateDesignV3Async( + string prompt, + int? seed = default, + global::Ideogram.ResolutionV3? resolution = default, + global::Ideogram.AspectRatioV3? aspectRatio = default, + global::Ideogram.RenderingSpeed? renderingSpeed = default, + global::Ideogram.MagicPromptOption? magicPrompt = default, + string? magicPromptSystemPromptConfigId = default, + string? negativePrompt = default, + int? numImages = default, + global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette = default, + global::System.Collections.Generic.IList? styleCodes = default, + global::Ideogram.StyleTypeV3? styleType = default, + global::Ideogram.StylePresetV3? stylePreset = default, + string? customModelUri = default, + global::System.IO.Stream? fontFileH1 = default, + string? fontFileH1name = default, + string? fontNameH1 = default, + global::System.IO.Stream? fontFileH2 = default, + string? fontFileH2name = default, + string? fontNameH2 = default, + global::System.IO.Stream? fontFileBody = default, + string? fontFileBodyname = default, + string? fontNameBody = default, + global::System.IO.Stream? fontFileSmall = default, + string? fontFileSmallname = default, + string? fontNameSmall = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImages = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImagesFileNames = default, + global::System.Collections.Generic.IReadOnlyList? referenceAssetImages = default, + global::System.Collections.Generic.IReadOnlyList? referenceAssetImagesFileNames = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Generate a design from a text prompt with text detection and correction
+ /// Generates a design synchronously from a text prompt using the Ideogram 3.0 model, then detects and corrects text layers within the generated image.
+ /// The response includes the generated image URL along with detected text layers (with font, size, color, position) and image asset layers.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// The prompt to use to generate the design.
+ /// Example: A birthday card saying 'Happy Birthday' + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// + /// The resolutions supported for Ideogram 3.0.
+ /// Example: 1280x800 + /// + /// + /// The aspect ratio to use for image generation, which determines the image's resolution. Cannot be used in conjunction with resolution. Defaults to 1x1. + /// + /// + /// The rendering speed to use.
+ /// Default Value: DEFAULT + /// + /// + /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON + /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + /// + /// Description of what to exclude from a design. Descriptions in the prompt take precedence
+ /// to descriptions in the negative prompt.
+ /// Example: brush strokes, painting + /// + /// + /// Number of designs to generate.
+ /// Default Value: 1 + /// + /// + /// A color palette for generation, must EITHER be specified via one of the presets (name) or explicitly via hexadecimal representations of the color with optional weights (members). Not supported by V_1, V_1_TURBO, V_2A and V_2A_TURBO models. + /// + /// + /// A list of 8 character hexadecimal codes representing the style of the image. Cannot be used in conjunction with style_reference_images or style_type.
+ /// Example: [AAFF5733, 0133FF57, DE3357FF] + /// + /// + /// The style type to generate with.
+ /// Default Value: GENERAL
+ /// Example: GENERAL + /// + /// + /// A predefined style preset that applies a specific artistic style to the generated image.
+ /// Example: BRIGHT_ART + /// + /// + /// A custom model URI in the format model/<model_name>/version/<version_name>.
+ /// When provided, the model version and style will be resolved from this URI, and style_type is not required.
+ /// Example: model/my-custom-model/version/1 + /// + /// + /// Custom font file for H1 (heading) text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_h1. + /// + /// + /// Custom font file for H1 (heading) text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_h1. + /// + /// + /// Font name from the available font library for H1 text. Ignored if font_file_h1 is provided.
+ /// Example: Ubuntu-Bold.ttf + /// + /// + /// Custom font file for H2 (subheading) text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_h2. + /// + /// + /// Custom font file for H2 (subheading) text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_h2. + /// + /// + /// Font name from the available font library for H2 text. Ignored if font_file_h2 is provided. + /// + /// + /// Custom font file for body text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_body. + /// + /// + /// Custom font file for body text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_body. + /// + /// + /// Font name from the available font library for body text. Ignored if font_file_body is provided. + /// + /// + /// Custom font file for small/caption text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_small. + /// + /// + /// Custom font file for small/caption text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_small. + /// + /// + /// Font name from the available font library for small text. Ignored if font_file_small is provided. + /// + /// + /// A set of images to use as style references (maximum total size 10MB across all style references). The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'style_reference_images' file parts. + /// + /// + /// A set of asset images (e.g., logos, icons) to use as references for detection and replacement (maximum 10 images). The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'reference_asset_images' file parts. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> PostGenerateDesignV3AsResponseAsync( + string prompt, + int? seed = default, + global::Ideogram.ResolutionV3? resolution = default, + global::Ideogram.AspectRatioV3? aspectRatio = default, + global::Ideogram.RenderingSpeed? renderingSpeed = default, + global::Ideogram.MagicPromptOption? magicPrompt = default, + string? magicPromptSystemPromptConfigId = default, + string? negativePrompt = default, + int? numImages = default, + global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette = default, + global::System.Collections.Generic.IList? styleCodes = default, + global::Ideogram.StyleTypeV3? styleType = default, + global::Ideogram.StylePresetV3? stylePreset = default, + string? customModelUri = default, + global::System.IO.Stream? fontFileH1 = default, + string? fontFileH1name = default, + string? fontNameH1 = default, + global::System.IO.Stream? fontFileH2 = default, + string? fontFileH2name = default, + string? fontNameH2 = default, + global::System.IO.Stream? fontFileBody = default, + string? fontFileBodyname = default, + string? fontNameBody = default, + global::System.IO.Stream? fontFileSmall = default, + string? fontFileSmallname = default, + string? fontNameSmall = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImages = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImagesFileNames = default, + global::System.Collections.Generic.IReadOnlyList? referenceAssetImages = default, + global::System.Collections.Generic.IReadOnlyList? referenceAssetImagesFileNames = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostGenerateImage.g.cs b/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostGenerateImage.g.cs index 31fcd0b..e5c59b1 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostGenerateImage.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostGenerateImage.g.cs @@ -23,6 +23,20 @@ public partial interface IGenerateClient /// Generates images synchronously based on a given prompt and optional parameters.
/// Images links are available for a limited period of time; if you would like to keep the image, you must download it. /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> PostGenerateImageAsResponseAsync( + + global::Ideogram.GenerateImageRequest request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Generate (legacy)
+ /// Generates images synchronously based on a given prompt and optional parameters.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
/// /// Example: {"aspect_ratio":"ASPECT_10_16","magic_prompt_option":"AUTO","model":"V_2","prompt":"A serene tropical beach scene. Dominating the foreground are tall palm trees with lush green leaves, standing tall against a backdrop of a sandy beach. The beach leads to the azure waters of the sea, which gently kisses the shoreline. In the distance, there is an island or landmass with a silhouette of what appears to be a lighthouse or tower. The sky above is painted with fluffy white clouds, some of which are tinged with hues of pink and orange, suggesting either a sunrise or sunset."} /// diff --git a/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostGenerateImageV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostGenerateImageV3.g.cs index 7215309..27c4bfe 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostGenerateImageV3.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostGenerateImageV3.g.cs @@ -23,6 +23,20 @@ public partial interface IGenerateClient /// Generates images synchronously based on a given prompt and optional parameters using the Ideogram 3.0 model.
/// Images links are available for a limited period of time; if you would like to keep the image, you must download it. /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> PostGenerateImageV3AsResponseAsync( + + global::Ideogram.GenerateImageRequestV3 request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Generate with Ideogram 3.0
+ /// Generates images synchronously based on a given prompt and optional parameters using the Ideogram 3.0 model.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
/// /// The prompt to use to generate the image.
/// Example: A photo of a cat @@ -46,6 +60,9 @@ public partial interface IGenerateClient /// Determine if MagicPrompt should be used in generating the request or not.
/// Example: ON /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// /// /// Description of what to exclude from an image. Descriptions in the prompt take precedence
/// to descriptions in the negative prompt.
@@ -95,6 +112,7 @@ public partial interface IGenerateClient global::Ideogram.AspectRatioV3? aspectRatio = default, global::Ideogram.RenderingSpeed? renderingSpeed = default, global::Ideogram.MagicPromptOption? magicPrompt = default, + string? magicPromptSystemPromptConfigId = default, string? negativePrompt = default, int? numImages = default, global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette = default, @@ -107,5 +125,216 @@ public partial interface IGenerateClient global::System.Collections.Generic.IList? characterReferenceImagesMask = default, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + + /// + /// Generate with Ideogram 3.0
+ /// Generates images synchronously based on a given prompt and optional parameters using the Ideogram 3.0 model.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// The prompt to use to generate the image.
+ /// Example: A photo of a cat + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// + /// The resolutions supported for Ideogram 3.0.
+ /// Example: 1280x800 + /// + /// + /// The aspect ratio to use for image generation, which determines the image's resolution. Cannot be used in conjunction with resolution. Defaults to 1x1. + /// + /// + /// The rendering speed to use.
+ /// Default Value: DEFAULT + /// + /// + /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON + /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + /// + /// Description of what to exclude from an image. Descriptions in the prompt take precedence
+ /// to descriptions in the negative prompt.
+ /// Example: brush strokes, painting + /// + /// + /// Number of images to generate.
+ /// Default Value: 1 + /// + /// + /// A color palette for generation, must EITHER be specified via one of the presets (name) or explicitly via hexadecimal representations of the color with optional weights (members). Not supported by V_1, V_1_TURBO, V_2A and V_2A_TURBO models. + /// + /// + /// A list of 8 character hexadecimal codes representing the style of the image. Cannot be used in conjunction with style_reference_images or style_type.
+ /// Example: [AAFF5733, 0133FF57, DE3357FF] + /// + /// + /// The style type to generate with.
+ /// Default Value: GENERAL
+ /// Example: GENERAL + /// + /// + /// A predefined style preset that applies a specific artistic style to the generated image.
+ /// Example: BRIGHT_ART + /// + /// + /// A custom model URI in the format model/<model_name>/version/<version_name>.
+ /// When provided, the model version and style will be resolved from this URI, and style_type is not required.
+ /// Example: model/my-custom-model/version/1 + /// + /// + /// A set of images to use as style references (maximum total size 10MB across all style references). The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'style_reference_images' file parts. + /// + /// + /// Generations with character reference are subject to the character reference pricing. A set of images to use as character references (maximum total size 10MB across all character references), currently only supports 1 character reference image. The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'character_reference_images' file parts. + /// + /// + /// Optional masks for character reference images. When provided, must match the number of character_reference_images. Each mask should be a grayscale image of the same dimensions as the corresponding character reference image. The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'character_reference_images_mask' file parts. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task PostGenerateImageV3Async( + string prompt, + int? seed = default, + global::Ideogram.ResolutionV3? resolution = default, + global::Ideogram.AspectRatioV3? aspectRatio = default, + global::Ideogram.RenderingSpeed? renderingSpeed = default, + global::Ideogram.MagicPromptOption? magicPrompt = default, + string? magicPromptSystemPromptConfigId = default, + string? negativePrompt = default, + int? numImages = default, + global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette = default, + global::System.Collections.Generic.IList? styleCodes = default, + global::Ideogram.StyleTypeV3? styleType = default, + global::Ideogram.StylePresetV3? stylePreset = default, + string? customModelUri = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImages = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImagesFileNames = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImages = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesFileNames = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesMask = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesMaskFileNames = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Generate with Ideogram 3.0
+ /// Generates images synchronously based on a given prompt and optional parameters using the Ideogram 3.0 model.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// The prompt to use to generate the image.
+ /// Example: A photo of a cat + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// + /// The resolutions supported for Ideogram 3.0.
+ /// Example: 1280x800 + /// + /// + /// The aspect ratio to use for image generation, which determines the image's resolution. Cannot be used in conjunction with resolution. Defaults to 1x1. + /// + /// + /// The rendering speed to use.
+ /// Default Value: DEFAULT + /// + /// + /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON + /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + /// + /// Description of what to exclude from an image. Descriptions in the prompt take precedence
+ /// to descriptions in the negative prompt.
+ /// Example: brush strokes, painting + /// + /// + /// Number of images to generate.
+ /// Default Value: 1 + /// + /// + /// A color palette for generation, must EITHER be specified via one of the presets (name) or explicitly via hexadecimal representations of the color with optional weights (members). Not supported by V_1, V_1_TURBO, V_2A and V_2A_TURBO models. + /// + /// + /// A list of 8 character hexadecimal codes representing the style of the image. Cannot be used in conjunction with style_reference_images or style_type.
+ /// Example: [AAFF5733, 0133FF57, DE3357FF] + /// + /// + /// The style type to generate with.
+ /// Default Value: GENERAL
+ /// Example: GENERAL + /// + /// + /// A predefined style preset that applies a specific artistic style to the generated image.
+ /// Example: BRIGHT_ART + /// + /// + /// A custom model URI in the format model/<model_name>/version/<version_name>.
+ /// When provided, the model version and style will be resolved from this URI, and style_type is not required.
+ /// Example: model/my-custom-model/version/1 + /// + /// + /// A set of images to use as style references (maximum total size 10MB across all style references). The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'style_reference_images' file parts. + /// + /// + /// Generations with character reference are subject to the character reference pricing. A set of images to use as character references (maximum total size 10MB across all character references), currently only supports 1 character reference image. The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'character_reference_images' file parts. + /// + /// + /// Optional masks for character reference images. When provided, must match the number of character_reference_images. Each mask should be a grayscale image of the same dimensions as the corresponding character reference image. The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'character_reference_images_mask' file parts. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> PostGenerateImageV3AsResponseAsync( + string prompt, + int? seed = default, + global::Ideogram.ResolutionV3? resolution = default, + global::Ideogram.AspectRatioV3? aspectRatio = default, + global::Ideogram.RenderingSpeed? renderingSpeed = default, + global::Ideogram.MagicPromptOption? magicPrompt = default, + string? magicPromptSystemPromptConfigId = default, + string? negativePrompt = default, + int? numImages = default, + global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette = default, + global::System.Collections.Generic.IList? styleCodes = default, + global::Ideogram.StyleTypeV3? styleType = default, + global::Ideogram.StylePresetV3? stylePreset = default, + string? customModelUri = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImages = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImagesFileNames = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImages = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesFileNames = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesMask = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesMaskFileNames = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostGenerateImageV3Transparent.g.cs b/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostGenerateImageV3Transparent.g.cs index 2d63ebb..ba98611 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostGenerateImageV3Transparent.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostGenerateImageV3Transparent.g.cs @@ -10,6 +10,8 @@ public partial interface IGenerateClient /// the Ideogram 3.0 model. Images will be generated using maximum supported resolution at the specified aspect ratio
/// to allow best results with upscaler. The selected resolution is written to the response, not the upscaled final
/// resolution.
+ /// `rendering_speed=FLASH` is not supported for transparent-background generation; the request will return a 400.
+ /// Use `TURBO`, `DEFAULT`, or `QUALITY` instead.
/// Images links are available for a limited period of time; if you would like to keep the image, you must download it. /// /// @@ -27,6 +29,27 @@ public partial interface IGenerateClient /// the Ideogram 3.0 model. Images will be generated using maximum supported resolution at the specified aspect ratio
/// to allow best results with upscaler. The selected resolution is written to the response, not the upscaled final
/// resolution.
+ /// `rendering_speed=FLASH` is not supported for transparent-background generation; the request will return a 400.
+ /// Use `TURBO`, `DEFAULT`, or `QUALITY` instead.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> PostGenerateImageV3TransparentAsResponseAsync( + + global::Ideogram.GenerateTransparentImageRequestV3 request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Generate with Ideogram 3.0 (Transparent Background)
+ /// Generates images with transparent background synchronously based on a given prompt and optional parameters using
+ /// the Ideogram 3.0 model. Images will be generated using maximum supported resolution at the specified aspect ratio
+ /// to allow best results with upscaler. The selected resolution is written to the response, not the upscaled final
+ /// resolution.
+ /// `rendering_speed=FLASH` is not supported for transparent-background generation; the request will return a 400.
+ /// Use `TURBO`, `DEFAULT`, or `QUALITY` instead.
/// Images links are available for a limited period of time; if you would like to keep the image, you must download it. ///
/// @@ -53,6 +76,9 @@ public partial interface IGenerateClient /// Determine if MagicPrompt should be used in generating the request or not.
/// Example: ON /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// /// /// Description of what to exclude from an image. Descriptions in the prompt take precedence
/// to descriptions in the negative prompt.
@@ -78,6 +104,7 @@ public partial interface IGenerateClient global::Ideogram.AspectRatioV3? aspectRatio = default, global::Ideogram.RenderingSpeed? renderingSpeed = default, global::Ideogram.MagicPromptOption? magicPrompt = default, + string? magicPromptSystemPromptConfigId = default, string? negativePrompt = default, int? numImages = default, string? customModelUri = default, diff --git a/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostGenerateImageV4.g.cs b/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostGenerateImageV4.g.cs index 69d0b50..7618d5d 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostGenerateImageV4.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostGenerateImageV4.g.cs @@ -23,6 +23,20 @@ public partial interface IGenerateClient /// Generates images synchronously using the Ideogram 4.0 model.
/// Images links are available for a limited period of time; if you would like to keep the image, you must download it. /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> PostGenerateImageV4AsResponseAsync( + + global::Ideogram.GenerateImageRequestV4 request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Generate with Ideogram 4.0
+ /// Generates images synchronously using the Ideogram 4.0 model.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
/// /// The text prompt for image generation. /// @@ -33,11 +47,22 @@ public partial interface IGenerateClient /// Determine if MagicPrompt should be used in generating the request or not.
/// Example: ON /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// /// /// A custom model URI in the format model/<model_name>/version/<version_name>.
/// When provided, the model version and style will be resolved from this URI.
/// Example: model/my-custom-model/version/0 /// + /// + /// The resolutions supported for Ideogram 4.0.
+ /// Example: 1280x800 + /// + /// + /// The rendering speed to use.
+ /// Default Value: DEFAULT + /// /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// @@ -45,7 +70,10 @@ public partial interface IGenerateClient string prompt, int? seed = default, global::Ideogram.MagicPromptOption? magicPromptOption = default, + string? magicPromptSystemPromptConfigId = default, string? customModelUri = default, + global::Ideogram.ResolutionV4? resolution = default, + global::Ideogram.RenderingSpeed? renderingSpeed = default, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } diff --git a/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostInpaintImageV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostInpaintImageV3.g.cs index a916b00..98bfa3d 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostInpaintImageV3.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostInpaintImageV3.g.cs @@ -27,6 +27,22 @@ public partial interface IGenerateClient /// Supported image formats include JPEG, PNG, and WebP.
/// Images links are available for a limited period of time; if you would like to keep the image, you must download it. /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> PostInpaintImageV3AsResponseAsync( + + global::Ideogram.EditImageRequestV3 request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Inpaint with Ideogram 3.0
+ /// Inpaint a given image synchronously using the provided mask with Ideogram 3.0. The mask indicates which part of the image
+ /// should be edited, while the prompt and chosen style can further guide the edit.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
/// /// The image being edited (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. /// @@ -47,6 +63,9 @@ public partial interface IGenerateClient /// Determine if MagicPrompt should be used in generating the request or not.
/// Example: ON /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// /// /// The number of images to generate.
/// Default Value: 1 @@ -99,6 +118,7 @@ public partial interface IGenerateClient string maskname, string prompt, global::Ideogram.MagicPromptOption? magicPrompt = default, + string? magicPromptSystemPromptConfigId = default, int? numImages = default, int? seed = default, global::Ideogram.RenderingSpeed? renderingSpeed = default, @@ -112,5 +132,222 @@ public partial interface IGenerateClient global::System.Collections.Generic.IList? characterReferenceImagesMask = default, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + + /// + /// Inpaint with Ideogram 3.0
+ /// Inpaint a given image synchronously using the provided mask with Ideogram 3.0. The mask indicates which part of the image
+ /// should be edited, while the prompt and chosen style can further guide the edit.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// The image being edited (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The image being edited (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// A black and white image of the same size as the image being edited (max size 10MB). Black regions in the mask should match up with the regions of the image that you would like to edit; only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// A black and white image of the same size as the image being edited (max size 10MB). Black regions in the mask should match up with the regions of the image that you would like to edit; only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The prompt used to describe the edited result.
+ /// Example: A photo of a cat. + /// + /// + /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON + /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + /// + /// The number of images to generate.
+ /// Default Value: 1 + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// + /// The rendering speed to use.
+ /// Default Value: DEFAULT + /// + /// + /// The style type to generate with.
+ /// Default Value: GENERAL
+ /// Example: GENERAL + /// + /// + /// A predefined style preset that applies a specific artistic style to the generated image.
+ /// Example: BRIGHT_ART + /// + /// + /// A custom model URI in the format model/<model_name>/version/<version_name>.
+ /// When provided, the model version and style will be resolved from this URI, and style_type is not required.
+ /// Example: model/my-custom-model/version/1 + /// + /// + /// A color palette for generation, must EITHER be specified via one of the presets (name) or explicitly via hexadecimal representations of the color with optional weights (members). Not supported by V_1, V_1_TURBO, V_2A and V_2A_TURBO models. + /// + /// + /// A list of 8 character hexadecimal codes representing the style of the image. Cannot be used in conjunction with style_reference_images or style_type.
+ /// Example: [AAFF5733, 0133FF57, DE3357FF] + /// + /// + /// A set of images to use as style references (maximum total size 10MB across all style references). The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'style_reference_images' file parts. + /// + /// + /// Generations with character reference are subject to the character reference pricing. A set of images to use as character references (maximum total size 10MB across all character references), currently only supports 1 character reference image. The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'character_reference_images' file parts. + /// + /// + /// Optional masks for character reference images. When provided, must match the number of character_reference_images. Each mask should be a grayscale image of the same dimensions as the corresponding character reference image. The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'character_reference_images_mask' file parts. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task PostInpaintImageV3Async( + global::System.IO.Stream image, + string imagename, + global::System.IO.Stream mask, + string maskname, + string prompt, + global::Ideogram.MagicPromptOption? magicPrompt = default, + string? magicPromptSystemPromptConfigId = default, + int? numImages = default, + int? seed = default, + global::Ideogram.RenderingSpeed? renderingSpeed = default, + global::Ideogram.StyleTypeV3? styleType = default, + global::Ideogram.StylePresetV3? stylePreset = default, + string? customModelUri = default, + global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette = default, + global::System.Collections.Generic.IList? styleCodes = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImages = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImagesFileNames = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImages = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesFileNames = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesMask = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesMaskFileNames = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Inpaint with Ideogram 3.0
+ /// Inpaint a given image synchronously using the provided mask with Ideogram 3.0. The mask indicates which part of the image
+ /// should be edited, while the prompt and chosen style can further guide the edit.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// The image being edited (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The image being edited (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// A black and white image of the same size as the image being edited (max size 10MB). Black regions in the mask should match up with the regions of the image that you would like to edit; only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// A black and white image of the same size as the image being edited (max size 10MB). Black regions in the mask should match up with the regions of the image that you would like to edit; only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The prompt used to describe the edited result.
+ /// Example: A photo of a cat. + /// + /// + /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON + /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + /// + /// The number of images to generate.
+ /// Default Value: 1 + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// + /// The rendering speed to use.
+ /// Default Value: DEFAULT + /// + /// + /// The style type to generate with.
+ /// Default Value: GENERAL
+ /// Example: GENERAL + /// + /// + /// A predefined style preset that applies a specific artistic style to the generated image.
+ /// Example: BRIGHT_ART + /// + /// + /// A custom model URI in the format model/<model_name>/version/<version_name>.
+ /// When provided, the model version and style will be resolved from this URI, and style_type is not required.
+ /// Example: model/my-custom-model/version/1 + /// + /// + /// A color palette for generation, must EITHER be specified via one of the presets (name) or explicitly via hexadecimal representations of the color with optional weights (members). Not supported by V_1, V_1_TURBO, V_2A and V_2A_TURBO models. + /// + /// + /// A list of 8 character hexadecimal codes representing the style of the image. Cannot be used in conjunction with style_reference_images or style_type.
+ /// Example: [AAFF5733, 0133FF57, DE3357FF] + /// + /// + /// A set of images to use as style references (maximum total size 10MB across all style references). The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'style_reference_images' file parts. + /// + /// + /// Generations with character reference are subject to the character reference pricing. A set of images to use as character references (maximum total size 10MB across all character references), currently only supports 1 character reference image. The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'character_reference_images' file parts. + /// + /// + /// Optional masks for character reference images. When provided, must match the number of character_reference_images. Each mask should be a grayscale image of the same dimensions as the corresponding character reference image. The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'character_reference_images_mask' file parts. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> PostInpaintImageV3AsResponseAsync( + global::System.IO.Stream image, + string imagename, + global::System.IO.Stream mask, + string maskname, + string prompt, + global::Ideogram.MagicPromptOption? magicPrompt = default, + string? magicPromptSystemPromptConfigId = default, + int? numImages = default, + int? seed = default, + global::Ideogram.RenderingSpeed? renderingSpeed = default, + global::Ideogram.StyleTypeV3? styleType = default, + global::Ideogram.StylePresetV3? stylePreset = default, + string? customModelUri = default, + global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette = default, + global::System.Collections.Generic.IList? styleCodes = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImages = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImagesFileNames = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImages = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesFileNames = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesMask = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesMaskFileNames = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostLayerizeDesignV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostLayerizeDesignV3.g.cs index e86ad16..384e94d 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostLayerizeDesignV3.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostLayerizeDesignV3.g.cs @@ -27,6 +27,22 @@ public partial interface IGenerateClient /// Supported image formats include JPEG, PNG, and WebP (max size 10MB).
/// Images links are available for a limited period of time; if you would like to keep the image, you must download it. /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> PostLayerizeDesignV3AsResponseAsync( + + global::Ideogram.LayerizeDesignRequestV3 request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Layerize an existing flat graphic image with text detection and correction
+ /// Processes an existing flat graphic image to detect and correct text layers without generating a new image from scratch.
+ /// The uploaded image is analyzed for text content, which is then removed and returned as structured text layers with font matching, sizing, and color information.
+ /// Supported image formats include JPEG, PNG, and WebP (max size 10MB).
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
/// /// The flat graphic image to process for text detection and correction. The image should be in JPEG, PNG or WebP format (max size 10MB). /// @@ -103,5 +119,180 @@ public partial interface IGenerateClient global::System.Collections.Generic.IList? referenceAssetImages = default, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + + /// + /// Layerize an existing flat graphic image with text detection and correction
+ /// Processes an existing flat graphic image to detect and correct text layers without generating a new image from scratch.
+ /// The uploaded image is analyzed for text content, which is then removed and returned as structured text layers with font matching, sizing, and color information.
+ /// Supported image formats include JPEG, PNG, and WebP (max size 10MB).
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// The flat graphic image to process for text detection and correction. The image should be in JPEG, PNG or WebP format (max size 10MB). + /// + /// + /// The flat graphic image to process for text detection and correction. The image should be in JPEG, PNG or WebP format (max size 10MB). + /// + /// + /// An optional prompt to describe the image. If not provided, a prompt will be auto-generated from the image via captioning. + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// + /// Custom font file for H1 (heading) text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_h1. + /// + /// + /// Custom font file for H1 (heading) text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_h1. + /// + /// + /// Font name from the available font library for H1 text. Ignored if font_file_h1 is provided.
+ /// Example: Ubuntu-Bold.ttf + /// + /// + /// Custom font file for H2 (subheading) text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_h2. + /// + /// + /// Custom font file for H2 (subheading) text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_h2. + /// + /// + /// Font name from the available font library for H2 text. Ignored if font_file_h2 is provided. + /// + /// + /// Custom font file for body text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_body. + /// + /// + /// Custom font file for body text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_body. + /// + /// + /// Font name from the available font library for body text. Ignored if font_file_body is provided. + /// + /// + /// Custom font file for small/caption text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_small. + /// + /// + /// Custom font file for small/caption text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_small. + /// + /// + /// Font name from the available font library for small text. Ignored if font_file_small is provided. + /// + /// + /// A set of asset images (e.g., logos, icons) to use as references for detection and replacement (maximum 10 images). The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'reference_asset_images' file parts. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task PostLayerizeDesignV3Async( + global::System.IO.Stream flatGraphicImage, + string flatGraphicImagename, + string? prompt = default, + int? seed = default, + global::System.IO.Stream? fontFileH1 = default, + string? fontFileH1name = default, + string? fontNameH1 = default, + global::System.IO.Stream? fontFileH2 = default, + string? fontFileH2name = default, + string? fontNameH2 = default, + global::System.IO.Stream? fontFileBody = default, + string? fontFileBodyname = default, + string? fontNameBody = default, + global::System.IO.Stream? fontFileSmall = default, + string? fontFileSmallname = default, + string? fontNameSmall = default, + global::System.Collections.Generic.IReadOnlyList? referenceAssetImages = default, + global::System.Collections.Generic.IReadOnlyList? referenceAssetImagesFileNames = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Layerize an existing flat graphic image with text detection and correction
+ /// Processes an existing flat graphic image to detect and correct text layers without generating a new image from scratch.
+ /// The uploaded image is analyzed for text content, which is then removed and returned as structured text layers with font matching, sizing, and color information.
+ /// Supported image formats include JPEG, PNG, and WebP (max size 10MB).
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// The flat graphic image to process for text detection and correction. The image should be in JPEG, PNG or WebP format (max size 10MB). + /// + /// + /// The flat graphic image to process for text detection and correction. The image should be in JPEG, PNG or WebP format (max size 10MB). + /// + /// + /// An optional prompt to describe the image. If not provided, a prompt will be auto-generated from the image via captioning. + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// + /// Custom font file for H1 (heading) text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_h1. + /// + /// + /// Custom font file for H1 (heading) text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_h1. + /// + /// + /// Font name from the available font library for H1 text. Ignored if font_file_h1 is provided.
+ /// Example: Ubuntu-Bold.ttf + /// + /// + /// Custom font file for H2 (subheading) text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_h2. + /// + /// + /// Custom font file for H2 (subheading) text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_h2. + /// + /// + /// Font name from the available font library for H2 text. Ignored if font_file_h2 is provided. + /// + /// + /// Custom font file for body text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_body. + /// + /// + /// Custom font file for body text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_body. + /// + /// + /// Font name from the available font library for body text. Ignored if font_file_body is provided. + /// + /// + /// Custom font file for small/caption text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_small. + /// + /// + /// Custom font file for small/caption text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_small. + /// + /// + /// Font name from the available font library for small text. Ignored if font_file_small is provided. + /// + /// + /// A set of asset images (e.g., logos, icons) to use as references for detection and replacement (maximum 10 images). The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'reference_asset_images' file parts. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> PostLayerizeDesignV3AsResponseAsync( + global::System.IO.Stream flatGraphicImage, + string flatGraphicImagename, + string? prompt = default, + int? seed = default, + global::System.IO.Stream? fontFileH1 = default, + string? fontFileH1name = default, + string? fontNameH1 = default, + global::System.IO.Stream? fontFileH2 = default, + string? fontFileH2name = default, + string? fontNameH2 = default, + global::System.IO.Stream? fontFileBody = default, + string? fontFileBodyname = default, + string? fontNameBody = default, + global::System.IO.Stream? fontFileSmall = default, + string? fontFileSmallname = default, + string? fontNameSmall = default, + global::System.Collections.Generic.IReadOnlyList? referenceAssetImages = default, + global::System.Collections.Generic.IReadOnlyList? referenceAssetImagesFileNames = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostLayerizeTextV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostLayerizeTextV3.g.cs index cb122e9..bc02a7f 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostLayerizeTextV3.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostLayerizeTextV3.g.cs @@ -27,6 +27,22 @@ public partial interface IGenerateClient /// Supported image formats include JPEG, PNG, and WebP (max size 10MB).
/// Image links are available for a limited period of time; if you would like to keep the image, you must download it. /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> PostLayerizeTextV3AsResponseAsync( + + global::Ideogram.LayerizeTextRequest request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Layerize Text
+ /// Analyzes an image to detect text regions, then returns each detected text block with its position, content, font information, and styling.
+ /// The response includes a text-erased base image (background with all text removed) and a flat list of detected text blocks.
+ /// Supported image formats include JPEG, PNG, and WebP (max size 10MB).
+ /// Image links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
/// /// The image to analyze for text detection. The image should be in JPEG, PNG, or WebP format (max size 10MB). /// @@ -50,5 +66,66 @@ public partial interface IGenerateClient int? seed = default, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + + /// + /// Layerize Text
+ /// Analyzes an image to detect text regions, then returns each detected text block with its position, content, font information, and styling.
+ /// The response includes a text-erased base image (background with all text removed) and a flat list of detected text blocks.
+ /// Supported image formats include JPEG, PNG, and WebP (max size 10MB).
+ /// Image links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// The image to analyze for text detection. The image should be in JPEG, PNG, or WebP format (max size 10MB). + /// + /// + /// The image to analyze for text detection. The image should be in JPEG, PNG, or WebP format (max size 10MB). + /// + /// + /// An optional text description of the image. If not provided, a description will be auto-generated from the image. + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task PostLayerizeTextV3Async( + global::System.IO.Stream image, + string imagename, + string? prompt = default, + int? seed = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Layerize Text
+ /// Analyzes an image to detect text regions, then returns each detected text block with its position, content, font information, and styling.
+ /// The response includes a text-erased base image (background with all text removed) and a flat list of detected text blocks.
+ /// Supported image formats include JPEG, PNG, and WebP (max size 10MB).
+ /// Image links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// The image to analyze for text detection. The image should be in JPEG, PNG, or WebP format (max size 10MB). + /// + /// + /// The image to analyze for text detection. The image should be in JPEG, PNG, or WebP format (max size 10MB). + /// + /// + /// An optional text description of the image. If not provided, a description will be auto-generated from the image. + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> PostLayerizeTextV3AsResponseAsync( + global::System.IO.Stream image, + string imagename, + string? prompt = default, + int? seed = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostReframeImage.g.cs b/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostReframeImage.g.cs index fb9f670..d8b677e 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostReframeImage.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostReframeImage.g.cs @@ -23,6 +23,20 @@ public partial interface IGenerateClient /// Reframe a square image to a chosen resolution. The supported image formats include JPEG, PNG, and WebP.
/// Image links are available for a limited period of time; if you would like to keep the image, you must download it. /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> PostReframeImageAsResponseAsync( + + global::Ideogram.ReframeImageRequest request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Reframe (legacy)
+ /// Reframe a square image to a chosen resolution. The supported image formats include JPEG, PNG, and WebP.
+ /// Image links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
/// /// The image being reframed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. /// @@ -63,5 +77,96 @@ public partial interface IGenerateClient global::Ideogram.StyleType? styleType = default, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + + /// + /// Reframe (legacy)
+ /// Reframe a square image to a chosen resolution. The supported image formats include JPEG, PNG, and WebP.
+ /// Image links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// The image being reframed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The image being reframed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// (For model_version for 2.0 only, cannot be used in conjunction with aspect_ratio) The resolution to use for image generation, represented in width x height. If not specified, defaults to using aspect_ratio.
+ /// Example: RESOLUTION_1024_1024 + /// + /// + /// The model used to generate an image or edit one. /generate and /remix supports all model types, however, /edit is only supported for V_2 and V_2_TURBO.
+ /// Default Value: V_2
+ /// Example: V_2_TURBO + /// + /// + /// The number of images to generate.
+ /// Default Value: 1 + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// + /// The style type to generate with; this is only applicable for models V_2 and above and should not be specified for model versions V_1.
+ /// Example: REALISTIC + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task PostReframeImageAsync( + global::System.IO.Stream imageFile, + string imageFilename, + global::Ideogram.Resolution resolution, + global::Ideogram.ModelEnum model = global::Ideogram.ModelEnum.V2, + int? numImages = default, + int? seed = default, + global::Ideogram.StyleType? styleType = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Reframe (legacy)
+ /// Reframe a square image to a chosen resolution. The supported image formats include JPEG, PNG, and WebP.
+ /// Image links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// The image being reframed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The image being reframed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// (For model_version for 2.0 only, cannot be used in conjunction with aspect_ratio) The resolution to use for image generation, represented in width x height. If not specified, defaults to using aspect_ratio.
+ /// Example: RESOLUTION_1024_1024 + /// + /// + /// The model used to generate an image or edit one. /generate and /remix supports all model types, however, /edit is only supported for V_2 and V_2_TURBO.
+ /// Default Value: V_2
+ /// Example: V_2_TURBO + /// + /// + /// The number of images to generate.
+ /// Default Value: 1 + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// + /// The style type to generate with; this is only applicable for models V_2 and above and should not be specified for model versions V_1.
+ /// Example: REALISTIC + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> PostReframeImageAsResponseAsync( + global::System.IO.Stream imageFile, + string imageFilename, + global::Ideogram.Resolution resolution, + global::Ideogram.ModelEnum model = global::Ideogram.ModelEnum.V2, + int? numImages = default, + int? seed = default, + global::Ideogram.StyleType? styleType = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostReframeImageV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostReframeImageV3.g.cs index e5827c0..899c534 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostReframeImageV3.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostReframeImageV3.g.cs @@ -23,6 +23,20 @@ public partial interface IGenerateClient /// Reframe a square image to a chosen resolution with Ideogram 3.0. The supported image formats include JPEG, PNG, and WebP.
/// Image links are available for a limited period of time; if you would like to keep the image, you must download it. /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> PostReframeImageV3AsResponseAsync( + + global::Ideogram.ReframeImageRequestV3 request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Reframe with Ideogram 3.0
+ /// Reframe a square image to a chosen resolution with Ideogram 3.0. The supported image formats include JPEG, PNG, and WebP.
+ /// Image links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
/// /// The image being reframed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. /// @@ -75,5 +89,128 @@ public partial interface IGenerateClient global::System.Collections.Generic.IList? styleReferenceImages = default, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + + /// + /// Reframe with Ideogram 3.0
+ /// Reframe a square image to a chosen resolution with Ideogram 3.0. The supported image formats include JPEG, PNG, and WebP.
+ /// Image links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// The image being reframed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The image being reframed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The resolutions supported for Ideogram 3.0.
+ /// Example: 1280x800 + /// + /// + /// The number of images to generate.
+ /// Default Value: 1 + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// + /// The rendering speed to use.
+ /// Default Value: DEFAULT + /// + /// + /// A predefined style preset that applies a specific artistic style to the generated image.
+ /// Example: BRIGHT_ART + /// + /// + /// A color palette for generation, must EITHER be specified via one of the presets (name) or explicitly via hexadecimal representations of the color with optional weights (members). Not supported by V_1, V_1_TURBO, V_2A and V_2A_TURBO models. + /// + /// + /// A list of 8 character hexadecimal codes representing the style of the image. Cannot be used in conjunction with style_reference_images or style_type.
+ /// Example: [AAFF5733, 0133FF57, DE3357FF] + /// + /// + /// A set of images to use as style references (maximum total size 10MB across all style references). The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'style_reference_images' file parts. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task PostReframeImageV3Async( + global::System.IO.Stream image, + string imagename, + global::Ideogram.ResolutionV3 resolution, + int? numImages = default, + int? seed = default, + global::Ideogram.RenderingSpeed? renderingSpeed = default, + global::Ideogram.StylePresetV3? stylePreset = default, + global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette = default, + global::System.Collections.Generic.IList? styleCodes = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImages = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImagesFileNames = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Reframe with Ideogram 3.0
+ /// Reframe a square image to a chosen resolution with Ideogram 3.0. The supported image formats include JPEG, PNG, and WebP.
+ /// Image links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// The image being reframed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The image being reframed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The resolutions supported for Ideogram 3.0.
+ /// Example: 1280x800 + /// + /// + /// The number of images to generate.
+ /// Default Value: 1 + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// + /// The rendering speed to use.
+ /// Default Value: DEFAULT + /// + /// + /// A predefined style preset that applies a specific artistic style to the generated image.
+ /// Example: BRIGHT_ART + /// + /// + /// A color palette for generation, must EITHER be specified via one of the presets (name) or explicitly via hexadecimal representations of the color with optional weights (members). Not supported by V_1, V_1_TURBO, V_2A and V_2A_TURBO models. + /// + /// + /// A list of 8 character hexadecimal codes representing the style of the image. Cannot be used in conjunction with style_reference_images or style_type.
+ /// Example: [AAFF5733, 0133FF57, DE3357FF] + /// + /// + /// A set of images to use as style references (maximum total size 10MB across all style references). The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'style_reference_images' file parts. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> PostReframeImageV3AsResponseAsync( + global::System.IO.Stream image, + string imagename, + global::Ideogram.ResolutionV3 resolution, + int? numImages = default, + int? seed = default, + global::Ideogram.RenderingSpeed? renderingSpeed = default, + global::Ideogram.StylePresetV3? stylePreset = default, + global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette = default, + global::System.Collections.Generic.IList? styleCodes = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImages = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImagesFileNames = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostRemixImage.g.cs b/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostRemixImage.g.cs index 9a98aee..6bc5989 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostRemixImage.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostRemixImage.g.cs @@ -27,6 +27,22 @@ public partial interface IGenerateClient /// Supported image formats include JPEG, PNG, and WebP.
/// Images links are available for a limited period of time; if you would like to keep the image, you must download it. /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> PostRemixImageAsResponseAsync( + + global::Ideogram.RemixImageRequest request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Remix (legacy)
+ /// Remix provided images synchronously based on a given prompt and optional parameters.
+ /// Input images are cropped to the chosen aspect ratio before being remixed.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
/// /// A request to generate a new image using a provided image and a prompt.
/// Example: {"aspect_ratio":"ASPECT_10_16","magic_prompt_option":"ON","model":"V_2","prompt":"A serene tropical beach scene. Dominating the foreground are tall palm trees with lush green leaves, standing tall against a backdrop of a sandy beach. The beach leads to the azure waters of the sea, which gently kisses the shoreline. In the distance, there is an island or landmass with a silhouette of what appears to be a lighthouse or tower. The sky above is painted with fluffy white clouds, some of which are tinged with hues of pink and orange, suggesting either a sunrise or sunset.","image_weight":50} @@ -46,5 +62,58 @@ public partial interface IGenerateClient string imageFilename, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + + /// + /// Remix (legacy)
+ /// Remix provided images synchronously based on a given prompt and optional parameters.
+ /// Input images are cropped to the chosen aspect ratio before being remixed.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// A request to generate a new image using a provided image and a prompt.
+ /// Example: {"aspect_ratio":"ASPECT_10_16","magic_prompt_option":"ON","model":"V_2","prompt":"A serene tropical beach scene. Dominating the foreground are tall palm trees with lush green leaves, standing tall against a backdrop of a sandy beach. The beach leads to the azure waters of the sea, which gently kisses the shoreline. In the distance, there is an island or landmass with a silhouette of what appears to be a lighthouse or tower. The sky above is painted with fluffy white clouds, some of which are tinged with hues of pink and orange, suggesting either a sunrise or sunset.","image_weight":50} + /// + /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task PostRemixImageAsync( + global::Ideogram.InitialImageRequest imageRequest, + global::System.IO.Stream imageFile, + string imageFilename, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Remix (legacy)
+ /// Remix provided images synchronously based on a given prompt and optional parameters.
+ /// Input images are cropped to the chosen aspect ratio before being remixed.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// A request to generate a new image using a provided image and a prompt.
+ /// Example: {"aspect_ratio":"ASPECT_10_16","magic_prompt_option":"ON","model":"V_2","prompt":"A serene tropical beach scene. Dominating the foreground are tall palm trees with lush green leaves, standing tall against a backdrop of a sandy beach. The beach leads to the azure waters of the sea, which gently kisses the shoreline. In the distance, there is an island or landmass with a silhouette of what appears to be a lighthouse or tower. The sky above is painted with fluffy white clouds, some of which are tinged with hues of pink and orange, suggesting either a sunrise or sunset.","image_weight":50} + /// + /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> PostRemixImageAsResponseAsync( + global::Ideogram.InitialImageRequest imageRequest, + global::System.IO.Stream imageFile, + string imageFilename, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostRemixImageV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostRemixImageV3.g.cs index 54a4146..23bf1b0 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostRemixImageV3.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostRemixImageV3.g.cs @@ -27,6 +27,22 @@ public partial interface IGenerateClient /// Supported image formats include JPEG, PNG, and WebP.
/// Images links are available for a limited period of time; if you would like to keep the image, you must download it. /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> PostRemixImageV3AsResponseAsync( + + global::Ideogram.RemixImageRequestV3 request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Remix with Ideogram 3.0
+ /// Remix provided images synchronously based on a given prompt and optional parameters with the Ideogram 3.0 model.
+ /// Input images are cropped to the chosen aspect ratio before being remixed.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
/// /// The image to remix binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. /// @@ -60,6 +76,9 @@ public partial interface IGenerateClient /// Determine if MagicPrompt should be used in generating the request or not.
/// Example: ON /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// /// /// Description of what to exclude from an image. Descriptions in the prompt take precedence
/// to descriptions in the negative prompt.
@@ -112,6 +131,7 @@ public partial interface IGenerateClient global::Ideogram.AspectRatioV3? aspectRatio = default, global::Ideogram.RenderingSpeed? renderingSpeed = default, global::Ideogram.MagicPromptOption? magicPrompt = default, + string? magicPromptSystemPromptConfigId = default, string? negativePrompt = default, int? numImages = default, global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette = default, @@ -124,5 +144,246 @@ public partial interface IGenerateClient global::System.Collections.Generic.IList? characterReferenceImagesMask = default, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + + /// + /// Remix with Ideogram 3.0
+ /// Remix provided images synchronously based on a given prompt and optional parameters with the Ideogram 3.0 model.
+ /// Input images are cropped to the chosen aspect ratio before being remixed.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// The image to remix binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The image to remix binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The prompt to use to generate the image.
+ /// Example: A photo of a cat + /// + /// + /// Default Value: 50
+ /// Example: 50 + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// + /// The resolutions supported for Ideogram 3.0.
+ /// Example: 1280x800 + /// + /// + /// The aspect ratio to use for image generation, which determines the image's resolution. Cannot be used in conjunction with resolution. Defaults to 1x1. + /// + /// + /// The rendering speed to use.
+ /// Default Value: DEFAULT + /// + /// + /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON + /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + /// + /// Description of what to exclude from an image. Descriptions in the prompt take precedence
+ /// to descriptions in the negative prompt.
+ /// Example: brush strokes, painting + /// + /// + /// Number of images to generate.
+ /// Default Value: 1 + /// + /// + /// A color palette for generation, must EITHER be specified via one of the presets (name) or explicitly via hexadecimal representations of the color with optional weights (members). Not supported by V_1, V_1_TURBO, V_2A and V_2A_TURBO models. + /// + /// + /// A list of 8 character hexadecimal codes representing the style of the image. Cannot be used in conjunction with style_reference_images or style_type.
+ /// Example: [AAFF5733, 0133FF57, DE3357FF] + /// + /// + /// The style type to generate with.
+ /// Default Value: GENERAL
+ /// Example: GENERAL + /// + /// + /// A predefined style preset that applies a specific artistic style to the generated image.
+ /// Example: BRIGHT_ART + /// + /// + /// A custom model URI in the format model/<model_name>/version/<version_name>.
+ /// When provided, the model version and style will be resolved from this URI, and style_type is not required.
+ /// Example: model/my-custom-model/version/1 + /// + /// + /// A set of images to use as style references (maximum total size 10MB across all style references). The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'style_reference_images' file parts. + /// + /// + /// Generations with character reference are subject to the character reference pricing. A set of images to use as character references (maximum total size 10MB across all character references), currently only supports 1 character reference image. The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'character_reference_images' file parts. + /// + /// + /// Optional masks for character reference images. When provided, must match the number of character_reference_images. Each mask should be a grayscale image of the same dimensions as the corresponding character reference image. The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'character_reference_images_mask' file parts. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task PostRemixImageV3Async( + global::System.IO.Stream image, + string imagename, + string prompt, + int? imageWeight = default, + int? seed = default, + global::Ideogram.ResolutionV3? resolution = default, + global::Ideogram.AspectRatioV3? aspectRatio = default, + global::Ideogram.RenderingSpeed? renderingSpeed = default, + global::Ideogram.MagicPromptOption? magicPrompt = default, + string? magicPromptSystemPromptConfigId = default, + string? negativePrompt = default, + int? numImages = default, + global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette = default, + global::System.Collections.Generic.IList? styleCodes = default, + global::Ideogram.StyleTypeV3? styleType = default, + global::Ideogram.StylePresetV3? stylePreset = default, + string? customModelUri = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImages = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImagesFileNames = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImages = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesFileNames = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesMask = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesMaskFileNames = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Remix with Ideogram 3.0
+ /// Remix provided images synchronously based on a given prompt and optional parameters with the Ideogram 3.0 model.
+ /// Input images are cropped to the chosen aspect ratio before being remixed.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// The image to remix binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The image to remix binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The prompt to use to generate the image.
+ /// Example: A photo of a cat + /// + /// + /// Default Value: 50
+ /// Example: 50 + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// + /// The resolutions supported for Ideogram 3.0.
+ /// Example: 1280x800 + /// + /// + /// The aspect ratio to use for image generation, which determines the image's resolution. Cannot be used in conjunction with resolution. Defaults to 1x1. + /// + /// + /// The rendering speed to use.
+ /// Default Value: DEFAULT + /// + /// + /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON + /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + /// + /// Description of what to exclude from an image. Descriptions in the prompt take precedence
+ /// to descriptions in the negative prompt.
+ /// Example: brush strokes, painting + /// + /// + /// Number of images to generate.
+ /// Default Value: 1 + /// + /// + /// A color palette for generation, must EITHER be specified via one of the presets (name) or explicitly via hexadecimal representations of the color with optional weights (members). Not supported by V_1, V_1_TURBO, V_2A and V_2A_TURBO models. + /// + /// + /// A list of 8 character hexadecimal codes representing the style of the image. Cannot be used in conjunction with style_reference_images or style_type.
+ /// Example: [AAFF5733, 0133FF57, DE3357FF] + /// + /// + /// The style type to generate with.
+ /// Default Value: GENERAL
+ /// Example: GENERAL + /// + /// + /// A predefined style preset that applies a specific artistic style to the generated image.
+ /// Example: BRIGHT_ART + /// + /// + /// A custom model URI in the format model/<model_name>/version/<version_name>.
+ /// When provided, the model version and style will be resolved from this URI, and style_type is not required.
+ /// Example: model/my-custom-model/version/1 + /// + /// + /// A set of images to use as style references (maximum total size 10MB across all style references). The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'style_reference_images' file parts. + /// + /// + /// Generations with character reference are subject to the character reference pricing. A set of images to use as character references (maximum total size 10MB across all character references), currently only supports 1 character reference image. The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'character_reference_images' file parts. + /// + /// + /// Optional masks for character reference images. When provided, must match the number of character_reference_images. Each mask should be a grayscale image of the same dimensions as the corresponding character reference image. The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'character_reference_images_mask' file parts. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> PostRemixImageV3AsResponseAsync( + global::System.IO.Stream image, + string imagename, + string prompt, + int? imageWeight = default, + int? seed = default, + global::Ideogram.ResolutionV3? resolution = default, + global::Ideogram.AspectRatioV3? aspectRatio = default, + global::Ideogram.RenderingSpeed? renderingSpeed = default, + global::Ideogram.MagicPromptOption? magicPrompt = default, + string? magicPromptSystemPromptConfigId = default, + string? negativePrompt = default, + int? numImages = default, + global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette = default, + global::System.Collections.Generic.IList? styleCodes = default, + global::Ideogram.StyleTypeV3? styleType = default, + global::Ideogram.StylePresetV3? stylePreset = default, + string? customModelUri = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImages = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImagesFileNames = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImages = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesFileNames = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesMask = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesMaskFileNames = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostRemoveBackground.g.cs b/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostRemoveBackground.g.cs new file mode 100644 index 0000000..73a6f66 --- /dev/null +++ b/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostRemoveBackground.g.cs @@ -0,0 +1,109 @@ +#nullable enable + +namespace Ideogram +{ + public partial interface IGenerateClient + { + /// + /// Remove Background
+ /// Remove the background of a given image synchronously. The foreground subject
+ /// is identified and returned on a transparent background. Supported image formats include JPEG,
+ /// PNG, and WebP.
+ /// Image links are available for a limited period of time; if you would like to keep the image,
+ /// you must download it. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task PostRemoveBackgroundAsync( + + global::Ideogram.RemoveBackgroundRequest request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Remove Background
+ /// Remove the background of a given image synchronously. The foreground subject
+ /// is identified and returned on a transparent background. Supported image formats include JPEG,
+ /// PNG, and WebP.
+ /// Image links are available for a limited period of time; if you would like to keep the image,
+ /// you must download it. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> PostRemoveBackgroundAsResponseAsync( + + global::Ideogram.RemoveBackgroundRequest request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Remove Background
+ /// Remove the background of a given image synchronously. The foreground subject
+ /// is identified and returned on a transparent background. Supported image formats include JPEG,
+ /// PNG, and WebP.
+ /// Image links are available for a limited period of time; if you would like to keep the image,
+ /// you must download it. + ///
+ /// + /// The image whose background is being removed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The image whose background is being removed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task PostRemoveBackgroundAsync( + byte[] image, + string imagename, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + + /// + /// Remove Background
+ /// Remove the background of a given image synchronously. The foreground subject
+ /// is identified and returned on a transparent background. Supported image formats include JPEG,
+ /// PNG, and WebP.
+ /// Image links are available for a limited period of time; if you would like to keep the image,
+ /// you must download it. + ///
+ /// + /// The image whose background is being removed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The image whose background is being removed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task PostRemoveBackgroundAsync( + global::System.IO.Stream image, + string imagename, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Remove Background
+ /// Remove the background of a given image synchronously. The foreground subject
+ /// is identified and returned on a transparent background. Supported image formats include JPEG,
+ /// PNG, and WebP.
+ /// Image links are available for a limited period of time; if you would like to keep the image,
+ /// you must download it. + ///
+ /// + /// The image whose background is being removed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The image whose background is being removed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> PostRemoveBackgroundAsResponseAsync( + global::System.IO.Stream image, + string imagename, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + } +} \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostReplaceBackgroundV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostReplaceBackgroundV3.g.cs index 0cd12f8..73e3be7 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostReplaceBackgroundV3.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostReplaceBackgroundV3.g.cs @@ -27,6 +27,22 @@ public partial interface IGenerateClient /// Supported image formats include JPEG, PNG, and WebP.
/// Images links are available for a limited period of time; if you would like to keep the image, you must download it. /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> PostReplaceBackgroundV3AsResponseAsync( + + global::Ideogram.ReplaceBackgroundRequestV3 request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Replace Background with Ideogram 3.0
+ /// Replace the background of a given image synchronously using a prompt with Ideogram 3.0. The foreground subject
+ /// will be identified and kept, while the background is replaced based on the prompt and chosen style.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
/// /// The image whose background is being replaced (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. /// @@ -41,6 +57,9 @@ public partial interface IGenerateClient /// Determine if MagicPrompt should be used in generating the request or not.
/// Example: ON /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// /// /// The number of images to generate.
/// Default Value: 1 @@ -75,6 +94,7 @@ public partial interface IGenerateClient string imagename, string prompt, global::Ideogram.MagicPromptOption? magicPrompt = default, + string? magicPromptSystemPromptConfigId = default, int? numImages = default, int? seed = default, global::Ideogram.RenderingSpeed? renderingSpeed = default, @@ -84,5 +104,150 @@ public partial interface IGenerateClient global::System.Collections.Generic.IList? styleReferenceImages = default, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + + /// + /// Replace Background with Ideogram 3.0
+ /// Replace the background of a given image synchronously using a prompt with Ideogram 3.0. The foreground subject
+ /// will be identified and kept, while the background is replaced based on the prompt and chosen style.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// The image whose background is being replaced (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The image whose background is being replaced (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The prompt describing the desired new background.
+ /// Example: A vibrant cityscape at night. + /// + /// + /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON + /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + /// + /// The number of images to generate.
+ /// Default Value: 1 + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// + /// The rendering speed to use.
+ /// Default Value: DEFAULT + /// + /// + /// A predefined style preset that applies a specific artistic style to the generated image.
+ /// Example: BRIGHT_ART + /// + /// + /// A color palette for generation, must EITHER be specified via one of the presets (name) or explicitly via hexadecimal representations of the color with optional weights (members). Not supported by V_1, V_1_TURBO, V_2A and V_2A_TURBO models. + /// + /// + /// A list of 8 character hexadecimal codes representing the style of the image. Cannot be used in conjunction with style_reference_images or style_type.
+ /// Example: [AAFF5733, 0133FF57, DE3357FF] + /// + /// + /// A set of images to use as style references (maximum total size 10MB across all style references). The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'style_reference_images' file parts. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task PostReplaceBackgroundV3Async( + global::System.IO.Stream image, + string imagename, + string prompt, + global::Ideogram.MagicPromptOption? magicPrompt = default, + string? magicPromptSystemPromptConfigId = default, + int? numImages = default, + int? seed = default, + global::Ideogram.RenderingSpeed? renderingSpeed = default, + global::Ideogram.StylePresetV3? stylePreset = default, + global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette = default, + global::System.Collections.Generic.IList? styleCodes = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImages = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImagesFileNames = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Replace Background with Ideogram 3.0
+ /// Replace the background of a given image synchronously using a prompt with Ideogram 3.0. The foreground subject
+ /// will be identified and kept, while the background is replaced based on the prompt and chosen style.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// The image whose background is being replaced (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The image whose background is being replaced (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The prompt describing the desired new background.
+ /// Example: A vibrant cityscape at night. + /// + /// + /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON + /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + /// + /// The number of images to generate.
+ /// Default Value: 1 + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// + /// The rendering speed to use.
+ /// Default Value: DEFAULT + /// + /// + /// A predefined style preset that applies a specific artistic style to the generated image.
+ /// Example: BRIGHT_ART + /// + /// + /// A color palette for generation, must EITHER be specified via one of the presets (name) or explicitly via hexadecimal representations of the color with optional weights (members). Not supported by V_1, V_1_TURBO, V_2A and V_2A_TURBO models. + /// + /// + /// A list of 8 character hexadecimal codes representing the style of the image. Cannot be used in conjunction with style_reference_images or style_type.
+ /// Example: [AAFF5733, 0133FF57, DE3357FF] + /// + /// + /// A set of images to use as style references (maximum total size 10MB across all style references). The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'style_reference_images' file parts. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> PostReplaceBackgroundV3AsResponseAsync( + global::System.IO.Stream image, + string imagename, + string prompt, + global::Ideogram.MagicPromptOption? magicPrompt = default, + string? magicPromptSystemPromptConfigId = default, + int? numImages = default, + int? seed = default, + global::Ideogram.RenderingSpeed? renderingSpeed = default, + global::Ideogram.StylePresetV3? stylePreset = default, + global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette = default, + global::System.Collections.Generic.IList? styleCodes = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImages = default, + global::System.Collections.Generic.IReadOnlyList? styleReferenceImagesFileNames = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostTryOnV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostTryOnV3.g.cs index 4165f99..dd94d16 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostTryOnV3.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostTryOnV3.g.cs @@ -29,6 +29,23 @@ public partial interface IGenerateClient /// Supported image formats include JPEG, PNG, and WebP.
/// Images links are available for a limited period of time; if you would like to keep the image, you must download it. /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> PostTryOnV3AsResponseAsync( + + global::Ideogram.TryOnRequestV3 request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Virtual Try-On with Ideogram 3.0
+ /// Performs virtual clothing try-on by automatically segmenting the clothing in the provided image
+ /// and replacing it based on the prompt. The user provides an image and an optional prompt describing
+ /// the desired clothing change (e.g., "change his shirt to a pink shirt").
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
/// /// The image containing a person wearing clothing to be modified (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. /// @@ -44,6 +61,9 @@ public partial interface IGenerateClient /// Determine if MagicPrompt should be used in generating the request or not.
/// Example: ON /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// /// /// The number of images to generate.
/// Default Value: 1 @@ -77,11 +97,155 @@ public partial interface IGenerateClient global::System.Collections.Generic.IList productReferenceImages, string? prompt = default, global::Ideogram.MagicPromptOption? magicPrompt = default, + string? magicPromptSystemPromptConfigId = default, + int? numImages = default, + int? seed = default, + global::Ideogram.RenderingSpeed? renderingSpeed = default, + global::Ideogram.StyleTypeV3? styleType = default, + global::Ideogram.StylePresetV3? stylePreset = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + + /// + /// Virtual Try-On with Ideogram 3.0
+ /// Performs virtual clothing try-on by automatically segmenting the clothing in the provided image
+ /// and replacing it based on the prompt. The user provides an image and an optional prompt describing
+ /// the desired clothing change (e.g., "change his shirt to a pink shirt").
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// The image containing a person wearing clothing to be modified (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The image containing a person wearing clothing to be modified (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The prompt describing the desired clothing change. Defaults to "Person wearing this piece of clothing" if omitted or empty.
+ /// Default Value: Person wearing this piece of clothing
+ /// Example: Change his shirt to a pink shirt + /// + /// + /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON + /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + /// + /// The number of images to generate.
+ /// Default Value: 1 + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// + /// The rendering speed to use.
+ /// Default Value: DEFAULT + /// + /// + /// The style type to generate with.
+ /// Default Value: GENERAL
+ /// Example: GENERAL + /// + /// + /// A predefined style preset that applies a specific artistic style to the generated image.
+ /// Example: BRIGHT_ART + /// + /// + /// An image to use as the product reference for the try-on (exactly 1 image required). The image should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'product_reference_images' file parts. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task PostTryOnV3Async( + global::System.IO.Stream image, + string imagename, + global::System.Collections.Generic.IReadOnlyList productReferenceImages, + string? prompt = default, + global::Ideogram.MagicPromptOption? magicPrompt = default, + string? magicPromptSystemPromptConfigId = default, + int? numImages = default, + int? seed = default, + global::Ideogram.RenderingSpeed? renderingSpeed = default, + global::Ideogram.StyleTypeV3? styleType = default, + global::Ideogram.StylePresetV3? stylePreset = default, + global::System.Collections.Generic.IReadOnlyList? productReferenceImagesFileNames = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Virtual Try-On with Ideogram 3.0
+ /// Performs virtual clothing try-on by automatically segmenting the clothing in the provided image
+ /// and replacing it based on the prompt. The user provides an image and an optional prompt describing
+ /// the desired clothing change (e.g., "change his shirt to a pink shirt").
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// The image containing a person wearing clothing to be modified (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The image containing a person wearing clothing to be modified (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The prompt describing the desired clothing change. Defaults to "Person wearing this piece of clothing" if omitted or empty.
+ /// Default Value: Person wearing this piece of clothing
+ /// Example: Change his shirt to a pink shirt + /// + /// + /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON + /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + /// + /// The number of images to generate.
+ /// Default Value: 1 + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// + /// The rendering speed to use.
+ /// Default Value: DEFAULT + /// + /// + /// The style type to generate with.
+ /// Default Value: GENERAL
+ /// Example: GENERAL + /// + /// + /// A predefined style preset that applies a specific artistic style to the generated image.
+ /// Example: BRIGHT_ART + /// + /// + /// An image to use as the product reference for the try-on (exactly 1 image required). The image should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'product_reference_images' file parts. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> PostTryOnV3AsResponseAsync( + global::System.IO.Stream image, + string imagename, + global::System.Collections.Generic.IReadOnlyList productReferenceImages, + string? prompt = default, + global::Ideogram.MagicPromptOption? magicPrompt = default, + string? magicPromptSystemPromptConfigId = default, int? numImages = default, int? seed = default, global::Ideogram.RenderingSpeed? renderingSpeed = default, global::Ideogram.StyleTypeV3? styleType = default, global::Ideogram.StylePresetV3? stylePreset = default, + global::System.Collections.Generic.IReadOnlyList? productReferenceImagesFileNames = default, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } diff --git a/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostUpscaleImage.g.cs b/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostUpscaleImage.g.cs index 2c0e8fb..6fb56ff 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostUpscaleImage.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostUpscaleImage.g.cs @@ -25,6 +25,21 @@ public partial interface IGenerateClient /// Supported image formats include JPEG, PNG, and WebP.
/// Images links are available for a limited period of time; if you would like to keep the image, you must download it. /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> PostUpscaleImageAsResponseAsync( + + global::Ideogram.UpscaleImageRequest request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Upscale
+ /// Upscale provided images synchronously with an optional prompt.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
/// /// A request to upscale a provided image with the help of an optional prompt. /// @@ -43,5 +58,54 @@ public partial interface IGenerateClient string imageFilename, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + + /// + /// Upscale
+ /// Upscale provided images synchronously with an optional prompt.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// A request to upscale a provided image with the help of an optional prompt. + /// + /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task PostUpscaleImageAsync( + global::Ideogram.UpscaleInitialImageRequest imageRequest, + global::System.IO.Stream imageFile, + string imageFilename, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Upscale
+ /// Upscale provided images synchronously with an optional prompt.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// A request to upscale a provided image with the help of an optional prompt. + /// + /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> PostUpscaleImageAsResponseAsync( + global::Ideogram.UpscaleInitialImageRequest imageRequest, + global::System.IO.Stream imageFile, + string imageFilename, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostV1EditImage.g.cs b/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostV1EditImage.g.cs index 37dd6d9..e6c307c 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostV1EditImage.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IGenerateClient.PostV1EditImage.g.cs @@ -27,6 +27,22 @@ public partial interface IGenerateClient /// Supported image formats include JPEG, PNG, and WebP.
/// Images links are available for a limited period of time; if you would like to keep the image, you must download it. /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> PostV1EditImageAsResponseAsync( + + global::Ideogram.V1EditImagesRequest request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Edit images with a prompt
+ /// Edit one or more images using a text prompt. Provide images via file upload
+ /// or Ideogram image URLs, and describe the desired edit in your prompt.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
/// /// The prompt describing the desired edit.
/// Example: Change the background to a beach sunset. @@ -49,6 +65,9 @@ public partial interface IGenerateClient /// Determine if MagicPrompt should be used in generating the request or not.
/// Example: ON /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// /// /// The resolutions supported for Ideogram 3.0.
/// Example: 1280x800 @@ -70,6 +89,134 @@ public partial interface IGenerateClient int? numImages = default, int? seed = default, global::Ideogram.MagicPromptOption? magicPrompt = default, + string? magicPromptSystemPromptConfigId = default, + global::Ideogram.ResolutionV3? resolution = default, + global::Ideogram.AspectRatioV3? aspectRatio = default, + bool? transparentBackground = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + + /// + /// Edit images with a prompt
+ /// Edit one or more images using a text prompt. Provide images via file upload
+ /// or Ideogram image URLs, and describe the desired edit in your prompt.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// The prompt describing the desired edit.
+ /// Example: Change the background to a beach sunset. + /// + /// + /// Images to edit (max 10 images, max size 10MB each); JPEG, WebP and PNG formats are supported. + /// + /// + /// Optional file names to use for the multipart 'images' file parts. + /// + /// + /// URLs to Ideogram images to use as references (max 10). Supports URLs from generation responses and image uploads. Alternative to uploading via the images field. + /// + /// + /// The number of images to generate.
+ /// Default Value: 1 + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// + /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON + /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + /// + /// The resolutions supported for Ideogram 3.0.
+ /// Example: 1280x800 + /// + /// + /// The aspect ratio to use for image generation, which determines the image's resolution. Cannot be used in conjunction with resolution. Defaults to 1x1. + /// + /// + /// Whether the output should have a transparent background. Default false.
+ /// Default Value: false + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task PostV1EditImageAsync( + string prompt, + global::System.Collections.Generic.IReadOnlyList? images = default, + global::System.Collections.Generic.IReadOnlyList? imagesFileNames = default, + global::System.Collections.Generic.IList? imageUrls = default, + int? numImages = default, + int? seed = default, + global::Ideogram.MagicPromptOption? magicPrompt = default, + string? magicPromptSystemPromptConfigId = default, + global::Ideogram.ResolutionV3? resolution = default, + global::Ideogram.AspectRatioV3? aspectRatio = default, + bool? transparentBackground = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Edit images with a prompt
+ /// Edit one or more images using a text prompt. Provide images via file upload
+ /// or Ideogram image URLs, and describe the desired edit in your prompt.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it. + ///
+ /// + /// The prompt describing the desired edit.
+ /// Example: Change the background to a beach sunset. + /// + /// + /// Images to edit (max 10 images, max size 10MB each); JPEG, WebP and PNG formats are supported. + /// + /// + /// Optional file names to use for the multipart 'images' file parts. + /// + /// + /// URLs to Ideogram images to use as references (max 10). Supports URLs from generation responses and image uploads. Alternative to uploading via the images field. + /// + /// + /// The number of images to generate.
+ /// Default Value: 1 + /// + /// + /// Random seed. Set for reproducible generation.
+ /// Example: 12345 + /// + /// + /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON + /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + /// + /// The resolutions supported for Ideogram 3.0.
+ /// Example: 1280x800 + /// + /// + /// The aspect ratio to use for image generation, which determines the image's resolution. Cannot be used in conjunction with resolution. Defaults to 1x1. + /// + /// + /// Whether the output should have a transparent background. Default false.
+ /// Default Value: false + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> PostV1EditImageAsResponseAsync( + string prompt, + global::System.Collections.Generic.IReadOnlyList? images = default, + global::System.Collections.Generic.IReadOnlyList? imagesFileNames = default, + global::System.Collections.Generic.IList? imageUrls = default, + int? numImages = default, + int? seed = default, + global::Ideogram.MagicPromptOption? magicPrompt = default, + string? magicPromptSystemPromptConfigId = default, global::Ideogram.ResolutionV3? resolution = default, global::Ideogram.AspectRatioV3? aspectRatio = default, bool? transparentBackground = default, diff --git a/src/libs/Ideogram/Generated/Ideogram.IInternalTestingClient.PostInternalTesting.g.cs b/src/libs/Ideogram/Generated/Ideogram.IInternalTestingClient.PostInternalTesting.g.cs index 89cf74e..8ee7c6b 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IInternalTestingClient.PostInternalTesting.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IInternalTestingClient.PostInternalTesting.g.cs @@ -27,6 +27,23 @@ public partial interface IInternalTestingClient /// /// /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> PostInternalTestingAsResponseAsync( + + global::Ideogram.InternalTestingRequest request, + string? xTestHeader = default, + string? xTestHeader2 = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Testing
+ /// Just a testing endpoint + ///
+ /// + /// /// /// /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. @@ -71,5 +88,106 @@ public partial interface IInternalTestingClient global::Ideogram.InternalTestingEnumField? enumTypeField = default, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + + /// + /// Testing
+ /// Just a testing endpoint + ///
+ /// + /// + /// + /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task PostInternalTestingAsync( + global::System.DateTime requiredDateTypeField, + string? xTestHeader = default, + string? xTestHeader2 = default, + int? xPosition = default, + global::System.IO.Stream? imageFile = default, + string? imageFilename = default, + global::System.IO.Stream? anotherImageFile = default, + string? anotherImageFilename = default, + string? someText = default, + global::Ideogram.InternalTestingNestedObject? nestedObject = default, + global::Ideogram.InternalTestingNestedObjectRequiredFields? nestedObjectRequiredFields = default, + global::System.DateTime? dateTypeField = default, + global::System.DateTime? dateTimeTypeField = default, + global::System.Collections.Generic.IList? repeatedPrimitiveField = default, + global::System.Collections.Generic.IList? repeatedComplexField = default, + global::Ideogram.InternalTestingEnumField? enumTypeField = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Testing
+ /// Just a testing endpoint + ///
+ /// + /// + /// + /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> PostInternalTestingAsResponseAsync( + global::System.DateTime requiredDateTypeField, + string? xTestHeader = default, + string? xTestHeader2 = default, + int? xPosition = default, + global::System.IO.Stream? imageFile = default, + string? imageFilename = default, + global::System.IO.Stream? anotherImageFile = default, + string? anotherImageFilename = default, + string? someText = default, + global::Ideogram.InternalTestingNestedObject? nestedObject = default, + global::Ideogram.InternalTestingNestedObjectRequiredFields? nestedObjectRequiredFields = default, + global::System.DateTime? dateTypeField = default, + global::System.DateTime? dateTimeTypeField = default, + global::System.Collections.Generic.IList? repeatedPrimitiveField = default, + global::System.Collections.Generic.IList? repeatedComplexField = default, + global::Ideogram.InternalTestingEnumField? enumTypeField = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.IManageClient.AddOrganizationMembers.g.cs b/src/libs/Ideogram/Generated/Ideogram.IManageClient.AddOrganizationMembers.g.cs index a356491..81a3252 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IManageClient.AddOrganizationMembers.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IManageClient.AddOrganizationMembers.g.cs @@ -22,6 +22,20 @@ public partial interface IManageClient /// Add members to a specific organization /// /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> AddOrganizationMembersAsResponseAsync( + string organizationId, + + global::Ideogram.AddOrganizationMembersRequest request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Add members to a specific organization + /// + /// /// /// List of organization members to add
/// Default Value: [] diff --git a/src/libs/Ideogram/Generated/Ideogram.IManageClient.CreateApiKey.g.cs b/src/libs/Ideogram/Generated/Ideogram.IManageClient.CreateApiKey.g.cs index 9251be3..73d7aa5 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IManageClient.CreateApiKey.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IManageClient.CreateApiKey.g.cs @@ -13,5 +13,14 @@ public partial interface IManageClient global::System.Threading.Tasks.Task CreateApiKeyAsync( global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Creates an API key. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> CreateApiKeyAsResponseAsync( + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.IManageClient.CreateApiKeyV2.g.cs b/src/libs/Ideogram/Generated/Ideogram.IManageClient.CreateApiKeyV2.g.cs index 88a2ab5..ebf43bd 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IManageClient.CreateApiKeyV2.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IManageClient.CreateApiKeyV2.g.cs @@ -15,5 +15,16 @@ public partial interface IManageClient string organizationId, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Create an API key for a specific organization + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> CreateApiKeyV2AsResponseAsync( + string organizationId, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.IManageClient.DeactivateOrganizationApiKey.g.cs b/src/libs/Ideogram/Generated/Ideogram.IManageClient.DeactivateOrganizationApiKey.g.cs index 0ed6131..2085cb2 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IManageClient.DeactivateOrganizationApiKey.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IManageClient.DeactivateOrganizationApiKey.g.cs @@ -15,5 +15,16 @@ public partial interface IManageClient string apiKeyId, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Deactivate an API key for a specific organization + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task DeactivateOrganizationApiKeyAsResponseAsync( + string apiKeyId, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.IManageClient.DeleteSingleApiKey.g.cs b/src/libs/Ideogram/Generated/Ideogram.IManageClient.DeleteSingleApiKey.g.cs index 39e5875..1698bfd 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IManageClient.DeleteSingleApiKey.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IManageClient.DeleteSingleApiKey.g.cs @@ -15,5 +15,16 @@ public partial interface IManageClient string apiKeyId, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Delete an API key. + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task DeleteSingleApiKeyAsResponseAsync( + string apiKeyId, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.IManageClient.GetApiKeys.g.cs b/src/libs/Ideogram/Generated/Ideogram.IManageClient.GetApiKeys.g.cs index d7e0474..35148b7 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IManageClient.GetApiKeys.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IManageClient.GetApiKeys.g.cs @@ -13,5 +13,14 @@ public partial interface IManageClient global::System.Threading.Tasks.Task GetApiKeysAsync( global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Retrieve current API keys and their respective data. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> GetApiKeysAsResponseAsync( + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.IManageClient.GetApiKeysV2.g.cs b/src/libs/Ideogram/Generated/Ideogram.IManageClient.GetApiKeysV2.g.cs index 6b962d4..a89ec32 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IManageClient.GetApiKeysV2.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IManageClient.GetApiKeysV2.g.cs @@ -15,5 +15,16 @@ public partial interface IManageClient string organizationId, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Retrieve API keys for a specific organization + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> GetApiKeysV2AsResponseAsync( + string organizationId, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.IManageClient.GetApiOrganizationUserSuggestions.g.cs b/src/libs/Ideogram/Generated/Ideogram.IManageClient.GetApiOrganizationUserSuggestions.g.cs index dcf3e19..eb5a020 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IManageClient.GetApiOrganizationUserSuggestions.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IManageClient.GetApiOrganizationUserSuggestions.g.cs @@ -21,5 +21,22 @@ public partial interface IManageClient int? maxItems = default, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get search results for user handles with suggestions for a particular organization. + /// + /// + /// + /// + /// Default Value: 3 + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> GetApiOrganizationUserSuggestionsAsResponseAsync( + string organizationId, + string? userHandlePrefix = default, + int? maxItems = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.IManageClient.GetApiProfiles.g.cs b/src/libs/Ideogram/Generated/Ideogram.IManageClient.GetApiProfiles.g.cs index ffc8856..e1ccade 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IManageClient.GetApiProfiles.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IManageClient.GetApiProfiles.g.cs @@ -13,5 +13,14 @@ public partial interface IManageClient global::System.Threading.Tasks.Task GetApiProfilesAsync( global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Retrieve the user's current API profiles + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> GetApiProfilesAsResponseAsync( + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.IManageClient.GetApiStripeSubscription.g.cs b/src/libs/Ideogram/Generated/Ideogram.IManageClient.GetApiStripeSubscription.g.cs index 5fb6499..dc269f3 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IManageClient.GetApiStripeSubscription.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IManageClient.GetApiStripeSubscription.g.cs @@ -15,5 +15,16 @@ public partial interface IManageClient bool? isBusiness = default, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Retrieve data relevant to connecting to Stripe. + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> GetApiStripeSubscriptionAsResponseAsync( + bool? isBusiness = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.IManageClient.GetApiSubscription.g.cs b/src/libs/Ideogram/Generated/Ideogram.IManageClient.GetApiSubscription.g.cs index 26525d7..bd8011a 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IManageClient.GetApiSubscription.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IManageClient.GetApiSubscription.g.cs @@ -13,5 +13,14 @@ public partial interface IManageClient global::System.Threading.Tasks.Task GetApiSubscriptionAsync( global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Retrieve data relevant to creating an API subscription. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> GetApiSubscriptionAsResponseAsync( + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.IManageClient.GetApiTerms.g.cs b/src/libs/Ideogram/Generated/Ideogram.IManageClient.GetApiTerms.g.cs index 1869981..308fa93 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IManageClient.GetApiTerms.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IManageClient.GetApiTerms.g.cs @@ -13,5 +13,14 @@ public partial interface IManageClient global::System.Threading.Tasks.Task GetApiTermsAsync( global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Retrieve the latest terms of service for API usage. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> GetApiTermsAsResponseAsync( + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.IManageClient.GetOrganizationMembers.g.cs b/src/libs/Ideogram/Generated/Ideogram.IManageClient.GetOrganizationMembers.g.cs index 0b518ef..150af36 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IManageClient.GetOrganizationMembers.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IManageClient.GetOrganizationMembers.g.cs @@ -15,5 +15,16 @@ public partial interface IManageClient string organizationId, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Retrieve members of a specific organization + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> GetOrganizationMembersAsResponseAsync( + string organizationId, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.IManageClient.GetUsageInfo.g.cs b/src/libs/Ideogram/Generated/Ideogram.IManageClient.GetUsageInfo.g.cs index 38803b2..f48323b 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IManageClient.GetUsageInfo.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IManageClient.GetUsageInfo.g.cs @@ -45,5 +45,46 @@ public partial interface IManageClient global::Ideogram.UsageSource? source = default, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Retrieve usage information segmented by time period with tool-specific breakdowns + /// + /// + /// + /// Time segment granularity for usage breakdown
+ /// Example: DAY + /// + /// + /// + /// + /// Default Value: [] + /// + /// + /// Default Value: [] + /// + /// + /// Default Value: [] + /// + /// + /// Default Value: [] + /// + /// + /// Filter usage by source - API for programmatic API usage, APP for web application usage
+ /// Default Value: API + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> GetUsageInfoAsResponseAsync( + string organizationId, + global::Ideogram.SegmentBy segmentBy, + global::System.DateTime startTime, + global::System.DateTime? endTime = default, + global::System.Collections.Generic.IList? modelVersions = default, + global::System.Collections.Generic.IList? tools = default, + global::System.Collections.Generic.IList? apiKeyIds = default, + global::System.Collections.Generic.IList? userEmails = default, + global::Ideogram.UsageSource? source = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.IManageClient.GetUserCredits.g.cs b/src/libs/Ideogram/Generated/Ideogram.IManageClient.GetUserCredits.g.cs index 813604c..e0c3178 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IManageClient.GetUserCredits.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IManageClient.GetUserCredits.g.cs @@ -19,5 +19,20 @@ public partial interface IManageClient global::System.DateTime? endTime = default, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Retrieve user credit information and spending metrics + /// + /// + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> GetUserCreditsAsResponseAsync( + string organizationId, + global::System.DateTime startTime, + global::System.DateTime? endTime = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.IManageClient.GetUserSpendCommitInfo.g.cs b/src/libs/Ideogram/Generated/Ideogram.IManageClient.GetUserSpendCommitInfo.g.cs index 96d01b4..e50a712 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IManageClient.GetUserSpendCommitInfo.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IManageClient.GetUserSpendCommitInfo.g.cs @@ -17,5 +17,18 @@ public partial interface IManageClient bool? postpaidOnly = default, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Retrieve user spend commit information + /// + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> GetUserSpendCommitInfoAsResponseAsync( + string organizationId, + bool? postpaidOnly = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.IManageClient.ListOrganizationInvoices.g.cs b/src/libs/Ideogram/Generated/Ideogram.IManageClient.ListOrganizationInvoices.g.cs index 76d7972..2c8b038 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IManageClient.ListOrganizationInvoices.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IManageClient.ListOrganizationInvoices.g.cs @@ -15,5 +15,16 @@ public partial interface IManageClient string organizationId, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Retrieve invoices for a specific organization + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> ListOrganizationInvoicesAsResponseAsync( + string organizationId, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.IManageClient.PostAddCreditsForApi.g.cs b/src/libs/Ideogram/Generated/Ideogram.IManageClient.PostAddCreditsForApi.g.cs index 644a24a..7b09521 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IManageClient.PostAddCreditsForApi.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IManageClient.PostAddCreditsForApi.g.cs @@ -19,6 +19,18 @@ public partial interface IManageClient /// /// Add credits to an API user's account. /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> PostAddCreditsForApiAsResponseAsync( + + global::Ideogram.PostAddCreditsRequest request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Add credits to an API user's account. + /// /// /// Represents a price.
/// Example: {"amount":1050,"currency_code":"USD"} diff --git a/src/libs/Ideogram/Generated/Ideogram.IManageClient.PostApiSubscription.g.cs b/src/libs/Ideogram/Generated/Ideogram.IManageClient.PostApiSubscription.g.cs index 37e86a9..41d38e2 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IManageClient.PostApiSubscription.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IManageClient.PostApiSubscription.g.cs @@ -19,6 +19,18 @@ public partial interface IManageClient /// /// Update API subscription settings /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> PostApiSubscriptionAsResponseAsync( + + global::Ideogram.PostApiSubscriptionRequest request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Update API subscription settings + /// /// /// The current recharge settings for the API subscription.
/// Example: {"minimum_balance_threshold":{"amount":1050,"currency_code":"USD"},"top_up_balance":{"amount":1050,"currency_code":"USD"}} diff --git a/src/libs/Ideogram/Generated/Ideogram.IManageClient.PostApiTerms.g.cs b/src/libs/Ideogram/Generated/Ideogram.IManageClient.PostApiTerms.g.cs index 9072bd3..4c1a83b 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IManageClient.PostApiTerms.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IManageClient.PostApiTerms.g.cs @@ -19,6 +19,18 @@ public partial interface IManageClient /// /// Accept terms /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task PostApiTermsAsResponseAsync( + + global::Ideogram.PostApiTermsRequest request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Accept terms + /// /// /// The ID of the terms which are being accepted.
/// Example: TOS_2024_04_20 diff --git a/src/libs/Ideogram/Generated/Ideogram.IManageClient.PromoteOrganizationMembers.g.cs b/src/libs/Ideogram/Generated/Ideogram.IManageClient.PromoteOrganizationMembers.g.cs index e3df422..93a3565 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IManageClient.PromoteOrganizationMembers.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IManageClient.PromoteOrganizationMembers.g.cs @@ -22,6 +22,20 @@ public partial interface IManageClient /// Promote members to OWNER role in a specific organization /// /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> PromoteOrganizationMembersAsResponseAsync( + string organizationId, + + global::Ideogram.PromoteOrganizationMembersRequest request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Promote members to OWNER role in a specific organization + /// + /// /// /// List of organization members to promote to OWNER role
/// Default Value: [] diff --git a/src/libs/Ideogram/Generated/Ideogram.IManageClient.ReactivateSubscription.g.cs b/src/libs/Ideogram/Generated/Ideogram.IManageClient.ReactivateSubscription.g.cs index 4be866c..21ec74b 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IManageClient.ReactivateSubscription.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IManageClient.ReactivateSubscription.g.cs @@ -13,5 +13,14 @@ public partial interface IManageClient global::System.Threading.Tasks.Task ReactivateSubscriptionAsync( global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Reactivates a subscription by attempting to re-enable Metronome billing. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> ReactivateSubscriptionAsResponseAsync( + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.IManageClient.RemoveOrganizationMembers.g.cs b/src/libs/Ideogram/Generated/Ideogram.IManageClient.RemoveOrganizationMembers.g.cs index e9e8616..795a7a2 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IManageClient.RemoveOrganizationMembers.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IManageClient.RemoveOrganizationMembers.g.cs @@ -22,6 +22,20 @@ public partial interface IManageClient /// Remove members from a specific organization /// /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> RemoveOrganizationMembersAsResponseAsync( + string organizationId, + + global::Ideogram.RemoveOrganizationMembersRequest request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Remove members from a specific organization + /// + /// /// /// List of organization members to remove
/// Default Value: [] diff --git a/src/libs/Ideogram/Generated/Ideogram.IModelsClient.GetCustomModel.g.cs b/src/libs/Ideogram/Generated/Ideogram.IModelsClient.GetCustomModel.g.cs index 2abb1b2..bb16532 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IModelsClient.GetCustomModel.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IModelsClient.GetCustomModel.g.cs @@ -16,5 +16,17 @@ public partial interface IModelsClient string modelId, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Get model details
+ /// Get detailed information about a specific custom model. The user must either own the model or the model must be shared with the user's organization via the model registry. Returns 404 if the model is not found or not accessible. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> GetCustomModelAsResponseAsync( + string modelId, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.IModelsClient.ListCustomModels.g.cs b/src/libs/Ideogram/Generated/Ideogram.IModelsClient.ListCustomModels.g.cs index 491e2c9..8afc917 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IModelsClient.ListCustomModels.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IModelsClient.ListCustomModels.g.cs @@ -18,5 +18,19 @@ public partial interface IModelsClient global::System.Collections.Generic.IList? status = default, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + /// + /// List models
+ /// Lists custom models for the authenticated user. Use the `scope` parameter to control which models are returned. If omitted, returns both owned models and models shared with the user's organization via the model registry. `owned` returns only models created by the user. `shared` returns only models shared via the model registry, excluding the user's own models. + ///
+ /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> ListCustomModelsAsResponseAsync( + global::Ideogram.ListCustomModelsScope? scope = default, + global::System.Collections.Generic.IList? status = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.IModelsClient.TrainModelV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.IModelsClient.TrainModelV3.g.cs index 1b7b710..1e4dec7 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IModelsClient.TrainModelV3.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IModelsClient.TrainModelV3.g.cs @@ -21,6 +21,19 @@ public partial interface IModelsClient /// Train a custom Ideogram v3 model
/// Start training a custom Ideogram v3 model from a dataset using default hyperparameters. The dataset must contain at least 15 images and a maximum of 100 images. /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> TrainModelV3AsResponseAsync( + + global::Ideogram.TrainModelV3Request request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Train a custom Ideogram v3 model
+ /// Start training a custom Ideogram v3 model from a dataset using default hyperparameters. The dataset must contain at least 15 images and a maximum of 100 images. + ///
/// /// ID of the dataset to train the model from.
/// Example: abc123 diff --git a/src/libs/Ideogram/Generated/Ideogram.IModelsClient.TrainModelV3Advanced.g.cs b/src/libs/Ideogram/Generated/Ideogram.IModelsClient.TrainModelV3Advanced.g.cs index 20ad2af..2ff5014 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IModelsClient.TrainModelV3Advanced.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IModelsClient.TrainModelV3Advanced.g.cs @@ -21,6 +21,19 @@ public partial interface IModelsClient /// Train a custom Ideogram v3 model with advanced hyperparameters
/// Start training a custom Ideogram v3 model from a dataset with caller-supplied hyperparameters (training steps, LoRA rank, EMA decay, learning rate). All hyperparameters are optional and fall back to defaults when omitted. The dataset must contain at least 15 images and a maximum of 100 images. Returns the model ID and training status. /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> TrainModelV3AdvancedAsResponseAsync( + + global::Ideogram.TrainModelV3AdvancedRequest request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Train a custom Ideogram v3 model with advanced hyperparameters
+ /// Start training a custom Ideogram v3 model from a dataset with caller-supplied hyperparameters (training steps, LoRA rank, EMA decay, learning rate). All hyperparameters are optional and fall back to defaults when omitted. The dataset must contain at least 15 images and a maximum of 100 images. Returns the model ID and training status. + ///
/// /// ID of the dataset to train the model from.
/// Example: abc123 diff --git a/src/libs/Ideogram/Generated/Ideogram.IPromptClient.PostMagicPrompt.g.cs b/src/libs/Ideogram/Generated/Ideogram.IPromptClient.PostMagicPrompt.g.cs index 7a61033..d4786f6 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IPromptClient.PostMagicPrompt.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IPromptClient.PostMagicPrompt.g.cs @@ -21,6 +21,19 @@ public partial interface IPromptClient /// Generate Magic Prompt
/// Transforms basic prompts into a magic prompt. Internal use only (feature flagged). TODO: update description if enabled externally. /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> PostMagicPromptAsResponseAsync( + + global::Ideogram.MagicPromptRequest request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Generate Magic Prompt
+ /// Transforms basic prompts into a magic prompt. Internal use only (feature flagged). TODO: update description if enabled externally. + ///
/// /// The prompt to enhance with a magic prompt
/// Example: a cat @@ -63,5 +76,106 @@ public partial interface IPromptClient string? systemPrompt = default, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + + /// + /// Generate Magic Prompt
+ /// Transforms basic prompts into a magic prompt. Internal use only (feature flagged). TODO: update description if enabled externally. + ///
+ /// + /// The prompt to enhance with a magic prompt
+ /// Example: a cat + /// + /// + /// The magic prompt version to use when magic prompt option is set to AUTO or ON.
+ /// Example: V_0 + /// + /// + /// Whether to classify the prompt into a use case category.
+ /// Default Value: true
+ /// Example: false + /// + /// + /// The style type to generate with.
+ /// Default Value: GENERAL
+ /// Example: GENERAL + /// + /// + /// Random seed for reproducible generation
+ /// Example: 12345 + /// + /// + /// Generations with character reference are subject to the character reference pricing. A set of images to use as character references (maximum total size 10MB across all character references), currently only supports 1 character reference image. The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'character_reference_images' file parts. + /// + /// + /// A system prompt to use for the magic prompt.
+ /// Example: You are a helpful assistant that generates magic prompts for images. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task PostMagicPromptAsync( + string prompt, + global::Ideogram.MagicPromptVersionEnum magicPromptVersion, + bool classifyPromptCategory, + global::Ideogram.StyleTypeV3? styleType = default, + int? seed = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImages = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesFileNames = default, + string? systemPrompt = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Generate Magic Prompt
+ /// Transforms basic prompts into a magic prompt. Internal use only (feature flagged). TODO: update description if enabled externally. + ///
+ /// + /// The prompt to enhance with a magic prompt
+ /// Example: a cat + /// + /// + /// The magic prompt version to use when magic prompt option is set to AUTO or ON.
+ /// Example: V_0 + /// + /// + /// Whether to classify the prompt into a use case category.
+ /// Default Value: true
+ /// Example: false + /// + /// + /// The style type to generate with.
+ /// Default Value: GENERAL
+ /// Example: GENERAL + /// + /// + /// Random seed for reproducible generation
+ /// Example: 12345 + /// + /// + /// Generations with character reference are subject to the character reference pricing. A set of images to use as character references (maximum total size 10MB across all character references), currently only supports 1 character reference image. The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'character_reference_images' file parts. + /// + /// + /// A system prompt to use for the magic prompt.
+ /// Example: You are a helpful assistant that generates magic prompts for images. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> PostMagicPromptAsResponseAsync( + string prompt, + global::Ideogram.MagicPromptVersionEnum magicPromptVersion, + bool classifyPromptCategory, + global::Ideogram.StyleTypeV3? styleType = default, + int? seed = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImages = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesFileNames = default, + string? systemPrompt = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.IVisionClient.PostDescribe.g.cs b/src/libs/Ideogram/Generated/Ideogram.IVisionClient.PostDescribe.g.cs index bb12700..5cfe73a 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IVisionClient.PostDescribe.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IVisionClient.PostDescribe.g.cs @@ -23,6 +23,20 @@ public partial interface IVisionClient /// Describe an image.
/// Supported image formats include JPEG, PNG, and WebP. /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> PostDescribeAsResponseAsync( + + global::Ideogram.DescribeRequest request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Describe
+ /// Describe an image.
+ /// Supported image formats include JPEG, PNG, and WebP. + ///
/// /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. /// @@ -42,5 +56,54 @@ public partial interface IVisionClient global::Ideogram.DescribeModelVersion? describeModelVersion = default, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + + /// + /// Describe
+ /// Describe an image.
+ /// Supported image formats include JPEG, PNG, and WebP. + ///
+ /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The model version to use for describing images. Defaults to V_3.
+ /// Default Value: V_3 + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task PostDescribeAsync( + global::System.IO.Stream imageFile, + string imageFilename, + global::Ideogram.DescribeModelVersion? describeModelVersion = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Describe
+ /// Describe an image.
+ /// Supported image formats include JPEG, PNG, and WebP. + ///
+ /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The model version to use for describing images. Defaults to V_3.
+ /// Default Value: V_3 + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> PostDescribeAsResponseAsync( + global::System.IO.Stream imageFile, + string imageFilename, + global::Ideogram.DescribeModelVersion? describeModelVersion = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.IdeogramClient.g.cs b/src/libs/Ideogram/Generated/Ideogram.IdeogramClient.g.cs index 5bde80b..2408c34 100644 --- a/src/libs/Ideogram/Generated/Ideogram.IdeogramClient.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.IdeogramClient.g.cs @@ -43,7 +43,7 @@ public sealed partial class IdeogramClient : global::Ideogram.IIdeogramClient, g /// /// /// - public BatchClient Batch => new BatchClient(HttpClient, authorizations: Authorizations, options: Options) + public BatchClient Batch => new BatchClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -52,7 +52,7 @@ public sealed partial class IdeogramClient : global::Ideogram.IIdeogramClient, g /// /// Operations related to managing datasets. /// - public DatasetsClient Datasets => new DatasetsClient(HttpClient, authorizations: Authorizations, options: Options) + public DatasetsClient Datasets => new DatasetsClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -61,7 +61,7 @@ public sealed partial class IdeogramClient : global::Ideogram.IIdeogramClient, g /// /// All things related to generating content. /// - public GenerateClient Generate => new GenerateClient(HttpClient, authorizations: Authorizations, options: Options) + public GenerateClient Generate => new GenerateClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -70,7 +70,7 @@ public sealed partial class IdeogramClient : global::Ideogram.IIdeogramClient, g /// /// Operations and endpoints designed for doing internal testing. Not intended to be called outside a test environment. /// - public InternalTestingClient InternalTesting => new InternalTestingClient(HttpClient, authorizations: Authorizations, options: Options) + public InternalTestingClient InternalTesting => new InternalTestingClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -79,7 +79,7 @@ public sealed partial class IdeogramClient : global::Ideogram.IIdeogramClient, g /// /// Content related to managing API account and API access. /// - public ManageClient Manage => new ManageClient(HttpClient, authorizations: Authorizations, options: Options) + public ManageClient Manage => new ManageClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -88,7 +88,7 @@ public sealed partial class IdeogramClient : global::Ideogram.IIdeogramClient, g /// /// Operations related to managing custom models. /// - public ModelsClient Models => new ModelsClient(HttpClient, authorizations: Authorizations, options: Options) + public ModelsClient Models => new ModelsClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -97,7 +97,7 @@ public sealed partial class IdeogramClient : global::Ideogram.IIdeogramClient, g /// /// /// - public PromptClient Prompt => new PromptClient(HttpClient, authorizations: Authorizations, options: Options) + public PromptClient Prompt => new PromptClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -106,7 +106,7 @@ public sealed partial class IdeogramClient : global::Ideogram.IIdeogramClient, g /// /// Operations related to understanding visual content. /// - public VisionClient Vision => new VisionClient(HttpClient, authorizations: Authorizations, options: Options) + public VisionClient Vision => new VisionClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -145,10 +145,10 @@ public IdeogramClient( /// Client-wide request defaults such as headers, query parameters, retries, and timeout. /// Dispose the HttpClient when the instance is disposed. True by default. public IdeogramClient( - global::System.Net.Http.HttpClient? httpClient = null, - global::System.Uri? baseUri = null, - global::System.Collections.Generic.List? authorizations = null, - global::Ideogram.AutoSDKClientOptions? options = null, + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Ideogram.AutoSDKClientOptions? options, bool disposeHttpClient = true) { diff --git a/src/libs/Ideogram/Generated/Ideogram.InternalTestingClient.PostInternalTesting.g.cs b/src/libs/Ideogram/Generated/Ideogram.InternalTestingClient.PostInternalTesting.g.cs index 29e3402..a45232e 100644 --- a/src/libs/Ideogram/Generated/Ideogram.InternalTestingClient.PostInternalTesting.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.InternalTestingClient.PostInternalTesting.g.cs @@ -57,6 +57,35 @@ partial void ProcessPostInternalTestingResponseContent( /// public async global::System.Threading.Tasks.Task PostInternalTestingAsync( + global::Ideogram.InternalTestingRequest request, + string? xTestHeader = default, + string? xTestHeader2 = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await PostInternalTestingAsResponseAsync( + + request: request, + xTestHeader: xTestHeader, + xTestHeader2: xTestHeader2, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Testing
+ /// Just a testing endpoint + ///
+ /// + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> PostInternalTestingAsResponseAsync( + global::Ideogram.InternalTestingRequest request, string? xTestHeader = default, string? xTestHeader2 = default, @@ -91,10 +120,11 @@ partial void ProcessPostInternalTestingResponseContent( var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/internal-testing", baseUri: HttpClient.BaseAddress); @@ -137,6 +167,7 @@ partial void ProcessPostInternalTestingResponseContent( __httpRequest.Headers.TryAddWithoutValidation("X-Test-Header-2", xTestHeader2.ToString()); } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); if (xTestHeader != default) { @@ -144,21 +175,24 @@ partial void ProcessPostInternalTestingResponseContent( __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(xTestHeader ?? string.Empty), name: "\"X-Test-Header\""); - } + + } if (xTestHeader2 != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(xTestHeader2 ?? string.Empty), name: "\"X-Test-Header-2\""); - } + + } if (request.XPosition != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.XPosition, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), name: "\"x_position\""); - } + + } if (request.ImageFile != default) { @@ -199,7 +233,8 @@ request.ImageFilename is null { __contentImageFile.Headers.ContentDisposition.FileNameStar = null; } - } + + } if (request.AnotherImageFile != default) { @@ -240,67 +275,79 @@ request.AnotherImageFilename is null { __contentAnotherImageFile.Headers.ContentDisposition.FileNameStar = null; } - } + + } if (request.SomeText != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.SomeText ?? string.Empty), name: "\"some_text\""); - } + + } if (request.NestedObject != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.NestedObject.ToJson(JsonSerializerContext)), name: "\"nested_object\""); - } + + } if (request.NestedObjectRequiredFields != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.NestedObjectRequiredFields.ToJson(JsonSerializerContext)), name: "\"nested_object_required_fields\""); - } + + } if (request.DateTypeField != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.DateTypeField).HasValue ? (request.DateTypeField).GetValueOrDefault().ToString("yyyy-MM-dd") : string.Empty), name: "\"date_type_field\""); + } __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.RequiredDateTypeField.ToString("yyyy-MM-dd")), name: "\"required_date_type_field\""); + if (request.DateTimeTypeField != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.DateTimeTypeField).HasValue ? (request.DateTimeTypeField).GetValueOrDefault().ToString("yyyy-MM-ddTHH:mm:ssZ") : string.Empty), name: "\"date_time_type_field\""); - } + + } if (request.RepeatedPrimitiveField != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.RepeatedPrimitiveField, x => x))}]"), name: "\"repeated_primitive_field\""); - } + + } if (request.RepeatedComplexField != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.RepeatedComplexField, x => x.ToJson(JsonSerializerContext)))}]"), name: "\"repeated_complex_field\""); - } + + } if (request.EnumTypeField != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.EnumTypeField).HasValue ? (request.EnumTypeField).GetValueOrDefault().ToValueString() : string.Empty), name: "\"enum_type_field\""); + } + __httpRequest.Content = __httpRequestContent; + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -344,6 +391,8 @@ request.AnotherImageFilename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -354,6 +403,11 @@ request.AnotherImageFilename is null } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -371,6 +425,8 @@ request.AnotherImageFilename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -380,8 +436,7 @@ request.AnotherImageFilename is null __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -390,6 +445,11 @@ request.AnotherImageFilename is null __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -406,14 +466,15 @@ request.AnotherImageFilename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -453,6 +514,8 @@ request.AnotherImageFilename is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -473,6 +536,8 @@ request.AnotherImageFilename is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } @@ -497,9 +562,13 @@ request.AnotherImageFilename is null { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.PostInternalTesting200Response.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.PostInternalTesting200Response.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -527,9 +596,13 @@ request.AnotherImageFilename is null #endif ).ConfigureAwait(false); - return - await global::Ideogram.PostInternalTesting200Response.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.PostInternalTesting200Response.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -643,5 +716,1228 @@ request.AnotherImageFilename is null requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } + + /// + /// Testing
+ /// Just a testing endpoint + ///
+ /// + /// + /// + /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task PostInternalTestingAsync( + global::System.DateTime requiredDateTypeField, + string? xTestHeader = default, + string? xTestHeader2 = default, + int? xPosition = default, + global::System.IO.Stream? imageFile = default, + string? imageFilename = default, + global::System.IO.Stream? anotherImageFile = default, + string? anotherImageFilename = default, + string? someText = default, + global::Ideogram.InternalTestingNestedObject? nestedObject = default, + global::Ideogram.InternalTestingNestedObjectRequiredFields? nestedObjectRequiredFields = default, + global::System.DateTime? dateTypeField = default, + global::System.DateTime? dateTimeTypeField = default, + global::System.Collections.Generic.IList? repeatedPrimitiveField = default, + global::System.Collections.Generic.IList? repeatedComplexField = default, + global::Ideogram.InternalTestingEnumField? enumTypeField = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + var request = new global::Ideogram.InternalTestingRequest + { + XPosition = xPosition, + ImageFile = global::System.Array.Empty(), + ImageFilename = imageFilename, + AnotherImageFile = global::System.Array.Empty(), + AnotherImageFilename = anotherImageFilename, + SomeText = someText, + NestedObject = nestedObject, + NestedObjectRequiredFields = nestedObjectRequiredFields, + DateTypeField = dateTypeField, + RequiredDateTypeField = requiredDateTypeField, + DateTimeTypeField = dateTimeTypeField, + RepeatedPrimitiveField = repeatedPrimitiveField, + RepeatedComplexField = repeatedComplexField, + EnumTypeField = enumTypeField, + }; + PrepareArguments( + client: HttpClient); + PreparePostInternalTestingArguments( + httpClient: HttpClient, + xTestHeader: ref xTestHeader, + xTestHeader2: ref xTestHeader2, + request: request); + + + var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_PostInternalTestingSecurityRequirements, + operationName: "PostInternalTestingAsync"); + + using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Ideogram.PathBuilder( + path: "/internal-testing", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + if (xTestHeader != default) + { + __httpRequest.Headers.TryAddWithoutValidation("X-Test-Header", xTestHeader.ToString()); + } + if (xTestHeader2 != default) + { + __httpRequest.Headers.TryAddWithoutValidation("X-Test-Header-2", xTestHeader2.ToString()); + } + + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + if (xTestHeader != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(xTestHeader ?? string.Empty), + name: "\"X-Test-Header\""); + + } + if (xTestHeader2 != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(xTestHeader2 ?? string.Empty), + name: "\"X-Test-Header-2\""); + + } + if (request.XPosition != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.XPosition, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"x_position\""); + + } + if (imageFile != default) + { + + var __contentImageFile = new global::System.Net.Http.StreamContent(imageFile); + __contentImageFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.ImageFilename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.ImageFilename) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentImageFile, + name: "\"image_file\"", + fileName: request.ImageFilename != null ? $"\"{request.ImageFilename}\"" : string.Empty); + if (__contentImageFile.Headers.ContentDisposition != null) + { + __contentImageFile.Headers.ContentDisposition.FileNameStar = null; + } + + } + if (anotherImageFile != default) + { + + var __contentAnotherImageFile = new global::System.Net.Http.StreamContent(anotherImageFile); + __contentAnotherImageFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.AnotherImageFilename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.AnotherImageFilename) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentAnotherImageFile, + name: "\"another_image_file\"", + fileName: request.AnotherImageFilename != null ? $"\"{request.AnotherImageFilename}\"" : string.Empty); + if (__contentAnotherImageFile.Headers.ContentDisposition != null) + { + __contentAnotherImageFile.Headers.ContentDisposition.FileNameStar = null; + } + + } + if (request.SomeText != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.SomeText ?? string.Empty), + name: "\"some_text\""); + + } + if (request.NestedObject != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.NestedObject.ToJson(JsonSerializerContext)), + name: "\"nested_object\""); + + } + if (request.NestedObjectRequiredFields != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.NestedObjectRequiredFields.ToJson(JsonSerializerContext)), + name: "\"nested_object_required_fields\""); + + } + if (request.DateTypeField != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.DateTypeField).HasValue ? (request.DateTypeField).GetValueOrDefault().ToString("yyyy-MM-dd") : string.Empty), + name: "\"date_type_field\""); + + } + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.RequiredDateTypeField.ToString("yyyy-MM-dd")), + name: "\"required_date_type_field\""); + + if (request.DateTimeTypeField != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.DateTimeTypeField).HasValue ? (request.DateTimeTypeField).GetValueOrDefault().ToString("yyyy-MM-ddTHH:mm:ssZ") : string.Empty), + name: "\"date_time_type_field\""); + + } + if (request.RepeatedPrimitiveField != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.RepeatedPrimitiveField, x => x))}]"), + name: "\"repeated_primitive_field\""); + + } + if (request.RepeatedComplexField != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.RepeatedComplexField, x => x.ToJson(JsonSerializerContext)))}]"), + name: "\"repeated_complex_field\""); + + } + if (request.EnumTypeField != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.EnumTypeField).HasValue ? (request.EnumTypeField).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"enum_type_field\""); + + } + + __httpRequest.Content = __httpRequestContent; + + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PreparePostInternalTestingRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + xTestHeader: xTestHeader, + xTestHeader2: xTestHeader2, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostInternalTesting", + methodName: "PostInternalTestingAsync", + pathTemplate: "\"/internal-testing\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostInternalTesting", + methodName: "PostInternalTestingAsync", + pathTemplate: "\"/internal-testing\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostInternalTesting", + methodName: "PostInternalTestingAsync", + pathTemplate: "\"/internal-testing\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessPostInternalTestingResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostInternalTesting", + methodName: "PostInternalTestingAsync", + pathTemplate: "\"/internal-testing\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostInternalTesting", + methodName: "PostInternalTestingAsync", + pathTemplate: "\"/internal-testing\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessPostInternalTestingResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Ideogram.PostInternalTesting200Response.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Ideogram.PostInternalTesting200Response.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Testing
+ /// Just a testing endpoint + ///
+ /// + /// + /// + /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> PostInternalTestingAsResponseAsync( + global::System.DateTime requiredDateTypeField, + string? xTestHeader = default, + string? xTestHeader2 = default, + int? xPosition = default, + global::System.IO.Stream? imageFile = default, + string? imageFilename = default, + global::System.IO.Stream? anotherImageFile = default, + string? anotherImageFilename = default, + string? someText = default, + global::Ideogram.InternalTestingNestedObject? nestedObject = default, + global::Ideogram.InternalTestingNestedObjectRequiredFields? nestedObjectRequiredFields = default, + global::System.DateTime? dateTypeField = default, + global::System.DateTime? dateTimeTypeField = default, + global::System.Collections.Generic.IList? repeatedPrimitiveField = default, + global::System.Collections.Generic.IList? repeatedComplexField = default, + global::Ideogram.InternalTestingEnumField? enumTypeField = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + var request = new global::Ideogram.InternalTestingRequest + { + XPosition = xPosition, + ImageFile = global::System.Array.Empty(), + ImageFilename = imageFilename, + AnotherImageFile = global::System.Array.Empty(), + AnotherImageFilename = anotherImageFilename, + SomeText = someText, + NestedObject = nestedObject, + NestedObjectRequiredFields = nestedObjectRequiredFields, + DateTypeField = dateTypeField, + RequiredDateTypeField = requiredDateTypeField, + DateTimeTypeField = dateTimeTypeField, + RepeatedPrimitiveField = repeatedPrimitiveField, + RepeatedComplexField = repeatedComplexField, + EnumTypeField = enumTypeField, + }; + PrepareArguments( + client: HttpClient); + PreparePostInternalTestingArguments( + httpClient: HttpClient, + xTestHeader: ref xTestHeader, + xTestHeader2: ref xTestHeader2, + request: request); + + + var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_PostInternalTestingSecurityRequirements, + operationName: "PostInternalTestingAsync"); + + using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Ideogram.PathBuilder( + path: "/internal-testing", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + if (xTestHeader != default) + { + __httpRequest.Headers.TryAddWithoutValidation("X-Test-Header", xTestHeader.ToString()); + } + if (xTestHeader2 != default) + { + __httpRequest.Headers.TryAddWithoutValidation("X-Test-Header-2", xTestHeader2.ToString()); + } + + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + if (xTestHeader != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(xTestHeader ?? string.Empty), + name: "\"X-Test-Header\""); + + } + if (xTestHeader2 != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(xTestHeader2 ?? string.Empty), + name: "\"X-Test-Header-2\""); + + } + if (request.XPosition != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.XPosition, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"x_position\""); + + } + if (imageFile != default) + { + + var __contentImageFile = new global::System.Net.Http.StreamContent(imageFile); + __contentImageFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.ImageFilename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.ImageFilename) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentImageFile, + name: "\"image_file\"", + fileName: request.ImageFilename != null ? $"\"{request.ImageFilename}\"" : string.Empty); + if (__contentImageFile.Headers.ContentDisposition != null) + { + __contentImageFile.Headers.ContentDisposition.FileNameStar = null; + } + + } + if (anotherImageFile != default) + { + + var __contentAnotherImageFile = new global::System.Net.Http.StreamContent(anotherImageFile); + __contentAnotherImageFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.AnotherImageFilename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.AnotherImageFilename) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentAnotherImageFile, + name: "\"another_image_file\"", + fileName: request.AnotherImageFilename != null ? $"\"{request.AnotherImageFilename}\"" : string.Empty); + if (__contentAnotherImageFile.Headers.ContentDisposition != null) + { + __contentAnotherImageFile.Headers.ContentDisposition.FileNameStar = null; + } + + } + if (request.SomeText != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.SomeText ?? string.Empty), + name: "\"some_text\""); + + } + if (request.NestedObject != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.NestedObject.ToJson(JsonSerializerContext)), + name: "\"nested_object\""); + + } + if (request.NestedObjectRequiredFields != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.NestedObjectRequiredFields.ToJson(JsonSerializerContext)), + name: "\"nested_object_required_fields\""); + + } + if (request.DateTypeField != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.DateTypeField).HasValue ? (request.DateTypeField).GetValueOrDefault().ToString("yyyy-MM-dd") : string.Empty), + name: "\"date_type_field\""); + + } + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.RequiredDateTypeField.ToString("yyyy-MM-dd")), + name: "\"required_date_type_field\""); + + if (request.DateTimeTypeField != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.DateTimeTypeField).HasValue ? (request.DateTimeTypeField).GetValueOrDefault().ToString("yyyy-MM-ddTHH:mm:ssZ") : string.Empty), + name: "\"date_time_type_field\""); + + } + if (request.RepeatedPrimitiveField != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.RepeatedPrimitiveField, x => x))}]"), + name: "\"repeated_primitive_field\""); + + } + if (request.RepeatedComplexField != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.RepeatedComplexField, x => x.ToJson(JsonSerializerContext)))}]"), + name: "\"repeated_complex_field\""); + + } + if (request.EnumTypeField != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.EnumTypeField).HasValue ? (request.EnumTypeField).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"enum_type_field\""); + + } + + __httpRequest.Content = __httpRequestContent; + + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PreparePostInternalTestingRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + xTestHeader: xTestHeader, + xTestHeader2: xTestHeader2, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostInternalTesting", + methodName: "PostInternalTestingAsync", + pathTemplate: "\"/internal-testing\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostInternalTesting", + methodName: "PostInternalTestingAsync", + pathTemplate: "\"/internal-testing\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostInternalTesting", + methodName: "PostInternalTestingAsync", + pathTemplate: "\"/internal-testing\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessPostInternalTestingResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostInternalTesting", + methodName: "PostInternalTestingAsync", + pathTemplate: "\"/internal-testing\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostInternalTesting", + methodName: "PostInternalTestingAsync", + pathTemplate: "\"/internal-testing\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessPostInternalTestingResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Ideogram.PostInternalTesting200Response.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + var __value = await global::Ideogram.PostInternalTesting200Response.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.InternalTestingClient.g.cs b/src/libs/Ideogram/Generated/Ideogram.InternalTestingClient.g.cs index 003e42a..a4ffc8c 100644 --- a/src/libs/Ideogram/Generated/Ideogram.InternalTestingClient.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.InternalTestingClient.g.cs @@ -73,10 +73,10 @@ public InternalTestingClient( /// Client-wide request defaults such as headers, query parameters, retries, and timeout. /// Dispose the HttpClient when the instance is disposed. True by default. public InternalTestingClient( - global::System.Net.Http.HttpClient? httpClient = null, - global::System.Uri? baseUri = null, - global::System.Collections.Generic.List? authorizations = null, - global::Ideogram.AutoSDKClientOptions? options = null, + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Ideogram.AutoSDKClientOptions? options, bool disposeHttpClient = true) { diff --git a/src/libs/Ideogram/Generated/Ideogram.JsonConverters.TextItemV3TextTransform.g.cs b/src/libs/Ideogram/Generated/Ideogram.JsonConverters.TextItemV3TextTransform.g.cs new file mode 100644 index 0000000..dc997b1 --- /dev/null +++ b/src/libs/Ideogram/Generated/Ideogram.JsonConverters.TextItemV3TextTransform.g.cs @@ -0,0 +1,53 @@ +#nullable enable + +namespace Ideogram.JsonConverters +{ + /// + public sealed class TextItemV3TextTransformJsonConverter : global::System.Text.Json.Serialization.JsonConverter + { + /// + public override global::Ideogram.TextItemV3TextTransform Read( + ref global::System.Text.Json.Utf8JsonReader reader, + global::System.Type typeToConvert, + global::System.Text.Json.JsonSerializerOptions options) + { + switch (reader.TokenType) + { + case global::System.Text.Json.JsonTokenType.String: + { + var stringValue = reader.GetString(); + if (stringValue != null) + { + return global::Ideogram.TextItemV3TextTransformExtensions.ToEnum(stringValue) ?? default; + } + + break; + } + case global::System.Text.Json.JsonTokenType.Number: + { + var numValue = reader.GetInt32(); + return (global::Ideogram.TextItemV3TextTransform)numValue; + } + case global::System.Text.Json.JsonTokenType.Null: + { + return default(global::Ideogram.TextItemV3TextTransform); + } + default: + throw new global::System.ArgumentOutOfRangeException(nameof(reader)); + } + + return default; + } + + /// + public override void Write( + global::System.Text.Json.Utf8JsonWriter writer, + global::Ideogram.TextItemV3TextTransform value, + global::System.Text.Json.JsonSerializerOptions options) + { + writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer)); + + writer.WriteStringValue(global::Ideogram.TextItemV3TextTransformExtensions.ToValueString(value)); + } + } +} diff --git a/src/libs/Ideogram/Generated/Ideogram.JsonConverters.TextItemV3TextTransformNullable.g.cs b/src/libs/Ideogram/Generated/Ideogram.JsonConverters.TextItemV3TextTransformNullable.g.cs new file mode 100644 index 0000000..6ed0026 --- /dev/null +++ b/src/libs/Ideogram/Generated/Ideogram.JsonConverters.TextItemV3TextTransformNullable.g.cs @@ -0,0 +1,60 @@ +#nullable enable + +namespace Ideogram.JsonConverters +{ + /// + public sealed class TextItemV3TextTransformNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter + { + /// + public override global::Ideogram.TextItemV3TextTransform? Read( + ref global::System.Text.Json.Utf8JsonReader reader, + global::System.Type typeToConvert, + global::System.Text.Json.JsonSerializerOptions options) + { + switch (reader.TokenType) + { + case global::System.Text.Json.JsonTokenType.String: + { + var stringValue = reader.GetString(); + if (stringValue != null) + { + return global::Ideogram.TextItemV3TextTransformExtensions.ToEnum(stringValue); + } + + break; + } + case global::System.Text.Json.JsonTokenType.Number: + { + var numValue = reader.GetInt32(); + return (global::Ideogram.TextItemV3TextTransform)numValue; + } + case global::System.Text.Json.JsonTokenType.Null: + { + return default(global::Ideogram.TextItemV3TextTransform?); + } + default: + throw new global::System.ArgumentOutOfRangeException(nameof(reader)); + } + + return default; + } + + /// + public override void Write( + global::System.Text.Json.Utf8JsonWriter writer, + global::Ideogram.TextItemV3TextTransform? value, + global::System.Text.Json.JsonSerializerOptions options) + { + writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer)); + + if (value == null) + { + writer.WriteNullValue(); + } + else + { + writer.WriteStringValue(global::Ideogram.TextItemV3TextTransformExtensions.ToValueString(value.Value)); + } + } + } +} diff --git a/src/libs/Ideogram/Generated/Ideogram.JsonConverters.TextItemV3VerticalAlignment.g.cs b/src/libs/Ideogram/Generated/Ideogram.JsonConverters.TextItemV3VerticalAlignment.g.cs new file mode 100644 index 0000000..8ab6b11 --- /dev/null +++ b/src/libs/Ideogram/Generated/Ideogram.JsonConverters.TextItemV3VerticalAlignment.g.cs @@ -0,0 +1,53 @@ +#nullable enable + +namespace Ideogram.JsonConverters +{ + /// + public sealed class TextItemV3VerticalAlignmentJsonConverter : global::System.Text.Json.Serialization.JsonConverter + { + /// + public override global::Ideogram.TextItemV3VerticalAlignment Read( + ref global::System.Text.Json.Utf8JsonReader reader, + global::System.Type typeToConvert, + global::System.Text.Json.JsonSerializerOptions options) + { + switch (reader.TokenType) + { + case global::System.Text.Json.JsonTokenType.String: + { + var stringValue = reader.GetString(); + if (stringValue != null) + { + return global::Ideogram.TextItemV3VerticalAlignmentExtensions.ToEnum(stringValue) ?? default; + } + + break; + } + case global::System.Text.Json.JsonTokenType.Number: + { + var numValue = reader.GetInt32(); + return (global::Ideogram.TextItemV3VerticalAlignment)numValue; + } + case global::System.Text.Json.JsonTokenType.Null: + { + return default(global::Ideogram.TextItemV3VerticalAlignment); + } + default: + throw new global::System.ArgumentOutOfRangeException(nameof(reader)); + } + + return default; + } + + /// + public override void Write( + global::System.Text.Json.Utf8JsonWriter writer, + global::Ideogram.TextItemV3VerticalAlignment value, + global::System.Text.Json.JsonSerializerOptions options) + { + writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer)); + + writer.WriteStringValue(global::Ideogram.TextItemV3VerticalAlignmentExtensions.ToValueString(value)); + } + } +} diff --git a/src/libs/Ideogram/Generated/Ideogram.JsonConverters.TextItemV3VerticalAlignmentNullable.g.cs b/src/libs/Ideogram/Generated/Ideogram.JsonConverters.TextItemV3VerticalAlignmentNullable.g.cs new file mode 100644 index 0000000..d0aea15 --- /dev/null +++ b/src/libs/Ideogram/Generated/Ideogram.JsonConverters.TextItemV3VerticalAlignmentNullable.g.cs @@ -0,0 +1,60 @@ +#nullable enable + +namespace Ideogram.JsonConverters +{ + /// + public sealed class TextItemV3VerticalAlignmentNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter + { + /// + public override global::Ideogram.TextItemV3VerticalAlignment? Read( + ref global::System.Text.Json.Utf8JsonReader reader, + global::System.Type typeToConvert, + global::System.Text.Json.JsonSerializerOptions options) + { + switch (reader.TokenType) + { + case global::System.Text.Json.JsonTokenType.String: + { + var stringValue = reader.GetString(); + if (stringValue != null) + { + return global::Ideogram.TextItemV3VerticalAlignmentExtensions.ToEnum(stringValue); + } + + break; + } + case global::System.Text.Json.JsonTokenType.Number: + { + var numValue = reader.GetInt32(); + return (global::Ideogram.TextItemV3VerticalAlignment)numValue; + } + case global::System.Text.Json.JsonTokenType.Null: + { + return default(global::Ideogram.TextItemV3VerticalAlignment?); + } + default: + throw new global::System.ArgumentOutOfRangeException(nameof(reader)); + } + + return default; + } + + /// + public override void Write( + global::System.Text.Json.Utf8JsonWriter writer, + global::Ideogram.TextItemV3VerticalAlignment? value, + global::System.Text.Json.JsonSerializerOptions options) + { + writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer)); + + if (value == null) + { + writer.WriteNullValue(); + } + else + { + writer.WriteStringValue(global::Ideogram.TextItemV3VerticalAlignmentExtensions.ToValueString(value.Value)); + } + } + } +} diff --git a/src/libs/Ideogram/Generated/Ideogram.JsonSerializerContext.g.cs b/src/libs/Ideogram/Generated/Ideogram.JsonSerializerContext.g.cs index a21e406..62846bd 100644 --- a/src/libs/Ideogram/Generated/Ideogram.JsonSerializerContext.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.JsonSerializerContext.g.cs @@ -41,6 +41,14 @@ namespace Ideogram typeof(global::Ideogram.JsonConverters.TextItemV3GlyphTypeNullableJsonConverter), + typeof(global::Ideogram.JsonConverters.TextItemV3TextTransformJsonConverter), + + typeof(global::Ideogram.JsonConverters.TextItemV3TextTransformNullableJsonConverter), + + typeof(global::Ideogram.JsonConverters.TextItemV3VerticalAlignmentJsonConverter), + + typeof(global::Ideogram.JsonConverters.TextItemV3VerticalAlignmentNullableJsonConverter), + typeof(global::Ideogram.JsonConverters.DetectedTextBlockAlignmentJsonConverter), typeof(global::Ideogram.JsonConverters.DetectedTextBlockAlignmentNullableJsonConverter), @@ -101,6 +109,14 @@ namespace Ideogram typeof(global::Ideogram.JsonConverters.MagicPromptOptionNullableJsonConverter), + typeof(global::Ideogram.JsonConverters.ResolutionV4JsonConverter), + + typeof(global::Ideogram.JsonConverters.ResolutionV4NullableJsonConverter), + + typeof(global::Ideogram.JsonConverters.RenderingSpeedJsonConverter), + + typeof(global::Ideogram.JsonConverters.RenderingSpeedNullableJsonConverter), + typeof(global::Ideogram.JsonConverters.DescribeModelVersionJsonConverter), typeof(global::Ideogram.JsonConverters.DescribeModelVersionNullableJsonConverter), @@ -117,10 +133,6 @@ namespace Ideogram typeof(global::Ideogram.JsonConverters.AspectRatioV3NullableJsonConverter), - typeof(global::Ideogram.JsonConverters.RenderingSpeedJsonConverter), - - typeof(global::Ideogram.JsonConverters.RenderingSpeedNullableJsonConverter), - typeof(global::Ideogram.JsonConverters.ColorPalettePresetNameJsonConverter), typeof(global::Ideogram.JsonConverters.ColorPalettePresetNameNullableJsonConverter), @@ -145,10 +157,6 @@ namespace Ideogram typeof(global::Ideogram.JsonConverters.AspectRatioNullableJsonConverter), - typeof(global::Ideogram.JsonConverters.ResolutionV4JsonConverter), - - typeof(global::Ideogram.JsonConverters.ResolutionV4NullableJsonConverter), - typeof(global::Ideogram.JsonConverters.AssetTypeJsonConverter), typeof(global::Ideogram.JsonConverters.AssetTypeNullableJsonConverter), @@ -166,6 +174,8 @@ namespace Ideogram [global::System.Text.Json.Serialization.JsonSerializable(typeof(string))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(int))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Ideogram.MagicPromptOption), TypeInfoPropertyName = "MagicPromptOption2")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Ideogram.ResolutionV4), TypeInfoPropertyName = "ResolutionV42")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Ideogram.RenderingSpeed), TypeInfoPropertyName = "RenderingSpeed2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Ideogram.DescribeResponse))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Ideogram.Description))] @@ -180,7 +190,6 @@ namespace Ideogram [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Ideogram.GenerateImageRequestV3))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Ideogram.ResolutionV3), TypeInfoPropertyName = "ResolutionV32")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Ideogram.AspectRatioV3), TypeInfoPropertyName = "AspectRatioV32")] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Ideogram.RenderingSpeed), TypeInfoPropertyName = "RenderingSpeed2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Ideogram.ColorPaletteWithPresetNameOrMembers), TypeInfoPropertyName = "ColorPaletteWithPresetNameOrMembers2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Ideogram.StyleTypeV3), TypeInfoPropertyName = "StyleTypeV32")] @@ -198,10 +207,14 @@ namespace Ideogram [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Ideogram.TryOnRequestV3))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Ideogram.ReframeImageRequestV3))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Ideogram.ReplaceBackgroundRequestV3))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Ideogram.RemoveBackgroundRequest))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Ideogram.RemoveBackgroundResponse))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.DateTime))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Ideogram.RemoveBackgroundImageObject))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Ideogram.InternalTestingRequest))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Ideogram.InternalTestingNestedObject))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Ideogram.InternalTestingNestedObjectRequiredFields))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.DateTime))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Ideogram.InternalTestingEnumField), TypeInfoPropertyName = "InternalTestingEnumField2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Ideogram.RemixImageRequest))] @@ -224,7 +237,6 @@ namespace Ideogram [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Ideogram.ImageGenerationResponseV4))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Ideogram.ImageGenerationObjectV4))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Ideogram.ResolutionV4), TypeInfoPropertyName = "ResolutionV42")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Ideogram.LayeredImageGenerationObjectV3))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Ideogram.TextContainerV3))] @@ -246,6 +258,10 @@ namespace Ideogram [global::System.Text.Json.Serialization.JsonSerializable(typeof(float))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Ideogram.TextItemV3StyleClass), TypeInfoPropertyName = "TextItemV3StyleClass2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Ideogram.TextItemV3GlyphType), TypeInfoPropertyName = "TextItemV3GlyphType2")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Ideogram.TextItemV3TextTransform), TypeInfoPropertyName = "TextItemV3TextTransform2")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Ideogram.TextItemV3VerticalAlignment), TypeInfoPropertyName = "TextItemV3VerticalAlignment2")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Ideogram.LayeredAssetTextShadow))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Ideogram.LayerizeTextRequest))] @@ -366,6 +382,7 @@ namespace Ideogram [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] @@ -375,6 +392,7 @@ namespace Ideogram [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.List))] diff --git a/src/libs/Ideogram/Generated/Ideogram.JsonSerializerContextTypes.g.cs b/src/libs/Ideogram/Generated/Ideogram.JsonSerializerContextTypes.g.cs index 4f481c2..1fdeb12 100644 --- a/src/libs/Ideogram/Generated/Ideogram.JsonSerializerContextTypes.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.JsonSerializerContextTypes.g.cs @@ -44,143 +44,143 @@ public sealed partial class JsonSerializerContextTypes /// /// /// - public global::Ideogram.DescribeResponse? Type4 { get; set; } + public global::Ideogram.ResolutionV4? Type4 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type5 { get; set; } + public global::Ideogram.RenderingSpeed? Type5 { get; set; } /// /// /// - public global::Ideogram.Description? Type6 { get; set; } + public global::Ideogram.DescribeResponse? Type6 { get; set; } /// /// /// - public global::Ideogram.DescribeRequest? Type7 { get; set; } + public global::System.Collections.Generic.IList? Type7 { get; set; } /// /// /// - public byte[]? Type8 { get; set; } + public global::Ideogram.Description? Type8 { get; set; } /// /// /// - public global::Ideogram.DescribeModelVersion? Type9 { get; set; } + public global::Ideogram.DescribeRequest? Type9 { get; set; } /// /// /// - public global::Ideogram.EditImageRequest? Type10 { get; set; } + public byte[]? Type10 { get; set; } /// /// /// - public global::Ideogram.ModelEnum? Type11 { get; set; } + public global::Ideogram.DescribeModelVersion? Type11 { get; set; } /// /// /// - public global::Ideogram.StyleType? Type12 { get; set; } + public global::Ideogram.EditImageRequest? Type12 { get; set; } /// /// /// - public global::Ideogram.GenerateImageRequest? Type13 { get; set; } + public global::Ideogram.ModelEnum? Type13 { get; set; } /// /// /// - public global::Ideogram.ImageRequest? Type14 { get; set; } + public global::Ideogram.StyleType? Type14 { get; set; } /// /// /// - public global::Ideogram.GenerateImageRequestV3? Type15 { get; set; } + public global::Ideogram.GenerateImageRequest? Type15 { get; set; } /// /// /// - public global::Ideogram.ResolutionV3? Type16 { get; set; } + public global::Ideogram.ImageRequest? Type16 { get; set; } /// /// /// - public global::Ideogram.AspectRatioV3? Type17 { get; set; } + public global::Ideogram.GenerateImageRequestV3? Type17 { get; set; } /// /// /// - public global::Ideogram.RenderingSpeed? Type18 { get; set; } + public global::Ideogram.ResolutionV3? Type18 { get; set; } /// /// /// - public global::Ideogram.ColorPaletteWithPresetNameOrMembers? Type19 { get; set; } + public global::Ideogram.AspectRatioV3? Type19 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type20 { get; set; } + public global::Ideogram.ColorPaletteWithPresetNameOrMembers? Type20 { get; set; } /// /// /// - public global::Ideogram.StyleTypeV3? Type21 { get; set; } + public global::System.Collections.Generic.IList? Type21 { get; set; } /// /// /// - public global::Ideogram.StylePresetV3? Type22 { get; set; } + public global::Ideogram.StyleTypeV3? Type22 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type23 { get; set; } + public global::Ideogram.StylePresetV3? Type23 { get; set; } /// /// /// - public global::Ideogram.GenerateGraphicRequestV3? Type24 { get; set; } + public global::System.Collections.Generic.IList? Type24 { get; set; } /// /// /// - public global::Ideogram.GenerateDesignRequestV3? Type25 { get; set; } + public global::Ideogram.GenerateGraphicRequestV3? Type25 { get; set; } /// /// /// - public global::Ideogram.LayerizeDesignRequestV3? Type26 { get; set; } + public global::Ideogram.GenerateDesignRequestV3? Type26 { get; set; } /// /// /// - public global::Ideogram.GenerateTransparentImageRequestV3? Type27 { get; set; } + public global::Ideogram.LayerizeDesignRequestV3? Type27 { get; set; } /// /// /// - public global::Ideogram.UpscaleFactor? Type28 { get; set; } + public global::Ideogram.GenerateTransparentImageRequestV3? Type28 { get; set; } /// /// /// - public global::Ideogram.RemixImageRequestV3? Type29 { get; set; } + public global::Ideogram.UpscaleFactor? Type29 { get; set; } /// /// /// - public global::Ideogram.EditImageRequestV3? Type30 { get; set; } + public global::Ideogram.RemixImageRequestV3? Type30 { get; set; } /// /// /// - public global::Ideogram.V1EditImagesRequest? Type31 { get; set; } + public global::Ideogram.EditImageRequestV3? Type31 { get; set; } /// /// /// - public bool? Type32 { get; set; } + public global::Ideogram.V1EditImagesRequest? Type32 { get; set; } /// /// /// - public global::Ideogram.TryOnRequestV3? Type33 { get; set; } + public bool? Type33 { get; set; } /// /// /// - public global::Ideogram.ReframeImageRequestV3? Type34 { get; set; } + public global::Ideogram.TryOnRequestV3? Type34 { get; set; } /// /// /// - public global::Ideogram.ReplaceBackgroundRequestV3? Type35 { get; set; } + public global::Ideogram.ReframeImageRequestV3? Type35 { get; set; } /// /// /// - public global::Ideogram.InternalTestingRequest? Type36 { get; set; } + public global::Ideogram.ReplaceBackgroundRequestV3? Type36 { get; set; } /// /// /// - public global::Ideogram.InternalTestingNestedObject? Type37 { get; set; } + public global::Ideogram.RemoveBackgroundRequest? Type37 { get; set; } /// /// /// - public global::Ideogram.InternalTestingNestedObjectRequiredFields? Type38 { get; set; } + public global::Ideogram.RemoveBackgroundResponse? Type38 { get; set; } /// /// /// @@ -188,647 +188,679 @@ public sealed partial class JsonSerializerContextTypes /// /// /// - public global::System.Collections.Generic.IList? Type40 { get; set; } + public global::System.Collections.Generic.IList? Type40 { get; set; } /// /// /// - public global::Ideogram.InternalTestingEnumField? Type41 { get; set; } + public global::Ideogram.RemoveBackgroundImageObject? Type41 { get; set; } /// /// /// - public global::Ideogram.RemixImageRequest? Type42 { get; set; } + public global::Ideogram.InternalTestingRequest? Type42 { get; set; } /// /// /// - public global::Ideogram.InitialImageRequest? Type43 { get; set; } + public global::Ideogram.InternalTestingNestedObject? Type43 { get; set; } /// /// /// - public global::Ideogram.ReframeImageRequest? Type44 { get; set; } + public global::Ideogram.InternalTestingNestedObjectRequiredFields? Type44 { get; set; } /// /// /// - public global::Ideogram.Resolution? Type45 { get; set; } + public global::System.Collections.Generic.IList? Type45 { get; set; } /// /// /// - public global::Ideogram.UpscaleImageRequest? Type46 { get; set; } + public global::Ideogram.InternalTestingEnumField? Type46 { get; set; } /// /// /// - public global::Ideogram.UpscaleInitialImageRequest? Type47 { get; set; } + public global::Ideogram.RemixImageRequest? Type47 { get; set; } /// /// /// - public global::Ideogram.AspectRatio? Type48 { get; set; } + public global::Ideogram.InitialImageRequest? Type48 { get; set; } /// /// /// - public global::Ideogram.MagicPromptVersionEnum? Type49 { get; set; } + public global::Ideogram.ReframeImageRequest? Type49 { get; set; } /// /// /// - public global::Ideogram.GenerateImageResponse? Type50 { get; set; } + public global::Ideogram.Resolution? Type50 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type51 { get; set; } + public global::Ideogram.UpscaleImageRequest? Type51 { get; set; } /// /// /// - public global::Ideogram.ImageObject? Type52 { get; set; } + public global::Ideogram.UpscaleInitialImageRequest? Type52 { get; set; } /// /// /// - public global::Ideogram.ImageGenerationResponseV3? Type53 { get; set; } + public global::Ideogram.AspectRatio? Type53 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type54 { get; set; } + public global::Ideogram.MagicPromptVersionEnum? Type54 { get; set; } /// /// /// - public global::Ideogram.ImageGenerationObjectV3? Type55 { get; set; } + public global::Ideogram.GenerateImageResponse? Type55 { get; set; } /// /// /// - public global::Ideogram.V1EditImagesResponse? Type56 { get; set; } + public global::System.Collections.Generic.IList? Type56 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type57 { get; set; } + public global::Ideogram.ImageObject? Type57 { get; set; } /// /// /// - public global::Ideogram.V1EditImageObject? Type58 { get; set; } + public global::Ideogram.ImageGenerationResponseV3? Type58 { get; set; } /// /// /// - public global::Ideogram.ImageGenerationResponseV4? Type59 { get; set; } + public global::System.Collections.Generic.IList? Type59 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type60 { get; set; } + public global::Ideogram.ImageGenerationObjectV3? Type60 { get; set; } /// /// /// - public global::Ideogram.ImageGenerationObjectV4? Type61 { get; set; } + public global::Ideogram.V1EditImagesResponse? Type61 { get; set; } /// /// /// - public global::Ideogram.ResolutionV4? Type62 { get; set; } + public global::System.Collections.Generic.IList? Type62 { get; set; } /// /// /// - public global::Ideogram.LayeredImageGenerationObjectV3? Type63 { get; set; } + public global::Ideogram.V1EditImageObject? Type63 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type64 { get; set; } + public global::Ideogram.ImageGenerationResponseV4? Type64 { get; set; } /// /// /// - public global::Ideogram.TextContainerV3? Type65 { get; set; } + public global::System.Collections.Generic.IList? Type65 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type66 { get; set; } + public global::Ideogram.ImageGenerationObjectV4? Type66 { get; set; } /// /// /// - public global::Ideogram.ImageLayerV3? Type67 { get; set; } + public global::Ideogram.LayeredImageGenerationObjectV3? Type67 { get; set; } /// /// /// - public global::Ideogram.LayeredImageGenerationResponseV3? Type68 { get; set; } + public global::System.Collections.Generic.IList? Type68 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type69 { get; set; } + public global::Ideogram.TextContainerV3? Type69 { get; set; } /// /// /// - public global::Ideogram.GenerateImageSafetyError? Type70 { get; set; } + public global::System.Collections.Generic.IList? Type70 { get; set; } /// /// /// - public global::Ideogram.MagicPromptRequest? Type71 { get; set; } + public global::Ideogram.ImageLayerV3? Type71 { get; set; } /// /// /// - public global::Ideogram.MagicPromptResponse? Type72 { get; set; } + public global::Ideogram.LayeredImageGenerationResponseV3? Type72 { get; set; } /// /// /// - public global::Ideogram.InternalBatchRequest? Type73 { get; set; } + public global::System.Collections.Generic.IList? Type73 { get; set; } /// /// /// - public global::Ideogram.SamplingRequestParams? Type74 { get; set; } + public global::Ideogram.GenerateImageSafetyError? Type74 { get; set; } /// /// /// - public global::Ideogram.InternalBatchResponse? Type75 { get; set; } + public global::Ideogram.MagicPromptRequest? Type75 { get; set; } /// /// /// - public global::Ideogram.TextSpanV3? Type76 { get; set; } + public global::Ideogram.MagicPromptResponse? Type76 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type77 { get; set; } + public global::Ideogram.InternalBatchRequest? Type77 { get; set; } /// /// /// - public global::Ideogram.TextSpanV3FontFxItem? Type78 { get; set; } + public global::Ideogram.SamplingRequestParams? Type78 { get; set; } /// /// /// - public global::Ideogram.TextItemV3? Type79 { get; set; } + public global::Ideogram.InternalBatchResponse? Type79 { get; set; } /// /// /// - public global::Ideogram.TextItemV3Alignment? Type80 { get; set; } + public global::Ideogram.TextSpanV3? Type80 { get; set; } /// /// /// - public float? Type81 { get; set; } + public global::System.Collections.Generic.IList? Type81 { get; set; } /// /// /// - public global::Ideogram.TextItemV3StyleClass? Type82 { get; set; } + public global::Ideogram.TextSpanV3FontFxItem? Type82 { get; set; } /// /// /// - public global::Ideogram.TextItemV3GlyphType? Type83 { get; set; } + public global::Ideogram.TextItemV3? Type83 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type84 { get; set; } + public global::Ideogram.TextItemV3Alignment? Type84 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type85 { get; set; } + public float? Type85 { get; set; } /// /// /// - public global::Ideogram.LayerizeTextRequest? Type86 { get; set; } + public global::Ideogram.TextItemV3StyleClass? Type86 { get; set; } /// /// /// - public global::Ideogram.LayerizeTextResponse? Type87 { get; set; } + public global::Ideogram.TextItemV3GlyphType? Type87 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type88 { get; set; } + public global::Ideogram.TextItemV3TextTransform? Type88 { get; set; } /// /// /// - public global::Ideogram.DetectedTextBlock? Type89 { get; set; } + public global::Ideogram.TextItemV3VerticalAlignment? Type89 { get; set; } /// /// /// - public global::Ideogram.DetectedTextBlockAlignment? Type90 { get; set; } + public global::System.Collections.Generic.IList? Type90 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type91 { get; set; } + public global::Ideogram.LayeredAssetTextShadow? Type91 { get; set; } /// /// /// - public global::Ideogram.DetectedTextBlockFormattingItem? Type92 { get; set; } + public global::System.Collections.Generic.IList? Type92 { get; set; } /// /// /// - public global::Ideogram.DetectedTextBlockRole? Type93 { get; set; } + public global::System.Collections.Generic.IList? Type93 { get; set; } /// /// /// - public global::Ideogram.InternalBatchResultsResponse? Type94 { get; set; } + public global::Ideogram.LayerizeTextRequest? Type94 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type95 { get; set; } + public global::Ideogram.LayerizeTextResponse? Type95 { get; set; } /// /// /// - public global::Ideogram.InternalBatchResultsResponseResultsInner? Type96 { get; set; } + public global::System.Collections.Generic.IList? Type96 { get; set; } /// /// /// - public global::Ideogram.ImageSafetyError? Type97 { get; set; } + public global::Ideogram.DetectedTextBlock? Type97 { get; set; } /// /// /// - public global::Ideogram.ManageApiSubscriptionResponse? Type98 { get; set; } + public global::Ideogram.DetectedTextBlockAlignment? Type98 { get; set; } /// /// /// - public global::Ideogram.MetronomeLinks? Type99 { get; set; } + public global::System.Collections.Generic.IList? Type99 { get; set; } /// /// /// - public global::Ideogram.RechargeSettingsResponse? Type100 { get; set; } + public global::Ideogram.DetectedTextBlockFormattingItem? Type100 { get; set; } /// /// /// - public global::Ideogram.Price? Type101 { get; set; } + public global::Ideogram.DetectedTextBlockRole? Type101 { get; set; } /// /// /// - public global::Ideogram.RechargeSettings? Type102 { get; set; } + public global::Ideogram.InternalBatchResultsResponse? Type102 { get; set; } /// /// /// - public global::Ideogram.PostApiSubscriptionResponse? Type103 { get; set; } + public global::System.Collections.Generic.IList? Type103 { get; set; } /// /// /// - public global::Ideogram.PostApiSubscriptionError? Type104 { get; set; } + public global::Ideogram.InternalBatchResultsResponseResultsInner? Type104 { get; set; } /// /// /// - public global::Ideogram.PostApiSubscriptionRequest? Type105 { get; set; } + public global::Ideogram.ImageSafetyError? Type105 { get; set; } /// /// /// - public global::Ideogram.PostApiReactivateResponse? Type106 { get; set; } + public global::Ideogram.ManageApiSubscriptionResponse? Type106 { get; set; } /// /// /// - public global::Ideogram.GetApiKeysResponse? Type107 { get; set; } + public global::Ideogram.MetronomeLinks? Type107 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type108 { get; set; } + public global::Ideogram.RechargeSettingsResponse? Type108 { get; set; } /// /// /// - public global::Ideogram.RedactedApiKey? Type109 { get; set; } + public global::Ideogram.Price? Type109 { get; set; } /// /// /// - public global::Ideogram.PostApiKeyResponse? Type110 { get; set; } + public global::Ideogram.RechargeSettings? Type110 { get; set; } /// /// /// - public global::Ideogram.ManageApiStripeSubscriptionResponse? Type111 { get; set; } + public global::Ideogram.PostApiSubscriptionResponse? Type111 { get; set; } /// /// /// - public global::Ideogram.GetApiTermsResponse? Type112 { get; set; } + public global::Ideogram.PostApiSubscriptionError? Type112 { get; set; } /// /// /// - public global::Ideogram.ApiTerms? Type113 { get; set; } + public global::Ideogram.PostApiSubscriptionRequest? Type113 { get; set; } /// /// /// - public global::Ideogram.PostApiTermsRequest? Type114 { get; set; } + public global::Ideogram.PostApiReactivateResponse? Type114 { get; set; } /// /// /// - public global::Ideogram.PostAddCreditsResponse? Type115 { get; set; } + public global::Ideogram.GetApiKeysResponse? Type115 { get; set; } /// /// /// - public global::Ideogram.PostAddCreditsError? Type116 { get; set; } + public global::System.Collections.Generic.IList? Type116 { get; set; } /// /// /// - public global::Ideogram.PostAddCreditsRequest? Type117 { get; set; } + public global::Ideogram.RedactedApiKey? Type117 { get; set; } /// /// /// - public global::Ideogram.GetUserCreditsResponse? Type118 { get; set; } + public global::Ideogram.PostApiKeyResponse? Type118 { get; set; } /// /// /// - public global::Ideogram.SpendCommitInfoResponse? Type119 { get; set; } + public global::Ideogram.ManageApiStripeSubscriptionResponse? Type119 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type120 { get; set; } + public global::Ideogram.GetApiTermsResponse? Type120 { get; set; } /// /// /// - public global::Ideogram.SpendCommitInfo? Type121 { get; set; } + public global::Ideogram.ApiTerms? Type121 { get; set; } /// /// /// - public global::Ideogram.GetUsageInfoResponse? Type122 { get; set; } + public global::Ideogram.PostApiTermsRequest? Type122 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type123 { get; set; } + public global::Ideogram.PostAddCreditsResponse? Type123 { get; set; } /// /// /// - public global::Ideogram.UsageSegment? Type124 { get; set; } + public global::Ideogram.PostAddCreditsError? Type124 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type125 { get; set; } + public global::Ideogram.PostAddCreditsRequest? Type125 { get; set; } /// /// /// - public global::Ideogram.ToolUsage? Type126 { get; set; } + public global::Ideogram.GetUserCreditsResponse? Type126 { get; set; } /// /// /// - public global::Ideogram.ToolType? Type127 { get; set; } + public global::Ideogram.SpendCommitInfoResponse? Type127 { get; set; } /// /// /// - public global::Ideogram.ModelVersion? Type128 { get; set; } + public global::System.Collections.Generic.IList? Type128 { get; set; } /// /// /// - public global::Ideogram.SegmentBy? Type129 { get; set; } + public global::Ideogram.SpendCommitInfo? Type129 { get; set; } /// /// /// - public global::Ideogram.UsageSource? Type130 { get; set; } + public global::Ideogram.GetUsageInfoResponse? Type130 { get; set; } /// /// /// - public global::Ideogram.GetApiProfilesResponse? Type131 { get; set; } + public global::System.Collections.Generic.IList? Type131 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type132 { get; set; } + public global::Ideogram.UsageSegment? Type132 { get; set; } /// /// /// - public global::Ideogram.ApiProfile? Type133 { get; set; } + public global::System.Collections.Generic.IList? Type133 { get; set; } /// /// /// - public global::Ideogram.ApiProfileType? Type134 { get; set; } + public global::Ideogram.ToolUsage? Type134 { get; set; } /// /// /// - public global::Ideogram.ApiProfileRole? Type135 { get; set; } + public global::Ideogram.ToolType? Type135 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type136 { get; set; } + public global::Ideogram.ModelVersion? Type136 { get; set; } /// /// /// - public global::Ideogram.ApiProfileApiKey? Type137 { get; set; } + public global::Ideogram.SegmentBy? Type137 { get; set; } /// /// /// - public global::Ideogram.ApiKeyStatus? Type138 { get; set; } + public global::Ideogram.UsageSource? Type138 { get; set; } /// /// /// - public global::Ideogram.GetApiOrganizationUserSuggestionsResponse? Type139 { get; set; } + public global::Ideogram.GetApiProfilesResponse? Type139 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type140 { get; set; } + public global::System.Collections.Generic.IList? Type140 { get; set; } /// /// /// - public global::Ideogram.ApiOrganizationUserSuggestion? Type141 { get; set; } + public global::Ideogram.ApiProfile? Type141 { get; set; } /// /// /// - public global::Ideogram.GetOrganizationMembersResponse? Type142 { get; set; } + public global::Ideogram.ApiProfileType? Type142 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type143 { get; set; } + public global::Ideogram.ApiProfileRole? Type143 { get; set; } /// /// /// - public global::Ideogram.OrganizationMember? Type144 { get; set; } + public global::System.Collections.Generic.IList? Type144 { get; set; } /// /// /// - public global::Ideogram.CreateApiKeyResponse? Type145 { get; set; } + public global::Ideogram.ApiProfileApiKey? Type145 { get; set; } /// /// /// - public global::Ideogram.GetApiKeysV2Response? Type146 { get; set; } + public global::Ideogram.ApiKeyStatus? Type146 { get; set; } /// /// /// - public global::Ideogram.OrganizationMemberOperationResponse? Type147 { get; set; } + public global::Ideogram.GetApiOrganizationUserSuggestionsResponse? Type147 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type148 { get; set; } + public global::System.Collections.Generic.IList? Type148 { get; set; } /// /// /// - public global::Ideogram.OrganizationMemberOperationResult? Type149 { get; set; } + public global::Ideogram.ApiOrganizationUserSuggestion? Type149 { get; set; } /// /// /// - public global::Ideogram.AddOrganizationMembersRequest? Type150 { get; set; } + public global::Ideogram.GetOrganizationMembersResponse? Type150 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type151 { get; set; } + public global::System.Collections.Generic.IList? Type151 { get; set; } /// /// /// - public global::Ideogram.LiteOrganizationMember? Type152 { get; set; } + public global::Ideogram.OrganizationMember? Type152 { get; set; } /// /// /// - public global::Ideogram.RemoveOrganizationMembersRequest? Type153 { get; set; } + public global::Ideogram.CreateApiKeyResponse? Type153 { get; set; } /// /// /// - public global::Ideogram.PromoteOrganizationMembersRequest? Type154 { get; set; } + public global::Ideogram.GetApiKeysV2Response? Type154 { get; set; } /// /// /// - public global::Ideogram.ListOrganizationInvoicesResponse? Type155 { get; set; } + public global::Ideogram.OrganizationMemberOperationResponse? Type155 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type156 { get; set; } + public global::System.Collections.Generic.IList? Type156 { get; set; } /// /// /// - public global::Ideogram.Invoice? Type157 { get; set; } + public global::Ideogram.OrganizationMemberOperationResult? Type157 { get; set; } /// /// /// - public global::Ideogram.InvoiceStatus? Type158 { get; set; } + public global::Ideogram.AddOrganizationMembersRequest? Type158 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type159 { get; set; } + public global::System.Collections.Generic.IList? Type159 { get; set; } /// /// /// - public global::Ideogram.InvoiceLineItem? Type160 { get; set; } + public global::Ideogram.LiteOrganizationMember? Type160 { get; set; } /// /// /// - public global::Ideogram.ListDatasetsResponse? Type161 { get; set; } + public global::Ideogram.RemoveOrganizationMembersRequest? Type161 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type162 { get; set; } + public global::Ideogram.PromoteOrganizationMembersRequest? Type162 { get; set; } /// /// /// - public global::Ideogram.Dataset? Type163 { get; set; } + public global::Ideogram.ListOrganizationInvoicesResponse? Type163 { get; set; } /// /// /// - public global::Ideogram.AssetIdentifier? Type164 { get; set; } + public global::System.Collections.Generic.IList? Type164 { get; set; } /// /// /// - public global::Ideogram.CreateDatasetRequest? Type165 { get; set; } + public global::Ideogram.Invoice? Type165 { get; set; } /// /// /// - public global::Ideogram.GetDatasetResponse? Type166 { get; set; } + public global::Ideogram.InvoiceStatus? Type166 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type167 { get; set; } + public global::System.Collections.Generic.IList? Type167 { get; set; } /// /// /// - public global::Ideogram.DatasetFile? Type168 { get; set; } + public global::Ideogram.InvoiceLineItem? Type168 { get; set; } /// /// /// - public long? Type169 { get; set; } + public global::Ideogram.ListDatasetsResponse? Type169 { get; set; } /// /// /// - public global::Ideogram.UploadDatasetAssetsResponse? Type170 { get; set; } + public global::System.Collections.Generic.IList? Type170 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type171 { get; set; } + public global::Ideogram.Dataset? Type171 { get; set; } /// /// /// - public global::Ideogram.DatasetUploadSucceededAsset? Type172 { get; set; } + public global::Ideogram.AssetIdentifier? Type172 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type173 { get; set; } + public global::Ideogram.CreateDatasetRequest? Type173 { get; set; } /// /// /// - public global::Ideogram.DatasetUploadFailedAsset? Type174 { get; set; } + public global::Ideogram.GetDatasetResponse? Type174 { get; set; } /// /// /// - public global::Ideogram.DatasetAssetFailureReason? Type175 { get; set; } + public global::System.Collections.Generic.IList? Type175 { get; set; } /// /// /// - public global::Ideogram.UploadDatasetAssetsRequest? Type176 { get; set; } + public global::Ideogram.DatasetFile? Type176 { get; set; } /// /// /// - public global::Ideogram.TrainDatasetModelResponse? Type177 { get; set; } + public long? Type177 { get; set; } /// /// /// - public global::Ideogram.TrainDatasetModelRequest? Type178 { get; set; } + public global::Ideogram.UploadDatasetAssetsResponse? Type178 { get; set; } /// /// /// - public global::Ideogram.ListModelsResponse? Type179 { get; set; } + public global::System.Collections.Generic.IList? Type179 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type180 { get; set; } + public global::Ideogram.DatasetUploadSucceededAsset? Type180 { get; set; } /// /// /// - public global::Ideogram.CustomModel? Type181 { get; set; } + public global::System.Collections.Generic.IList? Type181 { get; set; } /// /// /// - public global::Ideogram.ModelStatus? Type182 { get; set; } + public global::Ideogram.DatasetUploadFailedAsset? Type182 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type183 { get; set; } + public global::Ideogram.DatasetAssetFailureReason? Type183 { get; set; } /// /// /// - public global::Ideogram.TrainingRun? Type184 { get; set; } + public global::Ideogram.UploadDatasetAssetsRequest? Type184 { get; set; } /// /// /// - public global::Ideogram.TrainingRunStatus? Type185 { get; set; } + public global::Ideogram.TrainDatasetModelResponse? Type185 { get; set; } /// /// /// - public double? Type186 { get; set; } + public global::Ideogram.TrainDatasetModelRequest? Type186 { get; set; } /// /// /// - public global::Ideogram.GetModelResponse? Type187 { get; set; } + public global::Ideogram.ListModelsResponse? Type187 { get; set; } /// /// /// - public global::Ideogram.TrainModelV3Request? Type188 { get; set; } + public global::System.Collections.Generic.IList? Type188 { get; set; } /// /// /// - public global::Ideogram.TrainModelV3AdvancedRequest? Type189 { get; set; } + public global::Ideogram.CustomModel? Type189 { get; set; } /// /// /// - public global::Ideogram.ColorPaletteWithPresetName? Type190 { get; set; } + public global::Ideogram.ModelStatus? Type190 { get; set; } /// /// /// - public global::Ideogram.ColorPaletteWithMembers? Type191 { get; set; } + public global::System.Collections.Generic.IList? Type191 { get; set; } /// /// /// - public global::Ideogram.ColorPalettePresetName? Type192 { get; set; } + public global::Ideogram.TrainingRun? Type192 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type193 { get; set; } + public global::Ideogram.TrainingRunStatus? Type193 { get; set; } /// /// /// - public global::Ideogram.ColorPaletteMember? Type194 { get; set; } + public double? Type194 { get; set; } /// /// /// - public global::Ideogram.AssetType? Type195 { get; set; } + public global::Ideogram.GetModelResponse? Type195 { get; set; } /// /// /// - public global::Ideogram.PostInternalTesting200Response? Type196 { get; set; } + public global::Ideogram.TrainModelV3Request? Type196 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type197 { get; set; } + public global::Ideogram.TrainModelV3AdvancedRequest? Type197 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type198 { get; set; } + public global::Ideogram.ColorPaletteWithPresetName? Type198 { get; set; } /// /// /// - public global::Ideogram.ListCustomModelsScope? Type199 { get; set; } + public global::Ideogram.ColorPaletteWithMembers? Type199 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type200 { get; set; } + public global::Ideogram.ColorPalettePresetName? Type200 { get; set; } + /// + /// + /// + public global::System.Collections.Generic.IList? Type201 { get; set; } + /// + /// + /// + public global::Ideogram.ColorPaletteMember? Type202 { get; set; } + /// + /// + /// + public global::Ideogram.AssetType? Type203 { get; set; } + /// + /// + /// + public global::Ideogram.PostInternalTesting200Response? Type204 { get; set; } + /// + /// + /// + public global::System.Collections.Generic.IList? Type205 { get; set; } + /// + /// + /// + public global::System.Collections.Generic.IList? Type206 { get; set; } + /// + /// + /// + public global::Ideogram.ListCustomModelsScope? Type207 { get; set; } + /// + /// + /// + public global::System.Collections.Generic.IList? Type208 { get; set; } /// /// @@ -845,146 +877,154 @@ public sealed partial class JsonSerializerContextTypes /// /// /// - public global::System.Collections.Generic.List? ListType3 { get; set; } + public global::System.Collections.Generic.List? ListType3 { get; set; } + /// + /// + /// + public global::System.Collections.Generic.List? ListType4 { get; set; } + /// + /// + /// + public global::System.Collections.Generic.List? ListType5 { get; set; } /// /// /// - public global::System.Collections.Generic.List? ListType4 { get; set; } + public global::System.Collections.Generic.List? ListType6 { get; set; } /// /// /// - public global::System.Collections.Generic.List? ListType5 { get; set; } + public global::System.Collections.Generic.List? ListType7 { get; set; } /// /// /// - public global::System.Collections.Generic.List? ListType6 { get; set; } + public global::System.Collections.Generic.List? ListType8 { get; set; } /// /// /// - public global::System.Collections.Generic.List? ListType7 { get; set; } + public global::System.Collections.Generic.List? ListType9 { get; set; } /// /// /// - public global::System.Collections.Generic.List? ListType8 { get; set; } + public global::System.Collections.Generic.List? ListType10 { get; set; } /// /// /// - public global::System.Collections.Generic.List? ListType9 { get; set; } + public global::System.Collections.Generic.List? ListType11 { get; set; } /// /// /// - public global::System.Collections.Generic.List? ListType10 { get; set; } + public global::System.Collections.Generic.List? ListType12 { get; set; } /// /// /// - public global::System.Collections.Generic.List? ListType11 { get; set; } + public global::System.Collections.Generic.List? ListType13 { get; set; } /// /// /// - public global::System.Collections.Generic.List? ListType12 { get; set; } + public global::System.Collections.Generic.List? ListType14 { get; set; } /// /// /// - public global::System.Collections.Generic.List? ListType13 { get; set; } + public global::System.Collections.Generic.List? ListType15 { get; set; } /// /// /// - public global::System.Collections.Generic.List? ListType14 { get; set; } + public global::System.Collections.Generic.List? ListType16 { get; set; } /// /// /// - public global::System.Collections.Generic.List? ListType15 { get; set; } + public global::System.Collections.Generic.List? ListType17 { get; set; } /// /// /// - public global::System.Collections.Generic.List? ListType16 { get; set; } + public global::System.Collections.Generic.List? ListType18 { get; set; } /// /// /// - public global::System.Collections.Generic.List? ListType17 { get; set; } + public global::System.Collections.Generic.List? ListType19 { get; set; } /// /// /// - public global::System.Collections.Generic.List? ListType18 { get; set; } + public global::System.Collections.Generic.List? ListType20 { get; set; } /// /// /// - public global::System.Collections.Generic.List? ListType19 { get; set; } + public global::System.Collections.Generic.List? ListType21 { get; set; } /// /// /// - public global::System.Collections.Generic.List? ListType20 { get; set; } + public global::System.Collections.Generic.List? ListType22 { get; set; } /// /// /// - public global::System.Collections.Generic.List? ListType21 { get; set; } + public global::System.Collections.Generic.List? ListType23 { get; set; } /// /// /// - public global::System.Collections.Generic.List? ListType22 { get; set; } + public global::System.Collections.Generic.List? ListType24 { get; set; } /// /// /// - public global::System.Collections.Generic.List? ListType23 { get; set; } + public global::System.Collections.Generic.List? ListType25 { get; set; } /// /// /// - public global::System.Collections.Generic.List? ListType24 { get; set; } + public global::System.Collections.Generic.List? ListType26 { get; set; } /// /// /// - public global::System.Collections.Generic.List? ListType25 { get; set; } + public global::System.Collections.Generic.List? ListType27 { get; set; } /// /// /// - public global::System.Collections.Generic.List? ListType26 { get; set; } + public global::System.Collections.Generic.List? ListType28 { get; set; } /// /// /// - public global::System.Collections.Generic.List? ListType27 { get; set; } + public global::System.Collections.Generic.List? ListType29 { get; set; } /// /// /// - public global::System.Collections.Generic.List? ListType28 { get; set; } + public global::System.Collections.Generic.List? ListType30 { get; set; } /// /// /// - public global::System.Collections.Generic.List? ListType29 { get; set; } + public global::System.Collections.Generic.List? ListType31 { get; set; } /// /// /// - public global::System.Collections.Generic.List? ListType30 { get; set; } + public global::System.Collections.Generic.List? ListType32 { get; set; } /// /// /// - public global::System.Collections.Generic.List? ListType31 { get; set; } + public global::System.Collections.Generic.List? ListType33 { get; set; } /// /// /// - public global::System.Collections.Generic.List? ListType32 { get; set; } + public global::System.Collections.Generic.List? ListType34 { get; set; } /// /// /// - public global::System.Collections.Generic.List? ListType33 { get; set; } + public global::System.Collections.Generic.List? ListType35 { get; set; } /// /// /// - public global::System.Collections.Generic.List? ListType34 { get; set; } + public global::System.Collections.Generic.List? ListType36 { get; set; } /// /// /// - public global::System.Collections.Generic.List? ListType35 { get; set; } + public global::System.Collections.Generic.List? ListType37 { get; set; } /// /// /// - public global::System.Collections.Generic.List? ListType36 { get; set; } + public global::System.Collections.Generic.List? ListType38 { get; set; } /// /// /// - public global::System.Collections.Generic.List? ListType37 { get; set; } + public global::System.Collections.Generic.List? ListType39 { get; set; } /// /// /// - public global::System.Collections.Generic.List? ListType38 { get; set; } + public global::System.Collections.Generic.List? ListType40 { get; set; } } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.ManageClient.AddOrganizationMembers.g.cs b/src/libs/Ideogram/Generated/Ideogram.ManageClient.AddOrganizationMembers.g.cs index 14631d8..e3e2c3c 100644 --- a/src/libs/Ideogram/Generated/Ideogram.ManageClient.AddOrganizationMembers.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.ManageClient.AddOrganizationMembers.g.cs @@ -54,6 +54,31 @@ partial void ProcessAddOrganizationMembersResponseContent( public async global::System.Threading.Tasks.Task AddOrganizationMembersAsync( string organizationId, + global::Ideogram.AddOrganizationMembersRequest request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await AddOrganizationMembersAsResponseAsync( + organizationId: organizationId, + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Add members to a specific organization + /// + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> AddOrganizationMembersAsResponseAsync( + string organizationId, + global::Ideogram.AddOrganizationMembersRequest request, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) @@ -89,11 +114,12 @@ partial void ProcessAddOrganizationMembersResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/manage/api/organization/add_members", - baseUri: HttpClient.BaseAddress); + baseUri: HttpClient.BaseAddress); __pathBuilder - .AddRequiredParameter("organization_id", organizationId) + .AddRequiredParameter("organization_id", organizationId) ; var __path = __pathBuilder.ToString(); __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( @@ -172,6 +198,8 @@ partial void ProcessAddOrganizationMembersResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -182,6 +210,11 @@ partial void ProcessAddOrganizationMembersResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -199,6 +232,8 @@ partial void ProcessAddOrganizationMembersResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -208,8 +243,7 @@ partial void ProcessAddOrganizationMembersResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -218,6 +252,11 @@ partial void ProcessAddOrganizationMembersResponseContent( __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -234,14 +273,15 @@ partial void ProcessAddOrganizationMembersResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -281,6 +321,8 @@ partial void ProcessAddOrganizationMembersResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -301,6 +343,8 @@ partial void ProcessAddOrganizationMembersResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -457,9 +501,13 @@ partial void ProcessAddOrganizationMembersResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.OrganizationMemberOperationResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.OrganizationMemberOperationResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -487,9 +535,13 @@ partial void ProcessAddOrganizationMembersResponseContent( #endif ).ConfigureAwait(false); - return - await global::Ideogram.OrganizationMemberOperationResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.OrganizationMemberOperationResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/Ideogram/Generated/Ideogram.ManageClient.CreateApiKey.g.cs b/src/libs/Ideogram/Generated/Ideogram.ManageClient.CreateApiKey.g.cs index 4b28653..c2440d9 100644 --- a/src/libs/Ideogram/Generated/Ideogram.ManageClient.CreateApiKey.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.ManageClient.CreateApiKey.g.cs @@ -48,6 +48,23 @@ partial void ProcessCreateApiKeyResponseContent( public async global::System.Threading.Tasks.Task CreateApiKeyAsync( global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await CreateApiKeyAsResponseAsync( + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Creates an API key. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> CreateApiKeyAsResponseAsync( + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( client: HttpClient); @@ -76,6 +93,7 @@ partial void ProcessCreateApiKeyResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/manage/api/api_keys", baseUri: HttpClient.BaseAddress); @@ -148,6 +166,8 @@ partial void ProcessCreateApiKeyResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -158,6 +178,11 @@ partial void ProcessCreateApiKeyResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -175,6 +200,8 @@ partial void ProcessCreateApiKeyResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -184,8 +211,7 @@ partial void ProcessCreateApiKeyResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -194,6 +220,11 @@ partial void ProcessCreateApiKeyResponseContent( __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -210,14 +241,15 @@ partial void ProcessCreateApiKeyResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -257,6 +289,8 @@ partial void ProcessCreateApiKeyResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -277,6 +311,8 @@ partial void ProcessCreateApiKeyResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -367,9 +403,13 @@ partial void ProcessCreateApiKeyResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.PostApiKeyResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.PostApiKeyResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -397,9 +437,13 @@ partial void ProcessCreateApiKeyResponseContent( #endif ).ConfigureAwait(false); - return - await global::Ideogram.PostApiKeyResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.PostApiKeyResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/Ideogram/Generated/Ideogram.ManageClient.CreateApiKeyV2.g.cs b/src/libs/Ideogram/Generated/Ideogram.ManageClient.CreateApiKeyV2.g.cs index cc49da7..0744f2c 100644 --- a/src/libs/Ideogram/Generated/Ideogram.ManageClient.CreateApiKeyV2.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.ManageClient.CreateApiKeyV2.g.cs @@ -52,6 +52,26 @@ partial void ProcessCreateApiKeyV2ResponseContent( string organizationId, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await CreateApiKeyV2AsResponseAsync( + organizationId: organizationId, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Create an API key for a specific organization + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> CreateApiKeyV2AsResponseAsync( + string organizationId, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( client: HttpClient); @@ -81,11 +101,12 @@ partial void ProcessCreateApiKeyV2ResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/manage/api/api_keys_v2", - baseUri: HttpClient.BaseAddress); + baseUri: HttpClient.BaseAddress); __pathBuilder - .AddRequiredParameter("organization_id", organizationId) + .AddRequiredParameter("organization_id", organizationId) ; var __path = __pathBuilder.ToString(); __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( @@ -157,6 +178,8 @@ partial void ProcessCreateApiKeyV2ResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -167,6 +190,11 @@ partial void ProcessCreateApiKeyV2ResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -184,6 +212,8 @@ partial void ProcessCreateApiKeyV2ResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -193,8 +223,7 @@ partial void ProcessCreateApiKeyV2ResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -203,6 +232,11 @@ partial void ProcessCreateApiKeyV2ResponseContent( __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -219,14 +253,15 @@ partial void ProcessCreateApiKeyV2ResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -266,6 +301,8 @@ partial void ProcessCreateApiKeyV2ResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -286,6 +323,8 @@ partial void ProcessCreateApiKeyV2ResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -409,9 +448,13 @@ partial void ProcessCreateApiKeyV2ResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.CreateApiKeyResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.CreateApiKeyResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -439,9 +482,13 @@ partial void ProcessCreateApiKeyV2ResponseContent( #endif ).ConfigureAwait(false); - return - await global::Ideogram.CreateApiKeyResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.CreateApiKeyResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/Ideogram/Generated/Ideogram.ManageClient.DeactivateOrganizationApiKey.g.cs b/src/libs/Ideogram/Generated/Ideogram.ManageClient.DeactivateOrganizationApiKey.g.cs index d1741bc..e44bc1c 100644 --- a/src/libs/Ideogram/Generated/Ideogram.ManageClient.DeactivateOrganizationApiKey.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.ManageClient.DeactivateOrganizationApiKey.g.cs @@ -47,6 +47,24 @@ partial void ProcessDeactivateOrganizationApiKeyResponse( string apiKeyId, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) + { + await DeactivateOrganizationApiKeyAsResponseAsync( + apiKeyId: apiKeyId, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + } + /// + /// Deactivate an API key for a specific organization + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task DeactivateOrganizationApiKeyAsResponseAsync( + string apiKeyId, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( client: HttpClient); @@ -76,11 +94,12 @@ partial void ProcessDeactivateOrganizationApiKeyResponse( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/manage/api/organization/deactivate_api_key", - baseUri: HttpClient.BaseAddress); + baseUri: HttpClient.BaseAddress); __pathBuilder - .AddRequiredParameter("api_key_id", apiKeyId) + .AddRequiredParameter("api_key_id", apiKeyId) ; var __path = __pathBuilder.ToString(); __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( @@ -152,6 +171,8 @@ partial void ProcessDeactivateOrganizationApiKeyResponse( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -162,6 +183,11 @@ partial void ProcessDeactivateOrganizationApiKeyResponse( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -179,6 +205,8 @@ partial void ProcessDeactivateOrganizationApiKeyResponse( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -188,8 +216,7 @@ partial void ProcessDeactivateOrganizationApiKeyResponse( __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -198,6 +225,11 @@ partial void ProcessDeactivateOrganizationApiKeyResponse( __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -214,14 +246,15 @@ partial void ProcessDeactivateOrganizationApiKeyResponse( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -261,6 +294,8 @@ partial void ProcessDeactivateOrganizationApiKeyResponse( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -281,6 +316,8 @@ partial void ProcessDeactivateOrganizationApiKeyResponse( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -433,6 +470,10 @@ partial void ProcessDeactivateOrganizationApiKeyResponse( { __response.EnsureSuccessStatusCode(); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri); } catch (global::System.Exception __ex) { @@ -454,6 +495,10 @@ partial void ProcessDeactivateOrganizationApiKeyResponse( try { __response.EnsureSuccessStatusCode(); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri); } catch (global::System.Exception __ex) { diff --git a/src/libs/Ideogram/Generated/Ideogram.ManageClient.DeleteSingleApiKey.g.cs b/src/libs/Ideogram/Generated/Ideogram.ManageClient.DeleteSingleApiKey.g.cs index 06dc884..8134719 100644 --- a/src/libs/Ideogram/Generated/Ideogram.ManageClient.DeleteSingleApiKey.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.ManageClient.DeleteSingleApiKey.g.cs @@ -47,6 +47,24 @@ partial void ProcessDeleteSingleApiKeyResponse( string apiKeyId, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) + { + await DeleteSingleApiKeyAsResponseAsync( + apiKeyId: apiKeyId, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + } + /// + /// Delete an API key. + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task DeleteSingleApiKeyAsResponseAsync( + string apiKeyId, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( client: HttpClient); @@ -76,6 +94,7 @@ partial void ProcessDeleteSingleApiKeyResponse( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: $"/manage/api/api_keys/{apiKeyId}", baseUri: HttpClient.BaseAddress); @@ -149,6 +168,8 @@ partial void ProcessDeleteSingleApiKeyResponse( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -159,6 +180,11 @@ partial void ProcessDeleteSingleApiKeyResponse( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -176,6 +202,8 @@ partial void ProcessDeleteSingleApiKeyResponse( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -185,8 +213,7 @@ partial void ProcessDeleteSingleApiKeyResponse( __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -195,6 +222,11 @@ partial void ProcessDeleteSingleApiKeyResponse( __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -211,14 +243,15 @@ partial void ProcessDeleteSingleApiKeyResponse( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -258,6 +291,8 @@ partial void ProcessDeleteSingleApiKeyResponse( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -278,6 +313,8 @@ partial void ProcessDeleteSingleApiKeyResponse( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -364,6 +401,10 @@ partial void ProcessDeleteSingleApiKeyResponse( { __response.EnsureSuccessStatusCode(); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri); } catch (global::System.Exception __ex) { @@ -385,6 +426,10 @@ partial void ProcessDeleteSingleApiKeyResponse( try { __response.EnsureSuccessStatusCode(); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri); } catch (global::System.Exception __ex) { diff --git a/src/libs/Ideogram/Generated/Ideogram.ManageClient.GetApiKeys.g.cs b/src/libs/Ideogram/Generated/Ideogram.ManageClient.GetApiKeys.g.cs index 30b41fb..c3c7e57 100644 --- a/src/libs/Ideogram/Generated/Ideogram.ManageClient.GetApiKeys.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.ManageClient.GetApiKeys.g.cs @@ -48,6 +48,23 @@ partial void ProcessGetApiKeysResponseContent( public async global::System.Threading.Tasks.Task GetApiKeysAsync( global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetApiKeysAsResponseAsync( + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Retrieve current API keys and their respective data. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> GetApiKeysAsResponseAsync( + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( client: HttpClient); @@ -76,6 +93,7 @@ partial void ProcessGetApiKeysResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/manage/api/api_keys", baseUri: HttpClient.BaseAddress); @@ -148,6 +166,8 @@ partial void ProcessGetApiKeysResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -158,6 +178,11 @@ partial void ProcessGetApiKeysResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -175,6 +200,8 @@ partial void ProcessGetApiKeysResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -184,8 +211,7 @@ partial void ProcessGetApiKeysResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -194,6 +220,11 @@ partial void ProcessGetApiKeysResponseContent( __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -210,14 +241,15 @@ partial void ProcessGetApiKeysResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -257,6 +289,8 @@ partial void ProcessGetApiKeysResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -277,6 +311,8 @@ partial void ProcessGetApiKeysResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -367,9 +403,13 @@ partial void ProcessGetApiKeysResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.GetApiKeysResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.GetApiKeysResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -397,9 +437,13 @@ partial void ProcessGetApiKeysResponseContent( #endif ).ConfigureAwait(false); - return - await global::Ideogram.GetApiKeysResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.GetApiKeysResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/Ideogram/Generated/Ideogram.ManageClient.GetApiKeysV2.g.cs b/src/libs/Ideogram/Generated/Ideogram.ManageClient.GetApiKeysV2.g.cs index 5635480..02345bd 100644 --- a/src/libs/Ideogram/Generated/Ideogram.ManageClient.GetApiKeysV2.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.ManageClient.GetApiKeysV2.g.cs @@ -52,6 +52,26 @@ partial void ProcessGetApiKeysV2ResponseContent( string organizationId, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetApiKeysV2AsResponseAsync( + organizationId: organizationId, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Retrieve API keys for a specific organization + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> GetApiKeysV2AsResponseAsync( + string organizationId, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( client: HttpClient); @@ -81,11 +101,12 @@ partial void ProcessGetApiKeysV2ResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/manage/api/organization/api_keys", - baseUri: HttpClient.BaseAddress); + baseUri: HttpClient.BaseAddress); __pathBuilder - .AddRequiredParameter("organization_id", organizationId) + .AddRequiredParameter("organization_id", organizationId) ; var __path = __pathBuilder.ToString(); __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( @@ -157,6 +178,8 @@ partial void ProcessGetApiKeysV2ResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -167,6 +190,11 @@ partial void ProcessGetApiKeysV2ResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -184,6 +212,8 @@ partial void ProcessGetApiKeysV2ResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -193,8 +223,7 @@ partial void ProcessGetApiKeysV2ResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -203,6 +232,11 @@ partial void ProcessGetApiKeysV2ResponseContent( __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -219,14 +253,15 @@ partial void ProcessGetApiKeysV2ResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -266,6 +301,8 @@ partial void ProcessGetApiKeysV2ResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -286,6 +323,8 @@ partial void ProcessGetApiKeysV2ResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -409,9 +448,13 @@ partial void ProcessGetApiKeysV2ResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.GetApiKeysV2Response.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.GetApiKeysV2Response.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -439,9 +482,13 @@ partial void ProcessGetApiKeysV2ResponseContent( #endif ).ConfigureAwait(false); - return - await global::Ideogram.GetApiKeysV2Response.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.GetApiKeysV2Response.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/Ideogram/Generated/Ideogram.ManageClient.GetApiOrganizationUserSuggestions.g.cs b/src/libs/Ideogram/Generated/Ideogram.ManageClient.GetApiOrganizationUserSuggestions.g.cs index 23401b9..98282fd 100644 --- a/src/libs/Ideogram/Generated/Ideogram.ManageClient.GetApiOrganizationUserSuggestions.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.ManageClient.GetApiOrganizationUserSuggestions.g.cs @@ -62,6 +62,34 @@ partial void ProcessGetApiOrganizationUserSuggestionsResponseContent( int? maxItems = default, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetApiOrganizationUserSuggestionsAsResponseAsync( + organizationId: organizationId, + userHandlePrefix: userHandlePrefix, + maxItems: maxItems, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Get search results for user handles with suggestions for a particular organization. + /// + /// + /// + /// + /// Default Value: 3 + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> GetApiOrganizationUserSuggestionsAsResponseAsync( + string organizationId, + string? userHandlePrefix = default, + int? maxItems = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( client: HttpClient); @@ -93,13 +121,14 @@ partial void ProcessGetApiOrganizationUserSuggestionsResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/manage/api/organization/user_suggestions", - baseUri: HttpClient.BaseAddress); + baseUri: HttpClient.BaseAddress); __pathBuilder .AddRequiredParameter("organization_id", organizationId) .AddOptionalParameter("user_handle_prefix", userHandlePrefix) - .AddOptionalParameter("maxItems", maxItems?.ToString()) + .AddOptionalParameter("maxItems", maxItems?.ToString()) ; var __path = __pathBuilder.ToString(); __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( @@ -173,6 +202,8 @@ partial void ProcessGetApiOrganizationUserSuggestionsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -183,6 +214,11 @@ partial void ProcessGetApiOrganizationUserSuggestionsResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -200,6 +236,8 @@ partial void ProcessGetApiOrganizationUserSuggestionsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -209,8 +247,7 @@ partial void ProcessGetApiOrganizationUserSuggestionsResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -219,6 +256,11 @@ partial void ProcessGetApiOrganizationUserSuggestionsResponseContent( __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -235,14 +277,15 @@ partial void ProcessGetApiOrganizationUserSuggestionsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -282,6 +325,8 @@ partial void ProcessGetApiOrganizationUserSuggestionsResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -302,6 +347,8 @@ partial void ProcessGetApiOrganizationUserSuggestionsResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -425,9 +472,13 @@ partial void ProcessGetApiOrganizationUserSuggestionsResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.GetApiOrganizationUserSuggestionsResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.GetApiOrganizationUserSuggestionsResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -455,9 +506,13 @@ partial void ProcessGetApiOrganizationUserSuggestionsResponseContent( #endif ).ConfigureAwait(false); - return - await global::Ideogram.GetApiOrganizationUserSuggestionsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.GetApiOrganizationUserSuggestionsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/Ideogram/Generated/Ideogram.ManageClient.GetApiProfiles.g.cs b/src/libs/Ideogram/Generated/Ideogram.ManageClient.GetApiProfiles.g.cs index 875ac80..ecb76a4 100644 --- a/src/libs/Ideogram/Generated/Ideogram.ManageClient.GetApiProfiles.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.ManageClient.GetApiProfiles.g.cs @@ -48,6 +48,23 @@ partial void ProcessGetApiProfilesResponseContent( public async global::System.Threading.Tasks.Task GetApiProfilesAsync( global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetApiProfilesAsResponseAsync( + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Retrieve the user's current API profiles + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> GetApiProfilesAsResponseAsync( + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( client: HttpClient); @@ -76,6 +93,7 @@ partial void ProcessGetApiProfilesResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/manage/api/profiles", baseUri: HttpClient.BaseAddress); @@ -148,6 +166,8 @@ partial void ProcessGetApiProfilesResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -158,6 +178,11 @@ partial void ProcessGetApiProfilesResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -175,6 +200,8 @@ partial void ProcessGetApiProfilesResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -184,8 +211,7 @@ partial void ProcessGetApiProfilesResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -194,6 +220,11 @@ partial void ProcessGetApiProfilesResponseContent( __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -210,14 +241,15 @@ partial void ProcessGetApiProfilesResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -257,6 +289,8 @@ partial void ProcessGetApiProfilesResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -277,6 +311,8 @@ partial void ProcessGetApiProfilesResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -367,9 +403,13 @@ partial void ProcessGetApiProfilesResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.GetApiProfilesResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.GetApiProfilesResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -397,9 +437,13 @@ partial void ProcessGetApiProfilesResponseContent( #endif ).ConfigureAwait(false); - return - await global::Ideogram.GetApiProfilesResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.GetApiProfilesResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/Ideogram/Generated/Ideogram.ManageClient.GetApiStripeSubscription.g.cs b/src/libs/Ideogram/Generated/Ideogram.ManageClient.GetApiStripeSubscription.g.cs index 19b3af1..f679a17 100644 --- a/src/libs/Ideogram/Generated/Ideogram.ManageClient.GetApiStripeSubscription.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.ManageClient.GetApiStripeSubscription.g.cs @@ -52,6 +52,26 @@ partial void ProcessGetApiStripeSubscriptionResponseContent( bool? isBusiness = default, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetApiStripeSubscriptionAsResponseAsync( + isBusiness: isBusiness, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Retrieve data relevant to connecting to Stripe. + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> GetApiStripeSubscriptionAsResponseAsync( + bool? isBusiness = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( client: HttpClient); @@ -81,11 +101,12 @@ partial void ProcessGetApiStripeSubscriptionResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/manage/api/stripe_subscription", - baseUri: HttpClient.BaseAddress); + baseUri: HttpClient.BaseAddress); __pathBuilder - .AddOptionalParameter("isBusiness", isBusiness?.ToString().ToLowerInvariant()) + .AddOptionalParameter("isBusiness", isBusiness?.ToString().ToLowerInvariant()) ; var __path = __pathBuilder.ToString(); __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( @@ -157,6 +178,8 @@ partial void ProcessGetApiStripeSubscriptionResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -167,6 +190,11 @@ partial void ProcessGetApiStripeSubscriptionResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -184,6 +212,8 @@ partial void ProcessGetApiStripeSubscriptionResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -193,8 +223,7 @@ partial void ProcessGetApiStripeSubscriptionResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -203,6 +232,11 @@ partial void ProcessGetApiStripeSubscriptionResponseContent( __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -219,14 +253,15 @@ partial void ProcessGetApiStripeSubscriptionResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -266,6 +301,8 @@ partial void ProcessGetApiStripeSubscriptionResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -286,6 +323,8 @@ partial void ProcessGetApiStripeSubscriptionResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -376,9 +415,13 @@ partial void ProcessGetApiStripeSubscriptionResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.ManageApiStripeSubscriptionResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.ManageApiStripeSubscriptionResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -406,9 +449,13 @@ partial void ProcessGetApiStripeSubscriptionResponseContent( #endif ).ConfigureAwait(false); - return - await global::Ideogram.ManageApiStripeSubscriptionResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.ManageApiStripeSubscriptionResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/Ideogram/Generated/Ideogram.ManageClient.GetApiSubscription.g.cs b/src/libs/Ideogram/Generated/Ideogram.ManageClient.GetApiSubscription.g.cs index 3f5ebe6..e9a7f5a 100644 --- a/src/libs/Ideogram/Generated/Ideogram.ManageClient.GetApiSubscription.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.ManageClient.GetApiSubscription.g.cs @@ -48,6 +48,23 @@ partial void ProcessGetApiSubscriptionResponseContent( public async global::System.Threading.Tasks.Task GetApiSubscriptionAsync( global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetApiSubscriptionAsResponseAsync( + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Retrieve data relevant to creating an API subscription. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> GetApiSubscriptionAsResponseAsync( + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( client: HttpClient); @@ -76,6 +93,7 @@ partial void ProcessGetApiSubscriptionResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/manage/api/subscription", baseUri: HttpClient.BaseAddress); @@ -148,6 +166,8 @@ partial void ProcessGetApiSubscriptionResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -158,6 +178,11 @@ partial void ProcessGetApiSubscriptionResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -175,6 +200,8 @@ partial void ProcessGetApiSubscriptionResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -184,8 +211,7 @@ partial void ProcessGetApiSubscriptionResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -194,6 +220,11 @@ partial void ProcessGetApiSubscriptionResponseContent( __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -210,14 +241,15 @@ partial void ProcessGetApiSubscriptionResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -257,6 +289,8 @@ partial void ProcessGetApiSubscriptionResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -277,6 +311,8 @@ partial void ProcessGetApiSubscriptionResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -367,9 +403,13 @@ partial void ProcessGetApiSubscriptionResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.ManageApiSubscriptionResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.ManageApiSubscriptionResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -397,9 +437,13 @@ partial void ProcessGetApiSubscriptionResponseContent( #endif ).ConfigureAwait(false); - return - await global::Ideogram.ManageApiSubscriptionResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.ManageApiSubscriptionResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/Ideogram/Generated/Ideogram.ManageClient.GetApiTerms.g.cs b/src/libs/Ideogram/Generated/Ideogram.ManageClient.GetApiTerms.g.cs index 506926d..b778f25 100644 --- a/src/libs/Ideogram/Generated/Ideogram.ManageClient.GetApiTerms.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.ManageClient.GetApiTerms.g.cs @@ -48,6 +48,23 @@ partial void ProcessGetApiTermsResponseContent( public async global::System.Threading.Tasks.Task GetApiTermsAsync( global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetApiTermsAsResponseAsync( + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Retrieve the latest terms of service for API usage. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> GetApiTermsAsResponseAsync( + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( client: HttpClient); @@ -76,6 +93,7 @@ partial void ProcessGetApiTermsResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/manage/api/terms", baseUri: HttpClient.BaseAddress); @@ -148,6 +166,8 @@ partial void ProcessGetApiTermsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -158,6 +178,11 @@ partial void ProcessGetApiTermsResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -175,6 +200,8 @@ partial void ProcessGetApiTermsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -184,8 +211,7 @@ partial void ProcessGetApiTermsResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -194,6 +220,11 @@ partial void ProcessGetApiTermsResponseContent( __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -210,14 +241,15 @@ partial void ProcessGetApiTermsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -257,6 +289,8 @@ partial void ProcessGetApiTermsResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -277,6 +311,8 @@ partial void ProcessGetApiTermsResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -367,9 +403,13 @@ partial void ProcessGetApiTermsResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.GetApiTermsResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.GetApiTermsResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -397,9 +437,13 @@ partial void ProcessGetApiTermsResponseContent( #endif ).ConfigureAwait(false); - return - await global::Ideogram.GetApiTermsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.GetApiTermsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/Ideogram/Generated/Ideogram.ManageClient.GetOrganizationMembers.g.cs b/src/libs/Ideogram/Generated/Ideogram.ManageClient.GetOrganizationMembers.g.cs index c975cd3..40d635d 100644 --- a/src/libs/Ideogram/Generated/Ideogram.ManageClient.GetOrganizationMembers.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.ManageClient.GetOrganizationMembers.g.cs @@ -52,6 +52,26 @@ partial void ProcessGetOrganizationMembersResponseContent( string organizationId, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetOrganizationMembersAsResponseAsync( + organizationId: organizationId, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Retrieve members of a specific organization + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> GetOrganizationMembersAsResponseAsync( + string organizationId, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( client: HttpClient); @@ -81,11 +101,12 @@ partial void ProcessGetOrganizationMembersResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/manage/api/organization/members", - baseUri: HttpClient.BaseAddress); + baseUri: HttpClient.BaseAddress); __pathBuilder - .AddRequiredParameter("organization_id", organizationId) + .AddRequiredParameter("organization_id", organizationId) ; var __path = __pathBuilder.ToString(); __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( @@ -157,6 +178,8 @@ partial void ProcessGetOrganizationMembersResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -167,6 +190,11 @@ partial void ProcessGetOrganizationMembersResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -184,6 +212,8 @@ partial void ProcessGetOrganizationMembersResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -193,8 +223,7 @@ partial void ProcessGetOrganizationMembersResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -203,6 +232,11 @@ partial void ProcessGetOrganizationMembersResponseContent( __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -219,14 +253,15 @@ partial void ProcessGetOrganizationMembersResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -266,6 +301,8 @@ partial void ProcessGetOrganizationMembersResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -286,6 +323,8 @@ partial void ProcessGetOrganizationMembersResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -409,9 +448,13 @@ partial void ProcessGetOrganizationMembersResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.GetOrganizationMembersResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.GetOrganizationMembersResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -439,9 +482,13 @@ partial void ProcessGetOrganizationMembersResponseContent( #endif ).ConfigureAwait(false); - return - await global::Ideogram.GetOrganizationMembersResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.GetOrganizationMembersResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/Ideogram/Generated/Ideogram.ManageClient.GetUsageInfo.g.cs b/src/libs/Ideogram/Generated/Ideogram.ManageClient.GetUsageInfo.g.cs index 9ebd470..77ac413 100644 --- a/src/libs/Ideogram/Generated/Ideogram.ManageClient.GetUsageInfo.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.ManageClient.GetUsageInfo.g.cs @@ -98,6 +98,64 @@ partial void ProcessGetUsageInfoResponseContent( global::Ideogram.UsageSource? source = default, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetUsageInfoAsResponseAsync( + organizationId: organizationId, + segmentBy: segmentBy, + startTime: startTime, + endTime: endTime, + modelVersions: modelVersions, + tools: tools, + apiKeyIds: apiKeyIds, + userEmails: userEmails, + source: source, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Retrieve usage information segmented by time period with tool-specific breakdowns + /// + /// + /// + /// Time segment granularity for usage breakdown
+ /// Example: DAY + /// + /// + /// + /// + /// Default Value: [] + /// + /// + /// Default Value: [] + /// + /// + /// Default Value: [] + /// + /// + /// Default Value: [] + /// + /// + /// Filter usage by source - API for programmatic API usage, APP for web application usage
+ /// Default Value: API + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> GetUsageInfoAsResponseAsync( + string organizationId, + global::Ideogram.SegmentBy segmentBy, + global::System.DateTime startTime, + global::System.DateTime? endTime = default, + global::System.Collections.Generic.IList? modelVersions = default, + global::System.Collections.Generic.IList? tools = default, + global::System.Collections.Generic.IList? apiKeyIds = default, + global::System.Collections.Generic.IList? userEmails = default, + global::Ideogram.UsageSource? source = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( client: HttpClient); @@ -135,9 +193,10 @@ partial void ProcessGetUsageInfoResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/manage/api/usage", - baseUri: HttpClient.BaseAddress); + baseUri: HttpClient.BaseAddress); __pathBuilder .AddRequiredParameter("organization_id", organizationId) .AddRequiredParameter("segment_by", segmentBy.ToValueString()) @@ -147,7 +206,7 @@ partial void ProcessGetUsageInfoResponseContent( .AddOptionalParameter("tools", tools, selector: static x => x.ToValueString(), delimiter: ",", explode: true) .AddOptionalParameter("api_key_ids", apiKeyIds, delimiter: ",", explode: true) .AddOptionalParameter("user_emails", userEmails, delimiter: ",", explode: true) - .AddOptionalParameter("source", source?.ToValueString()) + .AddOptionalParameter("source", source?.ToValueString()) ; var __path = __pathBuilder.ToString(); __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( @@ -227,6 +286,8 @@ partial void ProcessGetUsageInfoResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -237,6 +298,11 @@ partial void ProcessGetUsageInfoResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -254,6 +320,8 @@ partial void ProcessGetUsageInfoResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -263,8 +331,7 @@ partial void ProcessGetUsageInfoResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -273,6 +340,11 @@ partial void ProcessGetUsageInfoResponseContent( __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -289,14 +361,15 @@ partial void ProcessGetUsageInfoResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -336,6 +409,8 @@ partial void ProcessGetUsageInfoResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -356,6 +431,8 @@ partial void ProcessGetUsageInfoResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -446,9 +523,13 @@ partial void ProcessGetUsageInfoResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.GetUsageInfoResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.GetUsageInfoResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -476,9 +557,13 @@ partial void ProcessGetUsageInfoResponseContent( #endif ).ConfigureAwait(false); - return - await global::Ideogram.GetUsageInfoResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.GetUsageInfoResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/Ideogram/Generated/Ideogram.ManageClient.GetUserCredits.g.cs b/src/libs/Ideogram/Generated/Ideogram.ManageClient.GetUserCredits.g.cs index 5798374..f5c8049 100644 --- a/src/libs/Ideogram/Generated/Ideogram.ManageClient.GetUserCredits.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.ManageClient.GetUserCredits.g.cs @@ -60,6 +60,32 @@ partial void ProcessGetUserCreditsResponseContent( global::System.DateTime? endTime = default, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetUserCreditsAsResponseAsync( + organizationId: organizationId, + startTime: startTime, + endTime: endTime, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Retrieve user credit information and spending metrics + /// + /// + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> GetUserCreditsAsResponseAsync( + string organizationId, + global::System.DateTime startTime, + global::System.DateTime? endTime = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( client: HttpClient); @@ -91,13 +117,14 @@ partial void ProcessGetUserCreditsResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/manage/api/credits", - baseUri: HttpClient.BaseAddress); + baseUri: HttpClient.BaseAddress); __pathBuilder .AddRequiredParameter("organization_id", organizationId) .AddRequiredParameter("start_time", startTime.ToString("yyyy-MM-ddTHH:mm:ssZ")) - .AddOptionalParameter("end_time", endTime?.ToString("yyyy-MM-ddTHH:mm:ssZ")) + .AddOptionalParameter("end_time", endTime?.ToString("yyyy-MM-ddTHH:mm:ssZ")) ; var __path = __pathBuilder.ToString(); __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( @@ -171,6 +198,8 @@ partial void ProcessGetUserCreditsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -181,6 +210,11 @@ partial void ProcessGetUserCreditsResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -198,6 +232,8 @@ partial void ProcessGetUserCreditsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -207,8 +243,7 @@ partial void ProcessGetUserCreditsResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -217,6 +252,11 @@ partial void ProcessGetUserCreditsResponseContent( __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -233,14 +273,15 @@ partial void ProcessGetUserCreditsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -280,6 +321,8 @@ partial void ProcessGetUserCreditsResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -300,6 +343,8 @@ partial void ProcessGetUserCreditsResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -390,9 +435,13 @@ partial void ProcessGetUserCreditsResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.GetUserCreditsResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.GetUserCreditsResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -420,9 +469,13 @@ partial void ProcessGetUserCreditsResponseContent( #endif ).ConfigureAwait(false); - return - await global::Ideogram.GetUserCreditsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.GetUserCreditsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/Ideogram/Generated/Ideogram.ManageClient.GetUserSpendCommitInfo.g.cs b/src/libs/Ideogram/Generated/Ideogram.ManageClient.GetUserSpendCommitInfo.g.cs index 2424e81..891a930 100644 --- a/src/libs/Ideogram/Generated/Ideogram.ManageClient.GetUserSpendCommitInfo.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.ManageClient.GetUserSpendCommitInfo.g.cs @@ -56,6 +56,29 @@ partial void ProcessGetUserSpendCommitInfoResponseContent( bool? postpaidOnly = default, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetUserSpendCommitInfoAsResponseAsync( + organizationId: organizationId, + postpaidOnly: postpaidOnly, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Retrieve user spend commit information + /// + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> GetUserSpendCommitInfoAsResponseAsync( + string organizationId, + bool? postpaidOnly = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( client: HttpClient); @@ -86,12 +109,13 @@ partial void ProcessGetUserSpendCommitInfoResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/manage/api/spend_commit", - baseUri: HttpClient.BaseAddress); + baseUri: HttpClient.BaseAddress); __pathBuilder .AddRequiredParameter("organization_id", organizationId) - .AddOptionalParameter("postpaid_only", postpaidOnly?.ToString().ToLowerInvariant()) + .AddOptionalParameter("postpaid_only", postpaidOnly?.ToString().ToLowerInvariant()) ; var __path = __pathBuilder.ToString(); __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( @@ -164,6 +188,8 @@ partial void ProcessGetUserSpendCommitInfoResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -174,6 +200,11 @@ partial void ProcessGetUserSpendCommitInfoResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -191,6 +222,8 @@ partial void ProcessGetUserSpendCommitInfoResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -200,8 +233,7 @@ partial void ProcessGetUserSpendCommitInfoResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -210,6 +242,11 @@ partial void ProcessGetUserSpendCommitInfoResponseContent( __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -226,14 +263,15 @@ partial void ProcessGetUserSpendCommitInfoResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -273,6 +311,8 @@ partial void ProcessGetUserSpendCommitInfoResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -293,6 +333,8 @@ partial void ProcessGetUserSpendCommitInfoResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -383,9 +425,13 @@ partial void ProcessGetUserSpendCommitInfoResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.SpendCommitInfoResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.SpendCommitInfoResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -413,9 +459,13 @@ partial void ProcessGetUserSpendCommitInfoResponseContent( #endif ).ConfigureAwait(false); - return - await global::Ideogram.SpendCommitInfoResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.SpendCommitInfoResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/Ideogram/Generated/Ideogram.ManageClient.ListOrganizationInvoices.g.cs b/src/libs/Ideogram/Generated/Ideogram.ManageClient.ListOrganizationInvoices.g.cs index ebc88e2..c522342 100644 --- a/src/libs/Ideogram/Generated/Ideogram.ManageClient.ListOrganizationInvoices.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.ManageClient.ListOrganizationInvoices.g.cs @@ -52,6 +52,26 @@ partial void ProcessListOrganizationInvoicesResponseContent( string organizationId, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await ListOrganizationInvoicesAsResponseAsync( + organizationId: organizationId, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Retrieve invoices for a specific organization + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> ListOrganizationInvoicesAsResponseAsync( + string organizationId, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( client: HttpClient); @@ -81,11 +101,12 @@ partial void ProcessListOrganizationInvoicesResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/manage/api/organization/list_invoices", - baseUri: HttpClient.BaseAddress); + baseUri: HttpClient.BaseAddress); __pathBuilder - .AddRequiredParameter("organization_id", organizationId) + .AddRequiredParameter("organization_id", organizationId) ; var __path = __pathBuilder.ToString(); __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( @@ -157,6 +178,8 @@ partial void ProcessListOrganizationInvoicesResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -167,6 +190,11 @@ partial void ProcessListOrganizationInvoicesResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -184,6 +212,8 @@ partial void ProcessListOrganizationInvoicesResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -193,8 +223,7 @@ partial void ProcessListOrganizationInvoicesResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -203,6 +232,11 @@ partial void ProcessListOrganizationInvoicesResponseContent( __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -219,14 +253,15 @@ partial void ProcessListOrganizationInvoicesResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -266,6 +301,8 @@ partial void ProcessListOrganizationInvoicesResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -286,6 +323,8 @@ partial void ProcessListOrganizationInvoicesResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -409,9 +448,13 @@ partial void ProcessListOrganizationInvoicesResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.ListOrganizationInvoicesResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.ListOrganizationInvoicesResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -439,9 +482,13 @@ partial void ProcessListOrganizationInvoicesResponseContent( #endif ).ConfigureAwait(false); - return - await global::Ideogram.ListOrganizationInvoicesResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.ListOrganizationInvoicesResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/Ideogram/Generated/Ideogram.ManageClient.PostAddCreditsForApi.g.cs b/src/libs/Ideogram/Generated/Ideogram.ManageClient.PostAddCreditsForApi.g.cs index 13a46bd..1ae888d 100644 --- a/src/libs/Ideogram/Generated/Ideogram.ManageClient.PostAddCreditsForApi.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.ManageClient.PostAddCreditsForApi.g.cs @@ -50,6 +50,28 @@ partial void ProcessPostAddCreditsForApiResponseContent( /// public async global::System.Threading.Tasks.Task PostAddCreditsForApiAsync( + global::Ideogram.PostAddCreditsRequest request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await PostAddCreditsForApiAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Add credits to an API user's account. + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> PostAddCreditsForApiAsResponseAsync( + global::Ideogram.PostAddCreditsRequest request, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) @@ -84,6 +106,7 @@ partial void ProcessPostAddCreditsForApiResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/manage/api/add_credits", baseUri: HttpClient.BaseAddress); @@ -163,6 +186,8 @@ partial void ProcessPostAddCreditsForApiResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -173,6 +198,11 @@ partial void ProcessPostAddCreditsForApiResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -190,6 +220,8 @@ partial void ProcessPostAddCreditsForApiResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -199,8 +231,7 @@ partial void ProcessPostAddCreditsForApiResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -209,6 +240,11 @@ partial void ProcessPostAddCreditsForApiResponseContent( __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -225,14 +261,15 @@ partial void ProcessPostAddCreditsForApiResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -272,6 +309,8 @@ partial void ProcessPostAddCreditsForApiResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -292,6 +331,8 @@ partial void ProcessPostAddCreditsForApiResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad request @@ -420,9 +461,13 @@ partial void ProcessPostAddCreditsForApiResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.PostAddCreditsResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.PostAddCreditsResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -450,9 +495,13 @@ partial void ProcessPostAddCreditsForApiResponseContent( #endif ).ConfigureAwait(false); - return - await global::Ideogram.PostAddCreditsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.PostAddCreditsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/Ideogram/Generated/Ideogram.ManageClient.PostApiSubscription.g.cs b/src/libs/Ideogram/Generated/Ideogram.ManageClient.PostApiSubscription.g.cs index 73f9660..725972e 100644 --- a/src/libs/Ideogram/Generated/Ideogram.ManageClient.PostApiSubscription.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.ManageClient.PostApiSubscription.g.cs @@ -50,6 +50,28 @@ partial void ProcessPostApiSubscriptionResponseContent( /// public async global::System.Threading.Tasks.Task PostApiSubscriptionAsync( + global::Ideogram.PostApiSubscriptionRequest request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await PostApiSubscriptionAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Update API subscription settings + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> PostApiSubscriptionAsResponseAsync( + global::Ideogram.PostApiSubscriptionRequest request, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) @@ -84,6 +106,7 @@ partial void ProcessPostApiSubscriptionResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/manage/api/subscription", baseUri: HttpClient.BaseAddress); @@ -163,6 +186,8 @@ partial void ProcessPostApiSubscriptionResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -173,6 +198,11 @@ partial void ProcessPostApiSubscriptionResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -190,6 +220,8 @@ partial void ProcessPostApiSubscriptionResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -199,8 +231,7 @@ partial void ProcessPostApiSubscriptionResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -209,6 +240,11 @@ partial void ProcessPostApiSubscriptionResponseContent( __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -225,14 +261,15 @@ partial void ProcessPostApiSubscriptionResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -272,6 +309,8 @@ partial void ProcessPostApiSubscriptionResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -292,6 +331,8 @@ partial void ProcessPostApiSubscriptionResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Bad request @@ -420,9 +461,13 @@ partial void ProcessPostApiSubscriptionResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.PostApiSubscriptionResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.PostApiSubscriptionResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -450,9 +495,13 @@ partial void ProcessPostApiSubscriptionResponseContent( #endif ).ConfigureAwait(false); - return - await global::Ideogram.PostApiSubscriptionResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.PostApiSubscriptionResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/Ideogram/Generated/Ideogram.ManageClient.PostApiTerms.g.cs b/src/libs/Ideogram/Generated/Ideogram.ManageClient.PostApiTerms.g.cs index f0bad0c..f7e06e6 100644 --- a/src/libs/Ideogram/Generated/Ideogram.ManageClient.PostApiTerms.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.ManageClient.PostApiTerms.g.cs @@ -45,6 +45,26 @@ partial void ProcessPostApiTermsResponse( /// public async global::System.Threading.Tasks.Task PostApiTermsAsync( + global::Ideogram.PostApiTermsRequest request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + await PostApiTermsAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + } + /// + /// Accept terms + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task PostApiTermsAsResponseAsync( + global::Ideogram.PostApiTermsRequest request, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) @@ -79,6 +99,7 @@ partial void ProcessPostApiTermsResponse( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/manage/api/terms", baseUri: HttpClient.BaseAddress); @@ -158,6 +179,8 @@ partial void ProcessPostApiTermsResponse( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -168,6 +191,11 @@ partial void ProcessPostApiTermsResponse( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -185,6 +213,8 @@ partial void ProcessPostApiTermsResponse( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -194,8 +224,7 @@ partial void ProcessPostApiTermsResponse( __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -204,6 +233,11 @@ partial void ProcessPostApiTermsResponse( __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -220,14 +254,15 @@ partial void ProcessPostApiTermsResponse( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -267,6 +302,8 @@ partial void ProcessPostApiTermsResponse( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -287,6 +324,8 @@ partial void ProcessPostApiTermsResponse( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -406,6 +445,10 @@ partial void ProcessPostApiTermsResponse( { __response.EnsureSuccessStatusCode(); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri); } catch (global::System.Exception __ex) { @@ -427,6 +470,10 @@ partial void ProcessPostApiTermsResponse( try { __response.EnsureSuccessStatusCode(); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri); } catch (global::System.Exception __ex) { diff --git a/src/libs/Ideogram/Generated/Ideogram.ManageClient.PromoteOrganizationMembers.g.cs b/src/libs/Ideogram/Generated/Ideogram.ManageClient.PromoteOrganizationMembers.g.cs index e4f3bdb..23736e2 100644 --- a/src/libs/Ideogram/Generated/Ideogram.ManageClient.PromoteOrganizationMembers.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.ManageClient.PromoteOrganizationMembers.g.cs @@ -54,6 +54,31 @@ partial void ProcessPromoteOrganizationMembersResponseContent( public async global::System.Threading.Tasks.Task PromoteOrganizationMembersAsync( string organizationId, + global::Ideogram.PromoteOrganizationMembersRequest request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await PromoteOrganizationMembersAsResponseAsync( + organizationId: organizationId, + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Promote members to OWNER role in a specific organization + /// + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> PromoteOrganizationMembersAsResponseAsync( + string organizationId, + global::Ideogram.PromoteOrganizationMembersRequest request, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) @@ -89,11 +114,12 @@ partial void ProcessPromoteOrganizationMembersResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/manage/api/organization/promote_members", - baseUri: HttpClient.BaseAddress); + baseUri: HttpClient.BaseAddress); __pathBuilder - .AddRequiredParameter("organization_id", organizationId) + .AddRequiredParameter("organization_id", organizationId) ; var __path = __pathBuilder.ToString(); __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( @@ -172,6 +198,8 @@ partial void ProcessPromoteOrganizationMembersResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -182,6 +210,11 @@ partial void ProcessPromoteOrganizationMembersResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -199,6 +232,8 @@ partial void ProcessPromoteOrganizationMembersResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -208,8 +243,7 @@ partial void ProcessPromoteOrganizationMembersResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -218,6 +252,11 @@ partial void ProcessPromoteOrganizationMembersResponseContent( __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -234,14 +273,15 @@ partial void ProcessPromoteOrganizationMembersResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -281,6 +321,8 @@ partial void ProcessPromoteOrganizationMembersResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -301,6 +343,8 @@ partial void ProcessPromoteOrganizationMembersResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -457,9 +501,13 @@ partial void ProcessPromoteOrganizationMembersResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.OrganizationMemberOperationResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.OrganizationMemberOperationResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -487,9 +535,13 @@ partial void ProcessPromoteOrganizationMembersResponseContent( #endif ).ConfigureAwait(false); - return - await global::Ideogram.OrganizationMemberOperationResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.OrganizationMemberOperationResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/Ideogram/Generated/Ideogram.ManageClient.ReactivateSubscription.g.cs b/src/libs/Ideogram/Generated/Ideogram.ManageClient.ReactivateSubscription.g.cs index 5865451..d227636 100644 --- a/src/libs/Ideogram/Generated/Ideogram.ManageClient.ReactivateSubscription.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.ManageClient.ReactivateSubscription.g.cs @@ -48,6 +48,23 @@ partial void ProcessReactivateSubscriptionResponseContent( public async global::System.Threading.Tasks.Task ReactivateSubscriptionAsync( global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await ReactivateSubscriptionAsResponseAsync( + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Reactivates a subscription by attempting to re-enable Metronome billing. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> ReactivateSubscriptionAsResponseAsync( + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( client: HttpClient); @@ -76,6 +93,7 @@ partial void ProcessReactivateSubscriptionResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/manage/api/reactivate", baseUri: HttpClient.BaseAddress); @@ -148,6 +166,8 @@ partial void ProcessReactivateSubscriptionResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -158,6 +178,11 @@ partial void ProcessReactivateSubscriptionResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -175,6 +200,8 @@ partial void ProcessReactivateSubscriptionResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -184,8 +211,7 @@ partial void ProcessReactivateSubscriptionResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -194,6 +220,11 @@ partial void ProcessReactivateSubscriptionResponseContent( __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -210,14 +241,15 @@ partial void ProcessReactivateSubscriptionResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -257,6 +289,8 @@ partial void ProcessReactivateSubscriptionResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -277,6 +311,8 @@ partial void ProcessReactivateSubscriptionResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -400,9 +436,13 @@ partial void ProcessReactivateSubscriptionResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.PostApiReactivateResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.PostApiReactivateResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -430,9 +470,13 @@ partial void ProcessReactivateSubscriptionResponseContent( #endif ).ConfigureAwait(false); - return - await global::Ideogram.PostApiReactivateResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.PostApiReactivateResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/Ideogram/Generated/Ideogram.ManageClient.RemoveOrganizationMembers.g.cs b/src/libs/Ideogram/Generated/Ideogram.ManageClient.RemoveOrganizationMembers.g.cs index bd5a28a..f6c4f81 100644 --- a/src/libs/Ideogram/Generated/Ideogram.ManageClient.RemoveOrganizationMembers.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.ManageClient.RemoveOrganizationMembers.g.cs @@ -54,6 +54,31 @@ partial void ProcessRemoveOrganizationMembersResponseContent( public async global::System.Threading.Tasks.Task RemoveOrganizationMembersAsync( string organizationId, + global::Ideogram.RemoveOrganizationMembersRequest request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await RemoveOrganizationMembersAsResponseAsync( + organizationId: organizationId, + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Remove members from a specific organization + /// + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> RemoveOrganizationMembersAsResponseAsync( + string organizationId, + global::Ideogram.RemoveOrganizationMembersRequest request, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) @@ -89,11 +114,12 @@ partial void ProcessRemoveOrganizationMembersResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/manage/api/organization/remove_members", - baseUri: HttpClient.BaseAddress); + baseUri: HttpClient.BaseAddress); __pathBuilder - .AddRequiredParameter("organization_id", organizationId) + .AddRequiredParameter("organization_id", organizationId) ; var __path = __pathBuilder.ToString(); __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( @@ -172,6 +198,8 @@ partial void ProcessRemoveOrganizationMembersResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -182,6 +210,11 @@ partial void ProcessRemoveOrganizationMembersResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -199,6 +232,8 @@ partial void ProcessRemoveOrganizationMembersResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -208,8 +243,7 @@ partial void ProcessRemoveOrganizationMembersResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -218,6 +252,11 @@ partial void ProcessRemoveOrganizationMembersResponseContent( __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -234,14 +273,15 @@ partial void ProcessRemoveOrganizationMembersResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -281,6 +321,8 @@ partial void ProcessRemoveOrganizationMembersResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -301,6 +343,8 @@ partial void ProcessRemoveOrganizationMembersResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -457,9 +501,13 @@ partial void ProcessRemoveOrganizationMembersResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.OrganizationMemberOperationResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.OrganizationMemberOperationResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -487,9 +535,13 @@ partial void ProcessRemoveOrganizationMembersResponseContent( #endif ).ConfigureAwait(false); - return - await global::Ideogram.OrganizationMemberOperationResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.OrganizationMemberOperationResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/Ideogram/Generated/Ideogram.ManageClient.g.cs b/src/libs/Ideogram/Generated/Ideogram.ManageClient.g.cs index b9db555..6a02c12 100644 --- a/src/libs/Ideogram/Generated/Ideogram.ManageClient.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.ManageClient.g.cs @@ -73,10 +73,10 @@ public ManageClient( /// Client-wide request defaults such as headers, query parameters, retries, and timeout. /// Dispose the HttpClient when the instance is disposed. True by default. public ManageClient( - global::System.Net.Http.HttpClient? httpClient = null, - global::System.Uri? baseUri = null, - global::System.Collections.Generic.List? authorizations = null, - global::Ideogram.AutoSDKClientOptions? options = null, + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Ideogram.AutoSDKClientOptions? options, bool disposeHttpClient = true) { diff --git a/src/libs/Ideogram/Generated/Ideogram.Models.EditImageRequest.g.cs b/src/libs/Ideogram/Generated/Ideogram.Models.EditImageRequest.g.cs index 9734e71..6855063 100644 --- a/src/libs/Ideogram/Generated/Ideogram.Models.EditImageRequest.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.Models.EditImageRequest.g.cs @@ -66,6 +66,12 @@ public sealed partial class EditImageRequest [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Ideogram.JsonConverters.MagicPromptOptionJsonConverter))] public global::Ideogram.MagicPromptOption? MagicPromptOption { get; set; } + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + [global::System.Text.Json.Serialization.JsonPropertyName("magic_prompt_system_prompt_config_id")] + public string? MagicPromptSystemPromptConfigId { get; set; } + /// /// The number of images to generate.
/// Default Value: 1 @@ -124,6 +130,9 @@ public sealed partial class EditImageRequest /// Determine if MagicPrompt should be used in generating the request or not.
/// Example: ON /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// /// /// The number of images to generate.
/// Default Value: 1 @@ -147,6 +156,7 @@ public EditImageRequest( string prompt, global::Ideogram.ModelEnum model, global::Ideogram.MagicPromptOption? magicPromptOption, + string? magicPromptSystemPromptConfigId, int? numImages, int? seed, global::Ideogram.StyleType? styleType) @@ -158,6 +168,7 @@ public EditImageRequest( this.Prompt = prompt ?? throw new global::System.ArgumentNullException(nameof(prompt)); this.Model = model; this.MagicPromptOption = magicPromptOption; + this.MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId; this.NumImages = numImages; this.Seed = seed; this.StyleType = styleType; diff --git a/src/libs/Ideogram/Generated/Ideogram.Models.EditImageRequestV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.Models.EditImageRequestV3.g.cs index 0a67f85..0825b40 100644 --- a/src/libs/Ideogram/Generated/Ideogram.Models.EditImageRequestV3.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.Models.EditImageRequestV3.g.cs @@ -54,6 +54,12 @@ public sealed partial class EditImageRequestV3 [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Ideogram.JsonConverters.MagicPromptOptionJsonConverter))] public global::Ideogram.MagicPromptOption? MagicPrompt { get; set; } + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + [global::System.Text.Json.Serialization.JsonPropertyName("magic_prompt_system_prompt_config_id")] + public string? MagicPromptSystemPromptConfigId { get; set; } + /// /// The number of images to generate.
/// Default Value: 1 @@ -167,6 +173,9 @@ public sealed partial class EditImageRequestV3 /// Determine if MagicPrompt should be used in generating the request or not.
/// Example: ON /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// /// /// The number of images to generate.
/// Default Value: 1 @@ -219,6 +228,7 @@ public EditImageRequestV3( string maskname, string prompt, global::Ideogram.MagicPromptOption? magicPrompt, + string? magicPromptSystemPromptConfigId, int? numImages, int? seed, global::Ideogram.RenderingSpeed? renderingSpeed, @@ -237,6 +247,7 @@ public EditImageRequestV3( this.Maskname = maskname ?? throw new global::System.ArgumentNullException(nameof(maskname)); this.Prompt = prompt ?? throw new global::System.ArgumentNullException(nameof(prompt)); this.MagicPrompt = magicPrompt; + this.MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId; this.NumImages = numImages; this.Seed = seed; this.RenderingSpeed = renderingSpeed; diff --git a/src/libs/Ideogram/Generated/Ideogram.Models.GenerateDesignRequestV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.Models.GenerateDesignRequestV3.g.cs index ed4fd8b..acbc44e 100644 --- a/src/libs/Ideogram/Generated/Ideogram.Models.GenerateDesignRequestV3.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.Models.GenerateDesignRequestV3.g.cs @@ -58,6 +58,12 @@ public sealed partial class GenerateDesignRequestV3 [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Ideogram.JsonConverters.MagicPromptOptionJsonConverter))] public global::Ideogram.MagicPromptOption? MagicPrompt { get; set; } + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + [global::System.Text.Json.Serialization.JsonPropertyName("magic_prompt_system_prompt_config_id")] + public string? MagicPromptSystemPromptConfigId { get; set; } + /// /// Description of what to exclude from a design. Descriptions in the prompt take precedence
/// to descriptions in the negative prompt.
@@ -235,6 +241,9 @@ public sealed partial class GenerateDesignRequestV3 /// Determine if MagicPrompt should be used in generating the request or not.
/// Example: ON /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// /// /// Description of what to exclude from a design. Descriptions in the prompt take precedence
/// to descriptions in the negative prompt.
@@ -318,6 +327,7 @@ public GenerateDesignRequestV3( global::Ideogram.AspectRatioV3? aspectRatio, global::Ideogram.RenderingSpeed? renderingSpeed, global::Ideogram.MagicPromptOption? magicPrompt, + string? magicPromptSystemPromptConfigId, string? negativePrompt, int? numImages, global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette, @@ -346,6 +356,7 @@ public GenerateDesignRequestV3( this.AspectRatio = aspectRatio; this.RenderingSpeed = renderingSpeed; this.MagicPrompt = magicPrompt; + this.MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId; this.NegativePrompt = negativePrompt; this.NumImages = numImages; this.ColorPalette = colorPalette; diff --git a/src/libs/Ideogram/Generated/Ideogram.Models.GenerateGraphicRequestV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.Models.GenerateGraphicRequestV3.g.cs index bda768e..bdeffd4 100644 --- a/src/libs/Ideogram/Generated/Ideogram.Models.GenerateGraphicRequestV3.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.Models.GenerateGraphicRequestV3.g.cs @@ -57,6 +57,12 @@ public sealed partial class GenerateGraphicRequestV3 [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Ideogram.JsonConverters.MagicPromptOptionJsonConverter))] public global::Ideogram.MagicPromptOption? MagicPrompt { get; set; } + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + [global::System.Text.Json.Serialization.JsonPropertyName("magic_prompt_system_prompt_config_id")] + public string? MagicPromptSystemPromptConfigId { get; set; } + /// /// Description of what to exclude from a graphic. Descriptions in the prompt take precedence
/// to descriptions in the negative prompt.
@@ -246,6 +252,9 @@ public sealed partial class GenerateGraphicRequestV3 /// Determine if MagicPrompt should be used in generating the request or not.
/// Example: ON /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// /// /// Description of what to exclude from a graphic. Descriptions in the prompt take precedence
/// to descriptions in the negative prompt.
@@ -335,6 +344,7 @@ public GenerateGraphicRequestV3( global::Ideogram.AspectRatioV3? aspectRatio, global::Ideogram.RenderingSpeed? renderingSpeed, global::Ideogram.MagicPromptOption? magicPrompt, + string? magicPromptSystemPromptConfigId, string? negativePrompt, int? numImages, global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette, @@ -365,6 +375,7 @@ public GenerateGraphicRequestV3( this.AspectRatio = aspectRatio; this.RenderingSpeed = renderingSpeed; this.MagicPrompt = magicPrompt; + this.MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId; this.NegativePrompt = negativePrompt; this.NumImages = numImages; this.ColorPalette = colorPalette; diff --git a/src/libs/Ideogram/Generated/Ideogram.Models.GenerateImageRequestV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.Models.GenerateImageRequestV3.g.cs index 49bf5d8..37b2684 100644 --- a/src/libs/Ideogram/Generated/Ideogram.Models.GenerateImageRequestV3.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.Models.GenerateImageRequestV3.g.cs @@ -58,6 +58,12 @@ public sealed partial class GenerateImageRequestV3 [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Ideogram.JsonConverters.MagicPromptOptionJsonConverter))] public global::Ideogram.MagicPromptOption? MagicPrompt { get; set; } + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + [global::System.Text.Json.Serialization.JsonPropertyName("magic_prompt_system_prompt_config_id")] + public string? MagicPromptSystemPromptConfigId { get; set; } + /// /// Description of what to exclude from an image. Descriptions in the prompt take precedence
/// to descriptions in the negative prompt.
@@ -167,6 +173,9 @@ public sealed partial class GenerateImageRequestV3 /// Determine if MagicPrompt should be used in generating the request or not.
/// Example: ON /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// /// /// Description of what to exclude from an image. Descriptions in the prompt take precedence
/// to descriptions in the negative prompt.
@@ -216,6 +225,7 @@ public GenerateImageRequestV3( global::Ideogram.AspectRatioV3? aspectRatio, global::Ideogram.RenderingSpeed? renderingSpeed, global::Ideogram.MagicPromptOption? magicPrompt, + string? magicPromptSystemPromptConfigId, string? negativePrompt, int? numImages, global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette, @@ -233,6 +243,7 @@ public GenerateImageRequestV3( this.AspectRatio = aspectRatio; this.RenderingSpeed = renderingSpeed; this.MagicPrompt = magicPrompt; + this.MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId; this.NegativePrompt = negativePrompt; this.NumImages = numImages; this.ColorPalette = colorPalette; diff --git a/src/libs/Ideogram/Generated/Ideogram.Models.GenerateImageRequestV4.g.cs b/src/libs/Ideogram/Generated/Ideogram.Models.GenerateImageRequestV4.g.cs index e9111e3..f9a09dc 100644 --- a/src/libs/Ideogram/Generated/Ideogram.Models.GenerateImageRequestV4.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.Models.GenerateImageRequestV4.g.cs @@ -30,6 +30,12 @@ public sealed partial class GenerateImageRequestV4 [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Ideogram.JsonConverters.MagicPromptOptionJsonConverter))] public global::Ideogram.MagicPromptOption? MagicPromptOption { get; set; } + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + [global::System.Text.Json.Serialization.JsonPropertyName("magic_prompt_system_prompt_config_id")] + public string? MagicPromptSystemPromptConfigId { get; set; } + /// /// A custom model URI in the format model/<model_name>/version/<version_name>.
/// When provided, the model version and style will be resolved from this URI.
@@ -39,6 +45,23 @@ public sealed partial class GenerateImageRequestV4 [global::System.Text.Json.Serialization.JsonPropertyName("custom_model_uri")] public string? CustomModelUri { get; set; } + /// + /// The resolutions supported for Ideogram 4.0.
+ /// Example: 1280x800 + ///
+ /// 1280x800 + [global::System.Text.Json.Serialization.JsonPropertyName("resolution")] + [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Ideogram.JsonConverters.ResolutionV4JsonConverter))] + public global::Ideogram.ResolutionV4? Resolution { get; set; } + + /// + /// The rendering speed to use.
+ /// Default Value: DEFAULT + ///
+ [global::System.Text.Json.Serialization.JsonPropertyName("rendering_speed")] + [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Ideogram.JsonConverters.RenderingSpeedJsonConverter))] + public global::Ideogram.RenderingSpeed? RenderingSpeed { get; set; } + /// /// Additional properties that are not explicitly defined in the schema /// @@ -58,11 +81,22 @@ public sealed partial class GenerateImageRequestV4 /// Determine if MagicPrompt should be used in generating the request or not.
/// Example: ON /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// /// /// A custom model URI in the format model/<model_name>/version/<version_name>.
/// When provided, the model version and style will be resolved from this URI.
/// Example: model/my-custom-model/version/0 /// + /// + /// The resolutions supported for Ideogram 4.0.
+ /// Example: 1280x800 + /// + /// + /// The rendering speed to use.
+ /// Default Value: DEFAULT + /// #if NET7_0_OR_GREATER [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] #endif @@ -70,12 +104,18 @@ public GenerateImageRequestV4( string prompt, int? seed, global::Ideogram.MagicPromptOption? magicPromptOption, - string? customModelUri) + string? magicPromptSystemPromptConfigId, + string? customModelUri, + global::Ideogram.ResolutionV4? resolution, + global::Ideogram.RenderingSpeed? renderingSpeed) { this.Prompt = prompt ?? throw new global::System.ArgumentNullException(nameof(prompt)); this.Seed = seed; this.MagicPromptOption = magicPromptOption; + this.MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId; this.CustomModelUri = customModelUri; + this.Resolution = resolution; + this.RenderingSpeed = renderingSpeed; } /// diff --git a/src/libs/Ideogram/Generated/Ideogram.Models.GenerateTransparentImageRequestV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.Models.GenerateTransparentImageRequestV3.g.cs index a9aec53..af56593 100644 --- a/src/libs/Ideogram/Generated/Ideogram.Models.GenerateTransparentImageRequestV3.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.Models.GenerateTransparentImageRequestV3.g.cs @@ -59,6 +59,12 @@ public sealed partial class GenerateTransparentImageRequestV3 [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Ideogram.JsonConverters.MagicPromptOptionJsonConverter))] public global::Ideogram.MagicPromptOption? MagicPrompt { get; set; } + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + [global::System.Text.Json.Serialization.JsonPropertyName("magic_prompt_system_prompt_config_id")] + public string? MagicPromptSystemPromptConfigId { get; set; } + /// /// Description of what to exclude from an image. Descriptions in the prompt take precedence
/// to descriptions in the negative prompt.
@@ -118,6 +124,9 @@ public sealed partial class GenerateTransparentImageRequestV3 /// Determine if MagicPrompt should be used in generating the request or not.
/// Example: ON /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// /// /// Description of what to exclude from an image. Descriptions in the prompt take precedence
/// to descriptions in the negative prompt.
@@ -143,6 +152,7 @@ public GenerateTransparentImageRequestV3( global::Ideogram.AspectRatioV3? aspectRatio, global::Ideogram.RenderingSpeed? renderingSpeed, global::Ideogram.MagicPromptOption? magicPrompt, + string? magicPromptSystemPromptConfigId, string? negativePrompt, int? numImages, string? customModelUri) @@ -153,6 +163,7 @@ public GenerateTransparentImageRequestV3( this.AspectRatio = aspectRatio; this.RenderingSpeed = renderingSpeed; this.MagicPrompt = magicPrompt; + this.MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId; this.NegativePrompt = negativePrompt; this.NumImages = numImages; this.CustomModelUri = customModelUri; diff --git a/src/libs/Ideogram/Generated/Ideogram.Models.ImageLayerV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.Models.ImageLayerV3.g.cs index 951774c..cd685c3 100644 --- a/src/libs/Ideogram/Generated/Ideogram.Models.ImageLayerV3.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.Models.ImageLayerV3.g.cs @@ -5,7 +5,7 @@ namespace Ideogram { /// /// An image layer (logo, brand asset, icon) for a layered image generation.
- /// Example: {"ref_id":"REF_0","x":7,"width":3,"y":9,"height":2} + /// Example: {"ref_id":"REF_0","x":4,"width":1,"y":7,"height":1} ///
public sealed partial class ImageLayerV3 { diff --git a/src/libs/Ideogram/Generated/Ideogram.Models.ImageRequest.g.cs b/src/libs/Ideogram/Generated/Ideogram.Models.ImageRequest.g.cs index b501b5e..5bffa08 100644 --- a/src/libs/Ideogram/Generated/Ideogram.Models.ImageRequest.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.Models.ImageRequest.g.cs @@ -45,6 +45,12 @@ public sealed partial class ImageRequest [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Ideogram.JsonConverters.MagicPromptOptionJsonConverter))] public global::Ideogram.MagicPromptOption? MagicPromptOption { get; set; } + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + [global::System.Text.Json.Serialization.JsonPropertyName("magic_prompt_system_prompt_config_id")] + public string? MagicPromptSystemPromptConfigId { get; set; } + /// /// The magic prompt version to use when magic prompt option is set to AUTO or ON.
/// Example: V_0 @@ -128,6 +134,9 @@ public sealed partial class ImageRequest /// Determine if MagicPrompt should be used in generating the request or not.
/// Example: ON /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// /// /// The magic prompt version to use when magic prompt option is set to AUTO or ON.
/// Example: V_0 @@ -163,6 +172,7 @@ public ImageRequest( global::Ideogram.AspectRatio? aspectRatio, global::Ideogram.ModelEnum? model, global::Ideogram.MagicPromptOption? magicPromptOption, + string? magicPromptSystemPromptConfigId, global::Ideogram.MagicPromptVersionEnum? magicPromptVersion, int? seed, global::Ideogram.StyleType? styleType, @@ -175,6 +185,7 @@ public ImageRequest( this.AspectRatio = aspectRatio; this.Model = model; this.MagicPromptOption = magicPromptOption; + this.MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId; this.MagicPromptVersion = magicPromptVersion; this.Seed = seed; this.StyleType = styleType; diff --git a/src/libs/Ideogram/Generated/Ideogram.Models.InternalBatchRequest.g.cs b/src/libs/Ideogram/Generated/Ideogram.Models.InternalBatchRequest.g.cs index 2b4bf40..48b9341 100644 --- a/src/libs/Ideogram/Generated/Ideogram.Models.InternalBatchRequest.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.Models.InternalBatchRequest.g.cs @@ -5,7 +5,7 @@ namespace Ideogram { /// /// A request for batch magic prompt evalution.
- /// Example: {"user_prompts":["a cat","a dog"],"sampling_request_params":{"aspect_ratio":"1x1","style_type":"GENERAL","magic_prompt_version":"V_0","seed":12345,"negative_prompt":"brush strokes, painting","magic_prompt_option":"ON","model":"V_2_TURBO","resolution":"1280x800","num_images":1,"color_palette":{"name":"PASTEL"}},"experiment_variant":"MAGIC_PROMPT_NO_TEXT"} + /// Example: {"user_prompts":["a cat","a dog"],"sampling_request_params":{"magic_prompt_system_prompt_config_id":"magic_prompt_system_prompt_config_id","aspect_ratio":"1x1","style_type":"GENERAL","magic_prompt_version":"V_0","seed":12345,"negative_prompt":"brush strokes, painting","magic_prompt_option":"ON","model":"V_2_TURBO","resolution":"1280x800","num_images":1,"color_palette":{"name":"PASTEL"}},"experiment_variant":"MAGIC_PROMPT_NO_TEXT"} ///
public sealed partial class InternalBatchRequest { @@ -27,9 +27,9 @@ public sealed partial class InternalBatchRequest public string? ExperimentVariant { get; set; } /// - /// Example: {"aspect_ratio":"1x1","style_type":"GENERAL","magic_prompt_version":"V_0","seed":12345,"negative_prompt":"brush strokes, painting","magic_prompt_option":"ON","model":"V_2_TURBO","resolution":"1280x800","num_images":1,"color_palette":{"name":"PASTEL"}} + /// Example: {"magic_prompt_system_prompt_config_id":"magic_prompt_system_prompt_config_id","aspect_ratio":"1x1","style_type":"GENERAL","magic_prompt_version":"V_0","seed":12345,"negative_prompt":"brush strokes, painting","magic_prompt_option":"ON","model":"V_2_TURBO","resolution":"1280x800","num_images":1,"color_palette":{"name":"PASTEL"}} /// - /// {"aspect_ratio":"1x1","style_type":"GENERAL","magic_prompt_version":"V_0","seed":12345,"negative_prompt":"brush strokes, painting","magic_prompt_option":"ON","model":"V_2_TURBO","resolution":"1280x800","num_images":1,"color_palette":{"name":"PASTEL"}} + /// {"magic_prompt_system_prompt_config_id":"magic_prompt_system_prompt_config_id","aspect_ratio":"1x1","style_type":"GENERAL","magic_prompt_version":"V_0","seed":12345,"negative_prompt":"brush strokes, painting","magic_prompt_option":"ON","model":"V_2_TURBO","resolution":"1280x800","num_images":1,"color_palette":{"name":"PASTEL"}} [global::System.Text.Json.Serialization.JsonPropertyName("sampling_request_params")] public global::Ideogram.SamplingRequestParams? SamplingRequestParams { get; set; } @@ -51,7 +51,7 @@ public sealed partial class InternalBatchRequest /// Example: MAGIC_PROMPT_NO_TEXT /// /// - /// Example: {"aspect_ratio":"1x1","style_type":"GENERAL","magic_prompt_version":"V_0","seed":12345,"negative_prompt":"brush strokes, painting","magic_prompt_option":"ON","model":"V_2_TURBO","resolution":"1280x800","num_images":1,"color_palette":{"name":"PASTEL"}} + /// Example: {"magic_prompt_system_prompt_config_id":"magic_prompt_system_prompt_config_id","aspect_ratio":"1x1","style_type":"GENERAL","magic_prompt_version":"V_0","seed":12345,"negative_prompt":"brush strokes, painting","magic_prompt_option":"ON","model":"V_2_TURBO","resolution":"1280x800","num_images":1,"color_palette":{"name":"PASTEL"}} /// #if NET7_0_OR_GREATER [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] diff --git a/src/libs/Ideogram/Generated/Ideogram.Models.LayeredAssetTextShadow.Json.g.cs b/src/libs/Ideogram/Generated/Ideogram.Models.LayeredAssetTextShadow.Json.g.cs new file mode 100644 index 0000000..446e47c --- /dev/null +++ b/src/libs/Ideogram/Generated/Ideogram.Models.LayeredAssetTextShadow.Json.g.cs @@ -0,0 +1,92 @@ +#nullable enable + +namespace Ideogram +{ + public sealed partial class LayeredAssetTextShadow + { + /// + /// Serializes the current instance to a JSON string using the provided JsonSerializerContext. + /// + public string ToJson( + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Serialize( + this, + this.GetType(), + jsonSerializerContext); + } + + /// + /// Serializes the current instance to a JSON string using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public string ToJson( + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + return global::System.Text.Json.JsonSerializer.Serialize( + this, + jsonSerializerOptions); + } + + /// + /// Deserializes a JSON string using the provided JsonSerializerContext. + /// + public static global::Ideogram.LayeredAssetTextShadow? FromJson( + string json, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + typeof(global::Ideogram.LayeredAssetTextShadow), + jsonSerializerContext) as global::Ideogram.LayeredAssetTextShadow; + } + + /// + /// Deserializes a JSON string using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public static global::Ideogram.LayeredAssetTextShadow? FromJson( + string json, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + jsonSerializerOptions); + } + + /// + /// Deserializes a JSON stream using the provided JsonSerializerContext. + /// + public static async global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return (await global::System.Text.Json.JsonSerializer.DeserializeAsync( + jsonStream, + typeof(global::Ideogram.LayeredAssetTextShadow), + jsonSerializerContext).ConfigureAwait(false)) as global::Ideogram.LayeredAssetTextShadow; + } + + /// + /// Deserializes a JSON stream using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public static global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + return global::System.Text.Json.JsonSerializer.DeserializeAsync( + jsonStream, + jsonSerializerOptions); + } + } +} diff --git a/src/libs/Ideogram/Generated/Ideogram.Models.LayeredAssetTextShadow.g.cs b/src/libs/Ideogram/Generated/Ideogram.Models.LayeredAssetTextShadow.g.cs new file mode 100644 index 0000000..206a8b9 --- /dev/null +++ b/src/libs/Ideogram/Generated/Ideogram.Models.LayeredAssetTextShadow.g.cs @@ -0,0 +1,80 @@ + +#nullable enable + +namespace Ideogram +{ + /// + /// Single drop shadow for V4 vector text. Phase-1 supports one shadow per item.
+ /// Example: {"color":"color","blur":0.2027123,"offset_x":9.301444,"offset_y":3.6160767} + ///
+ public sealed partial class LayeredAssetTextShadow + { + /// + /// Shadow hex color. + /// + [global::System.Text.Json.Serialization.JsonPropertyName("color")] + [global::System.Text.Json.Serialization.JsonRequired] + public required string Color { get; set; } + + /// + /// Default Value: 0 + /// + [global::System.Text.Json.Serialization.JsonPropertyName("offset_x")] + public float? OffsetX { get; set; } + + /// + /// Default Value: 0 + /// + [global::System.Text.Json.Serialization.JsonPropertyName("offset_y")] + public float? OffsetY { get; set; } + + /// + /// Default Value: 0 + /// + [global::System.Text.Json.Serialization.JsonPropertyName("blur")] + public float? Blur { get; set; } + + /// + /// Additional properties that are not explicitly defined in the schema + /// + [global::System.Text.Json.Serialization.JsonExtensionData] + public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + + /// + /// Initializes a new instance of the class. + /// + /// + /// Shadow hex color. + /// + /// + /// Default Value: 0 + /// + /// + /// Default Value: 0 + /// + /// + /// Default Value: 0 + /// +#if NET7_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] +#endif + public LayeredAssetTextShadow( + string color, + float? offsetX, + float? offsetY, + float? blur) + { + this.Color = color ?? throw new global::System.ArgumentNullException(nameof(color)); + this.OffsetX = offsetX; + this.OffsetY = offsetY; + this.Blur = blur; + } + + /// + /// Initializes a new instance of the class. + /// + public LayeredAssetTextShadow() + { + } + } +} \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.Models.LayeredImageGenerationObjectV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.Models.LayeredImageGenerationObjectV3.g.cs index 764f590..c44025a 100644 --- a/src/libs/Ideogram/Generated/Ideogram.Models.LayeredImageGenerationObjectV3.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.Models.LayeredImageGenerationObjectV3.g.cs @@ -4,7 +4,7 @@ namespace Ideogram { /// - /// Example: {"text_containers":[{"id":"id","items":[{"font_candidates":["font_candidates","font_candidates"],"spans":[{"color":"#212121","text":"text","font_fx":["bold","italic"]},{"color":"#212121","text":"text","font_fx":["bold","italic"]}],"font_size":5,"glyph_type":"bullet","line_height":2.302136,"x":0,"width":1,"style_class":"body","y":6,"angle":0,"alignment":"center","font_file":"font_file","height":5},{"font_candidates":["font_candidates","font_candidates"],"spans":[{"color":"#212121","text":"text","font_fx":["bold","italic"]},{"color":"#212121","text":"text","font_fx":["bold","italic"]}],"font_size":5,"glyph_type":"bullet","line_height":2.302136,"x":0,"width":1,"style_class":"body","y":6,"angle":0,"alignment":"center","font_file":"font_file","height":5}]},{"id":"id","items":[{"font_candidates":["font_candidates","font_candidates"],"spans":[{"color":"#212121","text":"text","font_fx":["bold","italic"]},{"color":"#212121","text":"text","font_fx":["bold","italic"]}],"font_size":5,"glyph_type":"bullet","line_height":2.302136,"x":0,"width":1,"style_class":"body","y":6,"angle":0,"alignment":"center","font_file":"font_file","height":5},{"font_candidates":["font_candidates","font_candidates"],"spans":[{"color":"#212121","text":"text","font_fx":["bold","italic"]},{"color":"#212121","text":"text","font_fx":["bold","italic"]}],"font_size":5,"glyph_type":"bullet","line_height":2.302136,"x":0,"width":1,"style_class":"body","y":6,"angle":0,"alignment":"center","font_file":"font_file","height":5}]}],"image_layers":[{"ref_id":"REF_0","x":7,"width":3,"y":9,"height":2},{"ref_id":"REF_0","x":7,"width":3,"y":9,"height":2}],"url":"https://openapi-generator.tech","text_html":"text_html"} + /// Example: {"text_containers":[{"id":"id","items":[{"font_candidates":["font_candidates","font_candidates"],"spans":[{"color":"#212121","text":"text","font_fx":["bold","italic"]},{"color":"#212121","text":"text","font_fx":["bold","italic"]}],"font_size":5,"vertical_alignment":"top","text_transform":"none","glyph_type":"bullet","line_height":2.302136,"x":0,"width":1,"style_class":"body","y":6,"angle":0,"alignment":"center","font_file":"font_file","letter_spacing":7.0614014,"drop_shadows":[{"color":"color","blur":0.2027123,"offset_x":9.301444,"offset_y":3.6160767},{"color":"color","blur":0.2027123,"offset_x":9.301444,"offset_y":3.6160767}],"height":5},{"font_candidates":["font_candidates","font_candidates"],"spans":[{"color":"#212121","text":"text","font_fx":["bold","italic"]},{"color":"#212121","text":"text","font_fx":["bold","italic"]}],"font_size":5,"vertical_alignment":"top","text_transform":"none","glyph_type":"bullet","line_height":2.302136,"x":0,"width":1,"style_class":"body","y":6,"angle":0,"alignment":"center","font_file":"font_file","letter_spacing":7.0614014,"drop_shadows":[{"color":"color","blur":0.2027123,"offset_x":9.301444,"offset_y":3.6160767},{"color":"color","blur":0.2027123,"offset_x":9.301444,"offset_y":3.6160767}],"height":5}]},{"id":"id","items":[{"font_candidates":["font_candidates","font_candidates"],"spans":[{"color":"#212121","text":"text","font_fx":["bold","italic"]},{"color":"#212121","text":"text","font_fx":["bold","italic"]}],"font_size":5,"vertical_alignment":"top","text_transform":"none","glyph_type":"bullet","line_height":2.302136,"x":0,"width":1,"style_class":"body","y":6,"angle":0,"alignment":"center","font_file":"font_file","letter_spacing":7.0614014,"drop_shadows":[{"color":"color","blur":0.2027123,"offset_x":9.301444,"offset_y":3.6160767},{"color":"color","blur":0.2027123,"offset_x":9.301444,"offset_y":3.6160767}],"height":5},{"font_candidates":["font_candidates","font_candidates"],"spans":[{"color":"#212121","text":"text","font_fx":["bold","italic"]},{"color":"#212121","text":"text","font_fx":["bold","italic"]}],"font_size":5,"vertical_alignment":"top","text_transform":"none","glyph_type":"bullet","line_height":2.302136,"x":0,"width":1,"style_class":"body","y":6,"angle":0,"alignment":"center","font_file":"font_file","letter_spacing":7.0614014,"drop_shadows":[{"color":"color","blur":0.2027123,"offset_x":9.301444,"offset_y":3.6160767},{"color":"color","blur":0.2027123,"offset_x":9.301444,"offset_y":3.6160767}],"height":5}]}],"image_layers":[{"ref_id":"REF_0","x":4,"width":1,"y":7,"height":1},{"ref_id":"REF_0","x":4,"width":1,"y":7,"height":1}],"url":"https://openapi-generator.tech","text_html":"text_html"} /// public sealed partial class LayeredImageGenerationObjectV3 { diff --git a/src/libs/Ideogram/Generated/Ideogram.Models.LayeredImageGenerationResponseV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.Models.LayeredImageGenerationResponseV3.g.cs index 204fbba..cd9d4f7 100644 --- a/src/libs/Ideogram/Generated/Ideogram.Models.LayeredImageGenerationResponseV3.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.Models.LayeredImageGenerationResponseV3.g.cs @@ -6,7 +6,7 @@ namespace Ideogram /// /// The response which contains information about the generated image, including the download link and other text layeres.
/// Images links are available for a limited period of time; if you would like to keep the image, you must download it.
- /// Example: {"data":[{"text_containers":[{"id":"id","items":[{"font_candidates":["font_candidates","font_candidates"],"spans":[{"color":"#212121","text":"text","font_fx":["bold","italic"]},{"color":"#212121","text":"text","font_fx":["bold","italic"]}],"font_size":5,"glyph_type":"bullet","line_height":2.302136,"x":0,"width":1,"style_class":"body","y":6,"angle":0,"alignment":"center","font_file":"font_file","height":5},{"font_candidates":["font_candidates","font_candidates"],"spans":[{"color":"#212121","text":"text","font_fx":["bold","italic"]},{"color":"#212121","text":"text","font_fx":["bold","italic"]}],"font_size":5,"glyph_type":"bullet","line_height":2.302136,"x":0,"width":1,"style_class":"body","y":6,"angle":0,"alignment":"center","font_file":"font_file","height":5}]},{"id":"id","items":[{"font_candidates":["font_candidates","font_candidates"],"spans":[{"color":"#212121","text":"text","font_fx":["bold","italic"]},{"color":"#212121","text":"text","font_fx":["bold","italic"]}],"font_size":5,"glyph_type":"bullet","line_height":2.302136,"x":0,"width":1,"style_class":"body","y":6,"angle":0,"alignment":"center","font_file":"font_file","height":5},{"font_candidates":["font_candidates","font_candidates"],"spans":[{"color":"#212121","text":"text","font_fx":["bold","italic"]},{"color":"#212121","text":"text","font_fx":["bold","italic"]}],"font_size":5,"glyph_type":"bullet","line_height":2.302136,"x":0,"width":1,"style_class":"body","y":6,"angle":0,"alignment":"center","font_file":"font_file","height":5}]}],"image_layers":[{"ref_id":"REF_0","x":7,"width":3,"y":9,"height":2},{"ref_id":"REF_0","x":7,"width":3,"y":9,"height":2}],"url":"https://openapi-generator.tech","text_html":"text_html"},{"text_containers":[{"id":"id","items":[{"font_candidates":["font_candidates","font_candidates"],"spans":[{"color":"#212121","text":"text","font_fx":["bold","italic"]},{"color":"#212121","text":"text","font_fx":["bold","italic"]}],"font_size":5,"glyph_type":"bullet","line_height":2.302136,"x":0,"width":1,"style_class":"body","y":6,"angle":0,"alignment":"center","font_file":"font_file","height":5},{"font_candidates":["font_candidates","font_candidates"],"spans":[{"color":"#212121","text":"text","font_fx":["bold","italic"]},{"color":"#212121","text":"text","font_fx":["bold","italic"]}],"font_size":5,"glyph_type":"bullet","line_height":2.302136,"x":0,"width":1,"style_class":"body","y":6,"angle":0,"alignment":"center","font_file":"font_file","height":5}]},{"id":"id","items":[{"font_candidates":["font_candidates","font_candidates"],"spans":[{"color":"#212121","text":"text","font_fx":["bold","italic"]},{"color":"#212121","text":"text","font_fx":["bold","italic"]}],"font_size":5,"glyph_type":"bullet","line_height":2.302136,"x":0,"width":1,"style_class":"body","y":6,"angle":0,"alignment":"center","font_file":"font_file","height":5},{"font_candidates":["font_candidates","font_candidates"],"spans":[{"color":"#212121","text":"text","font_fx":["bold","italic"]},{"color":"#212121","text":"text","font_fx":["bold","italic"]}],"font_size":5,"glyph_type":"bullet","line_height":2.302136,"x":0,"width":1,"style_class":"body","y":6,"angle":0,"alignment":"center","font_file":"font_file","height":5}]}],"image_layers":[{"ref_id":"REF_0","x":7,"width":3,"y":9,"height":2},{"ref_id":"REF_0","x":7,"width":3,"y":9,"height":2}],"url":"https://openapi-generator.tech","text_html":"text_html"}],"created":"2000-01-23T04:56:07\u002B00:00"} + /// Example: {"data":[{"text_containers":[{"id":"id","items":[{"font_candidates":["font_candidates","font_candidates"],"spans":[{"color":"#212121","text":"text","font_fx":["bold","italic"]},{"color":"#212121","text":"text","font_fx":["bold","italic"]}],"font_size":5,"vertical_alignment":"top","text_transform":"none","glyph_type":"bullet","line_height":2.302136,"x":0,"width":1,"style_class":"body","y":6,"angle":0,"alignment":"center","font_file":"font_file","letter_spacing":7.0614014,"drop_shadows":[{"color":"color","blur":0.2027123,"offset_x":9.301444,"offset_y":3.6160767},{"color":"color","blur":0.2027123,"offset_x":9.301444,"offset_y":3.6160767}],"height":5},{"font_candidates":["font_candidates","font_candidates"],"spans":[{"color":"#212121","text":"text","font_fx":["bold","italic"]},{"color":"#212121","text":"text","font_fx":["bold","italic"]}],"font_size":5,"vertical_alignment":"top","text_transform":"none","glyph_type":"bullet","line_height":2.302136,"x":0,"width":1,"style_class":"body","y":6,"angle":0,"alignment":"center","font_file":"font_file","letter_spacing":7.0614014,"drop_shadows":[{"color":"color","blur":0.2027123,"offset_x":9.301444,"offset_y":3.6160767},{"color":"color","blur":0.2027123,"offset_x":9.301444,"offset_y":3.6160767}],"height":5}]},{"id":"id","items":[{"font_candidates":["font_candidates","font_candidates"],"spans":[{"color":"#212121","text":"text","font_fx":["bold","italic"]},{"color":"#212121","text":"text","font_fx":["bold","italic"]}],"font_size":5,"vertical_alignment":"top","text_transform":"none","glyph_type":"bullet","line_height":2.302136,"x":0,"width":1,"style_class":"body","y":6,"angle":0,"alignment":"center","font_file":"font_file","letter_spacing":7.0614014,"drop_shadows":[{"color":"color","blur":0.2027123,"offset_x":9.301444,"offset_y":3.6160767},{"color":"color","blur":0.2027123,"offset_x":9.301444,"offset_y":3.6160767}],"height":5},{"font_candidates":["font_candidates","font_candidates"],"spans":[{"color":"#212121","text":"text","font_fx":["bold","italic"]},{"color":"#212121","text":"text","font_fx":["bold","italic"]}],"font_size":5,"vertical_alignment":"top","text_transform":"none","glyph_type":"bullet","line_height":2.302136,"x":0,"width":1,"style_class":"body","y":6,"angle":0,"alignment":"center","font_file":"font_file","letter_spacing":7.0614014,"drop_shadows":[{"color":"color","blur":0.2027123,"offset_x":9.301444,"offset_y":3.6160767},{"color":"color","blur":0.2027123,"offset_x":9.301444,"offset_y":3.6160767}],"height":5}]}],"image_layers":[{"ref_id":"REF_0","x":4,"width":1,"y":7,"height":1},{"ref_id":"REF_0","x":4,"width":1,"y":7,"height":1}],"url":"https://openapi-generator.tech","text_html":"text_html"},{"text_containers":[{"id":"id","items":[{"font_candidates":["font_candidates","font_candidates"],"spans":[{"color":"#212121","text":"text","font_fx":["bold","italic"]},{"color":"#212121","text":"text","font_fx":["bold","italic"]}],"font_size":5,"vertical_alignment":"top","text_transform":"none","glyph_type":"bullet","line_height":2.302136,"x":0,"width":1,"style_class":"body","y":6,"angle":0,"alignment":"center","font_file":"font_file","letter_spacing":7.0614014,"drop_shadows":[{"color":"color","blur":0.2027123,"offset_x":9.301444,"offset_y":3.6160767},{"color":"color","blur":0.2027123,"offset_x":9.301444,"offset_y":3.6160767}],"height":5},{"font_candidates":["font_candidates","font_candidates"],"spans":[{"color":"#212121","text":"text","font_fx":["bold","italic"]},{"color":"#212121","text":"text","font_fx":["bold","italic"]}],"font_size":5,"vertical_alignment":"top","text_transform":"none","glyph_type":"bullet","line_height":2.302136,"x":0,"width":1,"style_class":"body","y":6,"angle":0,"alignment":"center","font_file":"font_file","letter_spacing":7.0614014,"drop_shadows":[{"color":"color","blur":0.2027123,"offset_x":9.301444,"offset_y":3.6160767},{"color":"color","blur":0.2027123,"offset_x":9.301444,"offset_y":3.6160767}],"height":5}]},{"id":"id","items":[{"font_candidates":["font_candidates","font_candidates"],"spans":[{"color":"#212121","text":"text","font_fx":["bold","italic"]},{"color":"#212121","text":"text","font_fx":["bold","italic"]}],"font_size":5,"vertical_alignment":"top","text_transform":"none","glyph_type":"bullet","line_height":2.302136,"x":0,"width":1,"style_class":"body","y":6,"angle":0,"alignment":"center","font_file":"font_file","letter_spacing":7.0614014,"drop_shadows":[{"color":"color","blur":0.2027123,"offset_x":9.301444,"offset_y":3.6160767},{"color":"color","blur":0.2027123,"offset_x":9.301444,"offset_y":3.6160767}],"height":5},{"font_candidates":["font_candidates","font_candidates"],"spans":[{"color":"#212121","text":"text","font_fx":["bold","italic"]},{"color":"#212121","text":"text","font_fx":["bold","italic"]}],"font_size":5,"vertical_alignment":"top","text_transform":"none","glyph_type":"bullet","line_height":2.302136,"x":0,"width":1,"style_class":"body","y":6,"angle":0,"alignment":"center","font_file":"font_file","letter_spacing":7.0614014,"drop_shadows":[{"color":"color","blur":0.2027123,"offset_x":9.301444,"offset_y":3.6160767},{"color":"color","blur":0.2027123,"offset_x":9.301444,"offset_y":3.6160767}],"height":5}]}],"image_layers":[{"ref_id":"REF_0","x":4,"width":1,"y":7,"height":1},{"ref_id":"REF_0","x":4,"width":1,"y":7,"height":1}],"url":"https://openapi-generator.tech","text_html":"text_html"}],"created":"2000-01-23T04:56:07\u002B00:00"} ///
public sealed partial class LayeredImageGenerationResponseV3 { diff --git a/src/libs/Ideogram/Generated/Ideogram.Models.ModelVersion.g.cs b/src/libs/Ideogram/Generated/Ideogram.Models.ModelVersion.g.cs index 8549411..359bcb7 100644 --- a/src/libs/Ideogram/Generated/Ideogram.Models.ModelVersion.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.Models.ModelVersion.g.cs @@ -12,6 +12,7 @@ namespace Ideogram /// - V_3_0: Model 3.0 March 26
/// - V_3_1: Model 3.0 Latest
/// - V_4_0: Model 4.0
+ /// - V_4_D: Model 4.0 Layered Design (vector-text path; gated by the access_to_v4d feature flag)
/// - AUTO: Automatically select the best model version based on the request.
/// Example: V_0_3 ///
@@ -73,6 +74,10 @@ public enum ModelVersion /// Model 4.0 ///
V40, + /// + /// Model 4.0 Layered Design (vector-text path; gated by the access_to_v4d feature flag) + /// + V4d, } /// @@ -101,6 +106,7 @@ public static string ToValueString(this ModelVersion value) ModelVersion.V30 => "V_3_0", ModelVersion.V31 => "V_3_1", ModelVersion.V40 => "V_4_0", + ModelVersion.V4d => "V_4_D", _ => throw new global::System.ArgumentOutOfRangeException(nameof(value), value, null), }; } @@ -125,6 +131,7 @@ public static string ToValueString(this ModelVersion value) "V_3_0" => ModelVersion.V30, "V_3_1" => ModelVersion.V31, "V_4_0" => ModelVersion.V40, + "V_4_D" => ModelVersion.V4d, _ => null, }; } diff --git a/src/libs/Ideogram/Generated/Ideogram.Models.RemixImageRequestV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.Models.RemixImageRequestV3.g.cs index 2782121..8b2ec55 100644 --- a/src/libs/Ideogram/Generated/Ideogram.Models.RemixImageRequestV3.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.Models.RemixImageRequestV3.g.cs @@ -80,6 +80,12 @@ public sealed partial class RemixImageRequestV3 [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Ideogram.JsonConverters.MagicPromptOptionJsonConverter))] public global::Ideogram.MagicPromptOption? MagicPrompt { get; set; } + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + [global::System.Text.Json.Serialization.JsonPropertyName("magic_prompt_system_prompt_config_id")] + public string? MagicPromptSystemPromptConfigId { get; set; } + /// /// Description of what to exclude from an image. Descriptions in the prompt take precedence
/// to descriptions in the negative prompt.
@@ -199,6 +205,9 @@ public sealed partial class RemixImageRequestV3 /// Determine if MagicPrompt should be used in generating the request or not.
/// Example: ON /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// /// /// Description of what to exclude from an image. Descriptions in the prompt take precedence
/// to descriptions in the negative prompt.
@@ -251,6 +260,7 @@ public RemixImageRequestV3( global::Ideogram.AspectRatioV3? aspectRatio, global::Ideogram.RenderingSpeed? renderingSpeed, global::Ideogram.MagicPromptOption? magicPrompt, + string? magicPromptSystemPromptConfigId, string? negativePrompt, int? numImages, global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette, @@ -271,6 +281,7 @@ public RemixImageRequestV3( this.AspectRatio = aspectRatio; this.RenderingSpeed = renderingSpeed; this.MagicPrompt = magicPrompt; + this.MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId; this.NegativePrompt = negativePrompt; this.NumImages = numImages; this.ColorPalette = colorPalette; diff --git a/src/libs/Ideogram/Generated/Ideogram.Models.RemoveBackgroundImageObject.Json.g.cs b/src/libs/Ideogram/Generated/Ideogram.Models.RemoveBackgroundImageObject.Json.g.cs new file mode 100644 index 0000000..fa4257c --- /dev/null +++ b/src/libs/Ideogram/Generated/Ideogram.Models.RemoveBackgroundImageObject.Json.g.cs @@ -0,0 +1,92 @@ +#nullable enable + +namespace Ideogram +{ + public sealed partial class RemoveBackgroundImageObject + { + /// + /// Serializes the current instance to a JSON string using the provided JsonSerializerContext. + /// + public string ToJson( + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Serialize( + this, + this.GetType(), + jsonSerializerContext); + } + + /// + /// Serializes the current instance to a JSON string using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public string ToJson( + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + return global::System.Text.Json.JsonSerializer.Serialize( + this, + jsonSerializerOptions); + } + + /// + /// Deserializes a JSON string using the provided JsonSerializerContext. + /// + public static global::Ideogram.RemoveBackgroundImageObject? FromJson( + string json, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + typeof(global::Ideogram.RemoveBackgroundImageObject), + jsonSerializerContext) as global::Ideogram.RemoveBackgroundImageObject; + } + + /// + /// Deserializes a JSON string using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public static global::Ideogram.RemoveBackgroundImageObject? FromJson( + string json, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + jsonSerializerOptions); + } + + /// + /// Deserializes a JSON stream using the provided JsonSerializerContext. + /// + public static async global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return (await global::System.Text.Json.JsonSerializer.DeserializeAsync( + jsonStream, + typeof(global::Ideogram.RemoveBackgroundImageObject), + jsonSerializerContext).ConfigureAwait(false)) as global::Ideogram.RemoveBackgroundImageObject; + } + + /// + /// Deserializes a JSON stream using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public static global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + return global::System.Text.Json.JsonSerializer.DeserializeAsync( + jsonStream, + jsonSerializerOptions); + } + } +} diff --git a/src/libs/Ideogram/Generated/Ideogram.Models.RemoveBackgroundImageObject.g.cs b/src/libs/Ideogram/Generated/Ideogram.Models.RemoveBackgroundImageObject.g.cs new file mode 100644 index 0000000..bab7afe --- /dev/null +++ b/src/libs/Ideogram/Generated/Ideogram.Models.RemoveBackgroundImageObject.g.cs @@ -0,0 +1,60 @@ + +#nullable enable + +namespace Ideogram +{ + /// + /// + /// + public sealed partial class RemoveBackgroundImageObject + { + /// + /// The direct link to the foreground image. Empty when the image fails safety checks.
+ /// Example: https://ideogram.ai/api/images/ephemeral/xtdZiqPwRxqY1Y7NExFmzB.png?exp=1743867804&sig=e13e12677633f646d8531a153d20e2d3698dca9ee7661ee5ba4f3b64e7ec3f89 + ///
+ /// https://ideogram.ai/api/images/ephemeral/xtdZiqPwRxqY1Y7NExFmzB.png?exp=1743867804&sig=e13e12677633f646d8531a153d20e2d3698dca9ee7661ee5ba4f3b64e7ec3f89 + [global::System.Text.Json.Serialization.JsonPropertyName("url")] + public string? Url { get; set; } + + /// + /// Whether the foreground image passes safety checks. If false, the url field will be empty. + /// + [global::System.Text.Json.Serialization.JsonPropertyName("is_image_safe")] + [global::System.Text.Json.Serialization.JsonRequired] + public required bool IsImageSafe { get; set; } + + /// + /// Additional properties that are not explicitly defined in the schema + /// + [global::System.Text.Json.Serialization.JsonExtensionData] + public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + + /// + /// Initializes a new instance of the class. + /// + /// + /// Whether the foreground image passes safety checks. If false, the url field will be empty. + /// + /// + /// The direct link to the foreground image. Empty when the image fails safety checks.
+ /// Example: https://ideogram.ai/api/images/ephemeral/xtdZiqPwRxqY1Y7NExFmzB.png?exp=1743867804&sig=e13e12677633f646d8531a153d20e2d3698dca9ee7661ee5ba4f3b64e7ec3f89 + /// +#if NET7_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] +#endif + public RemoveBackgroundImageObject( + bool isImageSafe, + string? url) + { + this.Url = url; + this.IsImageSafe = isImageSafe; + } + + /// + /// Initializes a new instance of the class. + /// + public RemoveBackgroundImageObject() + { + } + } +} \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.Models.RemoveBackgroundRequest.Json.g.cs b/src/libs/Ideogram/Generated/Ideogram.Models.RemoveBackgroundRequest.Json.g.cs new file mode 100644 index 0000000..e9176a9 --- /dev/null +++ b/src/libs/Ideogram/Generated/Ideogram.Models.RemoveBackgroundRequest.Json.g.cs @@ -0,0 +1,92 @@ +#nullable enable + +namespace Ideogram +{ + public sealed partial class RemoveBackgroundRequest + { + /// + /// Serializes the current instance to a JSON string using the provided JsonSerializerContext. + /// + public string ToJson( + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Serialize( + this, + this.GetType(), + jsonSerializerContext); + } + + /// + /// Serializes the current instance to a JSON string using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public string ToJson( + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + return global::System.Text.Json.JsonSerializer.Serialize( + this, + jsonSerializerOptions); + } + + /// + /// Deserializes a JSON string using the provided JsonSerializerContext. + /// + public static global::Ideogram.RemoveBackgroundRequest? FromJson( + string json, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + typeof(global::Ideogram.RemoveBackgroundRequest), + jsonSerializerContext) as global::Ideogram.RemoveBackgroundRequest; + } + + /// + /// Deserializes a JSON string using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public static global::Ideogram.RemoveBackgroundRequest? FromJson( + string json, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + jsonSerializerOptions); + } + + /// + /// Deserializes a JSON stream using the provided JsonSerializerContext. + /// + public static async global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return (await global::System.Text.Json.JsonSerializer.DeserializeAsync( + jsonStream, + typeof(global::Ideogram.RemoveBackgroundRequest), + jsonSerializerContext).ConfigureAwait(false)) as global::Ideogram.RemoveBackgroundRequest; + } + + /// + /// Deserializes a JSON stream using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public static global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + return global::System.Text.Json.JsonSerializer.DeserializeAsync( + jsonStream, + jsonSerializerOptions); + } + } +} diff --git a/src/libs/Ideogram/Generated/Ideogram.Models.RemoveBackgroundRequest.g.cs b/src/libs/Ideogram/Generated/Ideogram.Models.RemoveBackgroundRequest.g.cs new file mode 100644 index 0000000..aea67a4 --- /dev/null +++ b/src/libs/Ideogram/Generated/Ideogram.Models.RemoveBackgroundRequest.g.cs @@ -0,0 +1,58 @@ + +#nullable enable + +namespace Ideogram +{ + /// + /// + /// + public sealed partial class RemoveBackgroundRequest + { + /// + /// The image whose background is being removed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + [global::System.Text.Json.Serialization.JsonPropertyName("image")] + [global::System.Text.Json.Serialization.JsonRequired] + public required byte[] Image { get; set; } + + /// + /// The image whose background is being removed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + [global::System.Text.Json.Serialization.JsonPropertyName("imagename")] + [global::System.Text.Json.Serialization.JsonRequired] + public required string Imagename { get; set; } + + /// + /// Additional properties that are not explicitly defined in the schema + /// + [global::System.Text.Json.Serialization.JsonExtensionData] + public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + + /// + /// Initializes a new instance of the class. + /// + /// + /// The image whose background is being removed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The image whose background is being removed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// +#if NET7_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] +#endif + public RemoveBackgroundRequest( + byte[] image, + string imagename) + { + this.Image = image ?? throw new global::System.ArgumentNullException(nameof(image)); + this.Imagename = imagename ?? throw new global::System.ArgumentNullException(nameof(imagename)); + } + + /// + /// Initializes a new instance of the class. + /// + public RemoveBackgroundRequest() + { + } + } +} \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.Models.RemoveBackgroundResponse.Json.g.cs b/src/libs/Ideogram/Generated/Ideogram.Models.RemoveBackgroundResponse.Json.g.cs new file mode 100644 index 0000000..8449096 --- /dev/null +++ b/src/libs/Ideogram/Generated/Ideogram.Models.RemoveBackgroundResponse.Json.g.cs @@ -0,0 +1,92 @@ +#nullable enable + +namespace Ideogram +{ + public sealed partial class RemoveBackgroundResponse + { + /// + /// Serializes the current instance to a JSON string using the provided JsonSerializerContext. + /// + public string ToJson( + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Serialize( + this, + this.GetType(), + jsonSerializerContext); + } + + /// + /// Serializes the current instance to a JSON string using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public string ToJson( + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + return global::System.Text.Json.JsonSerializer.Serialize( + this, + jsonSerializerOptions); + } + + /// + /// Deserializes a JSON string using the provided JsonSerializerContext. + /// + public static global::Ideogram.RemoveBackgroundResponse? FromJson( + string json, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + typeof(global::Ideogram.RemoveBackgroundResponse), + jsonSerializerContext) as global::Ideogram.RemoveBackgroundResponse; + } + + /// + /// Deserializes a JSON string using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public static global::Ideogram.RemoveBackgroundResponse? FromJson( + string json, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + jsonSerializerOptions); + } + + /// + /// Deserializes a JSON stream using the provided JsonSerializerContext. + /// + public static async global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return (await global::System.Text.Json.JsonSerializer.DeserializeAsync( + jsonStream, + typeof(global::Ideogram.RemoveBackgroundResponse), + jsonSerializerContext).ConfigureAwait(false)) as global::Ideogram.RemoveBackgroundResponse; + } + + /// + /// Deserializes a JSON stream using the provided JsonSerializerOptions. + /// +#if NET8_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")] + [global::System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed and might need runtime code generation. Use System.Text.Json source generation for native AOT applications.")] +#endif + public static global::System.Threading.Tasks.ValueTask FromJsonStreamAsync( + global::System.IO.Stream jsonStream, + global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions = null) + { + return global::System.Text.Json.JsonSerializer.DeserializeAsync( + jsonStream, + jsonSerializerOptions); + } + } +} diff --git a/src/libs/Ideogram/Generated/Ideogram.Models.RemoveBackgroundResponse.g.cs b/src/libs/Ideogram/Generated/Ideogram.Models.RemoveBackgroundResponse.g.cs new file mode 100644 index 0000000..0144223 --- /dev/null +++ b/src/libs/Ideogram/Generated/Ideogram.Models.RemoveBackgroundResponse.g.cs @@ -0,0 +1,60 @@ + +#nullable enable + +namespace Ideogram +{ + /// + /// The response containing the foreground image with the background removed.
+ /// Image links are available for a limited period of time; if you would like to keep the image, you must download it.
+ /// Example: {"created":"2000-01-23T04:56:07\u002B00:00","data":[{"url":"https://ideogram.ai/api/images/ephemeral/xtdZiqPwRxqY1Y7NExFmzB.png?exp=1743867804\u0026sig=e13e12677633f646d8531a153d20e2d3698dca9ee7661ee5ba4f3b64e7ec3f89","is_image_safe":true}]} + ///
+ public sealed partial class RemoveBackgroundResponse + { + /// + /// The time the request was created. + /// + [global::System.Text.Json.Serialization.JsonPropertyName("created")] + [global::System.Text.Json.Serialization.JsonRequired] + public required global::System.DateTime Created { get; set; } + + /// + /// A list containing the single foreground image. The endpoint always returns exactly one entry. + /// + [global::System.Text.Json.Serialization.JsonPropertyName("data")] + [global::System.Text.Json.Serialization.JsonRequired] + public required global::System.Collections.Generic.IList Data { get; set; } + + /// + /// Additional properties that are not explicitly defined in the schema + /// + [global::System.Text.Json.Serialization.JsonExtensionData] + public global::System.Collections.Generic.IDictionary AdditionalProperties { get; set; } = new global::System.Collections.Generic.Dictionary(); + + /// + /// Initializes a new instance of the class. + /// + /// + /// The time the request was created. + /// + /// + /// A list containing the single foreground image. The endpoint always returns exactly one entry. + /// +#if NET7_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] +#endif + public RemoveBackgroundResponse( + global::System.DateTime created, + global::System.Collections.Generic.IList data) + { + this.Created = created; + this.Data = data ?? throw new global::System.ArgumentNullException(nameof(data)); + } + + /// + /// Initializes a new instance of the class. + /// + public RemoveBackgroundResponse() + { + } + } +} \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.Models.ReplaceBackgroundRequestV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.Models.ReplaceBackgroundRequestV3.g.cs index ef09ffb..3b67472 100644 --- a/src/libs/Ideogram/Generated/Ideogram.Models.ReplaceBackgroundRequestV3.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.Models.ReplaceBackgroundRequestV3.g.cs @@ -40,6 +40,12 @@ public sealed partial class ReplaceBackgroundRequestV3 [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Ideogram.JsonConverters.MagicPromptOptionJsonConverter))] public global::Ideogram.MagicPromptOption? MagicPrompt { get; set; } + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + [global::System.Text.Json.Serialization.JsonPropertyName("magic_prompt_system_prompt_config_id")] + public string? MagicPromptSystemPromptConfigId { get; set; } + /// /// The number of images to generate.
/// Default Value: 1 @@ -116,6 +122,9 @@ public sealed partial class ReplaceBackgroundRequestV3 /// Determine if MagicPrompt should be used in generating the request or not.
/// Example: ON /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// /// /// The number of images to generate.
/// Default Value: 1 @@ -150,6 +159,7 @@ public ReplaceBackgroundRequestV3( string imagename, string prompt, global::Ideogram.MagicPromptOption? magicPrompt, + string? magicPromptSystemPromptConfigId, int? numImages, int? seed, global::Ideogram.RenderingSpeed? renderingSpeed, @@ -162,6 +172,7 @@ public ReplaceBackgroundRequestV3( this.Imagename = imagename ?? throw new global::System.ArgumentNullException(nameof(imagename)); this.Prompt = prompt ?? throw new global::System.ArgumentNullException(nameof(prompt)); this.MagicPrompt = magicPrompt; + this.MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId; this.NumImages = numImages; this.Seed = seed; this.RenderingSpeed = renderingSpeed; diff --git a/src/libs/Ideogram/Generated/Ideogram.Models.ResolutionV4.g.cs b/src/libs/Ideogram/Generated/Ideogram.Models.ResolutionV4.g.cs index 24dd3a4..c760fff 100644 --- a/src/libs/Ideogram/Generated/Ideogram.Models.ResolutionV4.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.Models.ResolutionV4.g.cs @@ -48,6 +48,10 @@ public enum ResolutionV4 /// /// /// + x1152x2944, + /// + /// + /// x1152x704, /// /// @@ -76,10 +80,18 @@ public enum ResolutionV4 /// /// /// + x1248x3328, + /// + /// + /// x1248x832, /// /// /// + x1280x3072, + /// + /// + /// x1280x704, /// /// @@ -92,6 +104,10 @@ public enum ResolutionV4 /// /// /// + x1296x3168, + /// + /// + /// x1312x736, /// /// @@ -120,6 +136,14 @@ public enum ResolutionV4 /// /// /// + x1440x2560, + /// + /// + /// + x1440x2880, + /// + /// + /// x1472x576, /// /// @@ -144,6 +168,66 @@ public enum ResolutionV4 /// /// /// + x1600x2560, + /// + /// + /// + x1664x2496, + /// + /// + /// + x1728x2304, + /// + /// + /// + x1792x2240, + /// + /// + /// + x2048x2048, + /// + /// + /// + x2240x1792, + /// + /// + /// + x2304x1728, + /// + /// + /// + x2496x1664, + /// + /// + /// + x2560x1440, + /// + /// + /// + x2560x1600, + /// + /// + /// + x2880x1440, + /// + /// + /// + x2944x1152, + /// + /// + /// + x3072x1280, + /// + /// + /// + x3168x1296, + /// + /// + /// + x3328x1248, + /// + /// + /// x512x1536, /// /// @@ -312,6 +396,7 @@ public static string ToValueString(this ResolutionV4 value) ResolutionV4.x1088x896 => "1088x896", ResolutionV4.x1088x960 => "1088x960", ResolutionV4.x1120x896 => "1120x896", + ResolutionV4.x1152x2944 => "1152x2944", ResolutionV4.x1152x704 => "1152x704", ResolutionV4.x1152x832 => "1152x832", ResolutionV4.x1152x864 => "1152x864", @@ -319,10 +404,13 @@ public static string ToValueString(this ResolutionV4 value) ResolutionV4.x1216x704 => "1216x704", ResolutionV4.x1216x768 => "1216x768", ResolutionV4.x1216x832 => "1216x832", + ResolutionV4.x1248x3328 => "1248x3328", ResolutionV4.x1248x832 => "1248x832", + ResolutionV4.x1280x3072 => "1280x3072", ResolutionV4.x1280x704 => "1280x704", ResolutionV4.x1280x768 => "1280x768", ResolutionV4.x1280x800 => "1280x800", + ResolutionV4.x1296x3168 => "1296x3168", ResolutionV4.x1312x736 => "1312x736", ResolutionV4.x1344x640 => "1344x640", ResolutionV4.x1344x704 => "1344x704", @@ -330,12 +418,29 @@ public static string ToValueString(this ResolutionV4 value) ResolutionV4.x1408x576 => "1408x576", ResolutionV4.x1408x640 => "1408x640", ResolutionV4.x1408x704 => "1408x704", + ResolutionV4.x1440x2560 => "1440x2560", + ResolutionV4.x1440x2880 => "1440x2880", ResolutionV4.x1472x576 => "1472x576", ResolutionV4.x1472x640 => "1472x640", ResolutionV4.x1472x704 => "1472x704", ResolutionV4.x1536x512 => "1536x512", ResolutionV4.x1536x576 => "1536x576", ResolutionV4.x1536x640 => "1536x640", + ResolutionV4.x1600x2560 => "1600x2560", + ResolutionV4.x1664x2496 => "1664x2496", + ResolutionV4.x1728x2304 => "1728x2304", + ResolutionV4.x1792x2240 => "1792x2240", + ResolutionV4.x2048x2048 => "2048x2048", + ResolutionV4.x2240x1792 => "2240x1792", + ResolutionV4.x2304x1728 => "2304x1728", + ResolutionV4.x2496x1664 => "2496x1664", + ResolutionV4.x2560x1440 => "2560x1440", + ResolutionV4.x2560x1600 => "2560x1600", + ResolutionV4.x2880x1440 => "2880x1440", + ResolutionV4.x2944x1152 => "2944x1152", + ResolutionV4.x3072x1280 => "3072x1280", + ResolutionV4.x3168x1296 => "3168x1296", + ResolutionV4.x3328x1248 => "3328x1248", ResolutionV4.x512x1536 => "512x1536", ResolutionV4.x512x512 => "512x512", ResolutionV4.x576x1408 => "576x1408", @@ -392,6 +497,7 @@ public static string ToValueString(this ResolutionV4 value) "1088x896" => ResolutionV4.x1088x896, "1088x960" => ResolutionV4.x1088x960, "1120x896" => ResolutionV4.x1120x896, + "1152x2944" => ResolutionV4.x1152x2944, "1152x704" => ResolutionV4.x1152x704, "1152x832" => ResolutionV4.x1152x832, "1152x864" => ResolutionV4.x1152x864, @@ -399,10 +505,13 @@ public static string ToValueString(this ResolutionV4 value) "1216x704" => ResolutionV4.x1216x704, "1216x768" => ResolutionV4.x1216x768, "1216x832" => ResolutionV4.x1216x832, + "1248x3328" => ResolutionV4.x1248x3328, "1248x832" => ResolutionV4.x1248x832, + "1280x3072" => ResolutionV4.x1280x3072, "1280x704" => ResolutionV4.x1280x704, "1280x768" => ResolutionV4.x1280x768, "1280x800" => ResolutionV4.x1280x800, + "1296x3168" => ResolutionV4.x1296x3168, "1312x736" => ResolutionV4.x1312x736, "1344x640" => ResolutionV4.x1344x640, "1344x704" => ResolutionV4.x1344x704, @@ -410,12 +519,29 @@ public static string ToValueString(this ResolutionV4 value) "1408x576" => ResolutionV4.x1408x576, "1408x640" => ResolutionV4.x1408x640, "1408x704" => ResolutionV4.x1408x704, + "1440x2560" => ResolutionV4.x1440x2560, + "1440x2880" => ResolutionV4.x1440x2880, "1472x576" => ResolutionV4.x1472x576, "1472x640" => ResolutionV4.x1472x640, "1472x704" => ResolutionV4.x1472x704, "1536x512" => ResolutionV4.x1536x512, "1536x576" => ResolutionV4.x1536x576, "1536x640" => ResolutionV4.x1536x640, + "1600x2560" => ResolutionV4.x1600x2560, + "1664x2496" => ResolutionV4.x1664x2496, + "1728x2304" => ResolutionV4.x1728x2304, + "1792x2240" => ResolutionV4.x1792x2240, + "2048x2048" => ResolutionV4.x2048x2048, + "2240x1792" => ResolutionV4.x2240x1792, + "2304x1728" => ResolutionV4.x2304x1728, + "2496x1664" => ResolutionV4.x2496x1664, + "2560x1440" => ResolutionV4.x2560x1440, + "2560x1600" => ResolutionV4.x2560x1600, + "2880x1440" => ResolutionV4.x2880x1440, + "2944x1152" => ResolutionV4.x2944x1152, + "3072x1280" => ResolutionV4.x3072x1280, + "3168x1296" => ResolutionV4.x3168x1296, + "3328x1248" => ResolutionV4.x3328x1248, "512x1536" => ResolutionV4.x512x1536, "512x512" => ResolutionV4.x512x512, "576x1408" => ResolutionV4.x576x1408, diff --git a/src/libs/Ideogram/Generated/Ideogram.Models.SamplingRequestParams.g.cs b/src/libs/Ideogram/Generated/Ideogram.Models.SamplingRequestParams.g.cs index f7a8b58..e8f708e 100644 --- a/src/libs/Ideogram/Generated/Ideogram.Models.SamplingRequestParams.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.Models.SamplingRequestParams.g.cs @@ -4,7 +4,7 @@ namespace Ideogram { /// - /// Example: {"aspect_ratio":"1x1","style_type":"GENERAL","magic_prompt_version":"V_0","seed":12345,"negative_prompt":"brush strokes, painting","magic_prompt_option":"ON","model":"V_2_TURBO","resolution":"1280x800","num_images":1,"color_palette":{"name":"PASTEL"}} + /// Example: {"magic_prompt_system_prompt_config_id":"magic_prompt_system_prompt_config_id","aspect_ratio":"1x1","style_type":"GENERAL","magic_prompt_version":"V_0","seed":12345,"negative_prompt":"brush strokes, painting","magic_prompt_option":"ON","model":"V_2_TURBO","resolution":"1280x800","num_images":1,"color_palette":{"name":"PASTEL"}} /// public sealed partial class SamplingRequestParams { @@ -35,6 +35,12 @@ public sealed partial class SamplingRequestParams [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Ideogram.JsonConverters.MagicPromptOptionJsonConverter))] public global::Ideogram.MagicPromptOption? MagicPromptOption { get; set; } + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + [global::System.Text.Json.Serialization.JsonPropertyName("magic_prompt_system_prompt_config_id")] + public string? MagicPromptSystemPromptConfigId { get; set; } + /// /// The magic prompt version to use when magic prompt option is set to AUTO or ON.
/// Example: V_0 @@ -114,6 +120,9 @@ public sealed partial class SamplingRequestParams /// Determine if MagicPrompt should be used in generating the request or not.
/// Example: ON /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// /// /// The magic prompt version to use when magic prompt option is set to AUTO or ON.
/// Example: V_0 @@ -149,6 +158,7 @@ public SamplingRequestParams( global::Ideogram.AspectRatioV3? aspectRatio, global::Ideogram.ModelEnum? model, global::Ideogram.MagicPromptOption? magicPromptOption, + string? magicPromptSystemPromptConfigId, global::Ideogram.MagicPromptVersionEnum? magicPromptVersion, int? seed, global::Ideogram.StyleTypeV3? styleType, @@ -160,6 +170,7 @@ public SamplingRequestParams( this.AspectRatio = aspectRatio; this.Model = model; this.MagicPromptOption = magicPromptOption; + this.MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId; this.MagicPromptVersion = magicPromptVersion; this.Seed = seed; this.StyleType = styleType; diff --git a/src/libs/Ideogram/Generated/Ideogram.Models.TextContainerV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.Models.TextContainerV3.g.cs index d10fabe..6e58111 100644 --- a/src/libs/Ideogram/Generated/Ideogram.Models.TextContainerV3.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.Models.TextContainerV3.g.cs @@ -5,7 +5,7 @@ namespace Ideogram { /// /// A spatial grouping of related text items that form a cohesive visual unit (e.g., a title group, a list, a card).
- /// Example: {"id":"id","items":[{"font_candidates":["font_candidates","font_candidates"],"spans":[{"color":"#212121","text":"text","font_fx":["bold","italic"]},{"color":"#212121","text":"text","font_fx":["bold","italic"]}],"font_size":5,"glyph_type":"bullet","line_height":2.302136,"x":0,"width":1,"style_class":"body","y":6,"angle":0,"alignment":"center","font_file":"font_file","height":5},{"font_candidates":["font_candidates","font_candidates"],"spans":[{"color":"#212121","text":"text","font_fx":["bold","italic"]},{"color":"#212121","text":"text","font_fx":["bold","italic"]}],"font_size":5,"glyph_type":"bullet","line_height":2.302136,"x":0,"width":1,"style_class":"body","y":6,"angle":0,"alignment":"center","font_file":"font_file","height":5}]} + /// Example: {"id":"id","items":[{"font_candidates":["font_candidates","font_candidates"],"spans":[{"color":"#212121","text":"text","font_fx":["bold","italic"]},{"color":"#212121","text":"text","font_fx":["bold","italic"]}],"font_size":5,"vertical_alignment":"top","text_transform":"none","glyph_type":"bullet","line_height":2.302136,"x":0,"width":1,"style_class":"body","y":6,"angle":0,"alignment":"center","font_file":"font_file","letter_spacing":7.0614014,"drop_shadows":[{"color":"color","blur":0.2027123,"offset_x":9.301444,"offset_y":3.6160767},{"color":"color","blur":0.2027123,"offset_x":9.301444,"offset_y":3.6160767}],"height":5},{"font_candidates":["font_candidates","font_candidates"],"spans":[{"color":"#212121","text":"text","font_fx":["bold","italic"]},{"color":"#212121","text":"text","font_fx":["bold","italic"]}],"font_size":5,"vertical_alignment":"top","text_transform":"none","glyph_type":"bullet","line_height":2.302136,"x":0,"width":1,"style_class":"body","y":6,"angle":0,"alignment":"center","font_file":"font_file","letter_spacing":7.0614014,"drop_shadows":[{"color":"color","blur":0.2027123,"offset_x":9.301444,"offset_y":3.6160767},{"color":"color","blur":0.2027123,"offset_x":9.301444,"offset_y":3.6160767}],"height":5}]} ///
public sealed partial class TextContainerV3 { diff --git a/src/libs/Ideogram/Generated/Ideogram.Models.TextItemV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.Models.TextItemV3.g.cs index 30dda9c..901ca49 100644 --- a/src/libs/Ideogram/Generated/Ideogram.Models.TextItemV3.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.Models.TextItemV3.g.cs @@ -5,7 +5,7 @@ namespace Ideogram { /// /// A single text block within a container, representing one logical unit of text (e.g., a headline, a paragraph, a list entry).
- /// Example: {"font_candidates":["font_candidates","font_candidates"],"spans":[{"color":"#212121","text":"text","font_fx":["bold","italic"]},{"color":"#212121","text":"text","font_fx":["bold","italic"]}],"font_size":5,"glyph_type":"bullet","line_height":2.302136,"x":0,"width":1,"style_class":"body","y":6,"angle":0,"alignment":"center","font_file":"font_file","height":5} + /// Example: {"font_candidates":["font_candidates","font_candidates"],"spans":[{"color":"#212121","text":"text","font_fx":["bold","italic"]},{"color":"#212121","text":"text","font_fx":["bold","italic"]}],"font_size":5,"vertical_alignment":"top","text_transform":"none","glyph_type":"bullet","line_height":2.302136,"x":0,"width":1,"style_class":"body","y":6,"angle":0,"alignment":"center","font_file":"font_file","letter_spacing":7.0614014,"drop_shadows":[{"color":"color","blur":0.2027123,"offset_x":9.301444,"offset_y":3.6160767},{"color":"color","blur":0.2027123,"offset_x":9.301444,"offset_y":3.6160767}],"height":5} ///
public sealed partial class TextItemV3 { @@ -98,6 +98,35 @@ public sealed partial class TextItemV3 [global::System.Text.Json.Serialization.JsonPropertyName("line_height")] public float? LineHeight { get; set; } + /// + /// Letter spacing in em units (e.g. 0.05 = 5% of em). V4 vector-text only. + /// + [global::System.Text.Json.Serialization.JsonPropertyName("letter_spacing")] + public float? LetterSpacing { get; set; } + + /// + /// Case folding applied at render time. V4 vector-text only. + /// + [global::System.Text.Json.Serialization.JsonPropertyName("text_transform")] + [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Ideogram.JsonConverters.TextItemV3TextTransformJsonConverter))] + public global::Ideogram.TextItemV3TextTransform? TextTransform { get; set; } + + /// + /// Vertical anchor (top|middle|bottom) for the rendered text within
+ /// its bounding box. Maps to SVG `dominant-baseline`. V4 vector-text
+ /// only. Distinct from horizontal `alignment` (left|center|right). + ///
+ [global::System.Text.Json.Serialization.JsonPropertyName("vertical_alignment")] + [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Ideogram.JsonConverters.TextItemV3VerticalAlignmentJsonConverter))] + public global::Ideogram.TextItemV3VerticalAlignment? VerticalAlignment { get; set; } + + /// + /// Stacked drop shadows, composed back-to-front. Phase-1 ships at
+ /// most one entry; phase-2 unlocks multi-stack. V4 vector-text only. + ///
+ [global::System.Text.Json.Serialization.JsonPropertyName("drop_shadows")] + public global::System.Collections.Generic.IList? DropShadows { get; set; } + /// /// Ordered list of text spans. Concatenating span text values produces the full item text. /// @@ -157,6 +186,21 @@ public sealed partial class TextItemV3 /// /// The line height multiplier (e.g., 1.2). Null for non-editable items. /// + /// + /// Letter spacing in em units (e.g. 0.05 = 5% of em). V4 vector-text only. + /// + /// + /// Case folding applied at render time. V4 vector-text only. + /// + /// + /// Vertical anchor (top|middle|bottom) for the rendered text within
+ /// its bounding box. Maps to SVG `dominant-baseline`. V4 vector-text
+ /// only. Distinct from horizontal `alignment` (left|center|right). + /// + /// + /// Stacked drop shadows, composed back-to-front. Phase-1 ships at
+ /// most one entry; phase-2 unlocks multi-stack. V4 vector-text only. + /// #if NET7_0_OR_GREATER [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] #endif @@ -173,7 +217,11 @@ public TextItemV3( string? fontFile, global::System.Collections.Generic.IList? fontCandidates, int? fontSize, - float? lineHeight) + float? lineHeight, + float? letterSpacing, + global::Ideogram.TextItemV3TextTransform? textTransform, + global::Ideogram.TextItemV3VerticalAlignment? verticalAlignment, + global::System.Collections.Generic.IList? dropShadows) { this.X = x; this.Y = y; @@ -187,6 +235,10 @@ public TextItemV3( this.FontCandidates = fontCandidates; this.FontSize = fontSize; this.LineHeight = lineHeight; + this.LetterSpacing = letterSpacing; + this.TextTransform = textTransform; + this.VerticalAlignment = verticalAlignment; + this.DropShadows = dropShadows; this.Spans = spans ?? throw new global::System.ArgumentNullException(nameof(spans)); } diff --git a/src/libs/Ideogram/Generated/Ideogram.Models.TextItemV3TextTransform.g.cs b/src/libs/Ideogram/Generated/Ideogram.Models.TextItemV3TextTransform.g.cs new file mode 100644 index 0000000..95ada3c --- /dev/null +++ b/src/libs/Ideogram/Generated/Ideogram.Models.TextItemV3TextTransform.g.cs @@ -0,0 +1,57 @@ + +#nullable enable + +namespace Ideogram +{ + /// + /// Case folding applied at render time. V4 vector-text only. + /// + public enum TextItemV3TextTransform + { + /// + /// + /// + Lowercase, + /// + /// + /// + None, + /// + /// + /// + Uppercase, + } + + /// + /// Enum extensions to do fast conversions without the reflection. + /// + public static class TextItemV3TextTransformExtensions + { + /// + /// Converts an enum to a string. + /// + public static string ToValueString(this TextItemV3TextTransform value) + { + return value switch + { + TextItemV3TextTransform.Lowercase => "lowercase", + TextItemV3TextTransform.None => "none", + TextItemV3TextTransform.Uppercase => "uppercase", + _ => throw new global::System.ArgumentOutOfRangeException(nameof(value), value, null), + }; + } + /// + /// Converts an string to a enum. + /// + public static TextItemV3TextTransform? ToEnum(string value) + { + return value switch + { + "lowercase" => TextItemV3TextTransform.Lowercase, + "none" => TextItemV3TextTransform.None, + "uppercase" => TextItemV3TextTransform.Uppercase, + _ => null, + }; + } + } +} \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.Models.TextItemV3VerticalAlignment.g.cs b/src/libs/Ideogram/Generated/Ideogram.Models.TextItemV3VerticalAlignment.g.cs new file mode 100644 index 0000000..5992d1a --- /dev/null +++ b/src/libs/Ideogram/Generated/Ideogram.Models.TextItemV3VerticalAlignment.g.cs @@ -0,0 +1,59 @@ + +#nullable enable + +namespace Ideogram +{ + /// + /// Vertical anchor (top|middle|bottom) for the rendered text within
+ /// its bounding box. Maps to SVG `dominant-baseline`. V4 vector-text
+ /// only. Distinct from horizontal `alignment` (left|center|right). + ///
+ public enum TextItemV3VerticalAlignment + { + /// + /// + /// + Bottom, + /// + /// + /// + Middle, + /// + /// + /// + Top, + } + + /// + /// Enum extensions to do fast conversions without the reflection. + /// + public static class TextItemV3VerticalAlignmentExtensions + { + /// + /// Converts an enum to a string. + /// + public static string ToValueString(this TextItemV3VerticalAlignment value) + { + return value switch + { + TextItemV3VerticalAlignment.Bottom => "bottom", + TextItemV3VerticalAlignment.Middle => "middle", + TextItemV3VerticalAlignment.Top => "top", + _ => throw new global::System.ArgumentOutOfRangeException(nameof(value), value, null), + }; + } + /// + /// Converts an string to a enum. + /// + public static TextItemV3VerticalAlignment? ToEnum(string value) + { + return value switch + { + "bottom" => TextItemV3VerticalAlignment.Bottom, + "middle" => TextItemV3VerticalAlignment.Middle, + "top" => TextItemV3VerticalAlignment.Top, + _ => null, + }; + } + } +} \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.Models.ToolUsage.g.cs b/src/libs/Ideogram/Generated/Ideogram.Models.ToolUsage.g.cs index 60a3aec..ab8055c 100644 --- a/src/libs/Ideogram/Generated/Ideogram.Models.ToolUsage.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.Models.ToolUsage.g.cs @@ -61,6 +61,7 @@ public sealed partial class ToolUsage /// - V_3_0: Model 3.0 March 26
/// - V_3_1: Model 3.0 Latest
/// - V_4_0: Model 4.0
+ /// - V_4_D: Model 4.0 Layered Design (vector-text path; gated by the access_to_v4d feature flag)
/// - AUTO: Automatically select the best model version based on the request.
/// Example: V_0_3 ///
@@ -107,6 +108,7 @@ public sealed partial class ToolUsage /// - V_3_0: Model 3.0 March 26
/// - V_3_1: Model 3.0 Latest
/// - V_4_0: Model 4.0
+ /// - V_4_D: Model 4.0 Layered Design (vector-text path; gated by the access_to_v4d feature flag)
/// - AUTO: Automatically select the best model version based on the request.
/// Example: V_0_3 /// diff --git a/src/libs/Ideogram/Generated/Ideogram.Models.TryOnRequestV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.Models.TryOnRequestV3.g.cs index 0518777..f64e1c8 100644 --- a/src/libs/Ideogram/Generated/Ideogram.Models.TryOnRequestV3.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.Models.TryOnRequestV3.g.cs @@ -40,6 +40,12 @@ public sealed partial class TryOnRequestV3 [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Ideogram.JsonConverters.MagicPromptOptionJsonConverter))] public global::Ideogram.MagicPromptOption? MagicPrompt { get; set; } + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + [global::System.Text.Json.Serialization.JsonPropertyName("magic_prompt_system_prompt_config_id")] + public string? MagicPromptSystemPromptConfigId { get; set; } + /// /// The number of images to generate.
/// Default Value: 1 @@ -116,6 +122,9 @@ public sealed partial class TryOnRequestV3 /// Determine if MagicPrompt should be used in generating the request or not.
/// Example: ON /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// /// /// The number of images to generate.
/// Default Value: 1 @@ -146,6 +155,7 @@ public TryOnRequestV3( global::System.Collections.Generic.IList productReferenceImages, string? prompt, global::Ideogram.MagicPromptOption? magicPrompt, + string? magicPromptSystemPromptConfigId, int? numImages, int? seed, global::Ideogram.RenderingSpeed? renderingSpeed, @@ -156,6 +166,7 @@ public TryOnRequestV3( this.Imagename = imagename ?? throw new global::System.ArgumentNullException(nameof(imagename)); this.Prompt = prompt; this.MagicPrompt = magicPrompt; + this.MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId; this.NumImages = numImages; this.Seed = seed; this.RenderingSpeed = renderingSpeed; diff --git a/src/libs/Ideogram/Generated/Ideogram.Models.UpscaleInitialImageRequest.g.cs b/src/libs/Ideogram/Generated/Ideogram.Models.UpscaleInitialImageRequest.g.cs index 3cd98bb..beff4e8 100644 --- a/src/libs/Ideogram/Generated/Ideogram.Models.UpscaleInitialImageRequest.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.Models.UpscaleInitialImageRequest.g.cs @@ -41,6 +41,12 @@ public sealed partial class UpscaleInitialImageRequest [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Ideogram.JsonConverters.MagicPromptOptionJsonConverter))] public global::Ideogram.MagicPromptOption? MagicPromptOption { get; set; } + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + [global::System.Text.Json.Serialization.JsonPropertyName("magic_prompt_system_prompt_config_id")] + public string? MagicPromptSystemPromptConfigId { get; set; } + /// /// The magic prompt version to use when magic prompt option is set to AUTO or ON.
/// Example: V_0 @@ -90,6 +96,9 @@ public sealed partial class UpscaleInitialImageRequest /// Determine if MagicPrompt should be used in generating the request or not.
/// Example: ON /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// /// /// The magic prompt version to use when magic prompt option is set to AUTO or ON.
/// Example: V_0 @@ -110,6 +119,7 @@ public UpscaleInitialImageRequest( int? resemblance, int? detail, global::Ideogram.MagicPromptOption? magicPromptOption, + string? magicPromptSystemPromptConfigId, global::Ideogram.MagicPromptVersionEnum? magicPromptVersion, int? numImages, int? seed) @@ -118,6 +128,7 @@ public UpscaleInitialImageRequest( this.Resemblance = resemblance; this.Detail = detail; this.MagicPromptOption = magicPromptOption; + this.MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId; this.MagicPromptVersion = magicPromptVersion; this.NumImages = numImages; this.Seed = seed; diff --git a/src/libs/Ideogram/Generated/Ideogram.Models.V1EditImagesRequest.g.cs b/src/libs/Ideogram/Generated/Ideogram.Models.V1EditImagesRequest.g.cs index 64369e8..1299a84 100644 --- a/src/libs/Ideogram/Generated/Ideogram.Models.V1EditImagesRequest.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.Models.V1EditImagesRequest.g.cs @@ -53,6 +53,12 @@ public sealed partial class V1EditImagesRequest [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Ideogram.JsonConverters.MagicPromptOptionJsonConverter))] public global::Ideogram.MagicPromptOption? MagicPrompt { get; set; } + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// + [global::System.Text.Json.Serialization.JsonPropertyName("magic_prompt_system_prompt_config_id")] + public string? MagicPromptSystemPromptConfigId { get; set; } + /// /// The resolutions supported for Ideogram 3.0.
/// Example: 1280x800 @@ -107,6 +113,9 @@ public sealed partial class V1EditImagesRequest /// Determine if MagicPrompt should be used in generating the request or not.
/// Example: ON /// + /// + /// A base64url-encoded magic prompt system prompt config ID to use for this request. + /// /// /// The resolutions supported for Ideogram 3.0.
/// Example: 1280x800 @@ -128,6 +137,7 @@ public V1EditImagesRequest( int? numImages, int? seed, global::Ideogram.MagicPromptOption? magicPrompt, + string? magicPromptSystemPromptConfigId, global::Ideogram.ResolutionV3? resolution, global::Ideogram.AspectRatioV3? aspectRatio, bool? transparentBackground) @@ -138,6 +148,7 @@ public V1EditImagesRequest( this.NumImages = numImages; this.Seed = seed; this.MagicPrompt = magicPrompt; + this.MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId; this.Resolution = resolution; this.AspectRatio = aspectRatio; this.TransparentBackground = transparentBackground; diff --git a/src/libs/Ideogram/Generated/Ideogram.ModelsClient.GetCustomModel.g.cs b/src/libs/Ideogram/Generated/Ideogram.ModelsClient.GetCustomModel.g.cs index 1e33076..3b815e4 100644 --- a/src/libs/Ideogram/Generated/Ideogram.ModelsClient.GetCustomModel.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.ModelsClient.GetCustomModel.g.cs @@ -53,6 +53,27 @@ partial void ProcessGetCustomModelResponseContent( string modelId, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetCustomModelAsResponseAsync( + modelId: modelId, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Get model details
+ /// Get detailed information about a specific custom model. The user must either own the model or the model must be shared with the user's organization via the model registry. Returns 404 if the model is not found or not accessible. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> GetCustomModelAsResponseAsync( + string modelId, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( client: HttpClient); @@ -82,6 +103,7 @@ partial void ProcessGetCustomModelResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: $"/models/{modelId}", baseUri: HttpClient.BaseAddress); @@ -155,6 +177,8 @@ partial void ProcessGetCustomModelResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -165,6 +189,11 @@ partial void ProcessGetCustomModelResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -182,6 +211,8 @@ partial void ProcessGetCustomModelResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -191,8 +222,7 @@ partial void ProcessGetCustomModelResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -201,6 +231,11 @@ partial void ProcessGetCustomModelResponseContent( __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -217,14 +252,15 @@ partial void ProcessGetCustomModelResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -264,6 +300,8 @@ partial void ProcessGetCustomModelResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -284,6 +322,8 @@ partial void ProcessGetCustomModelResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -374,9 +414,13 @@ partial void ProcessGetCustomModelResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.GetModelResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.GetModelResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -404,9 +448,13 @@ partial void ProcessGetCustomModelResponseContent( #endif ).ConfigureAwait(false); - return - await global::Ideogram.GetModelResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.GetModelResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/Ideogram/Generated/Ideogram.ModelsClient.ListCustomModels.g.cs b/src/libs/Ideogram/Generated/Ideogram.ModelsClient.ListCustomModels.g.cs index c26438b..60805cb 100644 --- a/src/libs/Ideogram/Generated/Ideogram.ModelsClient.ListCustomModels.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.ModelsClient.ListCustomModels.g.cs @@ -57,6 +57,30 @@ partial void ProcessListCustomModelsResponseContent( global::System.Collections.Generic.IList? status = default, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await ListCustomModelsAsResponseAsync( + scope: scope, + status: status, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// List models
+ /// Lists custom models for the authenticated user. Use the `scope` parameter to control which models are returned. If omitted, returns both owned models and models shared with the user's organization via the model registry. `owned` returns only models created by the user. `shared` returns only models shared via the model registry, excluding the user's own models. + ///
+ /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> ListCustomModelsAsResponseAsync( + global::Ideogram.ListCustomModelsScope? scope = default, + global::System.Collections.Generic.IList? status = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( client: HttpClient); @@ -87,12 +111,13 @@ partial void ProcessListCustomModelsResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/models", - baseUri: HttpClient.BaseAddress); + baseUri: HttpClient.BaseAddress); __pathBuilder .AddOptionalParameter("scope", scope?.ToValueString()) - .AddOptionalParameter("status", status, selector: static x => x.ToValueString(), delimiter: ",", explode: true) + .AddOptionalParameter("status", status, selector: static x => x.ToValueString(), delimiter: ",", explode: true) ; var __path = __pathBuilder.ToString(); __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( @@ -165,6 +190,8 @@ partial void ProcessListCustomModelsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -175,6 +202,11 @@ partial void ProcessListCustomModelsResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -192,6 +224,8 @@ partial void ProcessListCustomModelsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -201,8 +235,7 @@ partial void ProcessListCustomModelsResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -211,6 +244,11 @@ partial void ProcessListCustomModelsResponseContent( __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -227,14 +265,15 @@ partial void ProcessListCustomModelsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -274,6 +313,8 @@ partial void ProcessListCustomModelsResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -294,6 +335,8 @@ partial void ProcessListCustomModelsResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -351,9 +394,13 @@ partial void ProcessListCustomModelsResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.ListModelsResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.ListModelsResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -381,9 +428,13 @@ partial void ProcessListCustomModelsResponseContent( #endif ).ConfigureAwait(false); - return - await global::Ideogram.ListModelsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.ListModelsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/Ideogram/Generated/Ideogram.ModelsClient.TrainModelV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.ModelsClient.TrainModelV3.g.cs index c039b63..de08a9d 100644 --- a/src/libs/Ideogram/Generated/Ideogram.ModelsClient.TrainModelV3.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.ModelsClient.TrainModelV3.g.cs @@ -51,6 +51,29 @@ partial void ProcessTrainModelV3ResponseContent( /// public async global::System.Threading.Tasks.Task TrainModelV3Async( + global::Ideogram.TrainModelV3Request request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await TrainModelV3AsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Train a custom Ideogram v3 model
+ /// Start training a custom Ideogram v3 model from a dataset using default hyperparameters. The dataset must contain at least 15 images and a maximum of 100 images. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> TrainModelV3AsResponseAsync( + global::Ideogram.TrainModelV3Request request, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) @@ -85,6 +108,7 @@ partial void ProcessTrainModelV3ResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/v1/ideogram-v3/train-model", baseUri: HttpClient.BaseAddress); @@ -164,6 +188,8 @@ partial void ProcessTrainModelV3ResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -174,6 +200,11 @@ partial void ProcessTrainModelV3ResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -191,6 +222,8 @@ partial void ProcessTrainModelV3ResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -200,8 +233,7 @@ partial void ProcessTrainModelV3ResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -210,6 +242,11 @@ partial void ProcessTrainModelV3ResponseContent( __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -226,14 +263,15 @@ partial void ProcessTrainModelV3ResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -273,6 +311,8 @@ partial void ProcessTrainModelV3ResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -293,6 +333,8 @@ partial void ProcessTrainModelV3ResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -416,9 +458,13 @@ partial void ProcessTrainModelV3ResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.TrainDatasetModelResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.TrainDatasetModelResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -446,9 +492,13 @@ partial void ProcessTrainModelV3ResponseContent( #endif ).ConfigureAwait(false); - return - await global::Ideogram.TrainDatasetModelResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.TrainDatasetModelResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/Ideogram/Generated/Ideogram.ModelsClient.TrainModelV3Advanced.g.cs b/src/libs/Ideogram/Generated/Ideogram.ModelsClient.TrainModelV3Advanced.g.cs index 109e95e..ee142ba 100644 --- a/src/libs/Ideogram/Generated/Ideogram.ModelsClient.TrainModelV3Advanced.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.ModelsClient.TrainModelV3Advanced.g.cs @@ -51,6 +51,29 @@ partial void ProcessTrainModelV3AdvancedResponseContent( /// public async global::System.Threading.Tasks.Task TrainModelV3AdvancedAsync( + global::Ideogram.TrainModelV3AdvancedRequest request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await TrainModelV3AdvancedAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Train a custom Ideogram v3 model with advanced hyperparameters
+ /// Start training a custom Ideogram v3 model from a dataset with caller-supplied hyperparameters (training steps, LoRA rank, EMA decay, learning rate). All hyperparameters are optional and fall back to defaults when omitted. The dataset must contain at least 15 images and a maximum of 100 images. Returns the model ID and training status. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> TrainModelV3AdvancedAsResponseAsync( + global::Ideogram.TrainModelV3AdvancedRequest request, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) @@ -85,6 +108,7 @@ partial void ProcessTrainModelV3AdvancedResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/v1/ideogram-v3/train-model-advanced", baseUri: HttpClient.BaseAddress); @@ -164,6 +188,8 @@ partial void ProcessTrainModelV3AdvancedResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -174,6 +200,11 @@ partial void ProcessTrainModelV3AdvancedResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -191,6 +222,8 @@ partial void ProcessTrainModelV3AdvancedResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -200,8 +233,7 @@ partial void ProcessTrainModelV3AdvancedResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -210,6 +242,11 @@ partial void ProcessTrainModelV3AdvancedResponseContent( __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -226,14 +263,15 @@ partial void ProcessTrainModelV3AdvancedResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -273,6 +311,8 @@ partial void ProcessTrainModelV3AdvancedResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -293,6 +333,8 @@ partial void ProcessTrainModelV3AdvancedResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -416,9 +458,13 @@ partial void ProcessTrainModelV3AdvancedResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.TrainDatasetModelResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.TrainDatasetModelResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -446,9 +492,13 @@ partial void ProcessTrainModelV3AdvancedResponseContent( #endif ).ConfigureAwait(false); - return - await global::Ideogram.TrainDatasetModelResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.TrainDatasetModelResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/Ideogram/Generated/Ideogram.ModelsClient.g.cs b/src/libs/Ideogram/Generated/Ideogram.ModelsClient.g.cs index 856d94d..289a4c9 100644 --- a/src/libs/Ideogram/Generated/Ideogram.ModelsClient.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.ModelsClient.g.cs @@ -73,10 +73,10 @@ public ModelsClient( /// Client-wide request defaults such as headers, query parameters, retries, and timeout. /// Dispose the HttpClient when the instance is disposed. True by default. public ModelsClient( - global::System.Net.Http.HttpClient? httpClient = null, - global::System.Uri? baseUri = null, - global::System.Collections.Generic.List? authorizations = null, - global::Ideogram.AutoSDKClientOptions? options = null, + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Ideogram.AutoSDKClientOptions? options, bool disposeHttpClient = true) { diff --git a/src/libs/Ideogram/Generated/Ideogram.OptionsSupport.g.cs b/src/libs/Ideogram/Generated/Ideogram.OptionsSupport.g.cs index 3673312..1f3ecff 100644 --- a/src/libs/Ideogram/Generated/Ideogram.OptionsSupport.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.OptionsSupport.g.cs @@ -101,9 +101,45 @@ public sealed class AutoSDKRetryOptions public int MaxAttempts { get; set; } = 1; /// - /// Optional fixed delay between retry attempts. + /// Optional fixed delay between retry attempts. When set, this takes precedence over exponential backoff. /// public global::System.TimeSpan? Delay { get; set; } + + /// + /// Initial exponential backoff delay used when is not set. + /// + public global::System.TimeSpan InitialDelay { get; set; } = global::System.TimeSpan.FromSeconds(1); + + /// + /// Maximum retry delay after applying retry headers, backoff, and jitter. + /// + public global::System.TimeSpan MaxDelay { get; set; } = global::System.TimeSpan.FromSeconds(30); + + /// + /// Multiplier applied to exponential backoff after each failed attempt. + /// Values below 1 are normalized to 1. + /// + public double BackoffMultiplier { get; set; } = 2D; + + /// + /// Randomizes computed backoff by plus or minus this ratio. Values are clamped to 0..1. + /// + public double JitterRatio { get; set; } = 0.2D; + + /// + /// Whether Retry-After response headers should control retry delay when present. + /// + public bool UseRetryAfterHeader { get; set; } = true; + + /// + /// Whether a rate-limit reset response header should control retry delay when present. + /// + public bool UseRateLimitResetHeader { get; set; } + + /// + /// Optional provider-specific rate-limit reset header name. Values may be Unix seconds or an HTTP date. + /// + public string? RateLimitResetHeaderName { get; set; } = "X-RateLimit-Reset"; } @@ -231,6 +267,16 @@ public sealed class AutoSDKHookContext ///
public bool WillRetry { get; set; } + /// + /// The computed retry delay when is true. + /// + public global::System.TimeSpan? RetryDelay { get; set; } + + /// + /// A short retry reason such as exception or status:429. + /// + public string RetryReason { get; set; } = string.Empty; + /// /// The effective cancellation token for the current request attempt. /// @@ -254,6 +300,8 @@ internal static class AutoSDKRequestOptionsSupport int attempt, int maxAttempts, bool willRetry, + global::System.TimeSpan? retryDelay, + string retryReason, global::System.Threading.CancellationToken cancellationToken) { return new global::Ideogram.AutoSDKHookContext @@ -271,6 +319,8 @@ internal static class AutoSDKRequestOptionsSupport Attempt = attempt, MaxAttempts = maxAttempts, WillRetry = willRetry, + RetryDelay = retryDelay, + RetryReason = retryReason ?? string.Empty, CancellationToken = cancellationToken, }; } @@ -338,19 +388,188 @@ internal static int GetMaxAttempts( return maxAttempts < 1 ? 1 : maxAttempts; } - internal static async global::System.Threading.Tasks.Task DelayBeforeRetryAsync( + internal static global::System.TimeSpan GetRetryDelay( global::Ideogram.AutoSDKClientOptions clientOptions, global::Ideogram.AutoSDKRequestOptions? requestOptions, + global::System.Net.Http.HttpResponseMessage? response, + int attempt) + { + var retryOptions = requestOptions?.Retry ?? clientOptions.Retry ?? new global::Ideogram.AutoSDKRetryOptions(); + + if (retryOptions.UseRetryAfterHeader && + TryGetRetryAfterDelay(response, out var retryAfterDelay)) + { + return ClampRetryDelay(retryAfterDelay, retryOptions); + } + + if (retryOptions.UseRateLimitResetHeader && + TryGetRateLimitResetDelay(response, retryOptions.RateLimitResetHeaderName, out var rateLimitResetDelay)) + { + return ClampRetryDelay(rateLimitResetDelay, retryOptions); + } + + if (retryOptions.Delay.HasValue) + { + return ClampRetryDelay(retryOptions.Delay.Value, retryOptions); + } + + var initialDelay = retryOptions.InitialDelay; + if (initialDelay <= global::System.TimeSpan.Zero) + { + return global::System.TimeSpan.Zero; + } + + var multiplier = retryOptions.BackoffMultiplier < 1D ? 1D : retryOptions.BackoffMultiplier; + var exponent = attempt <= 1 ? 0 : attempt - 1; + var delayMilliseconds = initialDelay.TotalMilliseconds * global::System.Math.Pow(multiplier, exponent); + if (double.IsNaN(delayMilliseconds) || double.IsInfinity(delayMilliseconds) || delayMilliseconds < 0D) + { + delayMilliseconds = 0D; + } + + var delay = global::System.TimeSpan.FromMilliseconds(delayMilliseconds); + delay = ApplyJitter(delay, retryOptions.JitterRatio); + return ClampRetryDelay(delay, retryOptions); + } + + internal static async global::System.Threading.Tasks.Task DelayBeforeRetryAsync( + global::System.TimeSpan retryDelay, global::System.Threading.CancellationToken cancellationToken) { - var delay = requestOptions?.Retry?.Delay ?? - clientOptions.Retry?.Delay; - if (!delay.HasValue || delay.Value <= global::System.TimeSpan.Zero) + if (retryDelay <= global::System.TimeSpan.Zero) { return; } - await global::System.Threading.Tasks.Task.Delay(delay.Value, cancellationToken).ConfigureAwait(false); + await global::System.Threading.Tasks.Task.Delay(retryDelay, cancellationToken).ConfigureAwait(false); + } + + private static bool TryGetRetryAfterDelay( + global::System.Net.Http.HttpResponseMessage? response, + out global::System.TimeSpan delay) + { + delay = global::System.TimeSpan.Zero; + var retryAfter = response?.Headers.RetryAfter; + if (retryAfter == null) + { + return false; + } + + if (retryAfter.Delta.HasValue) + { + delay = retryAfter.Delta.Value; + return delay > global::System.TimeSpan.Zero; + } + + if (retryAfter.Date.HasValue) + { + delay = retryAfter.Date.Value - global::System.DateTimeOffset.UtcNow; + return delay > global::System.TimeSpan.Zero; + } + + return false; + } + + private static bool TryGetRateLimitResetDelay( + global::System.Net.Http.HttpResponseMessage? response, + string? headerName, + out global::System.TimeSpan delay) + { + delay = global::System.TimeSpan.Zero; + if (response == null || string.IsNullOrWhiteSpace(headerName)) + { + return false; + } + + if (!response.Headers.TryGetValues(headerName, out var values) && + (response.Content?.Headers == null || !response.Content.Headers.TryGetValues(headerName, out values))) + { + return false; + } + + var value = global::System.Linq.Enumerable.FirstOrDefault(values); + if (string.IsNullOrWhiteSpace(value)) + { + return false; + } + + value = value.Trim(); + if (long.TryParse( + value, + global::System.Globalization.NumberStyles.Integer, + global::System.Globalization.CultureInfo.InvariantCulture, + out var unixSeconds)) + { + delay = global::System.DateTimeOffset.FromUnixTimeSeconds(unixSeconds) - global::System.DateTimeOffset.UtcNow; + return delay > global::System.TimeSpan.Zero; + } + + if (global::System.DateTimeOffset.TryParse( + value, + global::System.Globalization.CultureInfo.InvariantCulture, + global::System.Globalization.DateTimeStyles.AssumeUniversal | global::System.Globalization.DateTimeStyles.AdjustToUniversal, + out var resetAt)) + { + delay = resetAt - global::System.DateTimeOffset.UtcNow; + return delay > global::System.TimeSpan.Zero; + } + + return false; + } + + private static global::System.TimeSpan ApplyJitter( + global::System.TimeSpan delay, + double jitterRatio) + { + if (delay <= global::System.TimeSpan.Zero || jitterRatio <= 0D) + { + return delay; + } + + if (jitterRatio > 1D) + { + jitterRatio = 1D; + } + + var sample = NextJitterSample(); + var multiplier = 1D - jitterRatio + (sample * jitterRatio * 2D); + var milliseconds = delay.TotalMilliseconds * multiplier; + if (double.IsNaN(milliseconds) || double.IsInfinity(milliseconds) || milliseconds < 0D) + { + milliseconds = 0D; + } + + return global::System.TimeSpan.FromMilliseconds(milliseconds); + } + + private static double NextJitterSample() + { + var bytes = new byte[8]; + using (var randomNumberGenerator = global::System.Security.Cryptography.RandomNumberGenerator.Create()) + { + randomNumberGenerator.GetBytes(bytes); + } + + var value = global::System.BitConverter.ToUInt64(bytes, 0); + return value / (double)ulong.MaxValue; + } + + private static global::System.TimeSpan ClampRetryDelay( + global::System.TimeSpan delay, + global::Ideogram.AutoSDKRetryOptions retryOptions) + { + if (delay <= global::System.TimeSpan.Zero) + { + return global::System.TimeSpan.Zero; + } + + var maxDelay = retryOptions.MaxDelay; + if (maxDelay > global::System.TimeSpan.Zero && delay > maxDelay) + { + return maxDelay; + } + + return delay; } internal static bool ShouldRetryStatusCode( diff --git a/src/libs/Ideogram/Generated/Ideogram.PromptClient.PostMagicPrompt.g.cs b/src/libs/Ideogram/Generated/Ideogram.PromptClient.PostMagicPrompt.g.cs index 8d4601a..7a30e30 100644 --- a/src/libs/Ideogram/Generated/Ideogram.PromptClient.PostMagicPrompt.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.PromptClient.PostMagicPrompt.g.cs @@ -51,6 +51,29 @@ partial void ProcessPostMagicPromptResponseContent( /// public async global::System.Threading.Tasks.Task PostMagicPromptAsync( + global::Ideogram.MagicPromptRequest request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await PostMagicPromptAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Generate Magic Prompt
+ /// Transforms basic prompts into a magic prompt. Internal use only (feature flagged). TODO: update description if enabled externally. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> PostMagicPromptAsResponseAsync( + global::Ideogram.MagicPromptRequest request, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) @@ -81,10 +104,11 @@ partial void ProcessPostMagicPromptResponseContent( var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/magic-prompt", baseUri: HttpClient.BaseAddress); @@ -117,30 +141,36 @@ partial void ProcessPostMagicPromptResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), name: "\"prompt\""); + __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.MagicPromptVersion.ToValueString()), name: "\"magic_prompt_version\""); + __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.ClassifyPromptCategory, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()), name: "\"classify_prompt_category\""); + if (request.StyleType != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.StyleType).HasValue ? (request.StyleType).GetValueOrDefault().ToValueString() : string.Empty), name: "\"style_type\""); - } + + } if (request.Seed != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), name: "\"seed\""); - } + + } if (request.CharacterReferenceImages != default) { @@ -157,15 +187,19 @@ partial void ProcessPostMagicPromptResponseContent( __contentCharacterReferenceImages.Headers.ContentDisposition.FileNameStar = null; } } - } + + } if (request.SystemPrompt != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.SystemPrompt ?? string.Empty), name: "\"system_prompt\""); + } + __httpRequest.Content = __httpRequestContent; + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -207,6 +241,8 @@ partial void ProcessPostMagicPromptResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -217,6 +253,11 @@ partial void ProcessPostMagicPromptResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -234,6 +275,8 @@ partial void ProcessPostMagicPromptResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -243,8 +286,7 @@ partial void ProcessPostMagicPromptResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -253,6 +295,11 @@ partial void ProcessPostMagicPromptResponseContent( __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -269,14 +316,15 @@ partial void ProcessPostMagicPromptResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -316,6 +364,8 @@ partial void ProcessPostMagicPromptResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -336,6 +386,8 @@ partial void ProcessPostMagicPromptResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -492,9 +544,13 @@ partial void ProcessPostMagicPromptResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.MagicPromptResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.MagicPromptResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -522,9 +578,13 @@ partial void ProcessPostMagicPromptResponseContent( #endif ).ConfigureAwait(false); - return - await global::Ideogram.MagicPromptResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.MagicPromptResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -625,5 +685,1270 @@ partial void ProcessPostMagicPromptResponseContent( requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } + + /// + /// Generate Magic Prompt
+ /// Transforms basic prompts into a magic prompt. Internal use only (feature flagged). TODO: update description if enabled externally. + ///
+ /// + /// The prompt to enhance with a magic prompt
+ /// Example: a cat + /// + /// + /// The magic prompt version to use when magic prompt option is set to AUTO or ON.
+ /// Example: V_0 + /// + /// + /// Whether to classify the prompt into a use case category.
+ /// Default Value: true
+ /// Example: false + /// + /// + /// The style type to generate with.
+ /// Default Value: GENERAL
+ /// Example: GENERAL + /// + /// + /// Random seed for reproducible generation
+ /// Example: 12345 + /// + /// + /// Generations with character reference are subject to the character reference pricing. A set of images to use as character references (maximum total size 10MB across all character references), currently only supports 1 character reference image. The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'character_reference_images' file parts. + /// + /// + /// A system prompt to use for the magic prompt.
+ /// Example: You are a helpful assistant that generates magic prompts for images. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task PostMagicPromptAsync( + string prompt, + global::Ideogram.MagicPromptVersionEnum magicPromptVersion, + bool classifyPromptCategory, + global::Ideogram.StyleTypeV3? styleType = default, + int? seed = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImages = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesFileNames = default, + string? systemPrompt = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + var request = new global::Ideogram.MagicPromptRequest + { + Prompt = prompt, + MagicPromptVersion = magicPromptVersion, + ClassifyPromptCategory = classifyPromptCategory, + StyleType = styleType, + Seed = seed, + CharacterReferenceImages = new global::System.Collections.Generic.List(), + SystemPrompt = systemPrompt, + }; + PrepareArguments( + client: HttpClient); + PreparePostMagicPromptArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_PostMagicPromptSecurityRequirements, + operationName: "PostMagicPromptAsync"); + + using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Ideogram.PathBuilder( + path: "/magic-prompt", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), + name: "\"prompt\""); + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.MagicPromptVersion.ToValueString()), + name: "\"magic_prompt_version\""); + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.ClassifyPromptCategory, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()), + name: "\"classify_prompt_category\""); + + if (request.StyleType != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.StyleType).HasValue ? (request.StyleType).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"style_type\""); + + } + if (request.Seed != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"seed\""); + + } + if (characterReferenceImages != default) + { + + for (var __iCharacterReferenceImages = 0; __iCharacterReferenceImages < characterReferenceImages.Count; __iCharacterReferenceImages++) + { + var __fileNameCharacterReferenceImages = characterReferenceImagesFileNames != null && + __iCharacterReferenceImages < characterReferenceImagesFileNames.Count && + characterReferenceImagesFileNames[__iCharacterReferenceImages] != null + ? characterReferenceImagesFileNames[__iCharacterReferenceImages] + : $"file{__iCharacterReferenceImages}.bin"; + var __contentCharacterReferenceImages = new global::System.Net.Http.StreamContent(characterReferenceImages[__iCharacterReferenceImages]); + __contentCharacterReferenceImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + __fileNameCharacterReferenceImages is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(__fileNameCharacterReferenceImages) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentCharacterReferenceImages, + name: "\"character_reference_images\"", + fileName: $"\"{__fileNameCharacterReferenceImages}\""); + if (__contentCharacterReferenceImages.Headers.ContentDisposition != null) + { + __contentCharacterReferenceImages.Headers.ContentDisposition.FileNameStar = null; + } + } + + } + if (request.SystemPrompt != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.SystemPrompt ?? string.Empty), + name: "\"system_prompt\""); + + } + + __httpRequest.Content = __httpRequestContent; + + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PreparePostMagicPromptRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostMagicPrompt", + methodName: "PostMagicPromptAsync", + pathTemplate: "\"/magic-prompt\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostMagicPrompt", + methodName: "PostMagicPromptAsync", + pathTemplate: "\"/magic-prompt\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostMagicPrompt", + methodName: "PostMagicPromptAsync", + pathTemplate: "\"/magic-prompt\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessPostMagicPromptResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostMagicPrompt", + methodName: "PostMagicPromptAsync", + pathTemplate: "\"/magic-prompt\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostMagicPrompt", + methodName: "PostMagicPromptAsync", + pathTemplate: "\"/magic-prompt\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessPostMagicPromptResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Ideogram.MagicPromptResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Ideogram.MagicPromptResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Generate Magic Prompt
+ /// Transforms basic prompts into a magic prompt. Internal use only (feature flagged). TODO: update description if enabled externally. + ///
+ /// + /// The prompt to enhance with a magic prompt
+ /// Example: a cat + /// + /// + /// The magic prompt version to use when magic prompt option is set to AUTO or ON.
+ /// Example: V_0 + /// + /// + /// Whether to classify the prompt into a use case category.
+ /// Default Value: true
+ /// Example: false + /// + /// + /// The style type to generate with.
+ /// Default Value: GENERAL
+ /// Example: GENERAL + /// + /// + /// Random seed for reproducible generation
+ /// Example: 12345 + /// + /// + /// Generations with character reference are subject to the character reference pricing. A set of images to use as character references (maximum total size 10MB across all character references), currently only supports 1 character reference image. The images should be in JPEG, PNG or WebP format. + /// + /// + /// Optional file names to use for the multipart 'character_reference_images' file parts. + /// + /// + /// A system prompt to use for the magic prompt.
+ /// Example: You are a helpful assistant that generates magic prompts for images. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> PostMagicPromptAsResponseAsync( + string prompt, + global::Ideogram.MagicPromptVersionEnum magicPromptVersion, + bool classifyPromptCategory, + global::Ideogram.StyleTypeV3? styleType = default, + int? seed = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImages = default, + global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesFileNames = default, + string? systemPrompt = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + var request = new global::Ideogram.MagicPromptRequest + { + Prompt = prompt, + MagicPromptVersion = magicPromptVersion, + ClassifyPromptCategory = classifyPromptCategory, + StyleType = styleType, + Seed = seed, + CharacterReferenceImages = new global::System.Collections.Generic.List(), + SystemPrompt = systemPrompt, + }; + PrepareArguments( + client: HttpClient); + PreparePostMagicPromptArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_PostMagicPromptSecurityRequirements, + operationName: "PostMagicPromptAsync"); + + using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Ideogram.PathBuilder( + path: "/magic-prompt", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), + name: "\"prompt\""); + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.MagicPromptVersion.ToValueString()), + name: "\"magic_prompt_version\""); + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.ClassifyPromptCategory, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()), + name: "\"classify_prompt_category\""); + + if (request.StyleType != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.StyleType).HasValue ? (request.StyleType).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"style_type\""); + + } + if (request.Seed != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), + name: "\"seed\""); + + } + if (characterReferenceImages != default) + { + + for (var __iCharacterReferenceImages = 0; __iCharacterReferenceImages < characterReferenceImages.Count; __iCharacterReferenceImages++) + { + var __fileNameCharacterReferenceImages = characterReferenceImagesFileNames != null && + __iCharacterReferenceImages < characterReferenceImagesFileNames.Count && + characterReferenceImagesFileNames[__iCharacterReferenceImages] != null + ? characterReferenceImagesFileNames[__iCharacterReferenceImages] + : $"file{__iCharacterReferenceImages}.bin"; + var __contentCharacterReferenceImages = new global::System.Net.Http.StreamContent(characterReferenceImages[__iCharacterReferenceImages]); + __contentCharacterReferenceImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + __fileNameCharacterReferenceImages is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(__fileNameCharacterReferenceImages) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentCharacterReferenceImages, + name: "\"character_reference_images\"", + fileName: $"\"{__fileNameCharacterReferenceImages}\""); + if (__contentCharacterReferenceImages.Headers.ContentDisposition != null) + { + __contentCharacterReferenceImages.Headers.ContentDisposition.FileNameStar = null; + } + } + + } + if (request.SystemPrompt != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.SystemPrompt ?? string.Empty), + name: "\"system_prompt\""); + + } + + __httpRequest.Content = __httpRequestContent; + + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PreparePostMagicPromptRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostMagicPrompt", + methodName: "PostMagicPromptAsync", + pathTemplate: "\"/magic-prompt\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostMagicPrompt", + methodName: "PostMagicPromptAsync", + pathTemplate: "\"/magic-prompt\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostMagicPrompt", + methodName: "PostMagicPromptAsync", + pathTemplate: "\"/magic-prompt\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessPostMagicPromptResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostMagicPrompt", + methodName: "PostMagicPromptAsync", + pathTemplate: "\"/magic-prompt\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostMagicPrompt", + methodName: "PostMagicPromptAsync", + pathTemplate: "\"/magic-prompt\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 401) + { + string? __content_401 = null; + global::System.Exception? __exception_401 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_401 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_401 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_401, + statusCode: __response.StatusCode) + { + ResponseBody = __content_401, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessPostMagicPromptResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Ideogram.MagicPromptResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + var __value = await global::Ideogram.MagicPromptResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.PromptClient.g.cs b/src/libs/Ideogram/Generated/Ideogram.PromptClient.g.cs index 343b26a..644cf87 100644 --- a/src/libs/Ideogram/Generated/Ideogram.PromptClient.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.PromptClient.g.cs @@ -72,10 +72,10 @@ public PromptClient( /// Client-wide request defaults such as headers, query parameters, retries, and timeout. /// Dispose the HttpClient when the instance is disposed. True by default. public PromptClient( - global::System.Net.Http.HttpClient? httpClient = null, - global::System.Uri? baseUri = null, - global::System.Collections.Generic.List? authorizations = null, - global::Ideogram.AutoSDKClientOptions? options = null, + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Ideogram.AutoSDKClientOptions? options, bool disposeHttpClient = true) { diff --git a/src/libs/Ideogram/Generated/Ideogram.VisionClient.PostDescribe.g.cs b/src/libs/Ideogram/Generated/Ideogram.VisionClient.PostDescribe.g.cs index f351933..dbda603 100644 --- a/src/libs/Ideogram/Generated/Ideogram.VisionClient.PostDescribe.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.VisionClient.PostDescribe.g.cs @@ -52,6 +52,30 @@ partial void ProcessPostDescribeResponseContent( /// public async global::System.Threading.Tasks.Task PostDescribeAsync( + global::Ideogram.DescribeRequest request, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await PostDescribeAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Describe
+ /// Describe an image.
+ /// Supported image formats include JPEG, PNG, and WebP. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> PostDescribeAsResponseAsync( + global::Ideogram.DescribeRequest request, global::Ideogram.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) @@ -82,10 +106,11 @@ partial void ProcessPostDescribeResponseContent( var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::Ideogram.PathBuilder( path: "/describe", baseUri: HttpClient.BaseAddress); @@ -118,6 +143,7 @@ partial void ProcessPostDescribeResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); var __contentImageFile = new global::System.Net.Http.ByteArrayContent(request.ImageFile ?? global::System.Array.Empty()); __contentImageFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( @@ -156,14 +182,18 @@ request.ImageFilename is null { __contentImageFile.Headers.ContentDisposition.FileNameStar = null; } + if (request.DescribeModelVersion != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((request.DescribeModelVersion).HasValue ? (request.DescribeModelVersion).GetValueOrDefault().ToValueString() : string.Empty), name: "\"describe_model_version\""); + } + __httpRequest.Content = __httpRequestContent; + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -205,6 +235,8 @@ request.ImageFilename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -215,6 +247,11 @@ request.ImageFilename is null } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -232,6 +269,8 @@ request.ImageFilename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -241,8 +280,7 @@ request.ImageFilename is null __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -251,6 +289,11 @@ request.ImageFilename is null __attempt < __maxAttempts && global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -267,14 +310,15 @@ request.ImageFilename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -314,6 +358,8 @@ request.ImageFilename is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -334,6 +380,8 @@ request.ImageFilename is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // @@ -462,9 +510,13 @@ request.ImageFilename is null { __response.EnsureSuccessStatusCode(); - return - global::Ideogram.DescribeResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::Ideogram.DescribeResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -492,9 +544,13 @@ request.ImageFilename is null #endif ).ConfigureAwait(false); - return - await global::Ideogram.DescribeResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::Ideogram.DescribeResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -569,5 +625,1076 @@ request.ImageFilename is null requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } + + /// + /// Describe
+ /// Describe an image.
+ /// Supported image formats include JPEG, PNG, and WebP. + ///
+ /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The model version to use for describing images. Defaults to V_3.
+ /// Default Value: V_3 + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task PostDescribeAsync( + global::System.IO.Stream imageFile, + string imageFilename, + global::Ideogram.DescribeModelVersion? describeModelVersion = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + imageFile = imageFile ?? throw new global::System.ArgumentNullException(nameof(imageFile)); + var request = new global::Ideogram.DescribeRequest + { + ImageFile = global::System.Array.Empty(), + ImageFilename = imageFilename, + DescribeModelVersion = describeModelVersion, + }; + PrepareArguments( + client: HttpClient); + PreparePostDescribeArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_PostDescribeSecurityRequirements, + operationName: "PostDescribeAsync"); + + using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Ideogram.PathBuilder( + path: "/describe", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + var __contentImageFile = new global::System.Net.Http.StreamContent(imageFile); + __contentImageFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.ImageFilename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.ImageFilename) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentImageFile, + name: "\"image_file\"", + fileName: request.ImageFilename != null ? $"\"{request.ImageFilename}\"" : string.Empty); + if (__contentImageFile.Headers.ContentDisposition != null) + { + __contentImageFile.Headers.ContentDisposition.FileNameStar = null; + } + + if (request.DescribeModelVersion != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.DescribeModelVersion).HasValue ? (request.DescribeModelVersion).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"describe_model_version\""); + + } + + __httpRequest.Content = __httpRequestContent; + + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PreparePostDescribeRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostDescribe", + methodName: "PostDescribeAsync", + pathTemplate: "\"/describe\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostDescribe", + methodName: "PostDescribeAsync", + pathTemplate: "\"/describe\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostDescribe", + methodName: "PostDescribeAsync", + pathTemplate: "\"/describe\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessPostDescribeResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostDescribe", + methodName: "PostDescribeAsync", + pathTemplate: "\"/describe\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostDescribe", + methodName: "PostDescribeAsync", + pathTemplate: "\"/describe\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Image failed the safety check. + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Ideogram.ImageSafetyError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Ideogram.ImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Ideogram.ImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessPostDescribeResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Ideogram.DescribeResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Ideogram.DescribeResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Describe
+ /// Describe an image.
+ /// Supported image formats include JPEG, PNG, and WebP. + ///
+ /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time. + /// + /// + /// The model version to use for describing images. Defaults to V_3.
+ /// Default Value: V_3 + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> PostDescribeAsResponseAsync( + global::System.IO.Stream imageFile, + string imageFilename, + global::Ideogram.DescribeModelVersion? describeModelVersion = default, + global::Ideogram.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + imageFile = imageFile ?? throw new global::System.ArgumentNullException(nameof(imageFile)); + var request = new global::Ideogram.DescribeRequest + { + ImageFile = global::System.Array.Empty(), + ImageFilename = imageFilename, + DescribeModelVersion = describeModelVersion, + }; + PrepareArguments( + client: HttpClient); + PreparePostDescribeArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_PostDescribeSecurityRequirements, + operationName: "PostDescribeAsync"); + + using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Ideogram.PathBuilder( + path: "/describe", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + var __contentImageFile = new global::System.Net.Http.StreamContent(imageFile); + __contentImageFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.ImageFilename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.ImageFilename) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentImageFile, + name: "\"image_file\"", + fileName: request.ImageFilename != null ? $"\"{request.ImageFilename}\"" : string.Empty); + if (__contentImageFile.Headers.ContentDisposition != null) + { + __contentImageFile.Headers.ContentDisposition.FileNameStar = null; + } + + if (request.DescribeModelVersion != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((request.DescribeModelVersion).HasValue ? (request.DescribeModelVersion).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"describe_model_version\""); + + } + + __httpRequest.Content = __httpRequestContent; + + global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PreparePostDescribeRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostDescribe", + methodName: "PostDescribeAsync", + pathTemplate: "\"/describe\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostDescribe", + methodName: "PostDescribeAsync", + pathTemplate: "\"/describe\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostDescribe", + methodName: "PostDescribeAsync", + pathTemplate: "\"/describe\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessPostDescribeResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostDescribe", + methodName: "PostDescribeAsync", + pathTemplate: "\"/describe\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "PostDescribe", + methodName: "PostDescribeAsync", + pathTemplate: "\"/describe\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Image failed the safety check. + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Ideogram.ImageSafetyError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Ideogram.ImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_422 = global::Ideogram.ImageSafetyError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 429) + { + string? __content_429 = null; + global::System.Exception? __exception_429 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_429 = __ex; + } + + throw new global::Ideogram.ApiException( + message: __content_429 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_429, + statusCode: __response.StatusCode) + { + ResponseBody = __content_429, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessPostDescribeResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Ideogram.DescribeResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + var __value = await global::Ideogram.DescribeResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Ideogram.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Ideogram.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } } } \ No newline at end of file diff --git a/src/libs/Ideogram/Generated/Ideogram.VisionClient.g.cs b/src/libs/Ideogram/Generated/Ideogram.VisionClient.g.cs index af92e48..01d3b3c 100644 --- a/src/libs/Ideogram/Generated/Ideogram.VisionClient.g.cs +++ b/src/libs/Ideogram/Generated/Ideogram.VisionClient.g.cs @@ -73,10 +73,10 @@ public VisionClient( /// Client-wide request defaults such as headers, query parameters, retries, and timeout. /// Dispose the HttpClient when the instance is disposed. True by default. public VisionClient( - global::System.Net.Http.HttpClient? httpClient = null, - global::System.Uri? baseUri = null, - global::System.Collections.Generic.List? authorizations = null, - global::Ideogram.AutoSDKClientOptions? options = null, + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Ideogram.AutoSDKClientOptions? options, bool disposeHttpClient = true) { diff --git a/src/libs/Ideogram/Generated/autosdk.generated-examples.json b/src/libs/Ideogram/Generated/autosdk.generated-examples.json index 0f7e3c6..396bdf0 100644 --- a/src/libs/Ideogram/Generated/autosdk.generated-examples.json +++ b/src/libs/Ideogram/Generated/autosdk.generated-examples.json @@ -17,7 +17,7 @@ "Slug": "post-batch", "Description": "Runs automated evaluation of multiple LLM models and system prompts for magic prompt generation. \nGenerates images using large batches of user prompt inputs. Internal use only (feature flagged).", "Language": "csharp", - "Code": "using var client = new IdeogramClient(apiKey);\n\nvar request = global::System.Text.Json.JsonSerializer.Deserialize\u003Cglobal::Ideogram.InternalBatchRequest\u003E(\n @\u0022{\n \u0022\u0022user_prompts\u0022\u0022: [\n \u0022\u0022a cat\u0022\u0022,\n \u0022\u0022a dog\u0022\u0022\n ],\n \u0022\u0022sampling_request_params\u0022\u0022: {\n \u0022\u0022aspect_ratio\u0022\u0022: \u0022\u00221x1\u0022\u0022,\n \u0022\u0022style_type\u0022\u0022: \u0022\u0022GENERAL\u0022\u0022,\n \u0022\u0022magic_prompt_version\u0022\u0022: \u0022\u0022V_0\u0022\u0022,\n \u0022\u0022seed\u0022\u0022: 12345,\n \u0022\u0022negative_prompt\u0022\u0022: \u0022\u0022brush strokes, painting\u0022\u0022,\n \u0022\u0022magic_prompt_option\u0022\u0022: \u0022\u0022ON\u0022\u0022,\n \u0022\u0022model\u0022\u0022: \u0022\u0022V_2_TURBO\u0022\u0022,\n \u0022\u0022resolution\u0022\u0022: \u0022\u00221280x800\u0022\u0022,\n \u0022\u0022num_images\u0022\u0022: 1,\n \u0022\u0022color_palette\u0022\u0022: {\n \u0022\u0022name\u0022\u0022: \u0022\u0022PASTEL\u0022\u0022\n }\n },\n \u0022\u0022experiment_variant\u0022\u0022: \u0022\u0022MAGIC_PROMPT_NO_TEXT\u0022\u0022\n}\u0022)!;\n\nvar response = await client.Batch.PostBatchAsync(\n request: request\n);\n\n// Example response:\n// {\n// \u0022job_id\u0022: \u0022job_id\u0022\n// }", + "Code": "using var client = new IdeogramClient(apiKey);\n\nvar request = global::System.Text.Json.JsonSerializer.Deserialize\u003Cglobal::Ideogram.InternalBatchRequest\u003E(\n @\u0022{\n \u0022\u0022user_prompts\u0022\u0022: [\n \u0022\u0022a cat\u0022\u0022,\n \u0022\u0022a dog\u0022\u0022\n ],\n \u0022\u0022sampling_request_params\u0022\u0022: {\n \u0022\u0022magic_prompt_system_prompt_config_id\u0022\u0022: \u0022\u0022magic_prompt_system_prompt_config_id\u0022\u0022,\n \u0022\u0022aspect_ratio\u0022\u0022: \u0022\u00221x1\u0022\u0022,\n \u0022\u0022style_type\u0022\u0022: \u0022\u0022GENERAL\u0022\u0022,\n \u0022\u0022magic_prompt_version\u0022\u0022: \u0022\u0022V_0\u0022\u0022,\n \u0022\u0022seed\u0022\u0022: 12345,\n \u0022\u0022negative_prompt\u0022\u0022: \u0022\u0022brush strokes, painting\u0022\u0022,\n \u0022\u0022magic_prompt_option\u0022\u0022: \u0022\u0022ON\u0022\u0022,\n \u0022\u0022model\u0022\u0022: \u0022\u0022V_2_TURBO\u0022\u0022,\n \u0022\u0022resolution\u0022\u0022: \u0022\u00221280x800\u0022\u0022,\n \u0022\u0022num_images\u0022\u0022: 1,\n \u0022\u0022color_palette\u0022\u0022: {\n \u0022\u0022name\u0022\u0022: \u0022\u0022PASTEL\u0022\u0022\n }\n },\n \u0022\u0022experiment_variant\u0022\u0022: \u0022\u0022MAGIC_PROMPT_NO_TEXT\u0022\u0022\n}\u0022)!;\n\nvar response = await client.Batch.PostBatchAsync(\n request: request\n);\n\n// Example response:\n// {\n// \u0022job_id\u0022: \u0022job_id\u0022\n// }", "Format": "sdk", "OperationId": "post_batch", "Setup": "This example assumes \u0060using Ideogram;\u0060 is in scope and \u0060apiKey\u0060 contains the required credential." @@ -90,28 +90,17 @@ }, { "Order": 9, - "Title": "Edit with Ideogram 3.0", - "Slug": "post-edit-image-v3", - "Description": "Edit a given image synchronously using the provided mask with Ideogram 3.0. The mask indicates which part of the image\nshould be edited, while the prompt and chosen style can further guide the edit.\n\nSupported image formats include JPEG, PNG, and WebP.\n\nImages links are available for a limited period of time; if you would like to keep the image, you must download it.", - "Language": "http", - "Code": "### Edit with Ideogram 3.0\n# @name post_edit_image_v3\nPOST {{host}}/v1/ideogram-v3/edit\nAuthorization: Bearer {{token}}\nContent-Type: multipart/form-data\nAccept: application/json\n\n## Responses\n# 200\n# Description: Image edits generated successfully.\n# Content-Type: application/json\n# 400\n# Description: Invalid input provided.\n# 401\n# Description: Not authorized to generate an image.\n# 422\n# Description: Prompt or Initial Image failed the safety checks.\n# Content-Type: application/json\n# 429\n# Description: Too many requests.", - "Format": "http", - "OperationId": "post_edit_image_v3", - "Setup": null - }, - { - "Order": 10, "Title": "Generate a design from a text prompt with text detection and correction", "Slug": "post-generate-design-v3", "Description": "Generates a design synchronously from a text prompt using the Ideogram 3.0 model, then detects and corrects text layers within the generated image.\n\nThe response includes the generated image URL along with detected text layers (with font, size, color, position) and image asset layers.\n\nImages links are available for a limited period of time; if you would like to keep the image, you must download it.", "Language": "http", - "Code": "### Generate a design from a text prompt with text detection and correction\n# @name post_generate_design_v3\nPOST {{host}}/v1/ideogram-v3/generate-design\nAuthorization: Bearer {{token}}\nContent-Type: application/json\nAccept: application/json\n\n{\n \u0022prompt\u0022: \u0022A birthday card saying \\u0027Happy Birthday\\u0027\u0022,\n \u0022seed\u0022: 12345,\n \u0022resolution\u0022: \u00221280x800\u0022,\n \u0022aspect_ratio\u0022: \u00221x3\u0022,\n \u0022rendering_speed\u0022: \u0022DEFAULT\u0022,\n \u0022magic_prompt\u0022: \u0022ON\u0022,\n \u0022negative_prompt\u0022: \u0022brush strokes, painting\u0022,\n \u0022num_images\u0022: 1,\n \u0022color_palette\u0022: {\n \u0022name\u0022: \u0022PASTEL\u0022\n },\n \u0022style_codes\u0022: [\n \u0022AAFF5733\u0022,\n \u00220133FF57\u0022,\n \u0022DE3357FF\u0022\n ],\n \u0022style_type\u0022: \u0022GENERAL\u0022,\n \u0022style_preset\u0022: \u0022BRIGHT_ART\u0022,\n \u0022custom_model_uri\u0022: \u0022model/my-custom-model/version/1\u0022,\n \u0022font_file_h1\u0022: \u0022\u0022,\n \u0022font_name_h1\u0022: \u0022Ubuntu-Bold.ttf\u0022,\n \u0022font_file_h2\u0022: \u0022\u0022,\n \u0022font_name_h2\u0022: \u0022string\u0022,\n \u0022font_file_body\u0022: \u0022\u0022,\n \u0022font_name_body\u0022: \u0022string\u0022,\n \u0022font_file_small\u0022: \u0022\u0022,\n \u0022font_name_small\u0022: \u0022string\u0022,\n \u0022style_reference_images\u0022: [\n \u0022\u0022\n ],\n \u0022reference_asset_images\u0022: [\n \u0022\u0022\n ]\n}\n\n## Responses\n# 200\n# Description: Design(s) generated successfully with text correction.\n# Content-Type: application/json\n# 400\n# Description: Invalid input provided.\n# 401\n# Description: Not authorized to generate an image.\n# 422\n# Description: Prompt failed the safety check.\n# Content-Type: application/json\n# 429\n# Description: Too many requests.", + "Code": "### Generate a design from a text prompt with text detection and correction\n# @name post_generate_design_v3\nPOST {{host}}/v1/ideogram-v3/generate-design\nAuthorization: Bearer {{token}}\nContent-Type: application/json\nAccept: application/json\n\n{\n \u0022prompt\u0022: \u0022A birthday card saying \\u0027Happy Birthday\\u0027\u0022,\n \u0022seed\u0022: 12345,\n \u0022resolution\u0022: \u00221280x800\u0022,\n \u0022aspect_ratio\u0022: \u00221x3\u0022,\n \u0022rendering_speed\u0022: \u0022DEFAULT\u0022,\n \u0022magic_prompt\u0022: \u0022ON\u0022,\n \u0022magic_prompt_system_prompt_config_id\u0022: \u0022string\u0022,\n \u0022negative_prompt\u0022: \u0022brush strokes, painting\u0022,\n \u0022num_images\u0022: 1,\n \u0022color_palette\u0022: {\n \u0022name\u0022: \u0022PASTEL\u0022\n },\n \u0022style_codes\u0022: [\n \u0022AAFF5733\u0022,\n \u00220133FF57\u0022,\n \u0022DE3357FF\u0022\n ],\n \u0022style_type\u0022: \u0022GENERAL\u0022,\n \u0022style_preset\u0022: \u0022BRIGHT_ART\u0022,\n \u0022custom_model_uri\u0022: \u0022model/my-custom-model/version/1\u0022,\n \u0022font_file_h1\u0022: \u0022\u0022,\n \u0022font_name_h1\u0022: \u0022Ubuntu-Bold.ttf\u0022,\n \u0022font_file_h2\u0022: \u0022\u0022,\n \u0022font_name_h2\u0022: \u0022string\u0022,\n \u0022font_file_body\u0022: \u0022\u0022,\n \u0022font_name_body\u0022: \u0022string\u0022,\n \u0022font_file_small\u0022: \u0022\u0022,\n \u0022font_name_small\u0022: \u0022string\u0022,\n \u0022style_reference_images\u0022: [\n \u0022\u0022\n ],\n \u0022reference_asset_images\u0022: [\n \u0022\u0022\n ]\n}\n\n## Responses\n# 200\n# Description: Design(s) generated successfully with text correction.\n# Content-Type: application/json\n# 400\n# Description: Invalid input provided.\n# 401\n# Description: Not authorized to generate an image.\n# 422\n# Description: Prompt failed the safety check.\n# Content-Type: application/json\n# 429\n# Description: Too many requests.", "Format": "http", "OperationId": "post_generate_design_v3", "Setup": null }, { - "Order": 11, + "Order": 10, "Title": "Generate (legacy)", "Slug": "post-generate-image", "Description": "Generates images synchronously based on a given prompt and optional parameters.\n\nImages links are available for a limited period of time; if you would like to keep the image, you must download it.", @@ -122,40 +111,40 @@ "Setup": "This example assumes \u0060using Ideogram;\u0060 is in scope and \u0060apiKey\u0060 contains the required credential." }, { - "Order": 12, + "Order": 11, "Title": "Generate with Ideogram 3.0", "Slug": "post-generate-image-v3", "Description": "Generates images synchronously based on a given prompt and optional parameters using the Ideogram 3.0 model.\n\nImages links are available for a limited period of time; if you would like to keep the image, you must download it.", "Language": "http", - "Code": "### Generate with Ideogram 3.0\n# @name post_generate_image_v3\nPOST {{host}}/v1/ideogram-v3/generate\nAuthorization: Bearer {{token}}\nContent-Type: application/json\nAccept: application/json\n\n{\n \u0022prompt\u0022: \u0022A photo of a cat\u0022,\n \u0022seed\u0022: 12345,\n \u0022resolution\u0022: \u00221280x800\u0022,\n \u0022aspect_ratio\u0022: \u00221x3\u0022,\n \u0022rendering_speed\u0022: \u0022DEFAULT\u0022,\n \u0022magic_prompt\u0022: \u0022ON\u0022,\n \u0022negative_prompt\u0022: \u0022brush strokes, painting\u0022,\n \u0022num_images\u0022: 1,\n \u0022color_palette\u0022: {\n \u0022name\u0022: \u0022PASTEL\u0022\n },\n \u0022style_codes\u0022: [\n \u0022AAFF5733\u0022,\n \u00220133FF57\u0022,\n \u0022DE3357FF\u0022\n ],\n \u0022style_type\u0022: \u0022GENERAL\u0022,\n \u0022style_preset\u0022: \u0022BRIGHT_ART\u0022,\n \u0022custom_model_uri\u0022: \u0022model/my-custom-model/version/1\u0022,\n \u0022style_reference_images\u0022: [\n \u0022\u0022\n ],\n \u0022character_reference_images\u0022: [\n \u0022\u0022\n ],\n \u0022character_reference_images_mask\u0022: [\n \u0022\u0022\n ]\n}\n\n## Responses\n# 200\n# Description: Image(s) generated successfully.\n# Content-Type: application/json\n# 400\n# Description: Invalid input provided.\n# 401\n# Description: Not authorized to generate an image.\n# 422\n# Description: Prompt failed the safety check.\n# Content-Type: application/json\n# 429\n# Description: Too many requests.", + "Code": "### Generate with Ideogram 3.0\n# @name post_generate_image_v3\nPOST {{host}}/v1/ideogram-v3/generate\nAuthorization: Bearer {{token}}\nContent-Type: application/json\nAccept: application/json\n\n{\n \u0022prompt\u0022: \u0022A photo of a cat\u0022,\n \u0022seed\u0022: 12345,\n \u0022resolution\u0022: \u00221280x800\u0022,\n \u0022aspect_ratio\u0022: \u00221x3\u0022,\n \u0022rendering_speed\u0022: \u0022DEFAULT\u0022,\n \u0022magic_prompt\u0022: \u0022ON\u0022,\n \u0022magic_prompt_system_prompt_config_id\u0022: \u0022string\u0022,\n \u0022negative_prompt\u0022: \u0022brush strokes, painting\u0022,\n \u0022num_images\u0022: 1,\n \u0022color_palette\u0022: {\n \u0022name\u0022: \u0022PASTEL\u0022\n },\n \u0022style_codes\u0022: [\n \u0022AAFF5733\u0022,\n \u00220133FF57\u0022,\n \u0022DE3357FF\u0022\n ],\n \u0022style_type\u0022: \u0022GENERAL\u0022,\n \u0022style_preset\u0022: \u0022BRIGHT_ART\u0022,\n \u0022custom_model_uri\u0022: \u0022model/my-custom-model/version/1\u0022,\n \u0022style_reference_images\u0022: [\n \u0022\u0022\n ],\n \u0022character_reference_images\u0022: [\n \u0022\u0022\n ],\n \u0022character_reference_images_mask\u0022: [\n \u0022\u0022\n ]\n}\n\n## Responses\n# 200\n# Description: Image(s) generated successfully.\n# Content-Type: application/json\n# 400\n# Description: Invalid input provided.\n# 401\n# Description: Not authorized to generate an image.\n# 422\n# Description: Prompt failed the safety check.\n# Content-Type: application/json\n# 429\n# Description: Too many requests.", "Format": "http", "OperationId": "post_generate_image_v3", "Setup": null }, { - "Order": 13, + "Order": 12, "Title": "Generate with Ideogram 3.0 (Transparent Background)", "Slug": "post-generate-image-v3-transparent", - "Description": "Generates images with transparent background synchronously based on a given prompt and optional parameters using\nthe Ideogram 3.0 model. Images will be generated using maximum supported resolution at the specified aspect ratio\nto allow best results with upscaler. The selected resolution is written to the response, not the upscaled final\nresolution.\n\nImages links are available for a limited period of time; if you would like to keep the image, you must download it.", + "Description": "Generates images with transparent background synchronously based on a given prompt and optional parameters using\nthe Ideogram 3.0 model. Images will be generated using maximum supported resolution at the specified aspect ratio\nto allow best results with upscaler. The selected resolution is written to the response, not the upscaled final\nresolution.\n\n\u0060rendering_speed=FLASH\u0060 is not supported for transparent-background generation; the request will return a 400.\nUse \u0060TURBO\u0060, \u0060DEFAULT\u0060, or \u0060QUALITY\u0060 instead.\n\nImages links are available for a limited period of time; if you would like to keep the image, you must download it.", "Language": "http", - "Code": "### Generate with Ideogram 3.0 (Transparent Background)\n# @name post_generate_image_v3_transparent\nPOST {{host}}/v1/ideogram-v3/generate-transparent\nAuthorization: Bearer {{token}}\nContent-Type: application/json\nAccept: application/json\n\n{\n \u0022prompt\u0022: \u0022A photo of a cat\u0022,\n \u0022seed\u0022: 12345,\n \u0022upscale_factor\u0022: \u0022X2\u0022,\n \u0022aspect_ratio\u0022: \u00221x3\u0022,\n \u0022rendering_speed\u0022: \u0022DEFAULT\u0022,\n \u0022magic_prompt\u0022: \u0022ON\u0022,\n \u0022negative_prompt\u0022: \u0022brush strokes, painting\u0022,\n \u0022num_images\u0022: 1,\n \u0022custom_model_uri\u0022: \u0022model/my-custom-model/version/1\u0022\n}\n\n## Responses\n# 200\n# Description: Image(s) generated successfully.\n# Content-Type: application/json\n# 400\n# Description: Invalid input provided.\n# 401\n# Description: Not authorized to generate an image.\n# 422\n# Description: Prompt failed the safety check.\n# Content-Type: application/json\n# 429\n# Description: Too many requests.", + "Code": "### Generate with Ideogram 3.0 (Transparent Background)\n# @name post_generate_image_v3_transparent\nPOST {{host}}/v1/ideogram-v3/generate-transparent\nAuthorization: Bearer {{token}}\nContent-Type: application/json\nAccept: application/json\n\n{\n \u0022prompt\u0022: \u0022A photo of a cat\u0022,\n \u0022seed\u0022: 12345,\n \u0022upscale_factor\u0022: \u0022X2\u0022,\n \u0022aspect_ratio\u0022: \u00221x3\u0022,\n \u0022rendering_speed\u0022: \u0022DEFAULT\u0022,\n \u0022magic_prompt\u0022: \u0022ON\u0022,\n \u0022magic_prompt_system_prompt_config_id\u0022: \u0022string\u0022,\n \u0022negative_prompt\u0022: \u0022brush strokes, painting\u0022,\n \u0022num_images\u0022: 1,\n \u0022custom_model_uri\u0022: \u0022model/my-custom-model/version/1\u0022\n}\n\n## Responses\n# 200\n# Description: Image(s) generated successfully.\n# Content-Type: application/json\n# 400\n# Description: Invalid input provided.\n# 401\n# Description: Not authorized to generate an image.\n# 422\n# Description: Prompt failed the safety check.\n# Content-Type: application/json\n# 429\n# Description: Too many requests.", "Format": "http", "OperationId": "post_generate_image_v3_transparent", "Setup": null }, { - "Order": 14, + "Order": 13, "Title": "Generate with Ideogram 4.0", "Slug": "post-generate-image-v4", "Description": "Generates images synchronously using the Ideogram 4.0 model.\n\nImages links are available for a limited period of time; if you would like to keep the image, you must download it.", "Language": "http", - "Code": "### Generate with Ideogram 4.0\n# @name post_generate_image_v4\nPOST {{host}}/v1/ideogram-v4/generate\nAuthorization: Bearer {{token}}\nContent-Type: application/json\nAccept: application/json\n\n{\n \u0022prompt\u0022: \u0022string\u0022,\n \u0022seed\u0022: 0,\n \u0022magic_prompt_option\u0022: \u0022ON\u0022,\n \u0022custom_model_uri\u0022: \u0022model/my-custom-model/version/0\u0022\n}\n\n## Responses\n# 200\n# Description: Image(s) generated successfully.\n# Content-Type: application/json\n# 400\n# Description: Invalid input provided.\n# 401\n# Description: Not authorized.\n# 422\n# Description: Prompt failed the safety check.\n# Content-Type: application/json\n# 429\n# Description: Too many requests.", + "Code": "### Generate with Ideogram 4.0\n# @name post_generate_image_v4\nPOST {{host}}/v1/ideogram-v4/generate\nAuthorization: Bearer {{token}}\nContent-Type: application/json\nAccept: application/json\n\n{\n \u0022prompt\u0022: \u0022string\u0022,\n \u0022seed\u0022: 0,\n \u0022magic_prompt_option\u0022: \u0022ON\u0022,\n \u0022magic_prompt_system_prompt_config_id\u0022: \u0022string\u0022,\n \u0022custom_model_uri\u0022: \u0022model/my-custom-model/version/0\u0022,\n \u0022resolution\u0022: \u00221280x800\u0022,\n \u0022rendering_speed\u0022: \u0022DEFAULT\u0022\n}\n\n## Responses\n# 200\n# Description: Image(s) generated successfully.\n# Content-Type: application/json\n# 400\n# Description: Invalid input provided.\n# 401\n# Description: Not authorized.\n# 422\n# Description: Prompt failed the safety check.\n# Content-Type: application/json\n# 429\n# Description: Too many requests.", "Format": "http", "OperationId": "post_generate_image_v4", "Setup": null }, { - "Order": 15, + "Order": 14, "Title": "Inpaint with Ideogram 3.0", "Slug": "post-inpaint-image-v3", "Description": "Inpaint a given image synchronously using the provided mask with Ideogram 3.0. The mask indicates which part of the image\nshould be edited, while the prompt and chosen style can further guide the edit.\n\nSupported image formats include JPEG, PNG, and WebP.\n\nImages links are available for a limited period of time; if you would like to keep the image, you must download it.", @@ -166,7 +155,7 @@ "Setup": null }, { - "Order": 16, + "Order": 15, "Title": "Layerize an existing flat graphic image with text detection and correction", "Slug": "post-layerize-design-v3", "Description": "Processes an existing flat graphic image to detect and correct text layers without generating a new image from scratch.\n\nThe uploaded image is analyzed for text content, which is then removed and returned as structured text layers with font matching, sizing, and color information.\n\nSupported image formats include JPEG, PNG, and WebP (max size 10MB).\n\nImages links are available for a limited period of time; if you would like to keep the image, you must download it.", @@ -177,7 +166,7 @@ "Setup": null }, { - "Order": 17, + "Order": 16, "Title": "Layerize Text", "Slug": "post-layerize-text-v3", "Description": "Analyzes an image to detect text regions, then returns each detected text block with its position, content, font information, and styling.\n\nThe response includes a text-erased base image (background with all text removed) and a flat list of detected text blocks.\n\nSupported image formats include JPEG, PNG, and WebP (max size 10MB).\n\nImage links are available for a limited period of time; if you would like to keep the image, you must download it.", @@ -188,7 +177,7 @@ "Setup": null }, { - "Order": 18, + "Order": 17, "Title": "Reframe (legacy)", "Slug": "post-reframe-image", "Description": "Reframe a square image to a chosen resolution. The supported image formats include JPEG, PNG, and WebP.\n\nImage links are available for a limited period of time; if you would like to keep the image, you must download it.", @@ -199,7 +188,7 @@ "Setup": null }, { - "Order": 19, + "Order": 18, "Title": "Reframe with Ideogram 3.0", "Slug": "post-reframe-image-v3", "Description": "Reframe a square image to a chosen resolution with Ideogram 3.0. The supported image formats include JPEG, PNG, and WebP.\n\nImage links are available for a limited period of time; if you would like to keep the image, you must download it.", @@ -210,7 +199,7 @@ "Setup": null }, { - "Order": 20, + "Order": 19, "Title": "Remix (legacy)", "Slug": "post-remix-image", "Description": "Remix provided images synchronously based on a given prompt and optional parameters.\n\nInput images are cropped to the chosen aspect ratio before being remixed.\n\nSupported image formats include JPEG, PNG, and WebP.\n\nImages links are available for a limited period of time; if you would like to keep the image, you must download it.", @@ -221,7 +210,7 @@ "Setup": null }, { - "Order": 21, + "Order": 20, "Title": "Remix with Ideogram 3.0", "Slug": "post-remix-image-v3", "Description": "Remix provided images synchronously based on a given prompt and optional parameters with the Ideogram 3.0 model.\n\nInput images are cropped to the chosen aspect ratio before being remixed.\n\nSupported image formats include JPEG, PNG, and WebP.\n\nImages links are available for a limited period of time; if you would like to keep the image, you must download it.", @@ -231,6 +220,17 @@ "OperationId": "post_remix_image_v3", "Setup": null }, + { + "Order": 21, + "Title": "Remove Background", + "Slug": "post-remove-background", + "Description": "Remove the background of a given image synchronously. The foreground subject\nis identified and returned on a transparent background. Supported image formats include JPEG,\nPNG, and WebP.\nImage links are available for a limited period of time; if you would like to keep the image,\nyou must download it.", + "Language": "http", + "Code": "### Remove Background\n# @name post_remove_background\nPOST {{host}}/v1/remove-background\nAuthorization: Bearer {{token}}\nContent-Type: multipart/form-data\nAccept: application/json\n\n## Responses\n# 200\n# Description: Background removed successfully.\n# Content-Type: application/json\n# 400\n# Description: Invalid input provided.\n# 401\n# Description: Not authorized to remove background.\n# 422\n# Description: Initial image failed the safety checks.\n# Content-Type: application/json\n# 429\n# Description: Too many requests.", + "Format": "http", + "OperationId": "post_remove_background", + "Setup": null + }, { "Order": 22, "Title": "Replace Background with Ideogram 3.0", diff --git a/src/libs/Ideogram/openapi.json b/src/libs/Ideogram/openapi.json index 788fd60..5f3acbb 100644 --- a/src/libs/Ideogram/openapi.json +++ b/src/libs/Ideogram/openapi.json @@ -2334,12 +2334,48 @@ "tags": [ "generate" ], + "x-fern-examples": [ + { + "request": { + "prompt": "Change the background to a beach sunset." + }, + "response": { + "body": { + "created": "2000-01-23T04:56:07+00:00", + "data": [ + { + "prompt": "Change the background to a beach sunset.", + "resolution": "1024x1024", + "is_image_safe": true, + "seed": 12345, + "url": "https://ideogram.ai/api/images/ephemeral/xtdZiqPwRxqY1Y7NExFmzB.png?exp=1743867804&sig=e13e12677633f646d8531a153d20e2d3698dca9ee7661ee5ba4f3b64e7ec3f89" + } + ] + } + }, + "code-samples": [ + { + "sdk": "curl", + "code": "curl -X POST https://api.ideogram.ai/v1/edit \\\n -H \"Api-Key: \" \\\n -H \"Content-Type: multipart/form-data\" \\\n -F images=@ \\\n -F prompt=\"Change the background to a beach sunset.\"\n" + }, + { + "sdk": "python", + "code": "import requests\n\nresponse = requests.post(\n \"https://api.ideogram.ai/v1/edit\",\n headers={\n \"Api-Key\": \"\"\n },\n data={\n \"prompt\": \"Change the background to a beach sunset.\"\n },\n files={\n \"images\": open(\"\", \"rb\"),\n }\n)\nprint(response.json())\nwith open('output.png', 'wb') as f:\n f.write(requests.get(response.json()['data'][0]['url']).content)\n" + }, + { + "sdk": "typescript", + "code": "const formData = new FormData();\nformData.append('prompt', 'Change the background to a beach sunset.');\nformData.append('images', '');\nconst response = await fetch('https://api.ideogram.ai/v1/edit', {\n method: 'POST',\n headers: { 'Api-Key': '' },\n body: formData\n});\nconst data = await response.json();\nconsole.log(data);\n" + } + ] + } + ], "x-openapi-router-controller": "external_api.generated.openapi.controllers.generate_controller" } }, "/v1/ideogram-v3/edit": { "post": { - "description": "Edit a given image synchronously using the provided mask with Ideogram 3.0. The mask indicates which part of the image\nshould be edited, while the prompt and chosen style can further guide the edit.\n\nSupported image formats include JPEG, PNG, and WebP.\n\nImages links are available for a limited period of time; if you would like to keep the image, you must download it.\n", + "deprecated": true, + "description": "Deprecated: use [`POST /v1/ideogram-v3/inpaint`](/api-reference/api-reference/inpaint-v3) instead. This endpoint will be removed in a future release.\n\nEdit a given image synchronously using the provided mask with Ideogram 3.0. The mask indicates which part of the image\nshould be edited, while the prompt and chosen style can further guide the edit.\n\nSupported image formats include JPEG, PNG, and WebP.\n\nImages links are available for a limited period of time; if you would like to keep the image, you must download it.\n", "operationId": "post_edit_image_v3", "requestBody": { "content": { @@ -2605,7 +2641,7 @@ }, "/v1/ideogram-v3/generate-transparent": { "post": { - "description": "Generates images with transparent background synchronously based on a given prompt and optional parameters using\nthe Ideogram 3.0 model. Images will be generated using maximum supported resolution at the specified aspect ratio\nto allow best results with upscaler. The selected resolution is written to the response, not the upscaled final\nresolution.\n\nImages links are available for a limited period of time; if you would like to keep the image, you must download it.\n", + "description": "Generates images with transparent background synchronously based on a given prompt and optional parameters using\nthe Ideogram 3.0 model. Images will be generated using maximum supported resolution at the specified aspect ratio\nto allow best results with upscaler. The selected resolution is written to the response, not the upscaled final\nresolution.\n\n`rendering_speed=FLASH` is not supported for transparent-background generation; the request will return a 400.\nUse `TURBO`, `DEFAULT`, or `QUALITY` instead.\n\nImages links are available for a limited period of time; if you would like to keep the image, you must download it.\n", "operationId": "post_generate_image_v3_transparent", "requestBody": { "content": { @@ -2863,6 +2899,43 @@ "tags": [ "generate" ], + "x-fern-examples": [ + { + "request": { + "prompt": "A photo of a cat wearing a hat.", + "style_type": "AUTO" + }, + "response": { + "body": { + "created": "2000-01-23T04:56:07+00:00", + "data": [ + { + "prompt": "A photo of a cat wearing a hat.", + "resolution": "1024x1024", + "is_image_safe": true, + "seed": 12345, + "url": "https://ideogram.ai/api/images/ephemeral/xtdZiqPwRxqY1Y7NExFmzB.png?exp=1743867804&sig=e13e12677633f646d8531a153d20e2d3698dca9ee7661ee5ba4f3b64e7ec3f89", + "style_type": "AUTO" + } + ] + } + }, + "code-samples": [ + { + "sdk": "curl", + "code": "curl -X POST https://api.ideogram.ai/v1/ideogram-v3/inpaint \\\n -H \"Api-Key: \" \\\n -H \"Content-Type: multipart/form-data\" \\\n -F image=@ \\\n -F mask=@ \\\n -F prompt=\"A photo of a cat wearing a hat.\" \\\n -F rendering_speed=\"DEFAULT\"\n" + }, + { + "sdk": "python", + "code": "import requests\n\nresponse = requests.post(\n \"https://api.ideogram.ai/v1/ideogram-v3/inpaint\",\n headers={\n \"Api-Key\": \"\"\n },\n data={\n \"prompt\": \"A photo of a cat wearing a hat.\",\n \"rendering_speed\": \"DEFAULT\"\n },\n files={\n \"image\": open(\"\", \"rb\"),\n \"mask\": open(\"\", \"rb\"),\n }\n)\nprint(response.json())\nwith open('output.png', 'wb') as f:\n f.write(requests.get(response.json()['data'][0]['url']).content)\n" + }, + { + "sdk": "typescript", + "code": "const formData = new FormData();\nformData.append('prompt', 'A photo of a cat');\nformData.append('rendering_speed', 'TURBO');\nconst response = await fetch('https://api.ideogram.ai/v1/ideogram-v3/inpaint', {\n method: 'POST',\n headers: { 'Api-Key': '' },\n body: formData\n});\nconst data = await response.json();\nconsole.log(data);\n" + } + ] + } + ], "x-openapi-router-controller": "external_api.generated.openapi.controllers.generate_controller" } }, @@ -3485,6 +3558,60 @@ ], "x-openapi-router-controller": "external_api.generated.openapi.controllers.generate_controller" } + }, + "/v1/remove-background": { + "post": { + "description": "Remove the background of a given image synchronously. The foreground subject\nis identified and returned on a transparent background. Supported image formats include JPEG,\nPNG, and WebP.\nImage links are available for a limited period of time; if you would like to keep the image,\nyou must download it.\n", + "operationId": "post_remove_background", + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "$ref": "#/components/schemas/RemoveBackgroundRequest" + } + } + }, + "description": "A request to remove the background of an image.", + "required": true, + "x-body-name": "body" + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RemoveBackgroundResponse" + } + } + }, + "description": "Background removed successfully." + }, + "400": { + "description": "Invalid input provided." + }, + "401": { + "description": "Not authorized to remove background." + }, + "422": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GenerateImageSafetyError" + } + } + }, + "description": "Initial image failed the safety checks." + }, + "429": { + "description": "Too many requests." + } + }, + "summary": "Remove Background", + "tags": [ + "generate" + ], + "x-openapi-router-controller": "external_api.generated.openapi.controllers.generate_controller" + } } }, "components": { @@ -3503,10 +3630,20 @@ "magic_prompt_option": { "$ref": "#/components/schemas/MagicPromptOption" }, + "magic_prompt_system_prompt_config_id": { + "description": "A base64url-encoded magic prompt system prompt config ID to use for this request.", + "type": "string" + }, "custom_model_uri": { "description": "A custom model URI in the format model//version/.\nWhen provided, the model version and style will be resolved from this URI.\n", "example": "model/my-custom-model/version/0", "type": "string" + }, + "resolution": { + "$ref": "#/components/schemas/ResolutionV4" + }, + "rendering_speed": { + "$ref": "#/components/schemas/RenderingSpeed" } }, "required": [ @@ -3574,6 +3711,10 @@ "magic_prompt_option": { "$ref": "#/components/schemas/MagicPromptOption" }, + "magic_prompt_system_prompt_config_id": { + "description": "A base64url-encoded magic prompt system prompt config ID to use for this request.", + "type": "string" + }, "num_images": { "$ref": "#/components/schemas/NumImages" }, @@ -3639,6 +3780,10 @@ "magic_prompt": { "$ref": "#/components/schemas/MagicPromptOption" }, + "magic_prompt_system_prompt_config_id": { + "description": "A base64url-encoded magic prompt system prompt config ID to use for this request.", + "type": "string" + }, "negative_prompt": { "description": "Description of what to exclude from an image. Descriptions in the prompt take precedence\nto descriptions in the negative prompt.\n", "example": "brush strokes, painting", @@ -3734,6 +3879,10 @@ "magic_prompt": { "$ref": "#/components/schemas/MagicPromptOption" }, + "magic_prompt_system_prompt_config_id": { + "description": "A base64url-encoded magic prompt system prompt config ID to use for this request.", + "type": "string" + }, "negative_prompt": { "description": "Description of what to exclude from a graphic. Descriptions in the prompt take precedence\nto descriptions in the negative prompt.\n", "example": "brush strokes, painting", @@ -3860,6 +4009,10 @@ "magic_prompt": { "$ref": "#/components/schemas/MagicPromptOption" }, + "magic_prompt_system_prompt_config_id": { + "description": "A base64url-encoded magic prompt system prompt config ID to use for this request.", + "type": "string" + }, "negative_prompt": { "description": "Description of what to exclude from a design. Descriptions in the prompt take precedence\nto descriptions in the negative prompt.\n", "example": "brush strokes, painting", @@ -4049,6 +4202,10 @@ "magic_prompt": { "$ref": "#/components/schemas/MagicPromptOption" }, + "magic_prompt_system_prompt_config_id": { + "description": "A base64url-encoded magic prompt system prompt config ID to use for this request.", + "type": "string" + }, "negative_prompt": { "description": "Description of what to exclude from an image. Descriptions in the prompt take precedence\nto descriptions in the negative prompt.\n", "example": "brush strokes, painting", @@ -4106,6 +4263,10 @@ "magic_prompt": { "$ref": "#/components/schemas/MagicPromptOption" }, + "magic_prompt_system_prompt_config_id": { + "description": "A base64url-encoded magic prompt system prompt config ID to use for this request.", + "type": "string" + }, "negative_prompt": { "description": "Description of what to exclude from an image. Descriptions in the prompt take precedence\nto descriptions in the negative prompt.\n", "example": "brush strokes, painting", @@ -4186,6 +4347,10 @@ "magic_prompt": { "$ref": "#/components/schemas/MagicPromptOption" }, + "magic_prompt_system_prompt_config_id": { + "description": "A base64url-encoded magic prompt system prompt config ID to use for this request.", + "type": "string" + }, "num_images": { "$ref": "#/components/schemas/NumImages" }, @@ -4277,6 +4442,10 @@ "magic_prompt": { "$ref": "#/components/schemas/MagicPromptOption" }, + "magic_prompt_system_prompt_config_id": { + "description": "A base64url-encoded magic prompt system prompt config ID to use for this request.", + "type": "string" + }, "resolution": { "$ref": "#/components/schemas/ResolutionV3" }, @@ -4310,6 +4479,10 @@ "magic_prompt": { "$ref": "#/components/schemas/MagicPromptOption" }, + "magic_prompt_system_prompt_config_id": { + "description": "A base64url-encoded magic prompt system prompt config ID to use for this request.", + "type": "string" + }, "num_images": { "$ref": "#/components/schemas/NumImages" }, @@ -4400,6 +4573,10 @@ "magic_prompt": { "$ref": "#/components/schemas/MagicPromptOption" }, + "magic_prompt_system_prompt_config_id": { + "description": "A base64url-encoded magic prompt system prompt config ID to use for this request.", + "type": "string" + }, "num_images": { "$ref": "#/components/schemas/NumImages" }, @@ -4433,6 +4610,73 @@ ], "type": "object" }, + "RemoveBackgroundRequest": { + "properties": { + "image": { + "description": "The image whose background is being removed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time.", + "format": "binary", + "type": "string" + } + }, + "required": [ + "image" + ], + "type": "object" + }, + "RemoveBackgroundResponse": { + "description": "The response containing the foreground image with the background removed.\nImage links are available for a limited period of time; if you would like to keep the image, you must download it.", + "example": { + "created": "2000-01-23T04:56:07+00:00", + "data": [ + { + "url": "https://ideogram.ai/api/images/ephemeral/xtdZiqPwRxqY1Y7NExFmzB.png?exp=1743867804&sig=e13e12677633f646d8531a153d20e2d3698dca9ee7661ee5ba4f3b64e7ec3f89", + "is_image_safe": true + } + ] + }, + "properties": { + "created": { + "description": "The time the request was created.", + "format": "date-time", + "type": "string" + }, + "data": { + "description": "A list containing the single foreground image. The endpoint always returns exactly one entry.", + "items": { + "$ref": "#/components/schemas/RemoveBackgroundImageObject" + }, + "type": "array" + } + }, + "required": [ + "created", + "data" + ], + "title": "RemoveBackgroundResponse", + "type": "object" + }, + "RemoveBackgroundImageObject": { + "properties": { + "url": { + "description": "The direct link to the foreground image. Empty when the image fails safety checks.", + "example": "https://ideogram.ai/api/images/ephemeral/xtdZiqPwRxqY1Y7NExFmzB.png?exp=1743867804&sig=e13e12677633f646d8531a153d20e2d3698dca9ee7661ee5ba4f3b64e7ec3f89", + "format": "uri", + "nullable": true, + "title": "url", + "type": "string" + }, + "is_image_safe": { + "description": "Whether the foreground image passes safety checks. If false, the url field will be empty.", + "title": "is_image_safe", + "type": "boolean" + } + }, + "required": [ + "is_image_safe" + ], + "title": "RemoveBackgroundImageObject", + "type": "object" + }, "InternalTestingRequest": { "properties": { "x_position": { @@ -4619,6 +4863,10 @@ "magic_prompt_option": { "$ref": "#/components/schemas/MagicPromptOption" }, + "magic_prompt_system_prompt_config_id": { + "description": "A base64url-encoded magic prompt system prompt config ID to use for this request.", + "type": "string" + }, "magic_prompt_version": { "$ref": "#/components/schemas/MagicPromptVersionEnum" }, @@ -4713,6 +4961,11 @@ "magic_prompt_option": { "$ref": "#/components/schemas/MagicPromptOption" }, + "magic_prompt_system_prompt_config_id": { + "description": "A base64url-encoded magic prompt system prompt config ID to use for this request.", + "title": "magic_prompt_system_prompt_config_id", + "type": "string" + }, "magic_prompt_version": { "$ref": "#/components/schemas/MagicPromptVersionEnum" }, @@ -5197,6 +5450,8 @@ } ], "font_size": 5, + "vertical_alignment": "top", + "text_transform": "none", "glyph_type": "bullet", "line_height": 2.302136, "x": 0, @@ -5206,6 +5461,21 @@ "angle": 0, "alignment": "center", "font_file": "font_file", + "letter_spacing": 7.0614014, + "drop_shadows": [ + { + "color": "color", + "blur": 0.2027123, + "offset_x": 9.301444, + "offset_y": 3.6160767 + }, + { + "color": "color", + "blur": 0.2027123, + "offset_x": 9.301444, + "offset_y": 3.6160767 + } + ], "height": 5 }, { @@ -5232,6 +5502,8 @@ } ], "font_size": 5, + "vertical_alignment": "top", + "text_transform": "none", "glyph_type": "bullet", "line_height": 2.302136, "x": 0, @@ -5241,6 +5513,21 @@ "angle": 0, "alignment": "center", "font_file": "font_file", + "letter_spacing": 7.0614014, + "drop_shadows": [ + { + "color": "color", + "blur": 0.2027123, + "offset_x": 9.301444, + "offset_y": 3.6160767 + }, + { + "color": "color", + "blur": 0.2027123, + "offset_x": 9.301444, + "offset_y": 3.6160767 + } + ], "height": 5 } ] @@ -5272,6 +5559,8 @@ } ], "font_size": 5, + "vertical_alignment": "top", + "text_transform": "none", "glyph_type": "bullet", "line_height": 2.302136, "x": 0, @@ -5281,6 +5570,21 @@ "angle": 0, "alignment": "center", "font_file": "font_file", + "letter_spacing": 7.0614014, + "drop_shadows": [ + { + "color": "color", + "blur": 0.2027123, + "offset_x": 9.301444, + "offset_y": 3.6160767 + }, + { + "color": "color", + "blur": 0.2027123, + "offset_x": 9.301444, + "offset_y": 3.6160767 + } + ], "height": 5 }, { @@ -5307,6 +5611,8 @@ } ], "font_size": 5, + "vertical_alignment": "top", + "text_transform": "none", "glyph_type": "bullet", "line_height": 2.302136, "x": 0, @@ -5316,6 +5622,21 @@ "angle": 0, "alignment": "center", "font_file": "font_file", + "letter_spacing": 7.0614014, + "drop_shadows": [ + { + "color": "color", + "blur": 0.2027123, + "offset_x": 9.301444, + "offset_y": 3.6160767 + }, + { + "color": "color", + "blur": 0.2027123, + "offset_x": 9.301444, + "offset_y": 3.6160767 + } + ], "height": 5 } ] @@ -5324,17 +5645,17 @@ "image_layers": [ { "ref_id": "REF_0", - "x": 7, - "width": 3, - "y": 9, - "height": 2 + "x": 4, + "width": 1, + "y": 7, + "height": 1 }, { "ref_id": "REF_0", - "x": 7, - "width": 3, - "y": 9, - "height": 2 + "x": 4, + "width": 1, + "y": 7, + "height": 1 } ], "url": "https://openapi-generator.tech", @@ -5407,6 +5728,8 @@ } ], "font_size": 5, + "vertical_alignment": "top", + "text_transform": "none", "glyph_type": "bullet", "line_height": 2.302136, "x": 0, @@ -5416,6 +5739,21 @@ "angle": 0, "alignment": "center", "font_file": "font_file", + "letter_spacing": 7.0614014, + "drop_shadows": [ + { + "color": "color", + "blur": 0.2027123, + "offset_x": 9.301444, + "offset_y": 3.6160767 + }, + { + "color": "color", + "blur": 0.2027123, + "offset_x": 9.301444, + "offset_y": 3.6160767 + } + ], "height": 5 }, { @@ -5442,6 +5780,8 @@ } ], "font_size": 5, + "vertical_alignment": "top", + "text_transform": "none", "glyph_type": "bullet", "line_height": 2.302136, "x": 0, @@ -5451,6 +5791,21 @@ "angle": 0, "alignment": "center", "font_file": "font_file", + "letter_spacing": 7.0614014, + "drop_shadows": [ + { + "color": "color", + "blur": 0.2027123, + "offset_x": 9.301444, + "offset_y": 3.6160767 + }, + { + "color": "color", + "blur": 0.2027123, + "offset_x": 9.301444, + "offset_y": 3.6160767 + } + ], "height": 5 } ] @@ -5482,6 +5837,8 @@ } ], "font_size": 5, + "vertical_alignment": "top", + "text_transform": "none", "glyph_type": "bullet", "line_height": 2.302136, "x": 0, @@ -5491,6 +5848,21 @@ "angle": 0, "alignment": "center", "font_file": "font_file", + "letter_spacing": 7.0614014, + "drop_shadows": [ + { + "color": "color", + "blur": 0.2027123, + "offset_x": 9.301444, + "offset_y": 3.6160767 + }, + { + "color": "color", + "blur": 0.2027123, + "offset_x": 9.301444, + "offset_y": 3.6160767 + } + ], "height": 5 }, { @@ -5517,6 +5889,8 @@ } ], "font_size": 5, + "vertical_alignment": "top", + "text_transform": "none", "glyph_type": "bullet", "line_height": 2.302136, "x": 0, @@ -5526,6 +5900,21 @@ "angle": 0, "alignment": "center", "font_file": "font_file", + "letter_spacing": 7.0614014, + "drop_shadows": [ + { + "color": "color", + "blur": 0.2027123, + "offset_x": 9.301444, + "offset_y": 3.6160767 + }, + { + "color": "color", + "blur": 0.2027123, + "offset_x": 9.301444, + "offset_y": 3.6160767 + } + ], "height": 5 } ] @@ -5534,17 +5923,17 @@ "image_layers": [ { "ref_id": "REF_0", - "x": 7, - "width": 3, - "y": 9, - "height": 2 + "x": 4, + "width": 1, + "y": 7, + "height": 1 }, { "ref_id": "REF_0", - "x": 7, - "width": 3, - "y": 9, - "height": 2 + "x": 4, + "width": 1, + "y": 7, + "height": 1 } ], "url": "https://openapi-generator.tech", @@ -5579,6 +5968,8 @@ } ], "font_size": 5, + "vertical_alignment": "top", + "text_transform": "none", "glyph_type": "bullet", "line_height": 2.302136, "x": 0, @@ -5588,6 +5979,21 @@ "angle": 0, "alignment": "center", "font_file": "font_file", + "letter_spacing": 7.0614014, + "drop_shadows": [ + { + "color": "color", + "blur": 0.2027123, + "offset_x": 9.301444, + "offset_y": 3.6160767 + }, + { + "color": "color", + "blur": 0.2027123, + "offset_x": 9.301444, + "offset_y": 3.6160767 + } + ], "height": 5 }, { @@ -5614,6 +6020,8 @@ } ], "font_size": 5, + "vertical_alignment": "top", + "text_transform": "none", "glyph_type": "bullet", "line_height": 2.302136, "x": 0, @@ -5623,6 +6031,21 @@ "angle": 0, "alignment": "center", "font_file": "font_file", + "letter_spacing": 7.0614014, + "drop_shadows": [ + { + "color": "color", + "blur": 0.2027123, + "offset_x": 9.301444, + "offset_y": 3.6160767 + }, + { + "color": "color", + "blur": 0.2027123, + "offset_x": 9.301444, + "offset_y": 3.6160767 + } + ], "height": 5 } ] @@ -5654,6 +6077,8 @@ } ], "font_size": 5, + "vertical_alignment": "top", + "text_transform": "none", "glyph_type": "bullet", "line_height": 2.302136, "x": 0, @@ -5663,6 +6088,21 @@ "angle": 0, "alignment": "center", "font_file": "font_file", + "letter_spacing": 7.0614014, + "drop_shadows": [ + { + "color": "color", + "blur": 0.2027123, + "offset_x": 9.301444, + "offset_y": 3.6160767 + }, + { + "color": "color", + "blur": 0.2027123, + "offset_x": 9.301444, + "offset_y": 3.6160767 + } + ], "height": 5 }, { @@ -5689,6 +6129,8 @@ } ], "font_size": 5, + "vertical_alignment": "top", + "text_transform": "none", "glyph_type": "bullet", "line_height": 2.302136, "x": 0, @@ -5698,6 +6140,21 @@ "angle": 0, "alignment": "center", "font_file": "font_file", + "letter_spacing": 7.0614014, + "drop_shadows": [ + { + "color": "color", + "blur": 0.2027123, + "offset_x": 9.301444, + "offset_y": 3.6160767 + }, + { + "color": "color", + "blur": 0.2027123, + "offset_x": 9.301444, + "offset_y": 3.6160767 + } + ], "height": 5 } ] @@ -5706,17 +6163,17 @@ "image_layers": [ { "ref_id": "REF_0", - "x": 7, - "width": 3, - "y": 9, - "height": 2 + "x": 4, + "width": 1, + "y": 7, + "height": 1 }, { "ref_id": "REF_0", - "x": 7, - "width": 3, - "y": 9, - "height": 2 + "x": 4, + "width": 1, + "y": 7, + "height": 1 } ], "url": "https://openapi-generator.tech", @@ -5878,6 +6335,7 @@ "a dog" ], "sampling_request_params": { + "magic_prompt_system_prompt_config_id": "magic_prompt_system_prompt_config_id", "aspect_ratio": "1x1", "style_type": "GENERAL", "magic_prompt_version": "V_0", @@ -5942,6 +6400,7 @@ }, "SamplingRequestParams": { "example": { + "magic_prompt_system_prompt_config_id": "magic_prompt_system_prompt_config_id", "aspect_ratio": "1x1", "style_type": "GENERAL", "magic_prompt_version": "V_0", @@ -5971,6 +6430,11 @@ "magic_prompt_option": { "$ref": "#/components/schemas/MagicPromptOption" }, + "magic_prompt_system_prompt_config_id": { + "description": "A base64url-encoded magic prompt system prompt config ID to use for this request.", + "title": "magic_prompt_system_prompt_config_id", + "type": "string" + }, "magic_prompt_version": { "$ref": "#/components/schemas/MagicPromptVersionEnum" }, @@ -6089,6 +6553,8 @@ } ], "font_size": 5, + "vertical_alignment": "top", + "text_transform": "none", "glyph_type": "bullet", "line_height": 2.302136, "x": 0, @@ -6098,6 +6564,21 @@ "angle": 0, "alignment": "center", "font_file": "font_file", + "letter_spacing": 7.0614014, + "drop_shadows": [ + { + "color": "color", + "blur": 0.2027123, + "offset_x": 9.301444, + "offset_y": 3.6160767 + }, + { + "color": "color", + "blur": 0.2027123, + "offset_x": 9.301444, + "offset_y": 3.6160767 + } + ], "height": 5 }, "properties": { @@ -6192,6 +6673,44 @@ "title": "line_height", "type": "number" }, + "letter_spacing": { + "description": "Letter spacing in em units (e.g. 0.05 = 5% of em). V4 vector-text only.", + "format": "float", + "nullable": true, + "title": "letter_spacing", + "type": "number" + }, + "text_transform": { + "description": "Case folding applied at render time. V4 vector-text only.", + "enum": [ + "none", + "uppercase", + "lowercase" + ], + "nullable": true, + "title": "text_transform", + "type": "string" + }, + "vertical_alignment": { + "description": "Vertical anchor (top|middle|bottom) for the rendered text within\nits bounding box. Maps to SVG `dominant-baseline`. V4 vector-text\nonly. Distinct from horizontal `alignment` (left|center|right).\n", + "enum": [ + "top", + "middle", + "bottom" + ], + "nullable": true, + "title": "vertical_alignment", + "type": "string" + }, + "drop_shadows": { + "description": "Stacked drop shadows, composed back-to-front. Phase-1 ships at\nmost one entry; phase-2 unlocks multi-stack. V4 vector-text only.\n", + "items": { + "$ref": "#/components/schemas/LayeredAssetTextShadow" + }, + "nullable": true, + "title": "drop_shadows", + "type": "array" + }, "spans": { "description": "Ordered list of text spans. Concatenating span text values produces the full item text.", "items": { @@ -6242,6 +6761,8 @@ } ], "font_size": 5, + "vertical_alignment": "top", + "text_transform": "none", "glyph_type": "bullet", "line_height": 2.302136, "x": 0, @@ -6251,6 +6772,21 @@ "angle": 0, "alignment": "center", "font_file": "font_file", + "letter_spacing": 7.0614014, + "drop_shadows": [ + { + "color": "color", + "blur": 0.2027123, + "offset_x": 9.301444, + "offset_y": 3.6160767 + }, + { + "color": "color", + "blur": 0.2027123, + "offset_x": 9.301444, + "offset_y": 3.6160767 + } + ], "height": 5 }, { @@ -6277,6 +6813,8 @@ } ], "font_size": 5, + "vertical_alignment": "top", + "text_transform": "none", "glyph_type": "bullet", "line_height": 2.302136, "x": 0, @@ -6286,6 +6824,21 @@ "angle": 0, "alignment": "center", "font_file": "font_file", + "letter_spacing": 7.0614014, + "drop_shadows": [ + { + "color": "color", + "blur": 0.2027123, + "offset_x": 9.301444, + "offset_y": 3.6160767 + }, + { + "color": "color", + "blur": 0.2027123, + "offset_x": 9.301444, + "offset_y": 3.6160767 + } + ], "height": 5 } ] @@ -6316,10 +6869,10 @@ "description": "An image layer (logo, brand asset, icon) for a layered image generation.", "example": { "ref_id": "REF_0", - "x": 7, - "width": 3, - "y": 9, - "height": 2 + "x": 4, + "width": 1, + "y": 7, + "height": 1 }, "properties": { "x": { @@ -7492,7 +8045,7 @@ "type": "string" }, "ModelVersion": { - "description": "The model_version to use.\n- V_0_3: Model 1.0\n- V_1_1: Model 1.1\n- V_1_5: Model 2.0\n- V_2_1: Model 2a\n- V_3_0: Model 3.0 March 26\n- V_3_1: Model 3.0 Latest\n- V_4_0: Model 4.0\n- AUTO: Automatically select the best model version based on the request.\n", + "description": "The model_version to use.\n- V_0_3: Model 1.0\n- V_1_1: Model 1.1\n- V_1_5: Model 2.0\n- V_2_1: Model 2a\n- V_3_0: Model 3.0 March 26\n- V_3_1: Model 3.0 Latest\n- V_4_0: Model 4.0\n- V_4_D: Model 4.0 Layered Design (vector-text path; gated by the access_to_v4d feature flag)\n- AUTO: Automatically select the best model version based on the request.\n", "enum": [ "V_0_1", "V_0_2", @@ -7503,6 +8056,7 @@ "V_3_0", "V_3_1", "V_4_0", + "V_4_D", "EXTERNAL_GOOGLE_VEO_3_0", "EXTERNAL_BYTEDANCE_SEEDANCE_1_0_PRO", "EXTERNAL_MINIMAX_HAILUO_02", @@ -9265,6 +9819,118 @@ "title": "MagicPromptOption", "type": "string" }, + "ResolutionV4": { + "description": "The resolutions supported for Ideogram 4.0.", + "enum": [ + "512x512", + "512x1536", + "576x1408", + "576x1472", + "576x1536", + "640x1344", + "640x1408", + "640x1472", + "640x1536", + "704x1152", + "704x1216", + "704x1280", + "704x1344", + "704x1408", + "704x1472", + "736x1312", + "768x1088", + "768x1216", + "768x1280", + "768x1344", + "800x1280", + "832x960", + "832x1024", + "832x1088", + "832x1152", + "832x1216", + "832x1248", + "864x1152", + "896x960", + "896x1024", + "896x1088", + "896x1120", + "896x1152", + "960x832", + "960x896", + "960x1024", + "960x1088", + "1024x832", + "1024x896", + "1024x960", + "1024x1024", + "1088x768", + "1088x832", + "1088x896", + "1088x960", + "1120x896", + "1152x704", + "1152x832", + "1152x864", + "1152x896", + "1216x704", + "1216x768", + "1216x832", + "1248x832", + "1280x704", + "1280x768", + "1280x800", + "1312x736", + "1344x640", + "1344x704", + "1344x768", + "1408x576", + "1408x640", + "1408x704", + "1472x576", + "1472x640", + "1472x704", + "1536x512", + "1536x576", + "1536x640", + "2048x2048", + "1440x2880", + "2880x1440", + "1664x2496", + "2496x1664", + "1792x2240", + "2240x1792", + "1440x2560", + "2560x1440", + "1600x2560", + "2560x1600", + "1728x2304", + "2304x1728", + "1296x3168", + "3168x1296", + "1152x2944", + "2944x1152", + "1248x3328", + "3328x1248", + "1280x3072", + "3072x1280" + ], + "example": "1280x800", + "title": "ResolutionV4", + "type": "string" + }, + "RenderingSpeed": { + "default": "DEFAULT", + "description": "The rendering speed to use.", + "enum": [ + "FLASH", + "TURBO", + "BALANCED", + "DEFAULT", + "QUALITY" + ], + "title": "RenderingSpeed", + "type": "string" + }, "Description": { "properties": { "text": { @@ -9420,19 +10086,6 @@ "title": "AspectRatioV3", "type": "string" }, - "RenderingSpeed": { - "default": "DEFAULT", - "description": "The rendering speed to use.", - "enum": [ - "FLASH", - "TURBO", - "BALANCED", - "DEFAULT", - "QUALITY" - ], - "title": "RenderingSpeed", - "type": "string" - }, "ColorPaletteWithPresetNameOrMembers": { "description": "A color palette for generation, must EITHER be specified via one of the presets (name) or explicitly via hexadecimal representations of the color with optional weights (members). Not supported by V_1, V_1_TURBO, V_2A and V_2A_TURBO models.", "oneOf": [ @@ -9826,83 +10479,46 @@ "title": "FreeformResolution", "type": "string" }, - "ResolutionV4": { - "description": "The resolutions supported for Ideogram 4.0.", - "enum": [ - "512x512", - "512x1536", - "576x1408", - "576x1472", - "576x1536", - "640x1344", - "640x1408", - "640x1472", - "640x1536", - "704x1152", - "704x1216", - "704x1280", - "704x1344", - "704x1408", - "704x1472", - "736x1312", - "768x1088", - "768x1216", - "768x1280", - "768x1344", - "800x1280", - "832x960", - "832x1024", - "832x1088", - "832x1152", - "832x1216", - "832x1248", - "864x1152", - "896x960", - "896x1024", - "896x1088", - "896x1120", - "896x1152", - "960x832", - "960x896", - "960x1024", - "960x1088", - "1024x832", - "1024x896", - "1024x960", - "1024x1024", - "1088x768", - "1088x832", - "1088x896", - "1088x960", - "1120x896", - "1152x704", - "1152x832", - "1152x864", - "1152x896", - "1216x704", - "1216x768", - "1216x832", - "1248x832", - "1280x704", - "1280x768", - "1280x800", - "1312x736", - "1344x640", - "1344x704", - "1344x768", - "1408x576", - "1408x640", - "1408x704", - "1472x576", - "1472x640", - "1472x704", - "1536x512", - "1536x576", - "1536x640" + "LayeredAssetTextShadow": { + "description": "Single drop shadow for V4 vector text. Phase-1 supports one shadow per item.", + "example": { + "color": "color", + "blur": 0.2027123, + "offset_x": 9.301444, + "offset_y": 3.6160767 + }, + "properties": { + "color": { + "description": "Shadow hex color.", + "pattern": "^#[0-9A-Fa-f]{6}$", + "title": "color", + "type": "string" + }, + "offset_x": { + "default": 0, + "format": "float", + "title": "offset_x", + "type": "number" + }, + "offset_y": { + "default": 0, + "format": "float", + "title": "offset_y", + "type": "number" + }, + "blur": { + "default": 0, + "format": "float", + "minimum": 0, + "title": "blur", + "type": "number" + } + }, + "required": [ + "color" ], - "example": "1280x800", - "title": "ResolutionV4", - "type": "string" + "title": "LayeredAssetTextShadow", + "type": "object" }, "Price": { "description": "Represents a price.",