diff --git a/src/libs/Recraft/Generated/Recraft.IImageClient.ImageToImage.g.cs b/src/libs/Recraft/Generated/Recraft.IImageClient.ImageToImage.g.cs index fd1496d..f5e6809 100644 --- a/src/libs/Recraft/Generated/Recraft.IImageClient.ImageToImage.g.cs +++ b/src/libs/Recraft/Generated/Recraft.IImageClient.ImageToImage.g.cs @@ -36,146 +36,11 @@ public partial interface IImageClient /// Generate image from image and prompt /// /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// /// 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 ImageToImageAsync( - byte[] image, - string imagename, - string prompt, - double strength, global::Recraft.BillingType? billing = default, - bool? blockNsfw = default, - bool? calculateFeatures = default, - global::Recraft.UserControls? controls = default, - bool? expire = default, - global::Recraft.ImageFormat? imageFormat = default, - global::Recraft.TransformModel? model = default, - int? n = default, - string? negativePrompt = default, - int? randomSeed = default, - global::Recraft.ResponseFormat? responseFormat = default, - string? style = default, - global::System.Guid? styleId = default, - global::Recraft.ImageSubStyle? substyle = default, - global::System.Collections.Generic.IList? textLayout = default, - global::Recraft.AutoSDKRequestOptions? requestOptions = default, - global::System.Threading.CancellationToken cancellationToken = default); - - /// - /// Generate image from image and prompt - /// - /// - /// - /// - /// - /// - /// - /// The stream to send as the multipart 'image' file part. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// 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 ImageToImageAsync( - global::System.IO.Stream image, - string imagename, - string prompt, - double strength, - global::Recraft.BillingType? billing = default, - bool? blockNsfw = default, - bool? calculateFeatures = default, - global::Recraft.UserControls? controls = default, - bool? expire = default, - global::Recraft.ImageFormat? imageFormat = default, - global::Recraft.TransformModel? model = default, - int? n = default, - string? negativePrompt = default, - int? randomSeed = default, - global::Recraft.ResponseFormat? responseFormat = default, - string? style = default, - global::System.Guid? styleId = default, - global::Recraft.ImageSubStyle? substyle = default, - global::System.Collections.Generic.IList? textLayout = default, - global::Recraft.AutoSDKRequestOptions? requestOptions = default, - global::System.Threading.CancellationToken cancellationToken = default); - /// - /// Generate image from image and prompt - /// - /// - /// - /// - /// - /// - /// - /// The stream to send as the multipart 'image' file part. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// 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> ImageToImageAsResponseAsync( - global::System.IO.Stream image, - string imagename, - string prompt, - double strength, - global::Recraft.BillingType? billing = default, - bool? blockNsfw = default, - bool? calculateFeatures = default, - global::Recraft.UserControls? controls = default, - bool? expire = default, - global::Recraft.ImageFormat? imageFormat = default, - global::Recraft.TransformModel? model = default, - int? n = default, - string? negativePrompt = default, - int? randomSeed = default, - global::Recraft.ResponseFormat? responseFormat = default, - string? style = default, - global::System.Guid? styleId = default, - global::Recraft.ImageSubStyle? substyle = default, - global::System.Collections.Generic.IList? textLayout = default, global::Recraft.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } diff --git a/src/libs/Recraft/Generated/Recraft.IImageClient.OutpaintImage.g.cs b/src/libs/Recraft/Generated/Recraft.IImageClient.OutpaintImage.g.cs new file mode 100644 index 0000000..fd78b51 --- /dev/null +++ b/src/libs/Recraft/Generated/Recraft.IImageClient.OutpaintImage.g.cs @@ -0,0 +1,47 @@ +#nullable enable + +namespace Recraft +{ + public partial interface IImageClient + { + /// + /// Outpaint Image + /// + /// + /// + /// 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 OutpaintImageAsync( + + global::Recraft.OutpaintImageRequest request, + global::Recraft.BillingType? billing = default, + global::Recraft.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Outpaint Image + /// + /// + /// + /// 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> OutpaintImageAsResponseAsync( + + global::Recraft.OutpaintImageRequest request, + global::Recraft.BillingType? billing = default, + global::Recraft.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Outpaint Image + /// + /// + /// 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 OutpaintImageAsync( + global::Recraft.BillingType? billing = default, + global::Recraft.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + } +} \ No newline at end of file diff --git a/src/libs/Recraft/Generated/Recraft.IImageClient.ReplaceBackground.g.cs b/src/libs/Recraft/Generated/Recraft.IImageClient.ReplaceBackground.g.cs index 3d7c3da..cf6a380 100644 --- a/src/libs/Recraft/Generated/Recraft.IImageClient.ReplaceBackground.g.cs +++ b/src/libs/Recraft/Generated/Recraft.IImageClient.ReplaceBackground.g.cs @@ -38,6 +38,7 @@ public partial interface IImageClient /// /// /// + /// /// /// /// @@ -62,6 +63,7 @@ public partial interface IImageClient global::Recraft.BillingType? billing = default, bool? blockNsfw = default, bool? calculateFeatures = default, + global::Recraft.UserControls? controls = default, bool? expire = default, global::Recraft.ImageFormat? imageFormat = default, global::Recraft.TransformModel? model = default, @@ -82,6 +84,7 @@ public partial interface IImageClient /// /// /// + /// /// /// /// The stream to send as the multipart 'image' file part. @@ -108,6 +111,7 @@ public partial interface IImageClient global::Recraft.BillingType? billing = default, bool? blockNsfw = default, bool? calculateFeatures = default, + global::Recraft.UserControls? controls = default, bool? expire = default, global::Recraft.ImageFormat? imageFormat = default, global::Recraft.TransformModel? model = default, @@ -127,6 +131,7 @@ public partial interface IImageClient /// /// /// + /// /// /// /// The stream to send as the multipart 'image' file part. @@ -153,6 +158,7 @@ public partial interface IImageClient global::Recraft.BillingType? billing = default, bool? blockNsfw = default, bool? calculateFeatures = default, + global::Recraft.UserControls? controls = default, bool? expire = default, global::Recraft.ImageFormat? imageFormat = default, global::Recraft.TransformModel? model = default, diff --git a/src/libs/Recraft/Generated/Recraft.IPromptClient.EnhancePrompt.g.cs b/src/libs/Recraft/Generated/Recraft.IPromptClient.EnhancePrompt.g.cs new file mode 100644 index 0000000..a1137f7 --- /dev/null +++ b/src/libs/Recraft/Generated/Recraft.IPromptClient.EnhancePrompt.g.cs @@ -0,0 +1,49 @@ +#nullable enable + +namespace Recraft +{ + public partial interface IPromptClient + { + /// + /// Enhance a prompt using an LLM + /// + /// + /// + /// 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 EnhancePromptAsync( + + global::Recraft.EnhancePromptRequest request, + global::Recraft.BillingType? billing = default, + global::Recraft.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Enhance a prompt using an LLM + /// + /// + /// + /// 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> EnhancePromptAsResponseAsync( + + global::Recraft.EnhancePromptRequest request, + global::Recraft.BillingType? billing = default, + global::Recraft.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Enhance a prompt using an LLM + /// + /// + /// + /// 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 EnhancePromptAsync( + string prompt, + global::Recraft.BillingType? billing = default, + global::Recraft.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + } +} \ No newline at end of file diff --git a/src/libs/Recraft/Generated/Recraft.IPromptClient.g.cs b/src/libs/Recraft/Generated/Recraft.IPromptClient.g.cs new file mode 100644 index 0000000..860304d --- /dev/null +++ b/src/libs/Recraft/Generated/Recraft.IPromptClient.g.cs @@ -0,0 +1,48 @@ + +#nullable enable + +namespace Recraft +{ + /// + /// If no httpClient is provided, a new one will be created.
+ /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + ///
+ public partial interface IPromptClient : global::System.IDisposable + { + /// + /// The HttpClient instance. + /// + public global::System.Net.Http.HttpClient HttpClient { get; } + + /// + /// The base URL for the API. + /// + public System.Uri? BaseUri { get; } + + /// + /// The authorizations to use for the requests. + /// + public global::System.Collections.Generic.List Authorizations { get; } + + /// + /// Gets or sets a value indicating whether the response content should be read as a string. + /// True by default in debug builds, false otherwise. + /// When false, successful responses are deserialized directly from the response stream for better performance. + /// Error responses are always read as strings regardless of this setting, + /// ensuring is populated. + /// + public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::Recraft.AutoSDKClientOptions Options { get; } + + + /// + /// + /// + global::System.Text.Json.Serialization.JsonSerializerContext JsonSerializerContext { get; set; } + + + } +} \ No newline at end of file diff --git a/src/libs/Recraft/Generated/Recraft.IRecraftClient.g.cs b/src/libs/Recraft/Generated/Recraft.IRecraftClient.g.cs index 5b2bc96..50bf20c 100644 --- a/src/libs/Recraft/Generated/Recraft.IRecraftClient.g.cs +++ b/src/libs/Recraft/Generated/Recraft.IRecraftClient.g.cs @@ -54,6 +54,11 @@ public partial interface IRecraftClient : global::System.IDisposable /// public ImageClient Image { get; } + /// + /// + /// + public PromptClient Prompt { get; } + /// /// /// diff --git a/src/libs/Recraft/Generated/Recraft.ImageClient.ImageToImage.g.cs b/src/libs/Recraft/Generated/Recraft.ImageClient.ImageToImage.g.cs index 7a6d4f5..2fba7aa 100644 --- a/src/libs/Recraft/Generated/Recraft.ImageClient.ImageToImage.g.cs +++ b/src/libs/Recraft/Generated/Recraft.ImageClient.ImageToImage.g.cs @@ -83,8 +83,6 @@ partial void ProcessImageToImageResponseContent( global::Recraft.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { - request = request ?? throw new global::System.ArgumentNullException(nameof(request)); - PrepareArguments( client: HttpClient); PrepareImageToImageArguments( @@ -159,164 +157,6 @@ partial void ProcessImageToImageResponseContent( content: new global::System.Net.Http.StringContent((billing).HasValue ? (billing).GetValueOrDefault().ToValueString() : string.Empty), name: "\"billing\""); - } - if (request.BlockNsfw != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.BlockNsfw, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()), - name: "\"block_nsfw\""); - - } - if (request.CalculateFeatures != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.CalculateFeatures, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()), - name: "\"calculate_features\""); - - } - if (request.Controls != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.Controls.ToJson(JsonSerializerContext)), - name: "\"controls\""); - - } - if (request.Expire != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.Expire, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()), - name: "\"expire\""); - - } - 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; - } - - if (request.ImageFormat != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent((request.ImageFormat).HasValue ? (request.ImageFormat).GetValueOrDefault().ToValueString() : string.Empty), - name: "\"image_format\""); - - } - if (request.Model != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent((request.Model).HasValue ? (request.Model).GetValueOrDefault().ToValueString() : string.Empty), - name: "\"model\""); - - } - if (request.N != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.N, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), - name: "\"n\""); - - } - if (request.NegativePrompt != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.NegativePrompt ?? string.Empty), - name: "\"negative_prompt\""); - - } - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), - name: "\"prompt\""); - - if (request.RandomSeed != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.RandomSeed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), - name: "\"random_seed\""); - - } - if (request.ResponseFormat != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent((request.ResponseFormat).HasValue ? (request.ResponseFormat).GetValueOrDefault().ToValueString() : string.Empty), - name: "\"response_format\""); - - } - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Strength, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), - name: "\"strength\""); - - if (request.Style != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.Style ?? string.Empty), - name: "\"style\""); - - } - if (request.StyleId != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.StyleId.ToString() ?? string.Empty), - name: "\"style_id\""); - - } - if (request.Substyle != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent((request.Substyle).HasValue ? (request.Substyle).GetValueOrDefault().ToValueString() : string.Empty), - name: "\"substyle\""); - - } - if (request.TextLayout != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.TextLayout, x => x.ToJson(JsonSerializerContext)))}]"), - name: "\"text_layout\""); - } __httpRequest.Content = __httpRequestContent; @@ -616,70 +456,16 @@ request.Imagename is null /// Generate image from image and prompt /// /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// /// 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 ImageToImageAsync( - byte[] image, - string imagename, - string prompt, - double strength, global::Recraft.BillingType? billing = default, - bool? blockNsfw = default, - bool? calculateFeatures = default, - global::Recraft.UserControls? controls = default, - bool? expire = default, - global::Recraft.ImageFormat? imageFormat = default, - global::Recraft.TransformModel? model = default, - int? n = default, - string? negativePrompt = default, - int? randomSeed = default, - global::Recraft.ResponseFormat? responseFormat = default, - string? style = default, - global::System.Guid? styleId = default, - global::Recraft.ImageSubStyle? substyle = default, - global::System.Collections.Generic.IList? textLayout = default, global::Recraft.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Recraft.ImageToImageRequest { - BlockNsfw = blockNsfw, - CalculateFeatures = calculateFeatures, - Controls = controls, - Expire = expire, - Image = image, - Imagename = imagename, - ImageFormat = imageFormat, - Model = model, - N = n, - NegativePrompt = negativePrompt, - Prompt = prompt, - RandomSeed = randomSeed, - ResponseFormat = responseFormat, - Strength = strength, - Style = style, - StyleId = styleId, - Substyle = substyle, - TextLayout = textLayout, }; return await ImageToImageAsync( @@ -688,1198 +474,5 @@ request.Imagename is null requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } - - /// - /// Generate image from image and prompt - /// - /// - /// - /// - /// - /// - /// - /// The stream to send as the multipart 'image' file part. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// 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 ImageToImageAsync( - global::System.IO.Stream image, - string imagename, - string prompt, - double strength, - global::Recraft.BillingType? billing = default, - bool? blockNsfw = default, - bool? calculateFeatures = default, - global::Recraft.UserControls? controls = default, - bool? expire = default, - global::Recraft.ImageFormat? imageFormat = default, - global::Recraft.TransformModel? model = default, - int? n = default, - string? negativePrompt = default, - int? randomSeed = default, - global::Recraft.ResponseFormat? responseFormat = default, - string? style = default, - global::System.Guid? styleId = default, - global::Recraft.ImageSubStyle? substyle = default, - global::System.Collections.Generic.IList? textLayout = default, - global::Recraft.AutoSDKRequestOptions? requestOptions = default, - global::System.Threading.CancellationToken cancellationToken = default) - { - - image = image ?? throw new global::System.ArgumentNullException(nameof(image)); - var request = new global::Recraft.ImageToImageRequest - { - BlockNsfw = blockNsfw, - CalculateFeatures = calculateFeatures, - Controls = controls, - Expire = expire, - Image = global::System.Array.Empty(), - Imagename = imagename, - ImageFormat = imageFormat, - Model = model, - N = n, - NegativePrompt = negativePrompt, - Prompt = prompt, - RandomSeed = randomSeed, - ResponseFormat = responseFormat, - Strength = strength, - Style = style, - StyleId = styleId, - Substyle = substyle, - TextLayout = textLayout, - }; - PrepareArguments( - client: HttpClient); - PrepareImageToImageArguments( - httpClient: HttpClient, - billing: ref billing, - request: request); - - - var __authorizations = global::Recraft.EndPointSecurityResolver.ResolveAuthorizations( - availableAuthorizations: Authorizations, - securityRequirements: s_ImageToImageSecurityRequirements, - operationName: "ImageToImageAsync"); - - using var __timeoutCancellationTokenSource = global::Recraft.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( - clientOptions: Options, - requestOptions: requestOptions, - cancellationToken: cancellationToken); - var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; - var __effectiveReadResponseAsString = global::Recraft.AutoSDKRequestOptionsSupport.GetReadResponseAsString( - clientOptions: Options, - requestOptions: requestOptions, - fallbackValue: ReadResponseAsString); - var __maxAttempts = global::Recraft.AutoSDKRequestOptionsSupport.GetMaxAttempts( - clientOptions: Options, - requestOptions: requestOptions, - supportsRetry: false); - - global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() - { - - var __pathBuilder = new global::Recraft.PathBuilder( - path: "/v1/images/imageToImage", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("billing", billing?.ToValueString()) - ; - var __path = __pathBuilder.ToString(); - __path = global::Recraft.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(); - if (billing != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent((billing).HasValue ? (billing).GetValueOrDefault().ToValueString() : string.Empty), - name: "\"billing\""); - - } - if (request.BlockNsfw != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.BlockNsfw, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()), - name: "\"block_nsfw\""); - - } - if (request.CalculateFeatures != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.CalculateFeatures, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()), - name: "\"calculate_features\""); - - } - if (request.Controls != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.Controls.ToJson(JsonSerializerContext)), - name: "\"controls\""); - - } - if (request.Expire != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.Expire, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()), - name: "\"expire\""); - - } - 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.ImageFormat != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent((request.ImageFormat).HasValue ? (request.ImageFormat).GetValueOrDefault().ToValueString() : string.Empty), - name: "\"image_format\""); - - } - if (request.Model != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent((request.Model).HasValue ? (request.Model).GetValueOrDefault().ToValueString() : string.Empty), - name: "\"model\""); - - } - if (request.N != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.N, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), - name: "\"n\""); - - } - if (request.NegativePrompt != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.NegativePrompt ?? string.Empty), - name: "\"negative_prompt\""); - - } - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), - name: "\"prompt\""); - - if (request.RandomSeed != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.RandomSeed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), - name: "\"random_seed\""); - - } - if (request.ResponseFormat != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent((request.ResponseFormat).HasValue ? (request.ResponseFormat).GetValueOrDefault().ToValueString() : string.Empty), - name: "\"response_format\""); - - } - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Strength, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), - name: "\"strength\""); - - if (request.Style != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.Style ?? string.Empty), - name: "\"style\""); - - } - if (request.StyleId != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.StyleId.ToString() ?? string.Empty), - name: "\"style_id\""); - - } - if (request.Substyle != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent((request.Substyle).HasValue ? (request.Substyle).GetValueOrDefault().ToValueString() : string.Empty), - name: "\"substyle\""); - - } - if (request.TextLayout != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.TextLayout, x => x.ToJson(JsonSerializerContext)))}]"), - name: "\"text_layout\""); - - } - - __httpRequest.Content = __httpRequestContent; - - global::Recraft.AutoSDKRequestOptionsSupport.ApplyHeaders( - request: __httpRequest, - clientHeaders: Options.Headers, - requestHeaders: requestOptions?.Headers); - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareImageToImageRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - billing: billing, - 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::Recraft.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( - clientOptions: Options, - context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "ImageToImage", - methodName: "ImageToImageAsync", - pathTemplate: "\"/v1/images/imageToImage\"", - 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::Recraft.AutoSDKRequestOptionsSupport.GetRetryDelay( - clientOptions: Options, - requestOptions: requestOptions, - response: null, - attempt: __attempt); - var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; - await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "ImageToImage", - methodName: "ImageToImageAsync", - pathTemplate: "\"/v1/images/imageToImage\"", - 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::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - retryDelay: __retryDelay, - cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); - continue; - } - - if (__response != null && - __attempt < __maxAttempts && - global::Recraft.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) - { - var __retryDelay = global::Recraft.AutoSDKRequestOptionsSupport.GetRetryDelay( - clientOptions: Options, - requestOptions: requestOptions, - response: __response, - attempt: __attempt); - await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "ImageToImage", - methodName: "ImageToImageAsync", - pathTemplate: "\"/v1/images/imageToImage\"", - 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::Recraft.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); - ProcessImageToImageResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - if (__response.IsSuccessStatusCode) - { - await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( - clientOptions: Options, - context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "ImageToImage", - methodName: "ImageToImageAsync", - pathTemplate: "\"/v1/images/imageToImage\"", - 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::Recraft.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "ImageToImage", - methodName: "ImageToImageAsync", - pathTemplate: "\"/v1/images/imageToImage\"", - 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); - ProcessImageToImageResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try - { - __response.EnsureSuccessStatusCode(); - - return - global::Recraft.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); - } - catch (global::System.Exception __ex) - { - throw new global::Recraft.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::Recraft.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::Recraft.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 image from image and prompt - /// - /// - /// - /// - /// - /// - /// - /// The stream to send as the multipart 'image' file part. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// 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> ImageToImageAsResponseAsync( - global::System.IO.Stream image, - string imagename, - string prompt, - double strength, - global::Recraft.BillingType? billing = default, - bool? blockNsfw = default, - bool? calculateFeatures = default, - global::Recraft.UserControls? controls = default, - bool? expire = default, - global::Recraft.ImageFormat? imageFormat = default, - global::Recraft.TransformModel? model = default, - int? n = default, - string? negativePrompt = default, - int? randomSeed = default, - global::Recraft.ResponseFormat? responseFormat = default, - string? style = default, - global::System.Guid? styleId = default, - global::Recraft.ImageSubStyle? substyle = default, - global::System.Collections.Generic.IList? textLayout = default, - global::Recraft.AutoSDKRequestOptions? requestOptions = default, - global::System.Threading.CancellationToken cancellationToken = default) - { - - image = image ?? throw new global::System.ArgumentNullException(nameof(image)); - var request = new global::Recraft.ImageToImageRequest - { - BlockNsfw = blockNsfw, - CalculateFeatures = calculateFeatures, - Controls = controls, - Expire = expire, - Image = global::System.Array.Empty(), - Imagename = imagename, - ImageFormat = imageFormat, - Model = model, - N = n, - NegativePrompt = negativePrompt, - Prompt = prompt, - RandomSeed = randomSeed, - ResponseFormat = responseFormat, - Strength = strength, - Style = style, - StyleId = styleId, - Substyle = substyle, - TextLayout = textLayout, - }; - PrepareArguments( - client: HttpClient); - PrepareImageToImageArguments( - httpClient: HttpClient, - billing: ref billing, - request: request); - - - var __authorizations = global::Recraft.EndPointSecurityResolver.ResolveAuthorizations( - availableAuthorizations: Authorizations, - securityRequirements: s_ImageToImageSecurityRequirements, - operationName: "ImageToImageAsync"); - - using var __timeoutCancellationTokenSource = global::Recraft.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( - clientOptions: Options, - requestOptions: requestOptions, - cancellationToken: cancellationToken); - var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; - var __effectiveReadResponseAsString = global::Recraft.AutoSDKRequestOptionsSupport.GetReadResponseAsString( - clientOptions: Options, - requestOptions: requestOptions, - fallbackValue: ReadResponseAsString); - var __maxAttempts = global::Recraft.AutoSDKRequestOptionsSupport.GetMaxAttempts( - clientOptions: Options, - requestOptions: requestOptions, - supportsRetry: false); - - global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() - { - - var __pathBuilder = new global::Recraft.PathBuilder( - path: "/v1/images/imageToImage", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("billing", billing?.ToValueString()) - ; - var __path = __pathBuilder.ToString(); - __path = global::Recraft.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(); - if (billing != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent((billing).HasValue ? (billing).GetValueOrDefault().ToValueString() : string.Empty), - name: "\"billing\""); - - } - if (request.BlockNsfw != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.BlockNsfw, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()), - name: "\"block_nsfw\""); - - } - if (request.CalculateFeatures != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.CalculateFeatures, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()), - name: "\"calculate_features\""); - - } - if (request.Controls != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.Controls.ToJson(JsonSerializerContext)), - name: "\"controls\""); - - } - if (request.Expire != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.Expire, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()), - name: "\"expire\""); - - } - 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.ImageFormat != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent((request.ImageFormat).HasValue ? (request.ImageFormat).GetValueOrDefault().ToValueString() : string.Empty), - name: "\"image_format\""); - - } - if (request.Model != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent((request.Model).HasValue ? (request.Model).GetValueOrDefault().ToValueString() : string.Empty), - name: "\"model\""); - - } - if (request.N != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.N, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), - name: "\"n\""); - - } - if (request.NegativePrompt != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.NegativePrompt ?? string.Empty), - name: "\"negative_prompt\""); - - } - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), - name: "\"prompt\""); - - if (request.RandomSeed != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.RandomSeed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), - name: "\"random_seed\""); - - } - if (request.ResponseFormat != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent((request.ResponseFormat).HasValue ? (request.ResponseFormat).GetValueOrDefault().ToValueString() : string.Empty), - name: "\"response_format\""); - - } - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Strength, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty), - name: "\"strength\""); - - if (request.Style != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.Style ?? string.Empty), - name: "\"style\""); - - } - if (request.StyleId != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(request.StyleId.ToString() ?? string.Empty), - name: "\"style_id\""); - - } - if (request.Substyle != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent((request.Substyle).HasValue ? (request.Substyle).GetValueOrDefault().ToValueString() : string.Empty), - name: "\"substyle\""); - - } - if (request.TextLayout != default) - { - - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.TextLayout, x => x.ToJson(JsonSerializerContext)))}]"), - name: "\"text_layout\""); - - } - - __httpRequest.Content = __httpRequestContent; - - global::Recraft.AutoSDKRequestOptionsSupport.ApplyHeaders( - request: __httpRequest, - clientHeaders: Options.Headers, - requestHeaders: requestOptions?.Headers); - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareImageToImageRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - billing: billing, - 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::Recraft.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( - clientOptions: Options, - context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "ImageToImage", - methodName: "ImageToImageAsync", - pathTemplate: "\"/v1/images/imageToImage\"", - 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::Recraft.AutoSDKRequestOptionsSupport.GetRetryDelay( - clientOptions: Options, - requestOptions: requestOptions, - response: null, - attempt: __attempt); - var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; - await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "ImageToImage", - methodName: "ImageToImageAsync", - pathTemplate: "\"/v1/images/imageToImage\"", - 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::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - retryDelay: __retryDelay, - cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); - continue; - } - - if (__response != null && - __attempt < __maxAttempts && - global::Recraft.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) - { - var __retryDelay = global::Recraft.AutoSDKRequestOptionsSupport.GetRetryDelay( - clientOptions: Options, - requestOptions: requestOptions, - response: __response, - attempt: __attempt); - await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "ImageToImage", - methodName: "ImageToImageAsync", - pathTemplate: "\"/v1/images/imageToImage\"", - 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::Recraft.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); - ProcessImageToImageResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - if (__response.IsSuccessStatusCode) - { - await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( - clientOptions: Options, - context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "ImageToImage", - methodName: "ImageToImageAsync", - pathTemplate: "\"/v1/images/imageToImage\"", - 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::Recraft.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( - clientOptions: Options, - context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext( - operationId: "ImageToImage", - methodName: "ImageToImageAsync", - pathTemplate: "\"/v1/images/imageToImage\"", - 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); - ProcessImageToImageResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try - { - __response.EnsureSuccessStatusCode(); - - var __value = global::Recraft.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); - return new global::Recraft.AutoSDKHttpResponse( - statusCode: __response.StatusCode, - headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response), - requestUri: __response.RequestMessage?.RequestUri, - body: __value); - } - catch (global::System.Exception __ex) - { - throw new global::Recraft.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::Recraft.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - return new global::Recraft.AutoSDKHttpResponse( - statusCode: __response.StatusCode, - headers: global::Recraft.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::Recraft.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/Recraft/Generated/Recraft.ImageClient.OutpaintImage.g.cs b/src/libs/Recraft/Generated/Recraft.ImageClient.OutpaintImage.g.cs new file mode 100644 index 0000000..ed12e99 --- /dev/null +++ b/src/libs/Recraft/Generated/Recraft.ImageClient.OutpaintImage.g.cs @@ -0,0 +1,478 @@ + +#nullable enable + +namespace Recraft +{ + public partial class ImageClient + { + + + private static readonly global::Recraft.EndPointSecurityRequirement s_OutpaintImageSecurityRequirement0 = + new global::Recraft.EndPointSecurityRequirement + { + Authorizations = new global::Recraft.EndPointAuthorizationRequirement[] + { new global::Recraft.EndPointAuthorizationRequirement + { + Type = "Http", + SchemeId = "HttpBearer", + Location = "Header", + Name = "Bearer", + FriendlyName = "Bearer", + }, + }, + }; + private static readonly global::Recraft.EndPointSecurityRequirement[] s_OutpaintImageSecurityRequirements = + new global::Recraft.EndPointSecurityRequirement[] + { s_OutpaintImageSecurityRequirement0, + }; + partial void PrepareOutpaintImageArguments( + global::System.Net.Http.HttpClient httpClient, + ref global::Recraft.BillingType? billing, + global::Recraft.OutpaintImageRequest request); + partial void PrepareOutpaintImageRequest( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpRequestMessage httpRequestMessage, + global::Recraft.BillingType? billing, + global::Recraft.OutpaintImageRequest request); + partial void ProcessOutpaintImageResponse( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpResponseMessage httpResponseMessage); + + partial void ProcessOutpaintImageResponseContent( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpResponseMessage httpResponseMessage, + ref string content); + + /// + /// Outpaint Image + /// + /// + /// + /// 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 OutpaintImageAsync( + + global::Recraft.OutpaintImageRequest request, + global::Recraft.BillingType? billing = default, + global::Recraft.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await OutpaintImageAsResponseAsync( + + request: request, + billing: billing, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Outpaint Image + /// + /// + /// + /// 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> OutpaintImageAsResponseAsync( + + global::Recraft.OutpaintImageRequest request, + global::Recraft.BillingType? billing = default, + global::Recraft.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + PrepareArguments( + client: HttpClient); + PrepareOutpaintImageArguments( + httpClient: HttpClient, + billing: ref billing, + request: request); + + + var __authorizations = global::Recraft.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_OutpaintImageSecurityRequirements, + operationName: "OutpaintImageAsync"); + + using var __timeoutCancellationTokenSource = global::Recraft.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Recraft.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Recraft.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Recraft.PathBuilder( + path: "/v1/images/outpaint", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("billing", billing?.ToValueString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::Recraft.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(); + if (billing != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((billing).HasValue ? (billing).GetValueOrDefault().ToValueString() : string.Empty), + name: "\"billing\""); + + } + + __httpRequest.Content = __httpRequestContent; + + global::Recraft.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareOutpaintImageRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + billing: billing, + 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::Recraft.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "OutpaintImage", + methodName: "OutpaintImageAsync", + pathTemplate: "\"/v1/images/outpaint\"", + 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::Recraft.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "OutpaintImage", + methodName: "OutpaintImageAsync", + pathTemplate: "\"/v1/images/outpaint\"", + 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::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Recraft.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Recraft.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "OutpaintImage", + methodName: "OutpaintImageAsync", + pathTemplate: "\"/v1/images/outpaint\"", + 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::Recraft.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); + ProcessOutpaintImageResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "OutpaintImage", + methodName: "OutpaintImageAsync", + pathTemplate: "\"/v1/images/outpaint\"", + 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::Recraft.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "OutpaintImage", + methodName: "OutpaintImageAsync", + pathTemplate: "\"/v1/images/outpaint\"", + 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); + ProcessOutpaintImageResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Recraft.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Recraft.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Recraft.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::Recraft.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Recraft.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Recraft.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::Recraft.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(); + } + } + /// + /// Outpaint Image + /// + /// + /// 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 OutpaintImageAsync( + global::Recraft.BillingType? billing = default, + global::Recraft.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __request = new global::Recraft.OutpaintImageRequest + { + }; + + return await OutpaintImageAsync( + billing: billing, + request: __request, + requestOptions: requestOptions, + cancellationToken: cancellationToken).ConfigureAwait(false); + } + } +} \ No newline at end of file diff --git a/src/libs/Recraft/Generated/Recraft.ImageClient.ReplaceBackground.g.cs b/src/libs/Recraft/Generated/Recraft.ImageClient.ReplaceBackground.g.cs index a047159..cee3e06 100644 --- a/src/libs/Recraft/Generated/Recraft.ImageClient.ReplaceBackground.g.cs +++ b/src/libs/Recraft/Generated/Recraft.ImageClient.ReplaceBackground.g.cs @@ -175,6 +175,14 @@ partial void ProcessReplaceBackgroundResponseContent( content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.CalculateFeatures, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()), name: "\"calculate_features\""); + } + if (request.Controls != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Controls.ToJson(JsonSerializerContext)), + name: "\"controls\""); + } if (request.Expire != default) { @@ -606,6 +614,7 @@ request.Imagename is null /// /// /// + /// /// /// /// @@ -630,6 +639,7 @@ request.Imagename is null global::Recraft.BillingType? billing = default, bool? blockNsfw = default, bool? calculateFeatures = default, + global::Recraft.UserControls? controls = default, bool? expire = default, global::Recraft.ImageFormat? imageFormat = default, global::Recraft.TransformModel? model = default, @@ -648,6 +658,7 @@ request.Imagename is null { BlockNsfw = blockNsfw, CalculateFeatures = calculateFeatures, + Controls = controls, Expire = expire, Image = image, Imagename = imagename, @@ -677,6 +688,7 @@ request.Imagename is null /// /// /// + /// /// /// /// The stream to send as the multipart 'image' file part. @@ -703,6 +715,7 @@ request.Imagename is null global::Recraft.BillingType? billing = default, bool? blockNsfw = default, bool? calculateFeatures = default, + global::Recraft.UserControls? controls = default, bool? expire = default, global::Recraft.ImageFormat? imageFormat = default, global::Recraft.TransformModel? model = default, @@ -723,6 +736,7 @@ request.Imagename is null { BlockNsfw = blockNsfw, CalculateFeatures = calculateFeatures, + Controls = controls, Expire = expire, Image = global::System.Array.Empty(), Imagename = imagename, @@ -828,6 +842,14 @@ request.Imagename is null content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.CalculateFeatures, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()), name: "\"calculate_features\""); + } + if (request.Controls != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Controls.ToJson(JsonSerializerContext)), + name: "\"controls\""); + } if (request.Expire != default) { @@ -1251,6 +1273,7 @@ request.Imagename is null /// /// /// + /// /// /// /// The stream to send as the multipart 'image' file part. @@ -1277,6 +1300,7 @@ request.Imagename is null global::Recraft.BillingType? billing = default, bool? blockNsfw = default, bool? calculateFeatures = default, + global::Recraft.UserControls? controls = default, bool? expire = default, global::Recraft.ImageFormat? imageFormat = default, global::Recraft.TransformModel? model = default, @@ -1297,6 +1321,7 @@ request.Imagename is null { BlockNsfw = blockNsfw, CalculateFeatures = calculateFeatures, + Controls = controls, Expire = expire, Image = global::System.Array.Empty(), Imagename = imagename, @@ -1402,6 +1427,14 @@ request.Imagename is null content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.CalculateFeatures, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()), name: "\"calculate_features\""); + } + if (request.Controls != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Controls.ToJson(JsonSerializerContext)), + name: "\"controls\""); + } if (request.Expire != default) { diff --git a/src/libs/Recraft/Generated/Recraft.JsonConverters.ImageToImageRequest.g.cs b/src/libs/Recraft/Generated/Recraft.JsonConverters.ImageToImageRequest.g.cs new file mode 100644 index 0000000..21a88bf --- /dev/null +++ b/src/libs/Recraft/Generated/Recraft.JsonConverters.ImageToImageRequest.g.cs @@ -0,0 +1,167 @@ +#nullable enable +#pragma warning disable CS0618 // Type or member is obsolete + +namespace Recraft.JsonConverters +{ + /// + public class ImageToImageRequestJsonConverter : global::System.Text.Json.Serialization.JsonConverter + { + /// + public override global::Recraft.ImageToImageRequest Read( + ref global::System.Text.Json.Utf8JsonReader reader, + global::System.Type typeToConvert, + global::System.Text.Json.JsonSerializerOptions options) + { + options = options ?? throw new global::System.ArgumentNullException(nameof(options)); + var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); + + using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader); + var __rawJson = __jsonDocument.RootElement.GetRawText(); + var __jsonProps = new global::System.Collections.Generic.HashSet(); + if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object) + { + foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) + { + __jsonProps.Add(__jsonProp.Name); + if (__jsonProp.Value.ValueKind == global::System.Text.Json.JsonValueKind.Object) + { + foreach (var __nestedJsonProp in __jsonProp.Value.EnumerateObject()) + { + __jsonProps.Add(__jsonProp.Name + "." + __nestedJsonProp.Name); + } + } + + } + } + + var __score0 = 0; + if (__jsonProps.Contains("block_nsfw")) __score0++; + if (__jsonProps.Contains("calculate_features")) __score0++; + if (__jsonProps.Contains("controls")) __score0++; + if (__jsonProps.Contains("controls.artistic_level")) __score0++; + if (__jsonProps.Contains("controls.background_color")) __score0++; + if (__jsonProps.Contains("controls.colors")) __score0++; + if (__jsonProps.Contains("controls.no_text")) __score0++; + if (__jsonProps.Contains("expire")) __score0++; + if (__jsonProps.Contains("image")) __score0++; + if (__jsonProps.Contains("image_format")) __score0++; + if (__jsonProps.Contains("model")) __score0++; + if (__jsonProps.Contains("n")) __score0++; + if (__jsonProps.Contains("negative_prompt")) __score0++; + if (__jsonProps.Contains("prompt")) __score0++; + if (__jsonProps.Contains("random_seed")) __score0++; + if (__jsonProps.Contains("response_format")) __score0++; + if (__jsonProps.Contains("style")) __score0++; + if (__jsonProps.Contains("style_id")) __score0++; + if (__jsonProps.Contains("substyle")) __score0++; + if (__jsonProps.Contains("text_layout")) __score0++; + var __score1 = 0; + if (__jsonProps.Contains("strength")) __score1++; + var __bestScore = 0; + var __bestIndex = -1; + if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; } + if (__score1 > __bestScore) { __bestScore = __score1; __bestIndex = 1; } + + global::Recraft.TransformImageRequest? transform = default; + global::Recraft.ImageToImageRequestVariant2? imageToImageRequestVariant2 = default; + if (__bestIndex >= 0) + { + if (__bestIndex == 0) + { + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Recraft.TransformImageRequest), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Recraft.TransformImageRequest).Name}"); + transform = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { + } + } + else if (__bestIndex == 1) + { + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Recraft.ImageToImageRequestVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Recraft.ImageToImageRequestVariant2).Name}"); + imageToImageRequestVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { + } + } + } + + if (transform == null && imageToImageRequestVariant2 == null) + { + try + { + + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Recraft.TransformImageRequest), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Recraft.TransformImageRequest).Name}"); + transform = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { + } + } + + if (transform == null && imageToImageRequestVariant2 == null) + { + try + { + + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Recraft.ImageToImageRequestVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Recraft.ImageToImageRequestVariant2).Name}"); + imageToImageRequestVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { + } + } + + var __value = new global::Recraft.ImageToImageRequest( + transform, + + imageToImageRequestVariant2 + ); + + return __value; + } + + /// + public override void Write( + global::System.Text.Json.Utf8JsonWriter writer, + global::Recraft.ImageToImageRequest value, + global::System.Text.Json.JsonSerializerOptions options) + { + options = options ?? throw new global::System.ArgumentNullException(nameof(options)); + var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); + + if (value.IsTransform) + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Recraft.TransformImageRequest), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Recraft.TransformImageRequest).Name}"); + global::System.Text.Json.JsonSerializer.Serialize(writer, value.Transform!, typeInfo); + } + else if (value.IsImageToImageRequestVariant2) + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Recraft.ImageToImageRequestVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Recraft.ImageToImageRequestVariant2).Name}"); + global::System.Text.Json.JsonSerializer.Serialize(writer, value.ImageToImageRequestVariant2!, typeInfo); + } + } + } +} \ No newline at end of file diff --git a/src/libs/Recraft/Generated/Recraft.JsonConverters.OutpaintImageRequest.g.cs b/src/libs/Recraft/Generated/Recraft.JsonConverters.OutpaintImageRequest.g.cs new file mode 100644 index 0000000..b481363 --- /dev/null +++ b/src/libs/Recraft/Generated/Recraft.JsonConverters.OutpaintImageRequest.g.cs @@ -0,0 +1,172 @@ +#nullable enable +#pragma warning disable CS0618 // Type or member is obsolete + +namespace Recraft.JsonConverters +{ + /// + public class OutpaintImageRequestJsonConverter : global::System.Text.Json.Serialization.JsonConverter + { + /// + public override global::Recraft.OutpaintImageRequest Read( + ref global::System.Text.Json.Utf8JsonReader reader, + global::System.Type typeToConvert, + global::System.Text.Json.JsonSerializerOptions options) + { + options = options ?? throw new global::System.ArgumentNullException(nameof(options)); + var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); + + using var __jsonDocument = global::System.Text.Json.JsonDocument.ParseValue(ref reader); + var __rawJson = __jsonDocument.RootElement.GetRawText(); + var __jsonProps = new global::System.Collections.Generic.HashSet(); + if (__jsonDocument.RootElement.ValueKind == global::System.Text.Json.JsonValueKind.Object) + { + foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) + { + __jsonProps.Add(__jsonProp.Name); + if (__jsonProp.Value.ValueKind == global::System.Text.Json.JsonValueKind.Object) + { + foreach (var __nestedJsonProp in __jsonProp.Value.EnumerateObject()) + { + __jsonProps.Add(__jsonProp.Name + "." + __nestedJsonProp.Name); + } + } + + } + } + + var __score0 = 0; + if (__jsonProps.Contains("block_nsfw")) __score0++; + if (__jsonProps.Contains("calculate_features")) __score0++; + if (__jsonProps.Contains("controls")) __score0++; + if (__jsonProps.Contains("controls.artistic_level")) __score0++; + if (__jsonProps.Contains("controls.background_color")) __score0++; + if (__jsonProps.Contains("controls.colors")) __score0++; + if (__jsonProps.Contains("controls.no_text")) __score0++; + if (__jsonProps.Contains("expire")) __score0++; + if (__jsonProps.Contains("image")) __score0++; + if (__jsonProps.Contains("image_format")) __score0++; + if (__jsonProps.Contains("model")) __score0++; + if (__jsonProps.Contains("n")) __score0++; + if (__jsonProps.Contains("negative_prompt")) __score0++; + if (__jsonProps.Contains("prompt")) __score0++; + if (__jsonProps.Contains("random_seed")) __score0++; + if (__jsonProps.Contains("response_format")) __score0++; + if (__jsonProps.Contains("style")) __score0++; + if (__jsonProps.Contains("style_id")) __score0++; + if (__jsonProps.Contains("substyle")) __score0++; + if (__jsonProps.Contains("text_layout")) __score0++; + var __score1 = 0; + if (__jsonProps.Contains("expand_bottom")) __score1++; + if (__jsonProps.Contains("expand_left")) __score1++; + if (__jsonProps.Contains("expand_right")) __score1++; + if (__jsonProps.Contains("expand_top")) __score1++; + if (__jsonProps.Contains("size")) __score1++; + if (__jsonProps.Contains("zoom_out_percentage")) __score1++; + var __bestScore = 0; + var __bestIndex = -1; + if (__score0 > __bestScore) { __bestScore = __score0; __bestIndex = 0; } + if (__score1 > __bestScore) { __bestScore = __score1; __bestIndex = 1; } + + global::Recraft.TransformImageRequest? transform = default; + global::Recraft.OutpaintImageRequestVariant2? outpaintImageRequestVariant2 = default; + if (__bestIndex >= 0) + { + if (__bestIndex == 0) + { + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Recraft.TransformImageRequest), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Recraft.TransformImageRequest).Name}"); + transform = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { + } + } + else if (__bestIndex == 1) + { + try + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Recraft.OutpaintImageRequestVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Recraft.OutpaintImageRequestVariant2).Name}"); + outpaintImageRequestVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { + } + } + } + + if (transform == null && outpaintImageRequestVariant2 == null) + { + try + { + + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Recraft.TransformImageRequest), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Recraft.TransformImageRequest).Name}"); + transform = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { + } + } + + if (transform == null && outpaintImageRequestVariant2 == null) + { + try + { + + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Recraft.OutpaintImageRequestVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Recraft.OutpaintImageRequestVariant2).Name}"); + outpaintImageRequestVariant2 = global::System.Text.Json.JsonSerializer.Deserialize(__rawJson, typeInfo); + } + catch (global::System.Text.Json.JsonException) + { + } + catch (global::System.InvalidOperationException) + { + } + } + + var __value = new global::Recraft.OutpaintImageRequest( + transform, + + outpaintImageRequestVariant2 + ); + + return __value; + } + + /// + public override void Write( + global::System.Text.Json.Utf8JsonWriter writer, + global::Recraft.OutpaintImageRequest value, + global::System.Text.Json.JsonSerializerOptions options) + { + options = options ?? throw new global::System.ArgumentNullException(nameof(options)); + var typeInfoResolver = options.TypeInfoResolver ?? throw new global::System.InvalidOperationException("TypeInfoResolver is not set."); + + if (value.IsTransform) + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Recraft.TransformImageRequest), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Recraft.TransformImageRequest).Name}"); + global::System.Text.Json.JsonSerializer.Serialize(writer, value.Transform!, typeInfo); + } + else if (value.IsOutpaintImageRequestVariant2) + { + var typeInfo = typeInfoResolver.GetTypeInfo(typeof(global::Recraft.OutpaintImageRequestVariant2), options) as global::System.Text.Json.Serialization.Metadata.JsonTypeInfo ?? + throw new global::System.InvalidOperationException($"Cannot get type info for {typeof(global::Recraft.OutpaintImageRequestVariant2).Name}"); + global::System.Text.Json.JsonSerializer.Serialize(writer, value.OutpaintImageRequestVariant2!, typeInfo); + } + } + } +} \ No newline at end of file diff --git a/src/libs/Recraft/Generated/Recraft.JsonConverters.TransformImageWithMaskRequest.g.cs b/src/libs/Recraft/Generated/Recraft.JsonConverters.TransformImageWithMaskRequest.g.cs index b99e3fb..f62a6e6 100644 --- a/src/libs/Recraft/Generated/Recraft.JsonConverters.TransformImageWithMaskRequest.g.cs +++ b/src/libs/Recraft/Generated/Recraft.JsonConverters.TransformImageWithMaskRequest.g.cs @@ -23,6 +23,13 @@ public class TransformImageWithMaskRequestJsonConverter : global::System.Text.Js foreach (var __jsonProp in __jsonDocument.RootElement.EnumerateObject()) { __jsonProps.Add(__jsonProp.Name); + if (__jsonProp.Value.ValueKind == global::System.Text.Json.JsonValueKind.Object) + { + foreach (var __nestedJsonProp in __jsonProp.Value.EnumerateObject()) + { + __jsonProps.Add(__jsonProp.Name + "." + __nestedJsonProp.Name); + } + } } } @@ -30,6 +37,11 @@ public class TransformImageWithMaskRequestJsonConverter : global::System.Text.Js var __score0 = 0; if (__jsonProps.Contains("block_nsfw")) __score0++; if (__jsonProps.Contains("calculate_features")) __score0++; + if (__jsonProps.Contains("controls")) __score0++; + if (__jsonProps.Contains("controls.artistic_level")) __score0++; + if (__jsonProps.Contains("controls.background_color")) __score0++; + if (__jsonProps.Contains("controls.colors")) __score0++; + if (__jsonProps.Contains("controls.no_text")) __score0++; if (__jsonProps.Contains("expire")) __score0++; if (__jsonProps.Contains("image")) __score0++; if (__jsonProps.Contains("image_format")) __score0++; diff --git a/src/libs/Recraft/Generated/Recraft.JsonSerializerContext.g.cs b/src/libs/Recraft/Generated/Recraft.JsonSerializerContext.g.cs index 7436b60..4460fd0 100644 --- a/src/libs/Recraft/Generated/Recraft.JsonSerializerContext.g.cs +++ b/src/libs/Recraft/Generated/Recraft.JsonSerializerContext.g.cs @@ -75,6 +75,10 @@ namespace Recraft typeof(global::Recraft.JsonConverters.CreateStyleResponseJsonConverter), + typeof(global::Recraft.JsonConverters.ImageToImageRequestJsonConverter), + + typeof(global::Recraft.JsonConverters.OutpaintImageRequestJsonConverter), + typeof(global::Recraft.JsonConverters.TransformImageWithMaskRequestJsonConverter), typeof(global::Recraft.JsonConverters.VectorizeImageRequestJsonConverter), @@ -104,6 +108,8 @@ namespace Recraft [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Recraft.Style))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Recraft.CreateStyleResponseVariant2))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(int))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Recraft.EnhancePromptRequest))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Recraft.EnhancePromptResponse))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Recraft.EraseRegionRequest))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Recraft.ImageFormat), TypeInfoPropertyName = "ImageFormat2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Recraft.ResponseFormat), TypeInfoPropertyName = "ResponseFormat2")] @@ -121,7 +127,9 @@ namespace Recraft [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Recraft.ImageFeatures))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Recraft.ImageColor))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Recraft.ImageToImageRequest))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Recraft.ImageToImageRequest), TypeInfoPropertyName = "ImageToImageRequest2")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Recraft.TransformImageRequest))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Recraft.ImageToImageRequestVariant2))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Recraft.LimitNumShapes), TypeInfoPropertyName = "LimitNumShapes2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Recraft.ListBasicStylesResponse))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] @@ -131,6 +139,8 @@ namespace Recraft [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Recraft.OptimizeColorsResponse))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Recraft.OutpaintImageRequest), TypeInfoPropertyName = "OutpaintImageRequest2")] + [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Recraft.OutpaintImageRequestVariant2))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Recraft.ProcessImageRequest))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Recraft.ProcessImageResponse))] @@ -142,7 +152,6 @@ namespace Recraft [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Recraft.SystemStatus))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Recraft.TextLayoutItem))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::System.Collections.Generic.IList>))] - [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Recraft.TransformImageRequest))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Recraft.TransformImageWithMaskRequest), TypeInfoPropertyName = "TransformImageWithMaskRequest2")] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Recraft.TransformImageWithMaskRequestVariant2))] [global::System.Text.Json.Serialization.JsonSerializable(typeof(global::Recraft.User))] diff --git a/src/libs/Recraft/Generated/Recraft.JsonSerializerContextTypes.g.cs b/src/libs/Recraft/Generated/Recraft.JsonSerializerContextTypes.g.cs index 705aacd..dc42b58 100644 --- a/src/libs/Recraft/Generated/Recraft.JsonSerializerContextTypes.g.cs +++ b/src/libs/Recraft/Generated/Recraft.JsonSerializerContextTypes.g.cs @@ -116,187 +116,207 @@ public sealed partial class JsonSerializerContextTypes /// /// /// - public global::Recraft.EraseRegionRequest? Type22 { get; set; } + public global::Recraft.EnhancePromptRequest? Type22 { get; set; } /// /// /// - public global::Recraft.ImageFormat? Type23 { get; set; } + public global::Recraft.EnhancePromptResponse? Type23 { get; set; } /// /// /// - public global::Recraft.ResponseFormat? Type24 { get; set; } + public global::Recraft.EraseRegionRequest? Type24 { get; set; } /// /// /// - public global::Recraft.ExploreRequest? Type25 { get; set; } + public global::Recraft.ImageFormat? Type25 { get; set; } /// /// /// - public global::Recraft.UserControls? Type26 { get; set; } + public global::Recraft.ResponseFormat? Type26 { get; set; } /// /// /// - public global::Recraft.ImageSize? Type27 { get; set; } + public global::Recraft.ExploreRequest? Type27 { get; set; } /// /// /// - public global::Recraft.ImageSubStyle? Type28 { get; set; } + public global::Recraft.UserControls? Type28 { get; set; } /// /// /// - public global::Recraft.ExploreSimilarRequest? Type29 { get; set; } + public global::Recraft.ImageSize? Type29 { get; set; } /// /// /// - public global::Recraft.GenerateImageRequest? Type30 { get; set; } + public global::Recraft.ImageSubStyle? Type30 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type31 { get; set; } + public global::Recraft.ExploreSimilarRequest? Type31 { get; set; } /// /// /// - public global::Recraft.UpscaleMode? Type32 { get; set; } + public global::Recraft.GenerateImageRequest? Type32 { get; set; } /// /// /// - public global::Recraft.GenerateImageResponse? Type33 { get; set; } + public global::System.Collections.Generic.IList? Type33 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type34 { get; set; } + public global::Recraft.UpscaleMode? Type34 { get; set; } /// /// /// - public global::Recraft.Image? Type35 { get; set; } + public global::Recraft.GenerateImageResponse? Type35 { get; set; } /// /// /// - public global::Recraft.ImageFeatures? Type36 { get; set; } + public global::System.Collections.Generic.IList? Type36 { get; set; } /// /// /// - public global::Recraft.ImageColor? Type37 { get; set; } + public global::Recraft.Image? Type37 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type38 { get; set; } + public global::Recraft.ImageFeatures? Type38 { get; set; } /// /// /// - public global::Recraft.ImageToImageRequest? Type39 { get; set; } + public global::Recraft.ImageColor? Type39 { get; set; } /// /// /// - public global::Recraft.LimitNumShapes? Type40 { get; set; } + public global::System.Collections.Generic.IList? Type40 { get; set; } /// /// /// - public global::Recraft.ListBasicStylesResponse? Type41 { get; set; } + public global::Recraft.ImageToImageRequest? Type41 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type42 { get; set; } + public global::Recraft.TransformImageRequest? Type42 { get; set; } /// /// /// - public global::Recraft.ListStylesResponse? Type43 { get; set; } + public global::Recraft.ImageToImageRequestVariant2? Type43 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type44 { get; set; } + public global::Recraft.LimitNumShapes? Type44 { get; set; } /// /// /// - public global::Recraft.OptimizeColorsRequest? Type45 { get; set; } + public global::Recraft.ListBasicStylesResponse? Type45 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type46 { get; set; } + public global::System.Collections.Generic.IList? Type46 { get; set; } /// /// /// - public global::Recraft.OptimizeColorsResponse? Type47 { get; set; } + public global::Recraft.ListStylesResponse? Type47 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type48 { get; set; } + public global::System.Collections.Generic.IList? Type48 { get; set; } /// /// /// - public global::System.Collections.Generic.IList? Type49 { get; set; } + public global::Recraft.OptimizeColorsRequest? Type49 { get; set; } /// /// /// - public global::Recraft.ProcessImageRequest? Type50 { get; set; } + public global::System.Collections.Generic.IList? Type50 { get; set; } /// /// /// - public global::Recraft.ProcessImageResponse? Type51 { get; set; } + public global::Recraft.OptimizeColorsResponse? Type51 { get; set; } /// /// /// - public global::Recraft.ReturnGradients? Type52 { get; set; } + public global::System.Collections.Generic.IList? Type52 { get; set; } /// /// /// - public global::Recraft.ShapeStacking? Type53 { get; set; } + public global::Recraft.OutpaintImageRequest? Type53 { get; set; } /// /// /// - public global::Recraft.SmallShapeFilter? Type54 { get; set; } + public global::Recraft.OutpaintImageRequestVariant2? Type54 { get; set; } /// /// /// - public global::System.DateTime? Type55 { get; set; } + public global::System.Collections.Generic.IList? Type55 { get; set; } /// /// /// - public global::Recraft.SvgCompression? Type56 { get; set; } + public global::Recraft.ProcessImageRequest? Type56 { get; set; } /// /// /// - public global::Recraft.SystemStatus? Type57 { get; set; } + public global::Recraft.ProcessImageResponse? Type57 { get; set; } /// /// /// - public global::Recraft.TextLayoutItem? Type58 { get; set; } + public global::Recraft.ReturnGradients? Type58 { get; set; } /// /// /// - public global::System.Collections.Generic.IList>? Type59 { get; set; } + public global::Recraft.ShapeStacking? Type59 { get; set; } /// /// /// - public global::Recraft.TransformImageRequest? Type60 { get; set; } + public global::Recraft.SmallShapeFilter? Type60 { get; set; } /// /// /// - public global::Recraft.TransformImageWithMaskRequest? Type61 { get; set; } + public global::System.DateTime? Type61 { get; set; } /// /// /// - public global::Recraft.TransformImageWithMaskRequestVariant2? Type62 { get; set; } + public global::Recraft.SvgCompression? Type62 { get; set; } /// /// /// - public global::Recraft.User? Type63 { get; set; } + public global::Recraft.SystemStatus? Type63 { get; set; } /// /// /// - public global::Recraft.VariateImageRequest? Type64 { get; set; } + public global::Recraft.TextLayoutItem? Type64 { get; set; } /// /// /// - public global::Recraft.VectorizeImageRequest? Type65 { get; set; } + public global::System.Collections.Generic.IList>? Type65 { get; set; } /// /// /// - public global::Recraft.VectorizeImageRequestVariant2? Type66 { get; set; } + public global::Recraft.TransformImageWithMaskRequest? Type66 { get; set; } /// /// /// - public object? Type67 { get; set; } + public global::Recraft.TransformImageWithMaskRequestVariant2? Type67 { get; set; } + /// + /// + /// + public global::Recraft.User? Type68 { get; set; } + /// + /// + /// + public global::Recraft.VariateImageRequest? Type69 { get; set; } + /// + /// + /// + public global::Recraft.VectorizeImageRequest? Type70 { get; set; } + /// + /// + /// + public global::Recraft.VectorizeImageRequestVariant2? Type71 { get; set; } + /// + /// + /// + public object? Type72 { get; set; } /// /// diff --git a/src/libs/Recraft/Generated/Recraft.Models.EnhancePromptRequest.Json.g.cs b/src/libs/Recraft/Generated/Recraft.Models.EnhancePromptRequest.Json.g.cs new file mode 100644 index 0000000..7115ec9 --- /dev/null +++ b/src/libs/Recraft/Generated/Recraft.Models.EnhancePromptRequest.Json.g.cs @@ -0,0 +1,92 @@ +#nullable enable + +namespace Recraft +{ + public sealed partial class EnhancePromptRequest + { + /// + /// 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::Recraft.EnhancePromptRequest? FromJson( + string json, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + typeof(global::Recraft.EnhancePromptRequest), + jsonSerializerContext) as global::Recraft.EnhancePromptRequest; + } + + /// + /// 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::Recraft.EnhancePromptRequest? 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::Recraft.EnhancePromptRequest), + jsonSerializerContext).ConfigureAwait(false)) as global::Recraft.EnhancePromptRequest; + } + + /// + /// 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/Recraft/Generated/Recraft.Models.EnhancePromptRequest.g.cs b/src/libs/Recraft/Generated/Recraft.Models.EnhancePromptRequest.g.cs new file mode 100644 index 0000000..910857b --- /dev/null +++ b/src/libs/Recraft/Generated/Recraft.Models.EnhancePromptRequest.g.cs @@ -0,0 +1,45 @@ + +#nullable enable + +namespace Recraft +{ + /// + /// + /// + public sealed partial class EnhancePromptRequest + { + /// + /// + /// + [global::System.Text.Json.Serialization.JsonPropertyName("prompt")] + [global::System.Text.Json.Serialization.JsonRequired] + public required string Prompt { 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. + /// + /// +#if NET7_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] +#endif + public EnhancePromptRequest( + string prompt) + { + this.Prompt = prompt ?? throw new global::System.ArgumentNullException(nameof(prompt)); + } + + /// + /// Initializes a new instance of the class. + /// + public EnhancePromptRequest() + { + } + + } +} \ No newline at end of file diff --git a/src/libs/Recraft/Generated/Recraft.Models.EnhancePromptResponse.Json.g.cs b/src/libs/Recraft/Generated/Recraft.Models.EnhancePromptResponse.Json.g.cs new file mode 100644 index 0000000..b041043 --- /dev/null +++ b/src/libs/Recraft/Generated/Recraft.Models.EnhancePromptResponse.Json.g.cs @@ -0,0 +1,92 @@ +#nullable enable + +namespace Recraft +{ + public sealed partial class EnhancePromptResponse + { + /// + /// 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::Recraft.EnhancePromptResponse? FromJson( + string json, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + typeof(global::Recraft.EnhancePromptResponse), + jsonSerializerContext) as global::Recraft.EnhancePromptResponse; + } + + /// + /// 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::Recraft.EnhancePromptResponse? 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::Recraft.EnhancePromptResponse), + jsonSerializerContext).ConfigureAwait(false)) as global::Recraft.EnhancePromptResponse; + } + + /// + /// 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/Recraft/Generated/Recraft.Models.EnhancePromptResponse.g.cs b/src/libs/Recraft/Generated/Recraft.Models.EnhancePromptResponse.g.cs new file mode 100644 index 0000000..30251c2 --- /dev/null +++ b/src/libs/Recraft/Generated/Recraft.Models.EnhancePromptResponse.g.cs @@ -0,0 +1,55 @@ + +#nullable enable + +namespace Recraft +{ + /// + /// + /// + public sealed partial class EnhancePromptResponse + { + /// + /// + /// + [global::System.Text.Json.Serialization.JsonPropertyName("credits")] + [global::System.Text.Json.Serialization.JsonRequired] + public required int Credits { get; set; } + + /// + /// + /// + [global::System.Text.Json.Serialization.JsonPropertyName("enhanced_prompt")] + [global::System.Text.Json.Serialization.JsonRequired] + public required string EnhancedPrompt { 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. + /// + /// + /// +#if NET7_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] +#endif + public EnhancePromptResponse( + int credits, + string enhancedPrompt) + { + this.Credits = credits; + this.EnhancedPrompt = enhancedPrompt ?? throw new global::System.ArgumentNullException(nameof(enhancedPrompt)); + } + + /// + /// Initializes a new instance of the class. + /// + public EnhancePromptResponse() + { + } + + } +} \ No newline at end of file diff --git a/src/libs/Recraft/Generated/Recraft.Models.ImageToImageRequest.Json.g.cs b/src/libs/Recraft/Generated/Recraft.Models.ImageToImageRequest.Json.g.cs index 5096784..4301d43 100644 --- a/src/libs/Recraft/Generated/Recraft.Models.ImageToImageRequest.Json.g.cs +++ b/src/libs/Recraft/Generated/Recraft.Models.ImageToImageRequest.Json.g.cs @@ -2,7 +2,7 @@ namespace Recraft { - public sealed partial class ImageToImageRequest + public readonly partial struct ImageToImageRequest { /// /// Serializes the current instance to a JSON string using the provided JsonSerializerContext. @@ -41,7 +41,7 @@ public string ToJson( return global::System.Text.Json.JsonSerializer.Deserialize( json, typeof(global::Recraft.ImageToImageRequest), - jsonSerializerContext) as global::Recraft.ImageToImageRequest; + jsonSerializerContext) as global::Recraft.ImageToImageRequest?; } /// @@ -70,7 +70,7 @@ public string ToJson( return (await global::System.Text.Json.JsonSerializer.DeserializeAsync( jsonStream, typeof(global::Recraft.ImageToImageRequest), - jsonSerializerContext).ConfigureAwait(false)) as global::Recraft.ImageToImageRequest; + jsonSerializerContext).ConfigureAwait(false)) as global::Recraft.ImageToImageRequest?; } /// diff --git a/src/libs/Recraft/Generated/Recraft.Models.ImageToImageRequest.g.cs b/src/libs/Recraft/Generated/Recraft.Models.ImageToImageRequest.g.cs index 254d614..758061c 100644 --- a/src/libs/Recraft/Generated/Recraft.Models.ImageToImageRequest.g.cs +++ b/src/libs/Recraft/Generated/Recraft.Models.ImageToImageRequest.g.cs @@ -1,3 +1,4 @@ +#pragma warning disable CS0618 // Type or member is obsolete #nullable enable @@ -6,200 +7,289 @@ namespace Recraft /// /// /// - public sealed partial class ImageToImageRequest + public readonly partial struct ImageToImageRequest : global::System.IEquatable { /// /// /// - [global::System.Text.Json.Serialization.JsonPropertyName("block_nsfw")] - public bool? BlockNsfw { get; set; } +#if NET6_0_OR_GREATER + public global::Recraft.TransformImageRequest? Transform { get; init; } +#else + public global::Recraft.TransformImageRequest? Transform { get; } +#endif /// /// /// - [global::System.Text.Json.Serialization.JsonPropertyName("calculate_features")] - public bool? CalculateFeatures { get; set; } +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, nameof(Transform))] +#endif + public bool IsTransform => Transform != null; /// /// /// - [global::System.Text.Json.Serialization.JsonPropertyName("controls")] - public global::Recraft.UserControls? Controls { get; set; } + public bool TryPickTransform( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out global::Recraft.TransformImageRequest? value) + { + value = Transform; + return IsTransform; + } /// /// /// - [global::System.Text.Json.Serialization.JsonPropertyName("expire")] - public bool? Expire { get; set; } + public global::Recraft.TransformImageRequest PickTransform() => IsTransform + ? Transform! + : throw new global::System.InvalidOperationException($"Expected union variant 'Transform' but the value was {ToString()}."); /// /// /// - [global::System.Text.Json.Serialization.JsonPropertyName("image")] - [global::System.Text.Json.Serialization.JsonRequired] - public required byte[] Image { get; set; } +#if NET6_0_OR_GREATER + public global::Recraft.ImageToImageRequestVariant2? ImageToImageRequestVariant2 { get; init; } +#else + public global::Recraft.ImageToImageRequestVariant2? ImageToImageRequestVariant2 { get; } +#endif /// /// /// - [global::System.Text.Json.Serialization.JsonPropertyName("imagename")] - [global::System.Text.Json.Serialization.JsonRequired] - public required string Imagename { get; set; } +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, nameof(ImageToImageRequestVariant2))] +#endif + public bool IsImageToImageRequestVariant2 => ImageToImageRequestVariant2 != null; /// /// /// - [global::System.Text.Json.Serialization.JsonPropertyName("image_format")] - [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Recraft.JsonConverters.ImageFormatJsonConverter))] - public global::Recraft.ImageFormat? ImageFormat { get; set; } + public bool TryPickImageToImageRequestVariant2( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out global::Recraft.ImageToImageRequestVariant2? value) + { + value = ImageToImageRequestVariant2; + return IsImageToImageRequestVariant2; + } + + /// + /// + /// + public global::Recraft.ImageToImageRequestVariant2 PickImageToImageRequestVariant2() => IsImageToImageRequestVariant2 + ? ImageToImageRequestVariant2! + : throw new global::System.InvalidOperationException($"Expected union variant 'ImageToImageRequestVariant2' but the value was {ToString()}."); + /// + /// + /// + public static implicit operator ImageToImageRequest(global::Recraft.TransformImageRequest value) => new ImageToImageRequest((global::Recraft.TransformImageRequest?)value); /// /// /// - [global::System.Text.Json.Serialization.JsonPropertyName("model")] - [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Recraft.JsonConverters.TransformModelJsonConverter))] - public global::Recraft.TransformModel? Model { get; set; } + public static implicit operator global::Recraft.TransformImageRequest?(ImageToImageRequest @this) => @this.Transform; /// /// /// - [global::System.Text.Json.Serialization.JsonPropertyName("n")] - public int? N { get; set; } + public ImageToImageRequest(global::Recraft.TransformImageRequest? value) + { + Transform = value; + } /// /// /// - [global::System.Text.Json.Serialization.JsonPropertyName("negative_prompt")] - public string? NegativePrompt { get; set; } + public static ImageToImageRequest FromTransform(global::Recraft.TransformImageRequest? value) => new ImageToImageRequest(value); /// /// /// - [global::System.Text.Json.Serialization.JsonPropertyName("prompt")] - [global::System.Text.Json.Serialization.JsonRequired] - public required string Prompt { get; set; } + public static implicit operator ImageToImageRequest(global::Recraft.ImageToImageRequestVariant2 value) => new ImageToImageRequest((global::Recraft.ImageToImageRequestVariant2?)value); /// /// /// - [global::System.Text.Json.Serialization.JsonPropertyName("random_seed")] - public int? RandomSeed { get; set; } + public static implicit operator global::Recraft.ImageToImageRequestVariant2?(ImageToImageRequest @this) => @this.ImageToImageRequestVariant2; /// /// /// - [global::System.Text.Json.Serialization.JsonPropertyName("response_format")] - [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Recraft.JsonConverters.ResponseFormatJsonConverter))] - public global::Recraft.ResponseFormat? ResponseFormat { get; set; } + public ImageToImageRequest(global::Recraft.ImageToImageRequestVariant2? value) + { + ImageToImageRequestVariant2 = value; + } /// /// /// - [global::System.Text.Json.Serialization.JsonPropertyName("strength")] - [global::System.Text.Json.Serialization.JsonRequired] - public required double Strength { get; set; } + public static ImageToImageRequest FromImageToImageRequestVariant2(global::Recraft.ImageToImageRequestVariant2? value) => new ImageToImageRequest(value); /// /// /// - [global::System.Text.Json.Serialization.JsonPropertyName("style")] - public string? Style { get; set; } + public ImageToImageRequest( + global::Recraft.TransformImageRequest? transform, + global::Recraft.ImageToImageRequestVariant2? imageToImageRequestVariant2 + ) + { + Transform = transform; + ImageToImageRequestVariant2 = imageToImageRequestVariant2; + } /// /// /// - [global::System.Text.Json.Serialization.JsonPropertyName("style_id")] - public global::System.Guid? StyleId { get; set; } + public object? Object => + ImageToImageRequestVariant2 as object ?? + Transform as object + ; /// /// /// - [global::System.Text.Json.Serialization.JsonPropertyName("substyle")] - [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Recraft.JsonConverters.ImageSubStyleJsonConverter))] - public global::Recraft.ImageSubStyle? Substyle { get; set; } + public override string? ToString() => + Transform?.ToString() ?? + ImageToImageRequestVariant2?.ToString() + ; /// /// /// - [global::System.Text.Json.Serialization.JsonPropertyName("text_layout")] - public global::System.Collections.Generic.IList? TextLayout { get; set; } + public bool Validate() + { + return IsTransform && IsImageToImageRequestVariant2; + } /// - /// 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(); + public TResult? Match( + global::System.Func? transform = null, + global::System.Func? imageToImageRequestVariant2 = null, + bool validate = true) + { + if (validate) + { + Validate(); + } + + if (IsTransform && transform != null) + { + return transform(Transform!); + } + else if (IsImageToImageRequestVariant2 && imageToImageRequestVariant2 != null) + { + return imageToImageRequestVariant2(ImageToImageRequestVariant2!); + } + + return default(TResult); + } /// - /// Initializes a new instance of the class. + /// /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// -#if NET7_0_OR_GREATER - [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] -#endif - public ImageToImageRequest( - byte[] image, - string imagename, - string prompt, - double strength, - bool? blockNsfw, - bool? calculateFeatures, - global::Recraft.UserControls? controls, - bool? expire, - global::Recraft.ImageFormat? imageFormat, - global::Recraft.TransformModel? model, - int? n, - string? negativePrompt, - int? randomSeed, - global::Recraft.ResponseFormat? responseFormat, - string? style, - global::System.Guid? styleId, - global::Recraft.ImageSubStyle? substyle, - global::System.Collections.Generic.IList? textLayout) + public void Match( + global::System.Action? transform = null, + + global::System.Action? imageToImageRequestVariant2 = null, + bool validate = true) + { + if (validate) + { + Validate(); + } + + if (IsTransform) + { + transform?.Invoke(Transform!); + } + else if (IsImageToImageRequestVariant2) + { + imageToImageRequestVariant2?.Invoke(ImageToImageRequestVariant2!); + } + } + + /// + /// + /// + public void Switch( + global::System.Action? transform = null, + global::System.Action? imageToImageRequestVariant2 = null, + bool validate = true) + { + if (validate) + { + Validate(); + } + + if (IsTransform) + { + transform?.Invoke(Transform!); + } + else if (IsImageToImageRequestVariant2) + { + imageToImageRequestVariant2?.Invoke(ImageToImageRequestVariant2!); + } + } + + /// + /// + /// + public override int GetHashCode() + { + var fields = new object?[] + { + Transform, + typeof(global::Recraft.TransformImageRequest), + ImageToImageRequestVariant2, + typeof(global::Recraft.ImageToImageRequestVariant2), + }; + const int offset = unchecked((int)2166136261); + const int prime = 16777619; + static int HashCodeAggregator(int hashCode, object? value) => value == null + ? (hashCode ^ 0) * prime + : (hashCode ^ value.GetHashCode()) * prime; + + return global::System.Linq.Enumerable.Aggregate(fields, offset, HashCodeAggregator); + } + + /// + /// + /// + public bool Equals(ImageToImageRequest other) { - this.BlockNsfw = blockNsfw; - this.CalculateFeatures = calculateFeatures; - this.Controls = controls; - this.Expire = expire; - this.Image = image ?? throw new global::System.ArgumentNullException(nameof(image)); - this.Imagename = imagename ?? throw new global::System.ArgumentNullException(nameof(imagename)); - this.ImageFormat = imageFormat; - this.Model = model; - this.N = n; - this.NegativePrompt = negativePrompt; - this.Prompt = prompt ?? throw new global::System.ArgumentNullException(nameof(prompt)); - this.RandomSeed = randomSeed; - this.ResponseFormat = responseFormat; - this.Strength = strength; - this.Style = style; - this.StyleId = styleId; - this.Substyle = substyle; - this.TextLayout = textLayout; + return + global::System.Collections.Generic.EqualityComparer.Default.Equals(Transform, other.Transform) && + global::System.Collections.Generic.EqualityComparer.Default.Equals(ImageToImageRequestVariant2, other.ImageToImageRequestVariant2) + ; } /// - /// Initializes a new instance of the class. + /// /// - public ImageToImageRequest() + public static bool operator ==(ImageToImageRequest obj1, ImageToImageRequest obj2) { + return global::System.Collections.Generic.EqualityComparer.Default.Equals(obj1, obj2); } + /// + /// + /// + public static bool operator !=(ImageToImageRequest obj1, ImageToImageRequest obj2) + { + return !(obj1 == obj2); + } + + /// + /// + /// + public override bool Equals(object? obj) + { + return obj is ImageToImageRequest o && Equals(o); + } } -} \ No newline at end of file +} diff --git a/src/libs/Recraft/Generated/Recraft.Models.ImageToImageRequestVariant2.Json.g.cs b/src/libs/Recraft/Generated/Recraft.Models.ImageToImageRequestVariant2.Json.g.cs new file mode 100644 index 0000000..d35ea15 --- /dev/null +++ b/src/libs/Recraft/Generated/Recraft.Models.ImageToImageRequestVariant2.Json.g.cs @@ -0,0 +1,92 @@ +#nullable enable + +namespace Recraft +{ + public sealed partial class ImageToImageRequestVariant2 + { + /// + /// 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::Recraft.ImageToImageRequestVariant2? FromJson( + string json, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + typeof(global::Recraft.ImageToImageRequestVariant2), + jsonSerializerContext) as global::Recraft.ImageToImageRequestVariant2; + } + + /// + /// 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::Recraft.ImageToImageRequestVariant2? 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::Recraft.ImageToImageRequestVariant2), + jsonSerializerContext).ConfigureAwait(false)) as global::Recraft.ImageToImageRequestVariant2; + } + + /// + /// 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/Recraft/Generated/Recraft.Models.ImageToImageRequestVariant2.g.cs b/src/libs/Recraft/Generated/Recraft.Models.ImageToImageRequestVariant2.g.cs new file mode 100644 index 0000000..bfeded3 --- /dev/null +++ b/src/libs/Recraft/Generated/Recraft.Models.ImageToImageRequestVariant2.g.cs @@ -0,0 +1,45 @@ + +#nullable enable + +namespace Recraft +{ + /// + /// + /// + public sealed partial class ImageToImageRequestVariant2 + { + /// + /// + /// + [global::System.Text.Json.Serialization.JsonPropertyName("strength")] + [global::System.Text.Json.Serialization.JsonRequired] + public required double Strength { 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. + /// + /// +#if NET7_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] +#endif + public ImageToImageRequestVariant2( + double strength) + { + this.Strength = strength; + } + + /// + /// Initializes a new instance of the class. + /// + public ImageToImageRequestVariant2() + { + } + + } +} \ No newline at end of file diff --git a/src/libs/Recraft/Generated/Recraft.Models.OutpaintImageRequest.Json.g.cs b/src/libs/Recraft/Generated/Recraft.Models.OutpaintImageRequest.Json.g.cs new file mode 100644 index 0000000..2764f84 --- /dev/null +++ b/src/libs/Recraft/Generated/Recraft.Models.OutpaintImageRequest.Json.g.cs @@ -0,0 +1,92 @@ +#nullable enable + +namespace Recraft +{ + public readonly partial struct OutpaintImageRequest + { + /// + /// 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::Recraft.OutpaintImageRequest? FromJson( + string json, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + typeof(global::Recraft.OutpaintImageRequest), + jsonSerializerContext) as global::Recraft.OutpaintImageRequest?; + } + + /// + /// 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::Recraft.OutpaintImageRequest? 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::Recraft.OutpaintImageRequest), + jsonSerializerContext).ConfigureAwait(false)) as global::Recraft.OutpaintImageRequest?; + } + + /// + /// 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/Recraft/Generated/Recraft.Models.OutpaintImageRequest.g.cs b/src/libs/Recraft/Generated/Recraft.Models.OutpaintImageRequest.g.cs new file mode 100644 index 0000000..db61460 --- /dev/null +++ b/src/libs/Recraft/Generated/Recraft.Models.OutpaintImageRequest.g.cs @@ -0,0 +1,295 @@ +#pragma warning disable CS0618 // Type or member is obsolete + +#nullable enable + +namespace Recraft +{ + /// + /// + /// + public readonly partial struct OutpaintImageRequest : global::System.IEquatable + { + /// + /// + /// +#if NET6_0_OR_GREATER + public global::Recraft.TransformImageRequest? Transform { get; init; } +#else + public global::Recraft.TransformImageRequest? Transform { get; } +#endif + + /// + /// + /// +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, nameof(Transform))] +#endif + public bool IsTransform => Transform != null; + + /// + /// + /// + public bool TryPickTransform( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out global::Recraft.TransformImageRequest? value) + { + value = Transform; + return IsTransform; + } + + /// + /// + /// + public global::Recraft.TransformImageRequest PickTransform() => IsTransform + ? Transform! + : throw new global::System.InvalidOperationException($"Expected union variant 'Transform' but the value was {ToString()}."); + + /// + /// + /// +#if NET6_0_OR_GREATER + public global::Recraft.OutpaintImageRequestVariant2? OutpaintImageRequestVariant2 { get; init; } +#else + public global::Recraft.OutpaintImageRequestVariant2? OutpaintImageRequestVariant2 { get; } +#endif + + /// + /// + /// +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.MemberNotNullWhen(true, nameof(OutpaintImageRequestVariant2))] +#endif + public bool IsOutpaintImageRequestVariant2 => OutpaintImageRequestVariant2 != null; + + /// + /// + /// + public bool TryPickOutpaintImageRequestVariant2( +#if NET6_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.NotNullWhen(true)] +#endif + out global::Recraft.OutpaintImageRequestVariant2? value) + { + value = OutpaintImageRequestVariant2; + return IsOutpaintImageRequestVariant2; + } + + /// + /// + /// + public global::Recraft.OutpaintImageRequestVariant2 PickOutpaintImageRequestVariant2() => IsOutpaintImageRequestVariant2 + ? OutpaintImageRequestVariant2! + : throw new global::System.InvalidOperationException($"Expected union variant 'OutpaintImageRequestVariant2' but the value was {ToString()}."); + /// + /// + /// + public static implicit operator OutpaintImageRequest(global::Recraft.TransformImageRequest value) => new OutpaintImageRequest((global::Recraft.TransformImageRequest?)value); + + /// + /// + /// + public static implicit operator global::Recraft.TransformImageRequest?(OutpaintImageRequest @this) => @this.Transform; + + /// + /// + /// + public OutpaintImageRequest(global::Recraft.TransformImageRequest? value) + { + Transform = value; + } + + /// + /// + /// + public static OutpaintImageRequest FromTransform(global::Recraft.TransformImageRequest? value) => new OutpaintImageRequest(value); + + /// + /// + /// + public static implicit operator OutpaintImageRequest(global::Recraft.OutpaintImageRequestVariant2 value) => new OutpaintImageRequest((global::Recraft.OutpaintImageRequestVariant2?)value); + + /// + /// + /// + public static implicit operator global::Recraft.OutpaintImageRequestVariant2?(OutpaintImageRequest @this) => @this.OutpaintImageRequestVariant2; + + /// + /// + /// + public OutpaintImageRequest(global::Recraft.OutpaintImageRequestVariant2? value) + { + OutpaintImageRequestVariant2 = value; + } + + /// + /// + /// + public static OutpaintImageRequest FromOutpaintImageRequestVariant2(global::Recraft.OutpaintImageRequestVariant2? value) => new OutpaintImageRequest(value); + + /// + /// + /// + public OutpaintImageRequest( + global::Recraft.TransformImageRequest? transform, + global::Recraft.OutpaintImageRequestVariant2? outpaintImageRequestVariant2 + ) + { + Transform = transform; + OutpaintImageRequestVariant2 = outpaintImageRequestVariant2; + } + + /// + /// + /// + public object? Object => + OutpaintImageRequestVariant2 as object ?? + Transform as object + ; + + /// + /// + /// + public override string? ToString() => + Transform?.ToString() ?? + OutpaintImageRequestVariant2?.ToString() + ; + + /// + /// + /// + public bool Validate() + { + return IsTransform && IsOutpaintImageRequestVariant2; + } + + /// + /// + /// + public TResult? Match( + global::System.Func? transform = null, + global::System.Func? outpaintImageRequestVariant2 = null, + bool validate = true) + { + if (validate) + { + Validate(); + } + + if (IsTransform && transform != null) + { + return transform(Transform!); + } + else if (IsOutpaintImageRequestVariant2 && outpaintImageRequestVariant2 != null) + { + return outpaintImageRequestVariant2(OutpaintImageRequestVariant2!); + } + + return default(TResult); + } + + /// + /// + /// + public void Match( + global::System.Action? transform = null, + + global::System.Action? outpaintImageRequestVariant2 = null, + bool validate = true) + { + if (validate) + { + Validate(); + } + + if (IsTransform) + { + transform?.Invoke(Transform!); + } + else if (IsOutpaintImageRequestVariant2) + { + outpaintImageRequestVariant2?.Invoke(OutpaintImageRequestVariant2!); + } + } + + /// + /// + /// + public void Switch( + global::System.Action? transform = null, + global::System.Action? outpaintImageRequestVariant2 = null, + bool validate = true) + { + if (validate) + { + Validate(); + } + + if (IsTransform) + { + transform?.Invoke(Transform!); + } + else if (IsOutpaintImageRequestVariant2) + { + outpaintImageRequestVariant2?.Invoke(OutpaintImageRequestVariant2!); + } + } + + /// + /// + /// + public override int GetHashCode() + { + var fields = new object?[] + { + Transform, + typeof(global::Recraft.TransformImageRequest), + OutpaintImageRequestVariant2, + typeof(global::Recraft.OutpaintImageRequestVariant2), + }; + const int offset = unchecked((int)2166136261); + const int prime = 16777619; + static int HashCodeAggregator(int hashCode, object? value) => value == null + ? (hashCode ^ 0) * prime + : (hashCode ^ value.GetHashCode()) * prime; + + return global::System.Linq.Enumerable.Aggregate(fields, offset, HashCodeAggregator); + } + + /// + /// + /// + public bool Equals(OutpaintImageRequest other) + { + return + global::System.Collections.Generic.EqualityComparer.Default.Equals(Transform, other.Transform) && + global::System.Collections.Generic.EqualityComparer.Default.Equals(OutpaintImageRequestVariant2, other.OutpaintImageRequestVariant2) + ; + } + + /// + /// + /// + public static bool operator ==(OutpaintImageRequest obj1, OutpaintImageRequest obj2) + { + return global::System.Collections.Generic.EqualityComparer.Default.Equals(obj1, obj2); + } + + /// + /// + /// + public static bool operator !=(OutpaintImageRequest obj1, OutpaintImageRequest obj2) + { + return !(obj1 == obj2); + } + + /// + /// + /// + public override bool Equals(object? obj) + { + return obj is OutpaintImageRequest o && Equals(o); + } + } +} diff --git a/src/libs/Recraft/Generated/Recraft.Models.OutpaintImageRequestVariant2.Json.g.cs b/src/libs/Recraft/Generated/Recraft.Models.OutpaintImageRequestVariant2.Json.g.cs new file mode 100644 index 0000000..6890fe4 --- /dev/null +++ b/src/libs/Recraft/Generated/Recraft.Models.OutpaintImageRequestVariant2.Json.g.cs @@ -0,0 +1,92 @@ +#nullable enable + +namespace Recraft +{ + public sealed partial class OutpaintImageRequestVariant2 + { + /// + /// 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::Recraft.OutpaintImageRequestVariant2? FromJson( + string json, + global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext) + { + return global::System.Text.Json.JsonSerializer.Deserialize( + json, + typeof(global::Recraft.OutpaintImageRequestVariant2), + jsonSerializerContext) as global::Recraft.OutpaintImageRequestVariant2; + } + + /// + /// 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::Recraft.OutpaintImageRequestVariant2? 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::Recraft.OutpaintImageRequestVariant2), + jsonSerializerContext).ConfigureAwait(false)) as global::Recraft.OutpaintImageRequestVariant2; + } + + /// + /// 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/Recraft/Generated/Recraft.Models.OutpaintImageRequestVariant2.g.cs b/src/libs/Recraft/Generated/Recraft.Models.OutpaintImageRequestVariant2.g.cs new file mode 100644 index 0000000..5e1e612 --- /dev/null +++ b/src/libs/Recraft/Generated/Recraft.Models.OutpaintImageRequestVariant2.g.cs @@ -0,0 +1,90 @@ + +#nullable enable + +namespace Recraft +{ + /// + /// + /// + public sealed partial class OutpaintImageRequestVariant2 + { + /// + /// + /// + [global::System.Text.Json.Serialization.JsonPropertyName("expand_bottom")] + public int? ExpandBottom { get; set; } + + /// + /// + /// + [global::System.Text.Json.Serialization.JsonPropertyName("expand_left")] + public int? ExpandLeft { get; set; } + + /// + /// + /// + [global::System.Text.Json.Serialization.JsonPropertyName("expand_right")] + public int? ExpandRight { get; set; } + + /// + /// + /// + [global::System.Text.Json.Serialization.JsonPropertyName("expand_top")] + public int? ExpandTop { get; set; } + + /// + /// + /// + [global::System.Text.Json.Serialization.JsonPropertyName("size")] + [global::System.Text.Json.Serialization.JsonConverter(typeof(global::Recraft.JsonConverters.ImageSizeJsonConverter))] + public global::Recraft.ImageSize? Size { get; set; } + + /// + /// + /// + [global::System.Text.Json.Serialization.JsonPropertyName("zoom_out_percentage")] + public double? ZoomOutPercentage { 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. + /// + /// + /// + /// + /// + /// + /// +#if NET7_0_OR_GREATER + [global::System.Diagnostics.CodeAnalysis.SetsRequiredMembers] +#endif + public OutpaintImageRequestVariant2( + int? expandBottom, + int? expandLeft, + int? expandRight, + int? expandTop, + global::Recraft.ImageSize? size, + double? zoomOutPercentage) + { + this.ExpandBottom = expandBottom; + this.ExpandLeft = expandLeft; + this.ExpandRight = expandRight; + this.ExpandTop = expandTop; + this.Size = size; + this.ZoomOutPercentage = zoomOutPercentage; + } + + /// + /// Initializes a new instance of the class. + /// + public OutpaintImageRequestVariant2() + { + } + + } +} \ No newline at end of file diff --git a/src/libs/Recraft/Generated/Recraft.Models.TransformImageRequest.g.cs b/src/libs/Recraft/Generated/Recraft.Models.TransformImageRequest.g.cs index fa90b2f..818e733 100644 --- a/src/libs/Recraft/Generated/Recraft.Models.TransformImageRequest.g.cs +++ b/src/libs/Recraft/Generated/Recraft.Models.TransformImageRequest.g.cs @@ -20,6 +20,12 @@ public sealed partial class TransformImageRequest [global::System.Text.Json.Serialization.JsonPropertyName("calculate_features")] public bool? CalculateFeatures { get; set; } + /// + /// + /// + [global::System.Text.Json.Serialization.JsonPropertyName("controls")] + public global::Recraft.UserControls? Controls { get; set; } + /// /// /// @@ -125,6 +131,7 @@ public sealed partial class TransformImageRequest /// /// /// + /// /// /// /// @@ -145,6 +152,7 @@ public TransformImageRequest( string prompt, bool? blockNsfw, bool? calculateFeatures, + global::Recraft.UserControls? controls, bool? expire, global::Recraft.ImageFormat? imageFormat, global::Recraft.TransformModel? model, @@ -159,6 +167,7 @@ public TransformImageRequest( { this.BlockNsfw = blockNsfw; this.CalculateFeatures = calculateFeatures; + this.Controls = controls; this.Expire = expire; this.Image = image ?? throw new global::System.ArgumentNullException(nameof(image)); this.Imagename = imagename ?? throw new global::System.ArgumentNullException(nameof(imagename)); diff --git a/src/libs/Recraft/Generated/Recraft.PromptClient.EnhancePrompt.g.cs b/src/libs/Recraft/Generated/Recraft.PromptClient.EnhancePrompt.g.cs new file mode 100644 index 0000000..97be1ea --- /dev/null +++ b/src/libs/Recraft/Generated/Recraft.PromptClient.EnhancePrompt.g.cs @@ -0,0 +1,476 @@ + +#nullable enable + +namespace Recraft +{ + public partial class PromptClient + { + + + private static readonly global::Recraft.EndPointSecurityRequirement s_EnhancePromptSecurityRequirement0 = + new global::Recraft.EndPointSecurityRequirement + { + Authorizations = new global::Recraft.EndPointAuthorizationRequirement[] + { new global::Recraft.EndPointAuthorizationRequirement + { + Type = "Http", + SchemeId = "HttpBearer", + Location = "Header", + Name = "Bearer", + FriendlyName = "Bearer", + }, + }, + }; + private static readonly global::Recraft.EndPointSecurityRequirement[] s_EnhancePromptSecurityRequirements = + new global::Recraft.EndPointSecurityRequirement[] + { s_EnhancePromptSecurityRequirement0, + }; + partial void PrepareEnhancePromptArguments( + global::System.Net.Http.HttpClient httpClient, + ref global::Recraft.BillingType? billing, + global::Recraft.EnhancePromptRequest request); + partial void PrepareEnhancePromptRequest( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpRequestMessage httpRequestMessage, + global::Recraft.BillingType? billing, + global::Recraft.EnhancePromptRequest request); + partial void ProcessEnhancePromptResponse( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpResponseMessage httpResponseMessage); + + partial void ProcessEnhancePromptResponseContent( + global::System.Net.Http.HttpClient httpClient, + global::System.Net.Http.HttpResponseMessage httpResponseMessage, + ref string content); + + /// + /// Enhance a prompt using an LLM + /// + /// + /// + /// 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 EnhancePromptAsync( + + global::Recraft.EnhancePromptRequest request, + global::Recraft.BillingType? billing = default, + global::Recraft.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await EnhancePromptAsResponseAsync( + + request: request, + billing: billing, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Enhance a prompt using an LLM + /// + /// + /// + /// 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> EnhancePromptAsResponseAsync( + + global::Recraft.EnhancePromptRequest request, + global::Recraft.BillingType? billing = default, + global::Recraft.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + request = request ?? throw new global::System.ArgumentNullException(nameof(request)); + + PrepareArguments( + client: HttpClient); + PrepareEnhancePromptArguments( + httpClient: HttpClient, + billing: ref billing, + request: request); + + + var __authorizations = global::Recraft.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_EnhancePromptSecurityRequirements, + operationName: "EnhancePromptAsync"); + + using var __timeoutCancellationTokenSource = global::Recraft.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Recraft.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Recraft.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::Recraft.PathBuilder( + path: "/v1/prompts/enhance", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("billing", billing?.ToValueString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::Recraft.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 __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Recraft.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareEnhancePromptRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + billing: billing, + 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::Recraft.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "EnhancePrompt", + methodName: "EnhancePromptAsync", + pathTemplate: "\"/v1/prompts/enhance\"", + 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::Recraft.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "EnhancePrompt", + methodName: "EnhancePromptAsync", + pathTemplate: "\"/v1/prompts/enhance\"", + 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::Recraft.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Recraft.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::Recraft.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "EnhancePrompt", + methodName: "EnhancePromptAsync", + pathTemplate: "\"/v1/prompts/enhance\"", + 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::Recraft.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); + ProcessEnhancePromptResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Recraft.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "EnhancePrompt", + methodName: "EnhancePromptAsync", + pathTemplate: "\"/v1/prompts/enhance\"", + 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::Recraft.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Recraft.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "EnhancePrompt", + methodName: "EnhancePromptAsync", + pathTemplate: "\"/v1/prompts/enhance\"", + 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); + ProcessEnhancePromptResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::Recraft.EnhancePromptResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::Recraft.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Recraft.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::Recraft.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::Recraft.EnhancePromptResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::Recraft.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::Recraft.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::Recraft.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(); + } + } + /// + /// Enhance a prompt using an LLM + /// + /// + /// + /// 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 EnhancePromptAsync( + string prompt, + global::Recraft.BillingType? billing = default, + global::Recraft.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __request = new global::Recraft.EnhancePromptRequest + { + Prompt = prompt, + }; + + return await EnhancePromptAsync( + billing: billing, + request: __request, + requestOptions: requestOptions, + cancellationToken: cancellationToken).ConfigureAwait(false); + } + } +} \ No newline at end of file diff --git a/src/libs/Recraft/Generated/Recraft.PromptClient.g.cs b/src/libs/Recraft/Generated/Recraft.PromptClient.g.cs new file mode 100644 index 0000000..f67333a --- /dev/null +++ b/src/libs/Recraft/Generated/Recraft.PromptClient.g.cs @@ -0,0 +1,136 @@ + +#nullable enable + +namespace Recraft +{ + /// + /// If no httpClient is provided, a new one will be created.
+ /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + ///
+ public sealed partial class PromptClient : global::Recraft.IPromptClient, global::System.IDisposable + { + /// + /// + /// + public const string DefaultBaseUrl = "https://external.api.recraft.ai/"; + + private bool _disposeHttpClient = true; + + /// + public global::System.Net.Http.HttpClient HttpClient { get; } + + /// + public System.Uri? BaseUri => HttpClient.BaseAddress; + + /// + public global::System.Collections.Generic.List Authorizations { get; } + + /// + public bool ReadResponseAsString { get; set; } +#if DEBUG + = true; +#endif + + /// + public global::Recraft.AutoSDKClientOptions Options { get; } + /// + /// + /// + public global::System.Text.Json.Serialization.JsonSerializerContext JsonSerializerContext { get; set; } = global::Recraft.SourceGenerationContext.Default; + + + /// + /// Creates a new instance of the PromptClient. + /// If no httpClient is provided, a new one will be created. + /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. + /// The authorizations to use for the requests. + /// 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, + bool disposeHttpClient = true) : this( + httpClient, + baseUri, + authorizations, + options: null, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the PromptClient with explicit options but no base URL override. + /// Skips passing baseUri so the default base URL from the OpenAPI spec applies. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The authorizations to use for the requests. + /// 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, + global::System.Collections.Generic.List? authorizations, + global::Recraft.AutoSDKClientOptions? options, + bool disposeHttpClient = true) : this( + httpClient, + baseUri: null, + authorizations, + options, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the PromptClient. + /// If no httpClient is provided, a new one will be created. + /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. + /// The authorizations to use for the requests. + /// 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, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::Recraft.AutoSDKClientOptions? options, + bool disposeHttpClient = true) + { + + HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); + HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); + Authorizations = authorizations ?? new global::System.Collections.Generic.List(); + Options = options ?? new global::Recraft.AutoSDKClientOptions(); + _disposeHttpClient = disposeHttpClient; + + Initialized(HttpClient); + } + + /// + public void Dispose() + { + if (_disposeHttpClient) + { + HttpClient.Dispose(); + } + } + + partial void Initialized( + global::System.Net.Http.HttpClient client); + partial void PrepareArguments( + global::System.Net.Http.HttpClient client); + partial void PrepareRequest( + global::System.Net.Http.HttpClient client, + global::System.Net.Http.HttpRequestMessage request); + partial void ProcessResponse( + global::System.Net.Http.HttpClient client, + global::System.Net.Http.HttpResponseMessage response); + partial void ProcessResponseContent( + global::System.Net.Http.HttpClient client, + global::System.Net.Http.HttpResponseMessage response, + ref string content); + } +} \ No newline at end of file diff --git a/src/libs/Recraft/Generated/Recraft.RecraftClient.g.cs b/src/libs/Recraft/Generated/Recraft.RecraftClient.g.cs index df45375..60c3e1f 100644 --- a/src/libs/Recraft/Generated/Recraft.RecraftClient.g.cs +++ b/src/libs/Recraft/Generated/Recraft.RecraftClient.g.cs @@ -57,6 +57,15 @@ public sealed partial class RecraftClient : global::Recraft.IRecraftClient, glob JsonSerializerContext = JsonSerializerContext, }; + /// + /// + /// + public PromptClient Prompt => new PromptClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options) + { + ReadResponseAsString = ReadResponseAsString, + JsonSerializerContext = JsonSerializerContext, + }; + /// /// /// diff --git a/src/libs/Recraft/openapi.yaml b/src/libs/Recraft/openapi.yaml index f459354..c9f3615 100644 --- a/src/libs/Recraft/openapi.yaml +++ b/src/libs/Recraft/openapi.yaml @@ -1 +1 @@ -{"components":{"parameters":{"billing":{"in":"query","name":"billing","schema":{"$ref":"#/components/schemas/BillingType"}}},"schemas":{"BasicStyle":{"properties":{"model":{"$ref":"#/components/schemas/TransformModel"},"style":{"type":"string"},"style_id":{"format":"uuid","type":"string","x-go-name":"StyleID","x-go-type":"uuid.UUID","x-go-type-import":{"path":"github.com/gofrs/uuid/v5"}}},"required":["style_id","style","model"],"type":"object"},"BillingType":{"enum":["api","subscription"],"type":"string","x-enum-varnames":["BillingTypeAPI","BillingTypeSubscription"]},"ColorHexAndWeight":{"properties":{"hex":{"type":"string"},"weight":{"type":"number"}},"required":["hex"],"type":"object"},"ColorMapping":{"properties":{"from":{"type":"string"},"to":{"type":"string"}},"required":["from","to"],"type":"object"},"ColorReduction":{"enum":["on","off"],"type":"string"},"CreateStyleRequest":{"properties":{"image_weights":{"items":{"type":"number"},"type":"array"},"images":{"items":{"format":"binary","type":"string"},"type":"array"},"mix_policy":{"$ref":"#/components/schemas/MixPolicy"},"model":{"$ref":"#/components/schemas/TransformModel"},"palette":{"$ref":"#/components/schemas/PaletteSuggest"},"private":{"type":"boolean"},"prompt":{"type":"string"},"source_style_weights":{"items":{"type":"number"},"type":"array"},"source_styles":{"items":{"format":"uuid","type":"string","x-go-type":"uuid.UUID","x-go-type-import":{"path":"github.com/gofrs/uuid/v5"}},"type":"array"},"style":{"$ref":"#/components/schemas/ImageStyle"}},"required":["images","style"],"type":"object"},"CreateStyleResponse":{"allOf":[{"$ref":"#/components/schemas/Style"},{"properties":{"credits":{"type":"integer"}},"required":["credits"],"type":"object"}]},"EraseRegionRequest":{"properties":{"expire":{"type":"boolean"},"image":{"format":"binary","type":"string"},"image_format":{"$ref":"#/components/schemas/ImageFormat"},"mask":{"format":"binary","type":"string"},"response_format":{"$ref":"#/components/schemas/ResponseFormat"}},"required":["image","mask"],"type":"object"},"ExploreRequest":{"properties":{"block_nsfw":{"type":"boolean"},"controls":{"$ref":"#/components/schemas/UserControls"},"expire":{"type":"boolean"},"image_format":{"$ref":"#/components/schemas/ImageFormat"},"model":{"$ref":"#/components/schemas/TransformModel"},"prompt":{"type":"string"},"response_format":{"$ref":"#/components/schemas/ResponseFormat"},"size":{"$ref":"#/components/schemas/ImageSize"},"style":{"type":"string"},"style_id":{"format":"uuid","type":"string","x-go-name":"StyleID","x-go-type":"uuid.UUID","x-go-type-import":{"path":"github.com/gofrs/uuid/v5"}},"substyle":{"$ref":"#/components/schemas/ImageSubStyle"}},"required":["prompt"],"type":"object"},"ExploreSimilarRequest":{"properties":{"block_nsfw":{"type":"boolean"},"expire":{"type":"boolean"},"image_format":{"$ref":"#/components/schemas/ImageFormat"},"response_format":{"$ref":"#/components/schemas/ResponseFormat"},"similarity":{"type":"integer"},"source_image_id":{"format":"uuid","type":"string","x-go-name":"SourceImageID","x-go-type":"uuid.UUID","x-go-type-import":{"path":"github.com/gofrs/uuid/v5"}}},"required":["source_image_id","similarity"],"type":"object"},"GenerateImageRequest":{"properties":{"block_nsfw":{"type":"boolean"},"calculate_features":{"type":"boolean"},"controls":{"$ref":"#/components/schemas/UserControls"},"expire":{"type":"boolean"},"image_format":{"$ref":"#/components/schemas/ImageFormat"},"model":{"$ref":"#/components/schemas/TransformModel"},"n":{"type":"integer"},"negative_prompt":{"type":"string"},"prompt":{"type":"string"},"random_seed":{"format":"uint32","type":"integer"},"response_format":{"$ref":"#/components/schemas/ResponseFormat"},"size":{"$ref":"#/components/schemas/ImageSize"},"style":{"type":"string"},"style_id":{"format":"uuid","type":"string","x-go-name":"StyleID","x-go-type":"uuid.UUID","x-go-type-import":{"path":"github.com/gofrs/uuid/v5"}},"substyle":{"$ref":"#/components/schemas/ImageSubStyle"},"text_layout":{"$ref":"#/components/schemas/TextLayout"},"upscale":{"$ref":"#/components/schemas/UpscaleMode"}},"required":["prompt"],"type":"object"},"GenerateImageResponse":{"properties":{"created":{"type":"integer"},"credits":{"type":"integer"},"data":{"items":{"$ref":"#/components/schemas/Image"},"type":"array"}},"required":["created","data","credits"],"type":"object"},"Image":{"properties":{"b64_json":{"type":"string"},"features":{"$ref":"#/components/schemas/ImageFeatures"},"image_id":{"format":"uuid","type":"string","x-go-name":"ImageID","x-go-type":"uuid.UUID","x-go-type-import":{"path":"github.com/gofrs/uuid/v5"}},"revised_prompt":{"type":"string"},"url":{"type":"string"}},"required":["image_id"],"type":"object"},"ImageColor":{"properties":{"rgb":{"items":{"type":"integer"},"type":"array"},"std":{"items":{"type":"number"},"type":"array"},"weight":{"type":"number"}},"type":"object"},"ImageFeatures":{"properties":{"nsfw_score":{"type":"number"}},"type":"object"},"ImageFormat":{"enum":["webp","png"],"type":"string"},"ImageSize":{"enum":["1024x1024","1365x1024","1024x1365","1536x1024","1024x1536","1820x1024","1024x1820","1024x2048","2048x1024","1434x1024","1024x1434","1024x1280","1280x1024","1024x1707","1707x1024","1024x1024","1216x896","896x1216","1280x832","832x1280","1152x896","896x1152","1280x896","896x1280","832x1344","768x1344","1344x768","768x1536","1536x768","2048x2048","2432x1792","1792x2432","2560x1664","1664x2560","2304x1792","1792x2304","2560x1792","1792x2560","1664x2688","1536x2688","2688x1536","1536x3072","3072x1536","1:1","2:1","1:2","3:2","2:3","4:3","3:4","5:4","4:5","6:10","14:10","10:14","16:9","9:16"],"type":"string"},"ImageStyle":{"enum":["any","digital_illustration","icon","realistic_image","vector_illustration","logo_raster"],"type":"string"},"ImageSubStyle":{"enum":["2d_art_poster","3d","80s","glow","grain","hand_drawn","infantile_sketch","kawaii","pixel_art","psychedelic","seamless","voxel","watercolor","broken_line","colored_outline","colored_shapes","colored_shapes_gradient","doodle_fill","doodle_offset_fill","offset_fill","outline","outline_gradient","cartoon","doodle_line_art","engraving","flat_2","line_art","linocut","b_and_w","enterprise","hard_flash","hdr","motion_blur","natural_light","studio_portrait","line_circuit","2d_art_poster_2","engraving_color","hand_drawn_outline","handmade_3d","plastic","pictogram","antiquarian","bold_fantasy","child_book","cover","crosshatch","digital_engraving","expressionism","freehand_details","grain_20","graphic_intensity","hard_comics","long_shadow","modern_folk","multicolor","neon_calm","noir","nostalgic_pastel","outline_details","pastel_gradient","pastel_sketch","pop_art","pop_renaissance","street_art","tablet_sketch","urban_glow","urban_sketching","young_adult_book","young_adult_book_2","evening_light","faded_nostalgia","forest_life","mystic_naturalism","natural_tones","organic_calm","real_life_glow","retro_realism","retro_snapshot","urban_drama","village_realism","warm_folk","bold_stroke","chemistry","colored_stencil","cosmics","cutout","depressive","editorial","emotional_flat","marker_outline","mosaic","naivector","roundish_flat","segmented_colors","sharp_contrast","thin","vector_photo","vivid_shapes","emblem_graffiti","emblem_pop_art","emblem_punk","emblem_stamp","emblem_vintage"],"type":"string"},"ImageToImageRequest":{"properties":{"block_nsfw":{"type":"boolean"},"calculate_features":{"type":"boolean"},"controls":{"$ref":"#/components/schemas/UserControls"},"expire":{"type":"boolean"},"image":{"format":"binary","type":"string"},"image_format":{"$ref":"#/components/schemas/ImageFormat"},"model":{"$ref":"#/components/schemas/TransformModel"},"n":{"type":"integer"},"negative_prompt":{"type":"string"},"prompt":{"type":"string"},"random_seed":{"format":"uint32","type":"integer"},"response_format":{"$ref":"#/components/schemas/ResponseFormat"},"strength":{"type":"number"},"style":{"type":"string"},"style_id":{"format":"uuid","type":"string","x-go-name":"StyleID","x-go-type":"uuid.UUID","x-go-type-import":{"path":"github.com/gofrs/uuid/v5"}},"substyle":{"$ref":"#/components/schemas/ImageSubStyle"},"text_layout":{"$ref":"#/components/schemas/TextLayout"}},"required":["prompt","image","strength"],"type":"object"},"LimitNumShapes":{"enum":["on","off"],"type":"string","x-enum-varnames":["LimitNumShapesOn","LimitNumShapesOff"]},"ListBasicStylesResponse":{"properties":{"styles":{"items":{"$ref":"#/components/schemas/BasicStyle"},"type":"array"}},"required":["styles"],"type":"object"},"ListStylesResponse":{"properties":{"styles":{"items":{"$ref":"#/components/schemas/Style"},"type":"array"}},"required":["styles"],"type":"object"},"MixPolicy":{"enum":["PaletteMatch","MaxWeight"],"type":"string"},"OptimizeColorsRequest":{"properties":{"colors":{"items":{"$ref":"#/components/schemas/ColorHexAndWeight"},"type":"array"},"num_colors_limit":{"type":"integer"}},"required":["colors","num_colors_limit"],"type":"object"},"OptimizeColorsResponse":{"properties":{"credits":{"type":"integer"},"mapping":{"items":{"$ref":"#/components/schemas/ColorMapping"},"type":"array"}},"required":["mapping","credits"],"type":"object"},"PaletteSuggest":{"properties":{"background_color":{"$ref":"#/components/schemas/ImageColor"},"colors":{"items":{"$ref":"#/components/schemas/ImageColor"},"type":"array"}},"required":["colors"],"type":"object"},"ProcessImageRequest":{"properties":{"expire":{"type":"boolean"},"image":{"format":"binary","type":"string"},"image_format":{"$ref":"#/components/schemas/ImageFormat"},"response_format":{"$ref":"#/components/schemas/ResponseFormat"},"upscale":{"$ref":"#/components/schemas/UpscaleMode"}},"required":["image"],"type":"object"},"ProcessImageResponse":{"properties":{"created":{"type":"integer"},"credits":{"type":"integer"},"image":{"$ref":"#/components/schemas/Image"}},"required":["created","image","credits"],"type":"object"},"ResponseFormat":{"enum":["url","b64_json"],"type":"string"},"ReturnGradients":{"enum":["on","off"],"type":"string","x-enum-varnames":["ReturnGradientsOn","ReturnGradientsOff"]},"ShapeStacking":{"enum":["cut_out","hierarchical"],"type":"string","x-enum-varnames":["ShapeStackingCutOut","ShapeStackingHierarchical"]},"SmallShapeFilter":{"enum":["on","off"],"type":"string"},"Style":{"properties":{"creation_time":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string","x-go-name":"ID","x-go-type":"uuid.UUID","x-go-type-import":{"path":"github.com/gofrs/uuid/v5"}},"is_private":{"type":"boolean"},"style":{"$ref":"#/components/schemas/ImageStyle"},"substyle":{"$ref":"#/components/schemas/ImageSubStyle"}},"required":["id","style","creation_time","is_private"],"type":"object"},"SvgCompression":{"enum":["on","off"],"type":"string","x-enum-varnames":["SvgCompressionOn","SvgCompressionOff"]},"SystemStatus":{"properties":{"generation":{"type":"boolean"},"service":{"type":"boolean"}},"required":["service","generation"],"type":"object"},"TextLayout":{"items":{"$ref":"#/components/schemas/TextLayoutItem"},"type":"array"},"TextLayoutItem":{"properties":{"bbox":{"items":{"items":{"type":"number","x-go-type":"float32"},"type":"array"},"type":"array"},"text":{"type":"string"}},"required":["text","bbox"],"type":"object"},"TransformImageRequest":{"properties":{"block_nsfw":{"type":"boolean"},"calculate_features":{"type":"boolean"},"expire":{"type":"boolean"},"image":{"format":"binary","type":"string"},"image_format":{"$ref":"#/components/schemas/ImageFormat"},"model":{"$ref":"#/components/schemas/TransformModel"},"n":{"type":"integer"},"negative_prompt":{"type":"string"},"prompt":{"type":"string"},"random_seed":{"format":"uint32","type":"integer"},"response_format":{"$ref":"#/components/schemas/ResponseFormat"},"style":{"type":"string"},"style_id":{"format":"uuid","type":"string","x-go-name":"StyleID","x-go-type":"uuid.UUID","x-go-type-import":{"path":"github.com/gofrs/uuid/v5"}},"substyle":{"$ref":"#/components/schemas/ImageSubStyle"},"text_layout":{"$ref":"#/components/schemas/TextLayout"}},"required":["image","prompt"],"type":"object"},"TransformImageWithMaskRequest":{"allOf":[{"$ref":"#/components/schemas/TransformImageRequest"},{"properties":{"mask":{"format":"binary","type":"string"}},"required":["mask"],"type":"object"}]},"TransformModel":{"enum":["refm1","recraft20b","recraftv2","recraftv2_raster","recraftv2_vector","recraftv3","recraftv3_raster","recraftv3_vector","recraftv4","recraftv4_raster","recraftv4_vector","recraftv4_pro","recraftv4_pro_raster","recraftv4_pro_vector","recraftv4_1","recraftv4_1_raster","recraftv4_1_vector","recraftv4_1_pro","recraftv4_1_pro_raster","recraftv4_1_pro_vector","recraftv4_1_utility","recraftv4_1_utility_raster","recraftv4_1_utility_vector","recraftv4_1_utility_pro","recraftv4_1_utility_pro_raster","recraftv4_1_utility_pro_vector","flux1_kontext_pro","flux1_kontext_max","flux1_1pro","flux1dev","imagen3","imagen4","imagen4_ultra","hidream_i1_dev","gpt_image_1_low","gpt_image_1_medium","gpt_image_1_high","gpt_image_1p5_low","gpt_image_1p5_medium","gpt_image_1p5_high","gpt_image_2_low","gpt_image_2_medium","gpt_image_2_high","ideogram_v3_turbo","ideogram_v3_default","ideogram_v3_quality","qwen_image","qwen_image_2","gemini_25_flash_image","bytedance-seedreamv4","bytedance_seedreamv4p5","nano_banana_pro","nano_banana_pro_4k","nano_banana_2","nano_banana_2_with_4k","flux2_dev","flux2_pro","flux2_flex","flux2_max","z_image_turbo","bytedance_seedreamv5_lite","qwen_image_2_pro","flux1_schnell","grok_imagine_image","imagineart_2","veo3p1","veo3p1_fast","veo3p1_lite","veo3","veo3_fast","veo2","sora2_pro","sora2","ray2","ray2_flash","kling2p6_pro","kling2p5_turbo","kling2p1_master","hailuo02_pro","hailuo02_standard","hailuo2p3_pro","hailuo2p3_standard","wan2p7","wan2p6","wan2p5_preview","wan2p2_a14b","bytedance_seedance1p5","bytedance_seedance2","bytedance_seedance2_fast","pixverse_v5p5","pixverse_v5p6","pixverse_v6","grok_imagine_video","kling3_pro","kling3_standard","kling3_omni_pro","kling3_omni_standard","recraft_super_resolution","recraft_generative_upscale","topaz"],"type":"string"},"UpscaleMode":{"enum":["upscale4mp","upscale16mp"],"type":"string"},"User":{"properties":{"credits":{"type":"integer"},"email":{"format":"email","type":"string"},"id":{"format":"uuid","type":"string","x-go-name":"ID","x-go-type":"uuid.UUID","x-go-type-import":{"path":"github.com/gofrs/uuid/v5"}},"name":{"type":"string"}},"required":["id","credits"],"type":"object"},"UserControls":{"properties":{"artistic_level":{"type":"integer"},"background_color":{"$ref":"#/components/schemas/ImageColor"},"colors":{"items":{"$ref":"#/components/schemas/ImageColor"},"type":"array"},"no_text":{"type":"boolean"}},"type":"object"},"VariateImageRequest":{"properties":{"expire":{"type":"boolean"},"image":{"format":"binary","type":"string"},"image_format":{"$ref":"#/components/schemas/ImageFormat"},"n":{"type":"integer"},"random_seed":{"format":"uint32","type":"integer"},"response_format":{"$ref":"#/components/schemas/ResponseFormat"},"size":{"$ref":"#/components/schemas/ImageSize"}},"required":["image","size"],"type":"object"},"VectorizeImageRequest":{"allOf":[{"$ref":"#/components/schemas/ProcessImageRequest"},{"properties":{"color_reduction":{"$ref":"#/components/schemas/ColorReduction"},"limit_num_shapes":{"$ref":"#/components/schemas/LimitNumShapes"},"max_num_shapes":{"format":"uint32","type":"integer"},"return_gradients":{"$ref":"#/components/schemas/ReturnGradients"},"shape_stacking":{"$ref":"#/components/schemas/ShapeStacking"},"small_shape_filter":{"$ref":"#/components/schemas/SmallShapeFilter"},"svg_compression":{"$ref":"#/components/schemas/SvgCompression"}},"type":"object"}]}},"securitySchemes":{"auth0":{"scheme":"bearer","type":"http"}}},"info":{"title":"recraft.ai external api","version":"0.0.1"},"openapi":"3.0.3","paths":{"/ping":{"get":{"operationId":"GetPing","responses":{"200":{"description":"OK"}}}},"/status":{"get":{"operationId":"GetSystemStatus","responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SystemStatus"}}},"description":"OK"}},"summary":"Get System Status"}},"/v1/colors/optimize":{"post":{"operationId":"OptimizeColors","parameters":[{"$ref":"#/components/parameters/billing"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OptimizeColorsRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OptimizeColorsResponse"}}},"description":"OK"}},"summary":"Optimize colors","tags":["colors"]}},"/v1/images/clarityUpscale":{"post":{"deprecated":true,"operationId":"ClarityUpscale","parameters":[{"$ref":"#/components/parameters/billing"}],"requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/ProcessImageRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProcessImageResponse"}}},"description":"OK"}},"summary":"Clarity Upscale","tags":["image"]}},"/v1/images/creativeUpscale":{"post":{"operationId":"CreativeUpscale","parameters":[{"$ref":"#/components/parameters/billing"}],"requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/ProcessImageRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProcessImageResponse"}}},"description":"OK"}},"summary":"Creative Upscale","tags":["image"]}},"/v1/images/crispUpscale":{"post":{"operationId":"CrispUpscale","parameters":[{"$ref":"#/components/parameters/billing"}],"requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/ProcessImageRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProcessImageResponse"}}},"description":"OK"}},"summary":"Crisp Upscale","tags":["image"]}},"/v1/images/eraseRegion":{"post":{"operationId":"EraseRegion","parameters":[{"$ref":"#/components/parameters/billing"}],"requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/EraseRegionRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProcessImageResponse"}}},"description":"OK"}},"summary":"Erase Region","tags":["image"]}},"/v1/images/explore":{"post":{"operationId":"Explore","parameters":[{"$ref":"#/components/parameters/billing"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExploreRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GenerateImageResponse"}}},"description":"OK"}},"summary":"Exploration","tags":["image"]}},"/v1/images/explore/similar":{"post":{"operationId":"ExploreSimilar","parameters":[{"$ref":"#/components/parameters/billing"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExploreSimilarRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GenerateImageResponse"}}},"description":"OK"}},"summary":"Continue exploration from a source image","tags":["image"]}},"/v1/images/generateBackground":{"post":{"operationId":"GenerateBackground","parameters":[{"$ref":"#/components/parameters/billing"}],"requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/TransformImageWithMaskRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GenerateImageResponse"}}},"description":"OK"}},"summary":"Generate Background","tags":["image"]}},"/v1/images/generations":{"post":{"operationId":"GenerateImage","parameters":[{"$ref":"#/components/parameters/billing"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GenerateImageRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GenerateImageResponse"}}},"description":"OK"}},"summary":"Generate image from prompt","tags":["image"]}},"/v1/images/generations/raster":{"post":{"operationId":"GenerateImageRaster","parameters":[{"$ref":"#/components/parameters/billing"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GenerateImageRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GenerateImageResponse"}}},"description":"OK"}},"summary":"Generate raster image from prompt","tags":["image"]}},"/v1/images/generations/vector":{"post":{"operationId":"GenerateImageVector","parameters":[{"$ref":"#/components/parameters/billing"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GenerateImageRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GenerateImageResponse"}}},"description":"OK"}},"summary":"Generate vector image from prompt","tags":["image"]}},"/v1/images/generativeUpscale":{"post":{"deprecated":true,"operationId":"GenerativeUpscale","parameters":[{"$ref":"#/components/parameters/billing"}],"requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/ProcessImageRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProcessImageResponse"}}},"description":"OK"}},"summary":"Generative Upscale","tags":["image"]}},"/v1/images/imageToImage":{"post":{"operationId":"ImageToImage","parameters":[{"$ref":"#/components/parameters/billing"}],"requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/ImageToImageRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GenerateImageResponse"}}},"description":"OK"}},"summary":"Generate image from image and prompt","tags":["image"]}},"/v1/images/inpaint":{"post":{"operationId":"InpaintImage","parameters":[{"$ref":"#/components/parameters/billing"}],"requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/TransformImageWithMaskRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GenerateImageResponse"}}},"description":"OK"}},"summary":"Inpaint Image","tags":["image"]}},"/v1/images/removeBackground":{"post":{"operationId":"RemoveBackground","parameters":[{"$ref":"#/components/parameters/billing"}],"requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/ProcessImageRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProcessImageResponse"}}},"description":"OK"}},"summary":"Remove background","tags":["image"]}},"/v1/images/replaceBackground":{"post":{"operationId":"ReplaceBackground","parameters":[{"$ref":"#/components/parameters/billing"}],"requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/TransformImageRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GenerateImageResponse"}}},"description":"OK"}},"summary":"Replace Background","tags":["image"]}},"/v1/images/variateImage":{"post":{"operationId":"VariateImage","parameters":[{"$ref":"#/components/parameters/billing"}],"requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/VariateImageRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GenerateImageResponse"}}},"description":"OK"}},"summary":"Variate Image","tags":["image"]}},"/v1/images/vectorize":{"post":{"operationId":"VectorizeImage","parameters":[{"$ref":"#/components/parameters/billing"}],"requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/VectorizeImageRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProcessImageResponse"}}},"description":"OK"}},"summary":"Vectorize image","tags":["image"]}},"/v1/styles":{"get":{"operationId":"ListStyles","responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ListStylesResponse"}}},"description":"OK"}},"summary":"List Styles","tags":["style"]},"post":{"operationId":"CreateStyle","parameters":[{"$ref":"#/components/parameters/billing"}],"requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/CreateStyleRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateStyleResponse"}}},"description":"OK"}},"summary":"Create Style","tags":["style"]}},"/v1/styles/basic":{"get":{"operationId":"ListBasicStyles","responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ListBasicStylesResponse"}}},"description":"OK"}},"summary":"List Basic Styles","tags":["style"]}},"/v1/styles/{style_id}":{"delete":{"operationId":"DeleteStyle","parameters":[{"in":"path","name":"style_id","required":true,"schema":{"format":"uuid","type":"string","x-go-name":"StyleID","x-go-type":"uuid.UUID","x-go-type-import":{"path":"github.com/gofrs/uuid/v5"}}}],"responses":{"200":{"content":{"application/json":{"schema":{"type":"object"}}},"description":"OK"}},"summary":"Delete Style","tags":["style"]},"get":{"operationId":"GetStyle","parameters":[{"in":"path","name":"style_id","required":true,"schema":{"format":"uuid","type":"string","x-go-name":"StyleID","x-go-type":"uuid.UUID","x-go-type-import":{"path":"github.com/gofrs/uuid/v5"}}}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Style"}}},"description":"OK"}},"summary":"Get Style","tags":["style"]}},"/v1/users/me":{"get":{"operationId":"GetCurrentUser","parameters":[{"$ref":"#/components/parameters/billing"}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/User"}}},"description":"OK"}},"summary":"Get current user info","tags":["user"]}}},"security":[{"auth0":[]}],"servers":[{"description":"Production","url":"https://external.api.recraft.ai"}]} \ No newline at end of file +{"components":{"parameters":{"billing":{"in":"query","name":"billing","schema":{"$ref":"#/components/schemas/BillingType"}}},"schemas":{"BasicStyle":{"properties":{"model":{"$ref":"#/components/schemas/TransformModel"},"style":{"type":"string"},"style_id":{"format":"uuid","type":"string","x-go-name":"StyleID","x-go-type":"uuid.UUID","x-go-type-import":{"path":"github.com/gofrs/uuid/v5"}}},"required":["style_id","style","model"],"type":"object"},"BillingType":{"enum":["api","subscription"],"type":"string","x-enum-varnames":["BillingTypeAPI","BillingTypeSubscription"]},"ColorHexAndWeight":{"properties":{"hex":{"type":"string"},"weight":{"type":"number"}},"required":["hex"],"type":"object"},"ColorMapping":{"properties":{"from":{"type":"string"},"to":{"type":"string"}},"required":["from","to"],"type":"object"},"ColorReduction":{"enum":["on","off"],"type":"string"},"CreateStyleRequest":{"properties":{"image_weights":{"items":{"type":"number"},"type":"array"},"images":{"items":{"format":"binary","type":"string"},"type":"array"},"mix_policy":{"$ref":"#/components/schemas/MixPolicy"},"model":{"$ref":"#/components/schemas/TransformModel"},"palette":{"$ref":"#/components/schemas/PaletteSuggest"},"private":{"type":"boolean"},"prompt":{"type":"string"},"source_style_weights":{"items":{"type":"number"},"type":"array"},"source_styles":{"items":{"format":"uuid","type":"string","x-go-type":"uuid.UUID","x-go-type-import":{"path":"github.com/gofrs/uuid/v5"}},"type":"array"},"style":{"$ref":"#/components/schemas/ImageStyle"}},"required":["images","style"],"type":"object"},"CreateStyleResponse":{"allOf":[{"$ref":"#/components/schemas/Style"},{"properties":{"credits":{"type":"integer"}},"required":["credits"],"type":"object"}]},"EnhancePromptRequest":{"properties":{"prompt":{"type":"string"}},"required":["prompt"],"type":"object"},"EnhancePromptResponse":{"properties":{"credits":{"type":"integer"},"enhanced_prompt":{"type":"string"}},"required":["enhanced_prompt","credits"],"type":"object"},"EraseRegionRequest":{"properties":{"expire":{"type":"boolean"},"image":{"format":"binary","type":"string"},"image_format":{"$ref":"#/components/schemas/ImageFormat"},"mask":{"format":"binary","type":"string"},"response_format":{"$ref":"#/components/schemas/ResponseFormat"}},"required":["image","mask"],"type":"object"},"ExploreRequest":{"properties":{"block_nsfw":{"type":"boolean"},"controls":{"$ref":"#/components/schemas/UserControls"},"expire":{"type":"boolean"},"image_format":{"$ref":"#/components/schemas/ImageFormat"},"model":{"$ref":"#/components/schemas/TransformModel"},"prompt":{"type":"string"},"response_format":{"$ref":"#/components/schemas/ResponseFormat"},"size":{"$ref":"#/components/schemas/ImageSize"},"style":{"type":"string"},"style_id":{"format":"uuid","type":"string","x-go-name":"StyleID","x-go-type":"uuid.UUID","x-go-type-import":{"path":"github.com/gofrs/uuid/v5"}},"substyle":{"$ref":"#/components/schemas/ImageSubStyle"}},"required":["prompt"],"type":"object"},"ExploreSimilarRequest":{"properties":{"block_nsfw":{"type":"boolean"},"expire":{"type":"boolean"},"image_format":{"$ref":"#/components/schemas/ImageFormat"},"response_format":{"$ref":"#/components/schemas/ResponseFormat"},"similarity":{"type":"integer"},"source_image_id":{"format":"uuid","type":"string","x-go-name":"SourceImageID","x-go-type":"uuid.UUID","x-go-type-import":{"path":"github.com/gofrs/uuid/v5"}}},"required":["source_image_id","similarity"],"type":"object"},"GenerateImageRequest":{"properties":{"block_nsfw":{"type":"boolean"},"calculate_features":{"type":"boolean"},"controls":{"$ref":"#/components/schemas/UserControls"},"expire":{"type":"boolean"},"image_format":{"$ref":"#/components/schemas/ImageFormat"},"model":{"$ref":"#/components/schemas/TransformModel"},"n":{"type":"integer"},"negative_prompt":{"type":"string"},"prompt":{"type":"string"},"random_seed":{"format":"uint32","type":"integer"},"response_format":{"$ref":"#/components/schemas/ResponseFormat"},"size":{"$ref":"#/components/schemas/ImageSize"},"style":{"type":"string"},"style_id":{"format":"uuid","type":"string","x-go-name":"StyleID","x-go-type":"uuid.UUID","x-go-type-import":{"path":"github.com/gofrs/uuid/v5"}},"substyle":{"$ref":"#/components/schemas/ImageSubStyle"},"text_layout":{"$ref":"#/components/schemas/TextLayout"},"upscale":{"$ref":"#/components/schemas/UpscaleMode"}},"required":["prompt"],"type":"object"},"GenerateImageResponse":{"properties":{"created":{"type":"integer"},"credits":{"type":"integer"},"data":{"items":{"$ref":"#/components/schemas/Image"},"type":"array"}},"required":["created","data","credits"],"type":"object"},"Image":{"properties":{"b64_json":{"type":"string"},"features":{"$ref":"#/components/schemas/ImageFeatures"},"image_id":{"format":"uuid","type":"string","x-go-name":"ImageID","x-go-type":"uuid.UUID","x-go-type-import":{"path":"github.com/gofrs/uuid/v5"}},"revised_prompt":{"type":"string"},"url":{"type":"string"}},"required":["image_id"],"type":"object"},"ImageColor":{"properties":{"rgb":{"items":{"type":"integer"},"type":"array"},"std":{"items":{"type":"number"},"type":"array"},"weight":{"type":"number"}},"type":"object"},"ImageFeatures":{"properties":{"nsfw_score":{"type":"number"}},"type":"object"},"ImageFormat":{"enum":["webp","png"],"type":"string"},"ImageSize":{"enum":["1024x1024","1365x1024","1024x1365","1536x1024","1024x1536","1820x1024","1024x1820","1024x2048","2048x1024","1434x1024","1024x1434","1024x1280","1280x1024","1024x1707","1707x1024","1024x1024","1216x896","896x1216","1280x832","832x1280","1152x896","896x1152","1280x896","896x1280","832x1344","768x1344","1344x768","768x1536","1536x768","2048x2048","2432x1792","1792x2432","2560x1664","1664x2560","2304x1792","1792x2304","2560x1792","1792x2560","1664x2688","1536x2688","2688x1536","1536x3072","3072x1536","1:1","2:1","1:2","3:2","2:3","4:3","3:4","5:4","4:5","6:10","14:10","10:14","16:9","9:16"],"type":"string"},"ImageStyle":{"enum":["any","digital_illustration","icon","realistic_image","vector_illustration","logo_raster"],"type":"string"},"ImageSubStyle":{"enum":["2d_art_poster","3d","80s","glow","grain","hand_drawn","infantile_sketch","kawaii","pixel_art","psychedelic","seamless","voxel","watercolor","broken_line","colored_outline","colored_shapes","colored_shapes_gradient","doodle_fill","doodle_offset_fill","offset_fill","outline","outline_gradient","cartoon","doodle_line_art","engraving","flat_2","line_art","linocut","b_and_w","enterprise","hard_flash","hdr","motion_blur","natural_light","studio_portrait","line_circuit","2d_art_poster_2","engraving_color","hand_drawn_outline","handmade_3d","plastic","pictogram","antiquarian","bold_fantasy","child_book","cover","crosshatch","digital_engraving","expressionism","freehand_details","grain_20","graphic_intensity","hard_comics","long_shadow","modern_folk","multicolor","neon_calm","noir","nostalgic_pastel","outline_details","pastel_gradient","pastel_sketch","pop_art","pop_renaissance","street_art","tablet_sketch","urban_glow","urban_sketching","young_adult_book","young_adult_book_2","evening_light","faded_nostalgia","forest_life","mystic_naturalism","natural_tones","organic_calm","real_life_glow","retro_realism","retro_snapshot","urban_drama","village_realism","warm_folk","bold_stroke","chemistry","colored_stencil","cosmics","cutout","depressive","editorial","emotional_flat","marker_outline","mosaic","naivector","roundish_flat","segmented_colors","sharp_contrast","thin","vector_photo","vivid_shapes","emblem_graffiti","emblem_pop_art","emblem_punk","emblem_stamp","emblem_vintage"],"type":"string"},"ImageToImageRequest":{"allOf":[{"$ref":"#/components/schemas/TransformImageRequest"},{"properties":{"strength":{"type":"number"}},"required":["strength"],"type":"object"}]},"LimitNumShapes":{"enum":["on","off"],"type":"string","x-enum-varnames":["LimitNumShapesOn","LimitNumShapesOff"]},"ListBasicStylesResponse":{"properties":{"styles":{"items":{"$ref":"#/components/schemas/BasicStyle"},"type":"array"}},"required":["styles"],"type":"object"},"ListStylesResponse":{"properties":{"styles":{"items":{"$ref":"#/components/schemas/Style"},"type":"array"}},"required":["styles"],"type":"object"},"MixPolicy":{"enum":["PaletteMatch","MaxWeight"],"type":"string"},"OptimizeColorsRequest":{"properties":{"colors":{"items":{"$ref":"#/components/schemas/ColorHexAndWeight"},"type":"array"},"num_colors_limit":{"type":"integer"}},"required":["colors","num_colors_limit"],"type":"object"},"OptimizeColorsResponse":{"properties":{"credits":{"type":"integer"},"mapping":{"items":{"$ref":"#/components/schemas/ColorMapping"},"type":"array"}},"required":["mapping","credits"],"type":"object"},"OutpaintImageRequest":{"allOf":[{"$ref":"#/components/schemas/TransformImageRequest"},{"properties":{"expand_bottom":{"format":"uint32","type":"integer"},"expand_left":{"format":"uint32","type":"integer"},"expand_right":{"format":"uint32","type":"integer"},"expand_top":{"format":"uint32","type":"integer"},"size":{"$ref":"#/components/schemas/ImageSize"},"zoom_out_percentage":{"type":"number"}},"type":"object"}]},"PaletteSuggest":{"properties":{"background_color":{"$ref":"#/components/schemas/ImageColor"},"colors":{"items":{"$ref":"#/components/schemas/ImageColor"},"type":"array"}},"required":["colors"],"type":"object"},"ProcessImageRequest":{"properties":{"expire":{"type":"boolean"},"image":{"format":"binary","type":"string"},"image_format":{"$ref":"#/components/schemas/ImageFormat"},"response_format":{"$ref":"#/components/schemas/ResponseFormat"},"upscale":{"$ref":"#/components/schemas/UpscaleMode"}},"required":["image"],"type":"object"},"ProcessImageResponse":{"properties":{"created":{"type":"integer"},"credits":{"type":"integer"},"image":{"$ref":"#/components/schemas/Image"}},"required":["created","image","credits"],"type":"object"},"ResponseFormat":{"enum":["url","b64_json"],"type":"string"},"ReturnGradients":{"enum":["on","off"],"type":"string","x-enum-varnames":["ReturnGradientsOn","ReturnGradientsOff"]},"ShapeStacking":{"enum":["cut_out","hierarchical"],"type":"string","x-enum-varnames":["ShapeStackingCutOut","ShapeStackingHierarchical"]},"SmallShapeFilter":{"enum":["on","off"],"type":"string"},"Style":{"properties":{"creation_time":{"format":"date-time","type":"string"},"id":{"format":"uuid","type":"string","x-go-name":"ID","x-go-type":"uuid.UUID","x-go-type-import":{"path":"github.com/gofrs/uuid/v5"}},"is_private":{"type":"boolean"},"style":{"$ref":"#/components/schemas/ImageStyle"},"substyle":{"$ref":"#/components/schemas/ImageSubStyle"}},"required":["id","style","creation_time","is_private"],"type":"object"},"SvgCompression":{"enum":["on","off"],"type":"string","x-enum-varnames":["SvgCompressionOn","SvgCompressionOff"]},"SystemStatus":{"properties":{"generation":{"type":"boolean"},"service":{"type":"boolean"}},"required":["service","generation"],"type":"object"},"TextLayout":{"items":{"$ref":"#/components/schemas/TextLayoutItem"},"type":"array"},"TextLayoutItem":{"properties":{"bbox":{"items":{"items":{"type":"number","x-go-type":"float32"},"type":"array"},"type":"array"},"text":{"type":"string"}},"required":["text","bbox"],"type":"object"},"TransformImageRequest":{"properties":{"block_nsfw":{"type":"boolean"},"calculate_features":{"type":"boolean"},"controls":{"$ref":"#/components/schemas/UserControls"},"expire":{"type":"boolean"},"image":{"format":"binary","type":"string"},"image_format":{"$ref":"#/components/schemas/ImageFormat"},"model":{"$ref":"#/components/schemas/TransformModel"},"n":{"type":"integer"},"negative_prompt":{"type":"string"},"prompt":{"type":"string"},"random_seed":{"format":"uint32","type":"integer"},"response_format":{"$ref":"#/components/schemas/ResponseFormat"},"style":{"type":"string"},"style_id":{"format":"uuid","type":"string","x-go-name":"StyleID","x-go-type":"uuid.UUID","x-go-type-import":{"path":"github.com/gofrs/uuid/v5"}},"substyle":{"$ref":"#/components/schemas/ImageSubStyle"},"text_layout":{"$ref":"#/components/schemas/TextLayout"}},"required":["image","prompt"],"type":"object"},"TransformImageWithMaskRequest":{"allOf":[{"$ref":"#/components/schemas/TransformImageRequest"},{"properties":{"mask":{"format":"binary","type":"string"}},"required":["mask"],"type":"object"}]},"TransformModel":{"enum":["refm1","recraft20b","recraftv2","recraftv2_raster","recraftv2_vector","recraftv3","recraftv3_raster","recraftv3_vector","recraftv4","recraftv4_raster","recraftv4_vector","recraftv4_pro","recraftv4_pro_raster","recraftv4_pro_vector","recraftv4_1","recraftv4_1_raster","recraftv4_1_vector","recraftv4_1_pro","recraftv4_1_pro_raster","recraftv4_1_pro_vector","recraftv4_1_utility","recraftv4_1_utility_raster","recraftv4_1_utility_vector","recraftv4_1_utility_pro","recraftv4_1_utility_pro_raster","recraftv4_1_utility_pro_vector","flux1_kontext_pro","flux1_kontext_max","flux1_1pro","flux1dev","imagen3","imagen4","imagen4_ultra","hidream_i1_dev","gpt_image_1_low","gpt_image_1_medium","gpt_image_1_high","gpt_image_1p5_low","gpt_image_1p5_medium","gpt_image_1p5_high","gpt_image_2_low","gpt_image_2_medium","gpt_image_2_high","ideogram_v3_turbo","ideogram_v3_default","ideogram_v3_quality","qwen_image","qwen_image_2","gemini_25_flash_image","bytedance-seedreamv4","bytedance_seedreamv4p5","nano_banana_pro","nano_banana_pro_4k","nano_banana_2","nano_banana_2_with_4k","flux2_dev","flux2_pro","flux2_flex","flux2_max","z_image_turbo","bytedance_seedreamv5_lite","qwen_image_2_pro","flux1_schnell","grok_imagine_image","imagineart_2","veo3p1","veo3p1_fast","veo3p1_lite","veo3","veo3_fast","veo2","sora2_pro","sora2","ray2","ray2_flash","kling2p6_pro","kling2p5_turbo","kling2p1_master","hailuo02_pro","hailuo02_standard","hailuo2p3_pro","hailuo2p3_standard","wan2p7","wan2p6","wan2p5_preview","wan2p2_a14b","bytedance_seedance1p5","bytedance_seedance2","bytedance_seedance2_fast","pixverse_v5p5","pixverse_v5p6","pixverse_v6","grok_imagine_video","kling3_pro","kling3_standard","kling3_omni_pro","kling3_omni_standard","recraft_super_resolution","recraft_generative_upscale","topaz"],"type":"string"},"UpscaleMode":{"enum":["upscale4mp","upscale16mp"],"type":"string"},"User":{"properties":{"credits":{"type":"integer"},"email":{"format":"email","type":"string"},"id":{"format":"uuid","type":"string","x-go-name":"ID","x-go-type":"uuid.UUID","x-go-type-import":{"path":"github.com/gofrs/uuid/v5"}},"name":{"type":"string"}},"required":["id","credits"],"type":"object"},"UserControls":{"properties":{"artistic_level":{"type":"integer"},"background_color":{"$ref":"#/components/schemas/ImageColor"},"colors":{"items":{"$ref":"#/components/schemas/ImageColor"},"type":"array"},"no_text":{"type":"boolean"}},"type":"object"},"VariateImageRequest":{"properties":{"expire":{"type":"boolean"},"image":{"format":"binary","type":"string"},"image_format":{"$ref":"#/components/schemas/ImageFormat"},"n":{"type":"integer"},"random_seed":{"format":"uint32","type":"integer"},"response_format":{"$ref":"#/components/schemas/ResponseFormat"},"size":{"$ref":"#/components/schemas/ImageSize"}},"required":["image","size"],"type":"object"},"VectorizeImageRequest":{"allOf":[{"$ref":"#/components/schemas/ProcessImageRequest"},{"properties":{"color_reduction":{"$ref":"#/components/schemas/ColorReduction"},"limit_num_shapes":{"$ref":"#/components/schemas/LimitNumShapes"},"max_num_shapes":{"format":"uint32","type":"integer"},"return_gradients":{"$ref":"#/components/schemas/ReturnGradients"},"shape_stacking":{"$ref":"#/components/schemas/ShapeStacking"},"small_shape_filter":{"$ref":"#/components/schemas/SmallShapeFilter"},"svg_compression":{"$ref":"#/components/schemas/SvgCompression"}},"type":"object"}]}},"securitySchemes":{"auth0":{"scheme":"bearer","type":"http"}}},"info":{"title":"recraft.ai external api","version":"0.0.1"},"openapi":"3.0.3","paths":{"/ping":{"get":{"operationId":"GetPing","responses":{"200":{"description":"OK"}}}},"/status":{"get":{"operationId":"GetSystemStatus","responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SystemStatus"}}},"description":"OK"}},"summary":"Get System Status"}},"/v1/colors/optimize":{"post":{"operationId":"OptimizeColors","parameters":[{"$ref":"#/components/parameters/billing"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OptimizeColorsRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OptimizeColorsResponse"}}},"description":"OK"}},"summary":"Optimize colors","tags":["colors"]}},"/v1/images/clarityUpscale":{"post":{"deprecated":true,"operationId":"ClarityUpscale","parameters":[{"$ref":"#/components/parameters/billing"}],"requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/ProcessImageRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProcessImageResponse"}}},"description":"OK"}},"summary":"Clarity Upscale","tags":["image"]}},"/v1/images/creativeUpscale":{"post":{"operationId":"CreativeUpscale","parameters":[{"$ref":"#/components/parameters/billing"}],"requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/ProcessImageRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProcessImageResponse"}}},"description":"OK"}},"summary":"Creative Upscale","tags":["image"]}},"/v1/images/crispUpscale":{"post":{"operationId":"CrispUpscale","parameters":[{"$ref":"#/components/parameters/billing"}],"requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/ProcessImageRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProcessImageResponse"}}},"description":"OK"}},"summary":"Crisp Upscale","tags":["image"]}},"/v1/images/eraseRegion":{"post":{"operationId":"EraseRegion","parameters":[{"$ref":"#/components/parameters/billing"}],"requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/EraseRegionRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProcessImageResponse"}}},"description":"OK"}},"summary":"Erase Region","tags":["image"]}},"/v1/images/explore":{"post":{"operationId":"Explore","parameters":[{"$ref":"#/components/parameters/billing"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExploreRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GenerateImageResponse"}}},"description":"OK"}},"summary":"Exploration","tags":["image"]}},"/v1/images/explore/similar":{"post":{"operationId":"ExploreSimilar","parameters":[{"$ref":"#/components/parameters/billing"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExploreSimilarRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GenerateImageResponse"}}},"description":"OK"}},"summary":"Continue exploration from a source image","tags":["image"]}},"/v1/images/generateBackground":{"post":{"operationId":"GenerateBackground","parameters":[{"$ref":"#/components/parameters/billing"}],"requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/TransformImageWithMaskRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GenerateImageResponse"}}},"description":"OK"}},"summary":"Generate Background","tags":["image"]}},"/v1/images/generations":{"post":{"operationId":"GenerateImage","parameters":[{"$ref":"#/components/parameters/billing"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GenerateImageRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GenerateImageResponse"}}},"description":"OK"}},"summary":"Generate image from prompt","tags":["image"]}},"/v1/images/generations/raster":{"post":{"operationId":"GenerateImageRaster","parameters":[{"$ref":"#/components/parameters/billing"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GenerateImageRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GenerateImageResponse"}}},"description":"OK"}},"summary":"Generate raster image from prompt","tags":["image"]}},"/v1/images/generations/vector":{"post":{"operationId":"GenerateImageVector","parameters":[{"$ref":"#/components/parameters/billing"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GenerateImageRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GenerateImageResponse"}}},"description":"OK"}},"summary":"Generate vector image from prompt","tags":["image"]}},"/v1/images/generativeUpscale":{"post":{"deprecated":true,"operationId":"GenerativeUpscale","parameters":[{"$ref":"#/components/parameters/billing"}],"requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/ProcessImageRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProcessImageResponse"}}},"description":"OK"}},"summary":"Generative Upscale","tags":["image"]}},"/v1/images/imageToImage":{"post":{"operationId":"ImageToImage","parameters":[{"$ref":"#/components/parameters/billing"}],"requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/ImageToImageRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GenerateImageResponse"}}},"description":"OK"}},"summary":"Generate image from image and prompt","tags":["image"]}},"/v1/images/inpaint":{"post":{"operationId":"InpaintImage","parameters":[{"$ref":"#/components/parameters/billing"}],"requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/TransformImageWithMaskRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GenerateImageResponse"}}},"description":"OK"}},"summary":"Inpaint Image","tags":["image"]}},"/v1/images/outpaint":{"post":{"operationId":"OutpaintImage","parameters":[{"$ref":"#/components/parameters/billing"}],"requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/OutpaintImageRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GenerateImageResponse"}}},"description":"OK"}},"summary":"Outpaint Image","tags":["image"]}},"/v1/images/removeBackground":{"post":{"operationId":"RemoveBackground","parameters":[{"$ref":"#/components/parameters/billing"}],"requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/ProcessImageRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProcessImageResponse"}}},"description":"OK"}},"summary":"Remove background","tags":["image"]}},"/v1/images/replaceBackground":{"post":{"operationId":"ReplaceBackground","parameters":[{"$ref":"#/components/parameters/billing"}],"requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/TransformImageRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GenerateImageResponse"}}},"description":"OK"}},"summary":"Replace Background","tags":["image"]}},"/v1/images/variateImage":{"post":{"operationId":"VariateImage","parameters":[{"$ref":"#/components/parameters/billing"}],"requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/VariateImageRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GenerateImageResponse"}}},"description":"OK"}},"summary":"Variate Image","tags":["image"]}},"/v1/images/vectorize":{"post":{"operationId":"VectorizeImage","parameters":[{"$ref":"#/components/parameters/billing"}],"requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/VectorizeImageRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProcessImageResponse"}}},"description":"OK"}},"summary":"Vectorize image","tags":["image"]}},"/v1/prompts/enhance":{"post":{"operationId":"EnhancePrompt","parameters":[{"$ref":"#/components/parameters/billing"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnhancePromptRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/EnhancePromptResponse"}}},"description":"OK"}},"summary":"Enhance a prompt using an LLM","tags":["prompt"]}},"/v1/styles":{"get":{"operationId":"ListStyles","responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ListStylesResponse"}}},"description":"OK"}},"summary":"List Styles","tags":["style"]},"post":{"operationId":"CreateStyle","parameters":[{"$ref":"#/components/parameters/billing"}],"requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/CreateStyleRequest"}}}},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateStyleResponse"}}},"description":"OK"}},"summary":"Create Style","tags":["style"]}},"/v1/styles/basic":{"get":{"operationId":"ListBasicStyles","responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ListBasicStylesResponse"}}},"description":"OK"}},"summary":"List Basic Styles","tags":["style"]}},"/v1/styles/{style_id}":{"delete":{"operationId":"DeleteStyle","parameters":[{"in":"path","name":"style_id","required":true,"schema":{"format":"uuid","type":"string","x-go-name":"StyleID","x-go-type":"uuid.UUID","x-go-type-import":{"path":"github.com/gofrs/uuid/v5"}}}],"responses":{"200":{"content":{"application/json":{"schema":{"type":"object"}}},"description":"OK"}},"summary":"Delete Style","tags":["style"]},"get":{"operationId":"GetStyle","parameters":[{"in":"path","name":"style_id","required":true,"schema":{"format":"uuid","type":"string","x-go-name":"StyleID","x-go-type":"uuid.UUID","x-go-type-import":{"path":"github.com/gofrs/uuid/v5"}}}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Style"}}},"description":"OK"}},"summary":"Get Style","tags":["style"]}},"/v1/users/me":{"get":{"operationId":"GetCurrentUser","parameters":[{"$ref":"#/components/parameters/billing"}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/User"}}},"description":"OK"}},"summary":"Get current user info","tags":["user"]}}},"security":[{"auth0":[]}],"servers":[{"description":"Production","url":"https://external.api.recraft.ai"}]} \ No newline at end of file