diff --git a/src/libs/Ideogram/Generated/Ideogram.AutoSDKHttpResponse.g.cs b/src/libs/Ideogram/Generated/Ideogram.AutoSDKHttpResponse.g.cs
new file mode 100644
index 0000000..44faf45
--- /dev/null
+++ b/src/libs/Ideogram/Generated/Ideogram.AutoSDKHttpResponse.g.cs
@@ -0,0 +1,121 @@
+
+#nullable enable
+
+namespace Ideogram
+{
+ ///
+ /// Represents a successful HTTP response with status code and headers.
+ ///
+ public partial class AutoSDKHttpResponse
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public AutoSDKHttpResponse(
+ global::System.Net.HttpStatusCode statusCode,
+ global::System.Collections.Generic.Dictionary> headers)
+ : this(
+ statusCode: statusCode,
+ headers: headers,
+ requestUri: null)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public AutoSDKHttpResponse(
+ global::System.Net.HttpStatusCode statusCode,
+ global::System.Collections.Generic.Dictionary> headers,
+ global::System.Uri? requestUri)
+ {
+ StatusCode = statusCode;
+ Headers = headers ?? throw new global::System.ArgumentNullException(nameof(headers));
+ RequestUri = requestUri;
+ }
+
+ ///
+ /// Gets the HTTP status code.
+ ///
+ public global::System.Net.HttpStatusCode StatusCode { get; }
+ ///
+ /// Gets the response headers.
+ ///
+ public global::System.Collections.Generic.Dictionary> Headers { get; }
+ ///
+ /// Gets the final request URI associated with the response.
+ ///
+ public global::System.Uri? RequestUri { get; }
+
+ internal static global::System.Collections.Generic.Dictionary> CreateHeaders(
+ global::System.Net.Http.HttpResponseMessage response)
+ {
+ response = response ?? throw new global::System.ArgumentNullException(nameof(response));
+
+ var headers = global::System.Linq.Enumerable.ToDictionary(
+ response.Headers,
+ static header => header.Key,
+ static header => (global::System.Collections.Generic.IEnumerable)global::System.Linq.Enumerable.ToArray(header.Value),
+ global::System.StringComparer.OrdinalIgnoreCase);
+
+ if (response.Content?.Headers == null)
+ {
+ return headers;
+ }
+
+ foreach (var header in response.Content.Headers)
+ {
+ if (headers.TryGetValue(header.Key, out var existingValues))
+ {
+ headers[header.Key] = global::System.Linq.Enumerable.ToArray(
+ global::System.Linq.Enumerable.Concat(existingValues, header.Value));
+ }
+ else
+ {
+ headers[header.Key] = global::System.Linq.Enumerable.ToArray(header.Value);
+ }
+ }
+
+ return headers;
+ }
+ }
+
+ ///
+ /// Represents a successful HTTP response with status code, headers, and body.
+ ///
+ public partial class AutoSDKHttpResponse : AutoSDKHttpResponse
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public AutoSDKHttpResponse(
+ global::System.Net.HttpStatusCode statusCode,
+ global::System.Collections.Generic.Dictionary> headers,
+ T body)
+ : this(
+ statusCode: statusCode,
+ headers: headers,
+ requestUri: null,
+ body: body)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public AutoSDKHttpResponse(
+ global::System.Net.HttpStatusCode statusCode,
+ global::System.Collections.Generic.Dictionary> headers,
+ global::System.Uri? requestUri,
+ T body)
+ : base(statusCode, headers, requestUri)
+ {
+ Body = body;
+ }
+
+ ///
+ /// Gets the response body.
+ ///
+ public T Body { get; }
+ }
+}
\ No newline at end of file
diff --git a/src/libs/Ideogram/Generated/Ideogram.BatchClient.GetMaybeBatchResults.g.cs b/src/libs/Ideogram/Generated/Ideogram.BatchClient.GetMaybeBatchResults.g.cs
index ea616c2..be3731f 100644
--- a/src/libs/Ideogram/Generated/Ideogram.BatchClient.GetMaybeBatchResults.g.cs
+++ b/src/libs/Ideogram/Generated/Ideogram.BatchClient.GetMaybeBatchResults.g.cs
@@ -53,6 +53,27 @@ partial void ProcessGetMaybeBatchResultsResponseContent(
string jobId,
global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await GetMaybeBatchResultsAsResponseAsync(
+ jobId: jobId,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// Get Batch Magic Prompt Job Results if available.
+ /// Gets the results of a batch magic prompt job if available.
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> GetMaybeBatchResultsAsResponseAsync(
+ string jobId,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
client: HttpClient);
@@ -82,6 +103,7 @@ partial void ProcessGetMaybeBatchResultsResponseContent(
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Ideogram.PathBuilder(
path: $"/internal/batch/get-maybe-batch-results/{jobId}",
baseUri: HttpClient.BaseAddress);
@@ -155,6 +177,8 @@ partial void ProcessGetMaybeBatchResultsResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -165,6 +189,11 @@ partial void ProcessGetMaybeBatchResultsResponseContent(
}
catch (global::System.Net.Http.HttpRequestException __exception)
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
@@ -182,6 +211,8 @@ partial void ProcessGetMaybeBatchResultsResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -191,8 +222,7 @@ partial void ProcessGetMaybeBatchResultsResponseContent(
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -201,6 +231,11 @@ partial void ProcessGetMaybeBatchResultsResponseContent(
__attempt < __maxAttempts &&
global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
@@ -217,14 +252,15 @@ partial void ProcessGetMaybeBatchResultsResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
__response.Dispose();
__response = null;
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -264,6 +300,8 @@ partial void ProcessGetMaybeBatchResultsResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -284,6 +322,8 @@ partial void ProcessGetMaybeBatchResultsResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
//
@@ -307,17 +347,16 @@ partial void ProcessGetMaybeBatchResultsResponseContent(
__exception_400 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_400,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
//
if ((int)__response.StatusCode == 401)
@@ -340,17 +379,16 @@ partial void ProcessGetMaybeBatchResultsResponseContent(
__exception_401 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_401,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_401,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_401,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
//
if ((int)__response.StatusCode == 429)
@@ -373,17 +411,16 @@ partial void ProcessGetMaybeBatchResultsResponseContent(
__exception_429 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_429,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_429,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_429,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
//
if ((int)__response.StatusCode == 500)
@@ -406,17 +443,16 @@ partial void ProcessGetMaybeBatchResultsResponseContent(
__exception_500 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_500,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_500,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_500,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
if (__effectiveReadResponseAsString)
@@ -440,23 +476,25 @@ partial void ProcessGetMaybeBatchResultsResponseContent(
{
__response.EnsureSuccessStatusCode();
- return
- global::Ideogram.InternalBatchResultsResponse.FromJson(__content, JsonSerializerContext) ??
+ var __value = global::Ideogram.InternalBatchResultsResponse.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
else
@@ -470,9 +508,13 @@ partial void ProcessGetMaybeBatchResultsResponseContent(
#endif
).ConfigureAwait(false);
- return
- await global::Ideogram.InternalBatchResultsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ var __value = await global::Ideogram.InternalBatchResultsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -489,17 +531,15 @@ partial void ProcessGetMaybeBatchResultsResponseContent(
{
}
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
diff --git a/src/libs/Ideogram/Generated/Ideogram.BatchClient.PostBatch.g.cs b/src/libs/Ideogram/Generated/Ideogram.BatchClient.PostBatch.g.cs
index ec458d4..ebba2b2 100644
--- a/src/libs/Ideogram/Generated/Ideogram.BatchClient.PostBatch.g.cs
+++ b/src/libs/Ideogram/Generated/Ideogram.BatchClient.PostBatch.g.cs
@@ -52,6 +52,30 @@ partial void ProcessPostBatchResponseContent(
///
public async global::System.Threading.Tasks.Task PostBatchAsync(
+ global::Ideogram.InternalBatchRequest request,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await PostBatchAsResponseAsync(
+
+ request: request,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// Initiate Batch Magic Prompt Evalution
+ /// Runs automated evaluation of multiple LLM models and system prompts for magic prompt generation.
+ /// Generates images using large batches of user prompt inputs. Internal use only (feature flagged).
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> PostBatchAsResponseAsync(
+
global::Ideogram.InternalBatchRequest request,
global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
@@ -86,6 +110,7 @@ partial void ProcessPostBatchResponseContent(
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Ideogram.PathBuilder(
path: "/internal/batch",
baseUri: HttpClient.BaseAddress);
@@ -165,6 +190,8 @@ partial void ProcessPostBatchResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -175,6 +202,11 @@ partial void ProcessPostBatchResponseContent(
}
catch (global::System.Net.Http.HttpRequestException __exception)
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
@@ -192,6 +224,8 @@ partial void ProcessPostBatchResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -201,8 +235,7 @@ partial void ProcessPostBatchResponseContent(
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -211,6 +244,11 @@ partial void ProcessPostBatchResponseContent(
__attempt < __maxAttempts &&
global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
@@ -227,14 +265,15 @@ partial void ProcessPostBatchResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
__response.Dispose();
__response = null;
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -274,6 +313,8 @@ partial void ProcessPostBatchResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -294,6 +335,8 @@ partial void ProcessPostBatchResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
//
@@ -317,17 +360,16 @@ partial void ProcessPostBatchResponseContent(
__exception_400 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_400,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
//
if ((int)__response.StatusCode == 401)
@@ -350,17 +392,16 @@ partial void ProcessPostBatchResponseContent(
__exception_401 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_401,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_401,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_401,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
//
if ((int)__response.StatusCode == 429)
@@ -383,17 +424,16 @@ partial void ProcessPostBatchResponseContent(
__exception_429 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_429,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_429,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_429,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
//
if ((int)__response.StatusCode == 500)
@@ -416,17 +456,16 @@ partial void ProcessPostBatchResponseContent(
__exception_500 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_500 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_500,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_500,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_500,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
if (__effectiveReadResponseAsString)
@@ -450,23 +489,25 @@ partial void ProcessPostBatchResponseContent(
{
__response.EnsureSuccessStatusCode();
- return
- global::Ideogram.InternalBatchResponse.FromJson(__content, JsonSerializerContext) ??
+ var __value = global::Ideogram.InternalBatchResponse.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
else
@@ -480,9 +521,13 @@ partial void ProcessPostBatchResponseContent(
#endif
).ConfigureAwait(false);
- return
- await global::Ideogram.InternalBatchResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ var __value = await global::Ideogram.InternalBatchResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -499,17 +544,15 @@ partial void ProcessPostBatchResponseContent(
{
}
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
@@ -534,7 +577,7 @@ partial void ProcessPostBatchResponseContent(
/// Example: MAGIC_PROMPT_NO_TEXT
///
///
- /// Example: {"aspect_ratio":"1x1","style_type":"GENERAL","magic_prompt_version":"V_0","seed":12345,"negative_prompt":"brush strokes, painting","magic_prompt_option":"ON","model":"V_2_TURBO","resolution":"1280x800","num_images":1,"color_palette":{"name":"PASTEL"}}
+ /// Example: {"magic_prompt_system_prompt_config_id":"magic_prompt_system_prompt_config_id","aspect_ratio":"1x1","style_type":"GENERAL","magic_prompt_version":"V_0","seed":12345,"negative_prompt":"brush strokes, painting","magic_prompt_option":"ON","model":"V_2_TURBO","resolution":"1280x800","num_images":1,"color_palette":{"name":"PASTEL"}}
///
/// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
diff --git a/src/libs/Ideogram/Generated/Ideogram.BatchClient.g.cs b/src/libs/Ideogram/Generated/Ideogram.BatchClient.g.cs
index 4b1418e..4574a23 100644
--- a/src/libs/Ideogram/Generated/Ideogram.BatchClient.g.cs
+++ b/src/libs/Ideogram/Generated/Ideogram.BatchClient.g.cs
@@ -61,6 +61,27 @@ public BatchClient(
{
}
+ ///
+ /// Creates a new instance of the BatchClient 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 BatchClient(
+ global::System.Net.Http.HttpClient? httpClient,
+ global::System.Collections.Generic.List? authorizations,
+ global::Ideogram.AutoSDKClientOptions? options,
+ bool disposeHttpClient = true) : this(
+ httpClient,
+ baseUri: null,
+ authorizations,
+ options,
+ disposeHttpClient: disposeHttpClient)
+ {
+ }
+
///
/// Creates a new instance of the BatchClient.
/// If no httpClient is provided, a new one will be created.
@@ -72,10 +93,10 @@ public BatchClient(
/// Client-wide request defaults such as headers, query parameters, retries, and timeout.
/// Dispose the HttpClient when the instance is disposed. True by default.
public BatchClient(
- global::System.Net.Http.HttpClient? httpClient = null,
- global::System.Uri? baseUri = null,
- global::System.Collections.Generic.List? authorizations = null,
- global::Ideogram.AutoSDKClientOptions? options = null,
+ global::System.Net.Http.HttpClient? httpClient,
+ global::System.Uri? baseUri,
+ global::System.Collections.Generic.List? authorizations,
+ global::Ideogram.AutoSDKClientOptions? options,
bool disposeHttpClient = true)
{
diff --git a/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.CreateDataset.g.cs b/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.CreateDataset.g.cs
index 6fefee1..9117361 100644
--- a/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.CreateDataset.g.cs
+++ b/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.CreateDataset.g.cs
@@ -51,6 +51,29 @@ partial void ProcessCreateDatasetResponseContent(
///
public async global::System.Threading.Tasks.Task CreateDatasetAsync(
+ global::Ideogram.CreateDatasetRequest request,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await CreateDatasetAsResponseAsync(
+
+ request: request,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// Create a new dataset
+ /// Creates a new dataset
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> CreateDatasetAsResponseAsync(
+
global::Ideogram.CreateDatasetRequest request,
global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
@@ -85,6 +108,7 @@ partial void ProcessCreateDatasetResponseContent(
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Ideogram.PathBuilder(
path: "/datasets",
baseUri: HttpClient.BaseAddress);
@@ -164,6 +188,8 @@ partial void ProcessCreateDatasetResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -174,6 +200,11 @@ partial void ProcessCreateDatasetResponseContent(
}
catch (global::System.Net.Http.HttpRequestException __exception)
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
@@ -191,6 +222,8 @@ partial void ProcessCreateDatasetResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -200,8 +233,7 @@ partial void ProcessCreateDatasetResponseContent(
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -210,6 +242,11 @@ partial void ProcessCreateDatasetResponseContent(
__attempt < __maxAttempts &&
global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
@@ -226,14 +263,15 @@ partial void ProcessCreateDatasetResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
__response.Dispose();
__response = null;
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -273,6 +311,8 @@ partial void ProcessCreateDatasetResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -293,6 +333,8 @@ partial void ProcessCreateDatasetResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
//
@@ -316,17 +358,16 @@ partial void ProcessCreateDatasetResponseContent(
__exception_400 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_400,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
//
if ((int)__response.StatusCode == 401)
@@ -349,17 +390,16 @@ partial void ProcessCreateDatasetResponseContent(
__exception_401 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_401,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_401,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_401,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
if (__effectiveReadResponseAsString)
@@ -383,23 +423,25 @@ partial void ProcessCreateDatasetResponseContent(
{
__response.EnsureSuccessStatusCode();
- return
- global::Ideogram.Dataset.FromJson(__content, JsonSerializerContext) ??
+ var __value = global::Ideogram.Dataset.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
else
@@ -413,9 +455,13 @@ partial void ProcessCreateDatasetResponseContent(
#endif
).ConfigureAwait(false);
- return
- await global::Ideogram.Dataset.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ var __value = await global::Ideogram.Dataset.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -432,17 +478,15 @@ partial void ProcessCreateDatasetResponseContent(
{
}
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
diff --git a/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.GetDataset.g.cs b/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.GetDataset.g.cs
index d7d49fa..7c4431e 100644
--- a/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.GetDataset.g.cs
+++ b/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.GetDataset.g.cs
@@ -53,6 +53,27 @@ partial void ProcessGetDatasetResponseContent(
string datasetId,
global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await GetDatasetAsResponseAsync(
+ datasetId: datasetId,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// Get a dataset
+ /// Returns a dataset by ID, including the total number of files and a list of each file's name and size in bytes.
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> GetDatasetAsResponseAsync(
+ string datasetId,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
client: HttpClient);
@@ -82,6 +103,7 @@ partial void ProcessGetDatasetResponseContent(
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Ideogram.PathBuilder(
path: $"/datasets/{datasetId}",
baseUri: HttpClient.BaseAddress);
@@ -155,6 +177,8 @@ partial void ProcessGetDatasetResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -165,6 +189,11 @@ partial void ProcessGetDatasetResponseContent(
}
catch (global::System.Net.Http.HttpRequestException __exception)
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
@@ -182,6 +211,8 @@ partial void ProcessGetDatasetResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -191,8 +222,7 @@ partial void ProcessGetDatasetResponseContent(
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -201,6 +231,11 @@ partial void ProcessGetDatasetResponseContent(
__attempt < __maxAttempts &&
global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
@@ -217,14 +252,15 @@ partial void ProcessGetDatasetResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
__response.Dispose();
__response = null;
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -264,6 +300,8 @@ partial void ProcessGetDatasetResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -284,6 +322,8 @@ partial void ProcessGetDatasetResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
//
@@ -307,17 +347,16 @@ partial void ProcessGetDatasetResponseContent(
__exception_401 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_401,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_401,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_401,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
//
if ((int)__response.StatusCode == 404)
@@ -340,17 +379,16 @@ partial void ProcessGetDatasetResponseContent(
__exception_404 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_404 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_404,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_404,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_404,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
if (__effectiveReadResponseAsString)
@@ -374,23 +412,25 @@ partial void ProcessGetDatasetResponseContent(
{
__response.EnsureSuccessStatusCode();
- return
- global::Ideogram.GetDatasetResponse.FromJson(__content, JsonSerializerContext) ??
+ var __value = global::Ideogram.GetDatasetResponse.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
else
@@ -404,9 +444,13 @@ partial void ProcessGetDatasetResponseContent(
#endif
).ConfigureAwait(false);
- return
- await global::Ideogram.GetDatasetResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ var __value = await global::Ideogram.GetDatasetResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -423,17 +467,15 @@ partial void ProcessGetDatasetResponseContent(
{
}
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
diff --git a/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.ListDatasets.g.cs b/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.ListDatasets.g.cs
index 437f498..93f1876 100644
--- a/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.ListDatasets.g.cs
+++ b/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.ListDatasets.g.cs
@@ -49,6 +49,24 @@ partial void ProcessListDatasetsResponseContent(
public async global::System.Threading.Tasks.Task ListDatasetsAsync(
global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await ListDatasetsAsResponseAsync(
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// List datasets
+ /// Lists all datasets for the authenticated user
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> ListDatasetsAsResponseAsync(
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
client: HttpClient);
@@ -77,6 +95,7 @@ partial void ProcessListDatasetsResponseContent(
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Ideogram.PathBuilder(
path: "/datasets",
baseUri: HttpClient.BaseAddress);
@@ -149,6 +168,8 @@ partial void ProcessListDatasetsResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -159,6 +180,11 @@ partial void ProcessListDatasetsResponseContent(
}
catch (global::System.Net.Http.HttpRequestException __exception)
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
@@ -176,6 +202,8 @@ partial void ProcessListDatasetsResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -185,8 +213,7 @@ partial void ProcessListDatasetsResponseContent(
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -195,6 +222,11 @@ partial void ProcessListDatasetsResponseContent(
__attempt < __maxAttempts &&
global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
@@ -211,14 +243,15 @@ partial void ProcessListDatasetsResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
__response.Dispose();
__response = null;
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -258,6 +291,8 @@ partial void ProcessListDatasetsResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -278,6 +313,8 @@ partial void ProcessListDatasetsResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
//
@@ -301,17 +338,16 @@ partial void ProcessListDatasetsResponseContent(
__exception_401 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_401,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_401,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_401,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
if (__effectiveReadResponseAsString)
@@ -335,23 +371,25 @@ partial void ProcessListDatasetsResponseContent(
{
__response.EnsureSuccessStatusCode();
- return
- global::Ideogram.ListDatasetsResponse.FromJson(__content, JsonSerializerContext) ??
+ var __value = global::Ideogram.ListDatasetsResponse.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
else
@@ -365,9 +403,13 @@ partial void ProcessListDatasetsResponseContent(
#endif
).ConfigureAwait(false);
- return
- await global::Ideogram.ListDatasetsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ var __value = await global::Ideogram.ListDatasetsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -384,17 +426,15 @@ partial void ProcessListDatasetsResponseContent(
{
}
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
diff --git a/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.TrainDatasetModel.g.cs b/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.TrainDatasetModel.g.cs
index da3f5e2..0fa8f8d 100644
--- a/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.TrainDatasetModel.g.cs
+++ b/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.TrainDatasetModel.g.cs
@@ -55,6 +55,32 @@ partial void ProcessTrainDatasetModelResponseContent(
public async global::System.Threading.Tasks.Task TrainDatasetModelAsync(
string datasetId,
+ global::Ideogram.TrainDatasetModelRequest request,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await TrainDatasetModelAsResponseAsync(
+ datasetId: datasetId,
+
+ request: request,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// Train a model from a dataset
+ /// Start training a custom model from a dataset. The dataset must contain at least 15 images and a maximum of 100 images. Returns the model ID and training status.
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> TrainDatasetModelAsResponseAsync(
+ string datasetId,
+
global::Ideogram.TrainDatasetModelRequest request,
global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
@@ -90,6 +116,7 @@ partial void ProcessTrainDatasetModelResponseContent(
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Ideogram.PathBuilder(
path: $"/datasets/{datasetId}/train_model",
baseUri: HttpClient.BaseAddress);
@@ -170,6 +197,8 @@ partial void ProcessTrainDatasetModelResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -180,6 +209,11 @@ partial void ProcessTrainDatasetModelResponseContent(
}
catch (global::System.Net.Http.HttpRequestException __exception)
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
@@ -197,6 +231,8 @@ partial void ProcessTrainDatasetModelResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -206,8 +242,7 @@ partial void ProcessTrainDatasetModelResponseContent(
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -216,6 +251,11 @@ partial void ProcessTrainDatasetModelResponseContent(
__attempt < __maxAttempts &&
global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
@@ -232,14 +272,15 @@ partial void ProcessTrainDatasetModelResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
__response.Dispose();
__response = null;
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -279,6 +320,8 @@ partial void ProcessTrainDatasetModelResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -299,6 +342,8 @@ partial void ProcessTrainDatasetModelResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
//
@@ -322,17 +367,16 @@ partial void ProcessTrainDatasetModelResponseContent(
__exception_400 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_400,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
//
if ((int)__response.StatusCode == 401)
@@ -355,17 +399,16 @@ partial void ProcessTrainDatasetModelResponseContent(
__exception_401 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_401,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_401,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_401,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
//
if ((int)__response.StatusCode == 404)
@@ -388,17 +431,16 @@ partial void ProcessTrainDatasetModelResponseContent(
__exception_404 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_404 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_404,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_404,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_404,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
if (__effectiveReadResponseAsString)
@@ -422,23 +464,25 @@ partial void ProcessTrainDatasetModelResponseContent(
{
__response.EnsureSuccessStatusCode();
- return
- global::Ideogram.TrainDatasetModelResponse.FromJson(__content, JsonSerializerContext) ??
+ var __value = global::Ideogram.TrainDatasetModelResponse.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
else
@@ -452,9 +496,13 @@ partial void ProcessTrainDatasetModelResponseContent(
#endif
).ConfigureAwait(false);
- return
- await global::Ideogram.TrainDatasetModelResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ var __value = await global::Ideogram.TrainDatasetModelResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -471,17 +519,15 @@ partial void ProcessTrainDatasetModelResponseContent(
{
}
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
diff --git a/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.UploadDatasetAssets.g.cs b/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.UploadDatasetAssets.g.cs
index 80697f7..fbe4f90 100644
--- a/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.UploadDatasetAssets.g.cs
+++ b/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.UploadDatasetAssets.g.cs
@@ -55,6 +55,32 @@ partial void ProcessUploadDatasetAssetsResponseContent(
public async global::System.Threading.Tasks.Task UploadDatasetAssetsAsync(
string datasetId,
+ global::Ideogram.UploadDatasetAssetsRequest request,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await UploadDatasetAssetsAsResponseAsync(
+ datasetId: datasetId,
+
+ request: request,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// Upload assets to a dataset
+ /// Upload image assets to a dataset for model training. Accepts individual images (JPEG, PNG, WebP), optional .txt caption sidecar files, and/or ZIP archives containing images and captions. A dataset can contain up to 100 images.
+ ///
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> UploadDatasetAssetsAsResponseAsync(
+ string datasetId,
+
global::Ideogram.UploadDatasetAssetsRequest request,
global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
@@ -86,10 +112,11 @@ partial void ProcessUploadDatasetAssetsResponseContent(
var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts(
clientOptions: Options,
requestOptions: requestOptions,
- supportsRetry: true);
+ supportsRetry: false);
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Ideogram.PathBuilder(
path: $"/datasets/{datasetId}/upload_assets",
baseUri: HttpClient.BaseAddress);
@@ -122,10 +149,12 @@ partial void ProcessUploadDatasetAssetsResponseContent(
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
}
}
+
var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(datasetId ?? string.Empty),
name: "\"dataset_id\"");
+
for (var __iFiles = 0; __iFiles < request.Files.Count; __iFiles++)
{
var __contentFiles = new global::System.Net.Http.ByteArrayContent(request.Files[__iFiles]);
@@ -139,7 +168,9 @@ partial void ProcessUploadDatasetAssetsResponseContent(
__contentFiles.Headers.ContentDisposition.FileNameStar = null;
}
}
+
__httpRequest.Content = __httpRequestContent;
+
global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders(
request: __httpRequest,
clientHeaders: Options.Headers,
@@ -182,6 +213,8 @@ partial void ProcessUploadDatasetAssetsResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -192,6 +225,11 @@ partial void ProcessUploadDatasetAssetsResponseContent(
}
catch (global::System.Net.Http.HttpRequestException __exception)
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
@@ -209,6 +247,8 @@ partial void ProcessUploadDatasetAssetsResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -218,8 +258,7 @@ partial void ProcessUploadDatasetAssetsResponseContent(
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -228,6 +267,11 @@ partial void ProcessUploadDatasetAssetsResponseContent(
__attempt < __maxAttempts &&
global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
@@ -244,14 +288,15 @@ partial void ProcessUploadDatasetAssetsResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
__response.Dispose();
__response = null;
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -291,6 +336,8 @@ partial void ProcessUploadDatasetAssetsResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -311,6 +358,8 @@ partial void ProcessUploadDatasetAssetsResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
//
@@ -334,17 +383,16 @@ partial void ProcessUploadDatasetAssetsResponseContent(
__exception_400 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_400,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
//
if ((int)__response.StatusCode == 401)
@@ -367,17 +415,16 @@ partial void ProcessUploadDatasetAssetsResponseContent(
__exception_401 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_401,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_401,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_401,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
//
if ((int)__response.StatusCode == 404)
@@ -400,17 +447,16 @@ partial void ProcessUploadDatasetAssetsResponseContent(
__exception_404 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_404 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_404,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_404,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_404,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
if (__effectiveReadResponseAsString)
@@ -434,23 +480,25 @@ partial void ProcessUploadDatasetAssetsResponseContent(
{
__response.EnsureSuccessStatusCode();
- return
- global::Ideogram.UploadDatasetAssetsResponse.FromJson(__content, JsonSerializerContext) ??
+ var __value = global::Ideogram.UploadDatasetAssetsResponse.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
else
@@ -464,9 +512,13 @@ partial void ProcessUploadDatasetAssetsResponseContent(
#endif
).ConfigureAwait(false);
- return
- await global::Ideogram.UploadDatasetAssetsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ var __value = await global::Ideogram.UploadDatasetAssetsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -483,17 +535,15 @@ partial void ProcessUploadDatasetAssetsResponseContent(
{
}
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
@@ -532,5 +582,1050 @@ partial void ProcessUploadDatasetAssetsResponseContent(
requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
+
+ ///
+ /// Upload assets to a dataset
+ /// Upload image assets to a dataset for model training. Accepts individual images (JPEG, PNG, WebP), optional .txt caption sidecar files, and/or ZIP archives containing images and captions. A dataset can contain up to 100 images.
+ ///
+ ///
+ ///
+ /// Image files (JPEG, PNG, WebP), .txt caption sidecar files, and/or ZIP archives containing images and captions. Caption .txt files are matched to images by filename stem (e.g. sunset.txt provides the caption for sunset.jpg). Captions are optional!
+ ///
+ ///
+ /// Optional file names to use for the multipart 'files' file parts.
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task UploadDatasetAssetsAsync(
+ string datasetId,
+ global::System.Collections.Generic.IReadOnlyList files,
+ global::System.Collections.Generic.IReadOnlyList? filesFileNames = default,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+
+ files = files ?? throw new global::System.ArgumentNullException(nameof(files));
+ var request = new global::Ideogram.UploadDatasetAssetsRequest
+ {
+ Files = new global::System.Collections.Generic.List(),
+ };
+ PrepareArguments(
+ client: HttpClient);
+ PrepareUploadDatasetAssetsArguments(
+ httpClient: HttpClient,
+ datasetId: ref datasetId,
+ request: request);
+
+
+ var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations(
+ availableAuthorizations: Authorizations,
+ securityRequirements: s_UploadDatasetAssetsSecurityRequirements,
+ operationName: "UploadDatasetAssetsAsync");
+
+ using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: false);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+
+ var __pathBuilder = new global::Ideogram.PathBuilder(
+ path: $"/datasets/{datasetId}/upload_assets",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+#endif
+
+ foreach (var __authorization in __authorizations)
+ {
+ if (__authorization.Type == "Http" ||
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
+ {
+ __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
+ scheme: __authorization.Name,
+ parameter: __authorization.Value);
+ }
+ else if (__authorization.Type == "ApiKey" &&
+ __authorization.Location == "Header")
+ {
+ __httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
+ }
+ }
+
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(datasetId ?? string.Empty),
+ name: "\"dataset_id\"");
+
+ for (var __iFiles = 0; __iFiles < files.Count; __iFiles++)
+ {
+ var __fileNameFiles = filesFileNames != null &&
+ __iFiles < filesFileNames.Count &&
+ filesFileNames[__iFiles] != null
+ ? filesFileNames[__iFiles]
+ : $"file{__iFiles}.bin";
+ var __contentFiles = new global::System.Net.Http.StreamContent(files[__iFiles]);
+ __contentFiles.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ __fileNameFiles is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(__fileNameFiles) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentFiles,
+ name: "\"files\"",
+ fileName: $"\"{__fileNameFiles}\"");
+ if (__contentFiles.Headers.ContentDisposition != null)
+ {
+ __contentFiles.Headers.ContentDisposition.FileNameStar = null;
+ }
+ }
+
+ __httpRequest.Content = __httpRequestContent;
+
+ global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareUploadDatasetAssetsRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ datasetId: datasetId!,
+ request: request);
+
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UploadDatasetAssets",
+ methodName: "UploadDatasetAssetsAsync",
+ pathTemplate: "$\"/datasets/{datasetId}/upload_assets\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ catch (global::System.Net.Http.HttpRequestException __exception)
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UploadDatasetAssets",
+ methodName: "UploadDatasetAssetsAsync",
+ pathTemplate: "$\"/datasets/{datasetId}/upload_assets\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UploadDatasetAssets",
+ methodName: "UploadDatasetAssetsAsync",
+ pathTemplate: "$\"/datasets/{datasetId}/upload_assets\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessUploadDatasetAssetsResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UploadDatasetAssets",
+ methodName: "UploadDatasetAssetsAsync",
+ pathTemplate: "$\"/datasets/{datasetId}/upload_assets\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UploadDatasetAssets",
+ methodName: "UploadDatasetAssetsAsync",
+ pathTemplate: "$\"/datasets/{datasetId}/upload_assets\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ //
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ responseBody: __content_401,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 404)
+ {
+ string? __content_404 = null;
+ global::System.Exception? __exception_404 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_404 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_404 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_404,
+ responseBody: __content_404,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessUploadDatasetAssetsResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Ideogram.UploadDatasetAssetsResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Ideogram.UploadDatasetAssetsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
+ }
+ ///
+ /// Upload assets to a dataset
+ /// Upload image assets to a dataset for model training. Accepts individual images (JPEG, PNG, WebP), optional .txt caption sidecar files, and/or ZIP archives containing images and captions. A dataset can contain up to 100 images.
+ ///
+ ///
+ ///
+ /// Image files (JPEG, PNG, WebP), .txt caption sidecar files, and/or ZIP archives containing images and captions. Caption .txt files are matched to images by filename stem (e.g. sunset.txt provides the caption for sunset.jpg). Captions are optional!
+ ///
+ ///
+ /// Optional file names to use for the multipart 'files' file parts.
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> UploadDatasetAssetsAsResponseAsync(
+ string datasetId,
+ global::System.Collections.Generic.IReadOnlyList files,
+ global::System.Collections.Generic.IReadOnlyList? filesFileNames = default,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+
+ files = files ?? throw new global::System.ArgumentNullException(nameof(files));
+ var request = new global::Ideogram.UploadDatasetAssetsRequest
+ {
+ Files = new global::System.Collections.Generic.List(),
+ };
+ PrepareArguments(
+ client: HttpClient);
+ PrepareUploadDatasetAssetsArguments(
+ httpClient: HttpClient,
+ datasetId: ref datasetId,
+ request: request);
+
+
+ var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations(
+ availableAuthorizations: Authorizations,
+ securityRequirements: s_UploadDatasetAssetsSecurityRequirements,
+ operationName: "UploadDatasetAssetsAsync");
+
+ using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: false);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+
+ var __pathBuilder = new global::Ideogram.PathBuilder(
+ path: $"/datasets/{datasetId}/upload_assets",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+#endif
+
+ foreach (var __authorization in __authorizations)
+ {
+ if (__authorization.Type == "Http" ||
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
+ {
+ __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
+ scheme: __authorization.Name,
+ parameter: __authorization.Value);
+ }
+ else if (__authorization.Type == "ApiKey" &&
+ __authorization.Location == "Header")
+ {
+ __httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
+ }
+ }
+
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(datasetId ?? string.Empty),
+ name: "\"dataset_id\"");
+
+ for (var __iFiles = 0; __iFiles < files.Count; __iFiles++)
+ {
+ var __fileNameFiles = filesFileNames != null &&
+ __iFiles < filesFileNames.Count &&
+ filesFileNames[__iFiles] != null
+ ? filesFileNames[__iFiles]
+ : $"file{__iFiles}.bin";
+ var __contentFiles = new global::System.Net.Http.StreamContent(files[__iFiles]);
+ __contentFiles.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ __fileNameFiles is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(__fileNameFiles) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentFiles,
+ name: "\"files\"",
+ fileName: $"\"{__fileNameFiles}\"");
+ if (__contentFiles.Headers.ContentDisposition != null)
+ {
+ __contentFiles.Headers.ContentDisposition.FileNameStar = null;
+ }
+ }
+
+ __httpRequest.Content = __httpRequestContent;
+
+ global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareUploadDatasetAssetsRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ datasetId: datasetId!,
+ request: request);
+
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UploadDatasetAssets",
+ methodName: "UploadDatasetAssetsAsync",
+ pathTemplate: "$\"/datasets/{datasetId}/upload_assets\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ catch (global::System.Net.Http.HttpRequestException __exception)
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UploadDatasetAssets",
+ methodName: "UploadDatasetAssetsAsync",
+ pathTemplate: "$\"/datasets/{datasetId}/upload_assets\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UploadDatasetAssets",
+ methodName: "UploadDatasetAssetsAsync",
+ pathTemplate: "$\"/datasets/{datasetId}/upload_assets\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessUploadDatasetAssetsResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UploadDatasetAssets",
+ methodName: "UploadDatasetAssetsAsync",
+ pathTemplate: "$\"/datasets/{datasetId}/upload_assets\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "UploadDatasetAssets",
+ methodName: "UploadDatasetAssetsAsync",
+ pathTemplate: "$\"/datasets/{datasetId}/upload_assets\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ //
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ responseBody: __content_401,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 404)
+ {
+ string? __content_404 = null;
+ global::System.Exception? __exception_404 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_404 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_404 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_404,
+ responseBody: __content_404,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessUploadDatasetAssetsResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ var __value = global::Ideogram.UploadDatasetAssetsResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ var __value = await global::Ideogram.UploadDatasetAssetsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
+ }
}
}
\ No newline at end of file
diff --git a/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.g.cs b/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.g.cs
index feacc49..0d8c320 100644
--- a/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.g.cs
+++ b/src/libs/Ideogram/Generated/Ideogram.DatasetsClient.g.cs
@@ -62,6 +62,27 @@ public DatasetsClient(
{
}
+ ///
+ /// Creates a new instance of the DatasetsClient 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 DatasetsClient(
+ global::System.Net.Http.HttpClient? httpClient,
+ global::System.Collections.Generic.List? authorizations,
+ global::Ideogram.AutoSDKClientOptions? options,
+ bool disposeHttpClient = true) : this(
+ httpClient,
+ baseUri: null,
+ authorizations,
+ options,
+ disposeHttpClient: disposeHttpClient)
+ {
+ }
+
///
/// Creates a new instance of the DatasetsClient.
/// If no httpClient is provided, a new one will be created.
@@ -73,10 +94,10 @@ public DatasetsClient(
/// Client-wide request defaults such as headers, query parameters, retries, and timeout.
/// Dispose the HttpClient when the instance is disposed. True by default.
public DatasetsClient(
- global::System.Net.Http.HttpClient? httpClient = null,
- global::System.Uri? baseUri = null,
- global::System.Collections.Generic.List? authorizations = null,
- global::Ideogram.AutoSDKClientOptions? options = null,
+ global::System.Net.Http.HttpClient? httpClient,
+ global::System.Uri? baseUri,
+ global::System.Collections.Generic.List? authorizations,
+ global::Ideogram.AutoSDKClientOptions? options,
bool disposeHttpClient = true)
{
diff --git a/src/libs/Ideogram/Generated/Ideogram.Exceptions.g.cs b/src/libs/Ideogram/Generated/Ideogram.Exceptions.g.cs
index 4fe7cb2..cd05323 100644
--- a/src/libs/Ideogram/Generated/Ideogram.Exceptions.g.cs
+++ b/src/libs/Ideogram/Generated/Ideogram.Exceptions.g.cs
@@ -12,16 +12,19 @@ public partial class ApiException : global::System.Exception
/// The HTTP status code of the response.
///
public global::System.Net.HttpStatusCode StatusCode { get; }
+
///
/// The response body as a string, or null if the body could not be read.
/// This is always populated for error responses regardless of the ReadResponseAsString setting.
/// For success-path failures (e.g. deserialization errors), the client attempts a best-effort read.
///
public string? ResponseBody { get; set; }
+
///
/// The response headers.
///
public global::System.Collections.Generic.Dictionary>? ResponseHeaders { get; set; }
+
///
/// Initializes a new instance of the class.
///
@@ -49,6 +52,103 @@ public ApiException(string message, global::System.Exception? innerException, gl
{
StatusCode = statusCode;
}
+
+ ///
+ /// Constructs an instance whose runtime type matches the response status code when the typed exception hierarchy is enabled. Always returns a plain when the hierarchy is disabled.
+ ///
+ /// The HTTP status code of the response.
+ /// The error message.
+ /// An inner exception, when one is available.
+ /// The response headers; consulted for 429 Retry-After parsing when present.
+ public static global::Ideogram.ApiException Create(
+ global::System.Net.HttpStatusCode statusCode,
+ string message,
+ global::System.Exception? innerException = null,
+ global::System.Collections.Generic.IDictionary>? responseHeaders = null)
+ {
+ return new global::Ideogram.ApiException(message, innerException, statusCode);
+ }
+
+ ///
+ /// Convenience overload that constructs an with response body and headers populated.
+ ///
+ public static global::Ideogram.ApiException Create(
+ global::System.Net.HttpStatusCode statusCode,
+ string message,
+ global::System.Exception? innerException,
+ string? responseBody,
+ global::System.Collections.Generic.Dictionary>? responseHeaders)
+ {
+ var exception = global::Ideogram.ApiException.Create(statusCode, message, innerException, responseHeaders);
+ exception.ResponseBody = responseBody;
+ exception.ResponseHeaders = responseHeaders;
+ return exception;
+ }
+
+ ///
+ /// Parses a Retry-After response header (delta-seconds or HTTP-date) into a .
+ /// Returns null when the header is missing or unparseable. Public so consumer code that observes
+ /// directly can recover the value without re-implementing the parser.
+ ///
+ public static global::System.TimeSpan? TryParseRetryAfter(
+ global::System.Collections.Generic.IDictionary>? headers)
+ {
+ if (headers == null)
+ {
+ return null;
+ }
+
+ global::System.Collections.Generic.IEnumerable? values = null;
+ foreach (var entry in headers)
+ {
+ if (string.Equals(entry.Key, "Retry-After", global::System.StringComparison.OrdinalIgnoreCase))
+ {
+ values = entry.Value;
+ break;
+ }
+ }
+
+ if (values == null)
+ {
+ return null;
+ }
+
+ string? raw = null;
+ foreach (var value in values)
+ {
+ if (!string.IsNullOrWhiteSpace(value))
+ {
+ raw = value.Trim();
+ break;
+ }
+ }
+
+ if (string.IsNullOrEmpty(raw))
+ {
+ return null;
+ }
+
+ if (int.TryParse(
+ raw,
+ global::System.Globalization.NumberStyles.Integer,
+ global::System.Globalization.CultureInfo.InvariantCulture,
+ out var seconds) && seconds >= 0)
+ {
+ return global::System.TimeSpan.FromSeconds(seconds);
+ }
+
+ if (global::System.DateTimeOffset.TryParse(
+ raw,
+ global::System.Globalization.CultureInfo.InvariantCulture,
+ global::System.Globalization.DateTimeStyles.AssumeUniversal | global::System.Globalization.DateTimeStyles.AdjustToUniversal,
+ out var when))
+ {
+ var delta = when - global::System.DateTimeOffset.UtcNow;
+ return delta > global::System.TimeSpan.Zero ? delta : global::System.TimeSpan.Zero;
+ }
+
+ return null;
+ }
}
///
@@ -88,5 +188,39 @@ public ApiException(string message, global::System.Net.HttpStatusCode statusCode
public ApiException(string message, global::System.Exception? innerException, global::System.Net.HttpStatusCode statusCode) : base(message, innerException, statusCode)
{
}
+
+ ///
+ /// Constructs an whose runtime type matches the response status code when the typed exception hierarchy is enabled.
+ ///
+ /// The HTTP status code of the response.
+ /// The error message.
+ /// An inner exception, when one is available.
+ /// The response headers; consulted for 429 Retry-After parsing when present.
+ public static new global::Ideogram.ApiException Create(
+ global::System.Net.HttpStatusCode statusCode,
+ string message,
+ global::System.Exception? innerException = null,
+ global::System.Collections.Generic.IDictionary>? responseHeaders = null)
+ {
+ return new global::Ideogram.ApiException(message, innerException, statusCode);
+ }
+
+ ///
+ /// Convenience overload that constructs an with response body, object, and headers populated.
+ ///
+ public static global::Ideogram.ApiException Create(
+ global::System.Net.HttpStatusCode statusCode,
+ string message,
+ global::System.Exception? innerException,
+ string? responseBody,
+ T? responseObject,
+ global::System.Collections.Generic.Dictionary>? responseHeaders)
+ {
+ var exception = global::Ideogram.ApiException.Create(statusCode, message, innerException, responseHeaders);
+ exception.ResponseBody = responseBody;
+ exception.ResponseObject = responseObject;
+ exception.ResponseHeaders = responseHeaders;
+ return exception;
+ }
}
}
\ No newline at end of file
diff --git a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostEditImage.g.cs b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostEditImage.g.cs
index f934dff..2e4c404 100644
--- a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostEditImage.g.cs
+++ b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostEditImage.g.cs
@@ -54,6 +54,32 @@ partial void ProcessPostEditImageResponseContent(
///
public async global::System.Threading.Tasks.Task PostEditImageAsync(
+ global::Ideogram.EditImageRequest request,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await PostEditImageAsResponseAsync(
+
+ request: request,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// Edit (legacy)
+ /// Edit a given image synchronously using the provided mask. The mask indicates which part of the image
+ /// should be edited, while the prompt and chosen style type can further guide the edit.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it.
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> PostEditImageAsResponseAsync(
+
global::Ideogram.EditImageRequest request,
global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
@@ -84,10 +110,11 @@ partial void ProcessPostEditImageResponseContent(
var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts(
clientOptions: Options,
requestOptions: requestOptions,
- supportsRetry: true);
+ supportsRetry: false);
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Ideogram.PathBuilder(
path: "/edit",
baseUri: HttpClient.BaseAddress);
@@ -120,6 +147,7 @@ partial void ProcessPostEditImageResponseContent(
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
}
}
+
var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
var __contentImageFile = new global::System.Net.Http.ByteArrayContent(request.ImageFile ?? global::System.Array.Empty());
__contentImageFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
@@ -158,6 +186,7 @@ request.ImageFilename is null
{
__contentImageFile.Headers.ContentDisposition.FileNameStar = null;
}
+
var __contentMask = new global::System.Net.Http.ByteArrayContent(request.Mask ?? global::System.Array.Empty());
__contentMask.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
request.Maskname is null
@@ -195,41 +224,58 @@ request.Maskname is null
{
__contentMask.Headers.ContentDisposition.FileNameStar = null;
}
+
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty),
name: "\"prompt\"");
+
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.Model.ToValueString()),
name: "\"model\"");
+
if (request.MagicPromptOption != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.MagicPromptOption).HasValue ? (request.MagicPromptOption).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"magic_prompt_option\"");
- }
+
+ }
+ if (request.MagicPromptSystemPromptConfigId != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty),
+ name: "\"magic_prompt_system_prompt_config_id\"");
+
+ }
if (request.NumImages != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
name: "\"num_images\"");
- }
+
+ }
if (request.Seed != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
name: "\"seed\"");
- }
+
+ }
if (request.StyleType != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.StyleType).HasValue ? (request.StyleType).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"style_type\"");
+
}
+
__httpRequest.Content = __httpRequestContent;
+
global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders(
request: __httpRequest,
clientHeaders: Options.Headers,
@@ -271,6 +317,8 @@ request.Maskname is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -281,6 +329,11 @@ request.Maskname is null
}
catch (global::System.Net.Http.HttpRequestException __exception)
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
@@ -298,6 +351,8 @@ request.Maskname is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -307,8 +362,7 @@ request.Maskname is null
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -317,6 +371,11 @@ request.Maskname is null
__attempt < __maxAttempts &&
global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
@@ -333,14 +392,15 @@ request.Maskname is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
__response.Dispose();
__response = null;
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -380,6 +440,8 @@ request.Maskname is null
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -400,6 +462,8 @@ request.Maskname is null
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
//
@@ -423,17 +487,16 @@ request.Maskname is null
__exception_400 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_400,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
//
if ((int)__response.StatusCode == 401)
@@ -456,17 +519,16 @@ request.Maskname is null
__exception_401 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_401,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_401,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_401,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
// Prompt or Initial Image failed the safety checks.
if ((int)__response.StatusCode == 422)
@@ -493,18 +555,17 @@ request.Maskname is null
__exception_422 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_422,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_422,
+ responseObject: __value_422,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
//
if ((int)__response.StatusCode == 429)
@@ -527,17 +588,16 @@ request.Maskname is null
__exception_429 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_429,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_429,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_429,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
if (__effectiveReadResponseAsString)
@@ -561,23 +621,25 @@ request.Maskname is null
{
__response.EnsureSuccessStatusCode();
- return
- global::Ideogram.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ??
+ var __value = global::Ideogram.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
else
@@ -591,9 +653,13 @@ request.Maskname is null
#endif
).ConfigureAwait(false);
- return
- await global::Ideogram.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ var __value = await global::Ideogram.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -610,17 +676,15 @@ request.Maskname is null
{
}
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
@@ -663,6 +727,9 @@ request.Maskname is null
/// Determine if MagicPrompt should be used in generating the request or not.
/// Example: ON
///
+ ///
+ /// A base64url-encoded magic prompt system prompt config ID to use for this request.
+ ///
///
/// The number of images to generate.
/// Default Value: 1
@@ -686,6 +753,7 @@ request.Maskname is null
string prompt,
global::Ideogram.ModelEnum model = global::Ideogram.ModelEnum.V2,
global::Ideogram.MagicPromptOption? magicPromptOption = default,
+ string? magicPromptSystemPromptConfigId = default,
int? numImages = default,
int? seed = default,
global::Ideogram.StyleType? styleType = default,
@@ -701,6 +769,7 @@ request.Maskname is null
Prompt = prompt,
Model = model,
MagicPromptOption = magicPromptOption,
+ MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId,
NumImages = numImages,
Seed = seed,
StyleType = styleType,
@@ -711,5 +780,1380 @@ request.Maskname is null
requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
+
+ ///
+ /// Edit (legacy)
+ /// Edit a given image synchronously using the provided mask. The mask indicates which part of the image
+ /// should be edited, while the prompt and chosen style type can further guide the edit.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it.
+ ///
+ ///
+ /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ ///
+ /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ ///
+ /// A black and white image of the same size as the image being edited (max size 10MB). Black regions in the mask should match up with the regions of the image that you would like to edit; only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ ///
+ /// A black and white image of the same size as the image being edited (max size 10MB). Black regions in the mask should match up with the regions of the image that you would like to edit; only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ ///
+ /// The prompt used to describe the edited result.
+ /// Example: A serene tropical beach scene. Dominating the foreground are tall palm trees with lush green leaves, standing tall against a backdrop of a sandy beach. The beach leads to the azure waters of the sea, which gently kisses the shoreline. In the distance, there is an island or landmass with a silhouette of what appears to be a lighthouse or tower. The sky above is painted with fluffy white clouds, some of which are tinged with hues of pink and orange, suggesting either a sunrise or sunset.
+ ///
+ ///
+ /// The model used to generate an image or edit one. /generate and /remix supports all model types, however, /edit is only supported for V_2 and V_2_TURBO.
+ /// Default Value: V_2
+ /// Example: V_2_TURBO
+ ///
+ ///
+ /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON
+ ///
+ ///
+ /// A base64url-encoded magic prompt system prompt config ID to use for this request.
+ ///
+ ///
+ /// The number of images to generate.
+ /// Default Value: 1
+ ///
+ ///
+ /// Random seed. Set for reproducible generation.
+ /// Example: 12345
+ ///
+ ///
+ /// The style type to generate with; this is only applicable for models V_2 and above and should not be specified for model versions V_1.
+ /// Example: REALISTIC
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task PostEditImageAsync(
+ global::System.IO.Stream imageFile,
+ string imageFilename,
+ global::System.IO.Stream mask,
+ string maskname,
+ string prompt,
+ global::Ideogram.ModelEnum model = global::Ideogram.ModelEnum.V2,
+ global::Ideogram.MagicPromptOption? magicPromptOption = default,
+ string? magicPromptSystemPromptConfigId = default,
+ int? numImages = default,
+ int? seed = default,
+ global::Ideogram.StyleType? styleType = default,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+
+ imageFile = imageFile ?? throw new global::System.ArgumentNullException(nameof(imageFile));
+ mask = mask ?? throw new global::System.ArgumentNullException(nameof(mask));
+ var request = new global::Ideogram.EditImageRequest
+ {
+ ImageFile = global::System.Array.Empty(),
+ ImageFilename = imageFilename,
+ Mask = global::System.Array.Empty(),
+ Maskname = maskname,
+ Prompt = prompt,
+ Model = model,
+ MagicPromptOption = magicPromptOption,
+ MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId,
+ NumImages = numImages,
+ Seed = seed,
+ StyleType = styleType,
+ };
+ PrepareArguments(
+ client: HttpClient);
+ PreparePostEditImageArguments(
+ httpClient: HttpClient,
+ request: request);
+
+
+ var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations(
+ availableAuthorizations: Authorizations,
+ securityRequirements: s_PostEditImageSecurityRequirements,
+ operationName: "PostEditImageAsync");
+
+ using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: false);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+
+ var __pathBuilder = new global::Ideogram.PathBuilder(
+ path: "/edit",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+#endif
+
+ foreach (var __authorization in __authorizations)
+ {
+ if (__authorization.Type == "Http" ||
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
+ {
+ __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
+ scheme: __authorization.Name,
+ parameter: __authorization.Value);
+ }
+ else if (__authorization.Type == "ApiKey" &&
+ __authorization.Location == "Header")
+ {
+ __httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
+ }
+ }
+
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ var __contentImageFile = new global::System.Net.Http.StreamContent(imageFile);
+ __contentImageFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.ImageFilename is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.ImageFilename) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentImageFile,
+ name: "\"image_file\"",
+ fileName: request.ImageFilename != null ? $"\"{request.ImageFilename}\"" : string.Empty);
+ if (__contentImageFile.Headers.ContentDisposition != null)
+ {
+ __contentImageFile.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ var __contentMask = new global::System.Net.Http.StreamContent(mask);
+ __contentMask.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.Maskname is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.Maskname) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentMask,
+ name: "\"mask\"",
+ fileName: request.Maskname != null ? $"\"{request.Maskname}\"" : string.Empty);
+ if (__contentMask.Headers.ContentDisposition != null)
+ {
+ __contentMask.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty),
+ name: "\"prompt\"");
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Model.ToValueString()),
+ name: "\"model\"");
+
+ if (request.MagicPromptOption != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.MagicPromptOption).HasValue ? (request.MagicPromptOption).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"magic_prompt_option\"");
+
+ }
+ if (request.MagicPromptSystemPromptConfigId != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty),
+ name: "\"magic_prompt_system_prompt_config_id\"");
+
+ }
+ if (request.NumImages != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"num_images\"");
+
+ }
+ if (request.Seed != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"seed\"");
+
+ }
+ if (request.StyleType != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.StyleType).HasValue ? (request.StyleType).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"style_type\"");
+
+ }
+
+ __httpRequest.Content = __httpRequestContent;
+
+ global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PreparePostEditImageRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
+
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostEditImage",
+ methodName: "PostEditImageAsync",
+ pathTemplate: "\"/edit\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ catch (global::System.Net.Http.HttpRequestException __exception)
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostEditImage",
+ methodName: "PostEditImageAsync",
+ pathTemplate: "\"/edit\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostEditImage",
+ methodName: "PostEditImageAsync",
+ pathTemplate: "\"/edit\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessPostEditImageResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostEditImage",
+ methodName: "PostEditImageAsync",
+ pathTemplate: "\"/edit\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostEditImage",
+ methodName: "PostEditImageAsync",
+ pathTemplate: "\"/edit\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ //
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ responseBody: __content_401,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ // Prompt or Initial Image failed the safety checks.
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Ideogram.GenerateImageSafetyError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ responseBody: __content_422,
+ responseObject: __value_422,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ responseBody: __content_429,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessPostEditImageResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Ideogram.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Ideogram.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
+ }
+ ///
+ /// Edit (legacy)
+ /// Edit a given image synchronously using the provided mask. The mask indicates which part of the image
+ /// should be edited, while the prompt and chosen style type can further guide the edit.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it.
+ ///
+ ///
+ /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ ///
+ /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ ///
+ /// A black and white image of the same size as the image being edited (max size 10MB). Black regions in the mask should match up with the regions of the image that you would like to edit; only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ ///
+ /// A black and white image of the same size as the image being edited (max size 10MB). Black regions in the mask should match up with the regions of the image that you would like to edit; only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ ///
+ /// The prompt used to describe the edited result.
+ /// Example: A serene tropical beach scene. Dominating the foreground are tall palm trees with lush green leaves, standing tall against a backdrop of a sandy beach. The beach leads to the azure waters of the sea, which gently kisses the shoreline. In the distance, there is an island or landmass with a silhouette of what appears to be a lighthouse or tower. The sky above is painted with fluffy white clouds, some of which are tinged with hues of pink and orange, suggesting either a sunrise or sunset.
+ ///
+ ///
+ /// The model used to generate an image or edit one. /generate and /remix supports all model types, however, /edit is only supported for V_2 and V_2_TURBO.
+ /// Default Value: V_2
+ /// Example: V_2_TURBO
+ ///
+ ///
+ /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON
+ ///
+ ///
+ /// A base64url-encoded magic prompt system prompt config ID to use for this request.
+ ///
+ ///
+ /// The number of images to generate.
+ /// Default Value: 1
+ ///
+ ///
+ /// Random seed. Set for reproducible generation.
+ /// Example: 12345
+ ///
+ ///
+ /// The style type to generate with; this is only applicable for models V_2 and above and should not be specified for model versions V_1.
+ /// Example: REALISTIC
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> PostEditImageAsResponseAsync(
+ global::System.IO.Stream imageFile,
+ string imageFilename,
+ global::System.IO.Stream mask,
+ string maskname,
+ string prompt,
+ global::Ideogram.ModelEnum model = global::Ideogram.ModelEnum.V2,
+ global::Ideogram.MagicPromptOption? magicPromptOption = default,
+ string? magicPromptSystemPromptConfigId = default,
+ int? numImages = default,
+ int? seed = default,
+ global::Ideogram.StyleType? styleType = default,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+
+ imageFile = imageFile ?? throw new global::System.ArgumentNullException(nameof(imageFile));
+ mask = mask ?? throw new global::System.ArgumentNullException(nameof(mask));
+ var request = new global::Ideogram.EditImageRequest
+ {
+ ImageFile = global::System.Array.Empty(),
+ ImageFilename = imageFilename,
+ Mask = global::System.Array.Empty(),
+ Maskname = maskname,
+ Prompt = prompt,
+ Model = model,
+ MagicPromptOption = magicPromptOption,
+ MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId,
+ NumImages = numImages,
+ Seed = seed,
+ StyleType = styleType,
+ };
+ PrepareArguments(
+ client: HttpClient);
+ PreparePostEditImageArguments(
+ httpClient: HttpClient,
+ request: request);
+
+
+ var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations(
+ availableAuthorizations: Authorizations,
+ securityRequirements: s_PostEditImageSecurityRequirements,
+ operationName: "PostEditImageAsync");
+
+ using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: false);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+
+ var __pathBuilder = new global::Ideogram.PathBuilder(
+ path: "/edit",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+#endif
+
+ foreach (var __authorization in __authorizations)
+ {
+ if (__authorization.Type == "Http" ||
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
+ {
+ __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
+ scheme: __authorization.Name,
+ parameter: __authorization.Value);
+ }
+ else if (__authorization.Type == "ApiKey" &&
+ __authorization.Location == "Header")
+ {
+ __httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
+ }
+ }
+
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ var __contentImageFile = new global::System.Net.Http.StreamContent(imageFile);
+ __contentImageFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.ImageFilename is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.ImageFilename) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentImageFile,
+ name: "\"image_file\"",
+ fileName: request.ImageFilename != null ? $"\"{request.ImageFilename}\"" : string.Empty);
+ if (__contentImageFile.Headers.ContentDisposition != null)
+ {
+ __contentImageFile.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ var __contentMask = new global::System.Net.Http.StreamContent(mask);
+ __contentMask.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.Maskname is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.Maskname) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentMask,
+ name: "\"mask\"",
+ fileName: request.Maskname != null ? $"\"{request.Maskname}\"" : string.Empty);
+ if (__contentMask.Headers.ContentDisposition != null)
+ {
+ __contentMask.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty),
+ name: "\"prompt\"");
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Model.ToValueString()),
+ name: "\"model\"");
+
+ if (request.MagicPromptOption != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.MagicPromptOption).HasValue ? (request.MagicPromptOption).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"magic_prompt_option\"");
+
+ }
+ if (request.MagicPromptSystemPromptConfigId != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty),
+ name: "\"magic_prompt_system_prompt_config_id\"");
+
+ }
+ if (request.NumImages != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"num_images\"");
+
+ }
+ if (request.Seed != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"seed\"");
+
+ }
+ if (request.StyleType != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.StyleType).HasValue ? (request.StyleType).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"style_type\"");
+
+ }
+
+ __httpRequest.Content = __httpRequestContent;
+
+ global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PreparePostEditImageRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
+
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostEditImage",
+ methodName: "PostEditImageAsync",
+ pathTemplate: "\"/edit\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ catch (global::System.Net.Http.HttpRequestException __exception)
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostEditImage",
+ methodName: "PostEditImageAsync",
+ pathTemplate: "\"/edit\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostEditImage",
+ methodName: "PostEditImageAsync",
+ pathTemplate: "\"/edit\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessPostEditImageResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostEditImage",
+ methodName: "PostEditImageAsync",
+ pathTemplate: "\"/edit\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostEditImage",
+ methodName: "PostEditImageAsync",
+ pathTemplate: "\"/edit\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ //
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ responseBody: __content_401,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ // Prompt or Initial Image failed the safety checks.
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Ideogram.GenerateImageSafetyError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ responseBody: __content_422,
+ responseObject: __value_422,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ responseBody: __content_429,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessPostEditImageResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ var __value = global::Ideogram.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ var __value = await global::Ideogram.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
+ }
}
}
\ No newline at end of file
diff --git a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateDesignV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateDesignV3.g.cs
index 90a5817..6f2832a 100644
--- a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateDesignV3.g.cs
+++ b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateDesignV3.g.cs
@@ -53,6 +53,31 @@ partial void ProcessPostGenerateDesignV3ResponseContent(
///
public async global::System.Threading.Tasks.Task PostGenerateDesignV3Async(
+ global::Ideogram.GenerateDesignRequestV3 request,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await PostGenerateDesignV3AsResponseAsync(
+
+ request: request,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// Generate a design from a text prompt with text detection and correction
+ /// Generates a design synchronously from a text prompt using the Ideogram 3.0 model, then detects and corrects text layers within the generated image.
+ /// The response includes the generated image URL along with detected text layers (with font, size, color, position) and image asset layers.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it.
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> PostGenerateDesignV3AsResponseAsync(
+
global::Ideogram.GenerateDesignRequestV3 request,
global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
@@ -83,10 +108,11 @@ partial void ProcessPostGenerateDesignV3ResponseContent(
var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts(
clientOptions: Options,
requestOptions: requestOptions,
- supportsRetry: true);
+ supportsRetry: false);
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Ideogram.PathBuilder(
path: "/v1/ideogram-v3/generate-design",
baseUri: HttpClient.BaseAddress);
@@ -119,94 +145,116 @@ partial void ProcessPostGenerateDesignV3ResponseContent(
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
}
}
+
var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty),
name: "\"prompt\"");
+
if (request.Seed != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
name: "\"seed\"");
- }
+
+ }
if (request.Resolution != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.Resolution).HasValue ? (request.Resolution).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"resolution\"");
- }
+
+ }
if (request.AspectRatio != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.AspectRatio).HasValue ? (request.AspectRatio).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"aspect_ratio\"");
- }
+
+ }
if (request.RenderingSpeed != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"rendering_speed\"");
- }
+
+ }
if (request.MagicPrompt != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.MagicPrompt).HasValue ? (request.MagicPrompt).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"magic_prompt\"");
- }
+
+ }
+ if (request.MagicPromptSystemPromptConfigId != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty),
+ name: "\"magic_prompt_system_prompt_config_id\"");
+
+ }
if (request.NegativePrompt != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.NegativePrompt ?? string.Empty),
name: "\"negative_prompt\"");
- }
+
+ }
if (request.NumImages != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
name: "\"num_images\"");
- }
+
+ }
if (request.ColorPalette != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.ColorPalette.ToString() ?? string.Empty),
name: "\"color_palette\"");
- }
+
+ }
if (request.StyleCodes != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.StyleCodes, x => x))}]"),
name: "\"style_codes\"");
- }
+
+ }
if (request.StyleType != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.StyleType).HasValue ? (request.StyleType).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"style_type\"");
- }
+
+ }
if (request.StylePreset != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.StylePreset).HasValue ? (request.StylePreset).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"style_preset\"");
- }
+
+ }
if (request.CustomModelUri != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.CustomModelUri ?? string.Empty),
name: "\"custom_model_uri\"");
- }
+
+ }
if (request.FontFileH1 != default)
{
@@ -247,14 +295,16 @@ request.FontFileH1name is null
{
__contentFontFileH1.Headers.ContentDisposition.FileNameStar = null;
}
- }
+
+ }
if (request.FontNameH1 != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.FontNameH1 ?? string.Empty),
name: "\"font_name_h1\"");
- }
+
+ }
if (request.FontFileH2 != default)
{
@@ -295,14 +345,16 @@ request.FontFileH2name is null
{
__contentFontFileH2.Headers.ContentDisposition.FileNameStar = null;
}
- }
+
+ }
if (request.FontNameH2 != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.FontNameH2 ?? string.Empty),
name: "\"font_name_h2\"");
- }
+
+ }
if (request.FontFileBody != default)
{
@@ -343,14 +395,16 @@ request.FontFileBodyname is null
{
__contentFontFileBody.Headers.ContentDisposition.FileNameStar = null;
}
- }
+
+ }
if (request.FontNameBody != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.FontNameBody ?? string.Empty),
name: "\"font_name_body\"");
- }
+
+ }
if (request.FontFileSmall != default)
{
@@ -391,14 +445,16 @@ request.FontFileSmallname is null
{
__contentFontFileSmall.Headers.ContentDisposition.FileNameStar = null;
}
- }
+
+ }
if (request.FontNameSmall != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.FontNameSmall ?? string.Empty),
name: "\"font_name_small\"");
- }
+
+ }
if (request.StyleReferenceImages != default)
{
@@ -415,7 +471,8 @@ request.FontFileSmallname is null
__contentStyleReferenceImages.Headers.ContentDisposition.FileNameStar = null;
}
}
- }
+
+ }
if (request.ReferenceAssetImages != default)
{
@@ -432,8 +489,11 @@ request.FontFileSmallname is null
__contentReferenceAssetImages.Headers.ContentDisposition.FileNameStar = null;
}
}
+
}
+
__httpRequest.Content = __httpRequestContent;
+
global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders(
request: __httpRequest,
clientHeaders: Options.Headers,
@@ -475,6 +535,8 @@ request.FontFileSmallname is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -485,6 +547,11 @@ request.FontFileSmallname is null
}
catch (global::System.Net.Http.HttpRequestException __exception)
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
@@ -502,6 +569,8 @@ request.FontFileSmallname is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -511,8 +580,7 @@ request.FontFileSmallname is null
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -521,6 +589,11 @@ request.FontFileSmallname is null
__attempt < __maxAttempts &&
global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
@@ -537,14 +610,15 @@ request.FontFileSmallname is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
__response.Dispose();
__response = null;
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -584,6 +658,8 @@ request.FontFileSmallname is null
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -604,6 +680,8 @@ request.FontFileSmallname is null
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
//
@@ -627,17 +705,16 @@ request.FontFileSmallname is null
__exception_400 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_400,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
//
if ((int)__response.StatusCode == 401)
@@ -660,17 +737,16 @@ request.FontFileSmallname is null
__exception_401 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_401,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_401,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_401,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
// Prompt failed the safety check.
if ((int)__response.StatusCode == 422)
@@ -697,18 +773,17 @@ request.FontFileSmallname is null
__exception_422 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_422,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_422,
+ responseObject: __value_422,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
//
if ((int)__response.StatusCode == 429)
@@ -731,17 +806,16 @@ request.FontFileSmallname is null
__exception_429 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_429,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_429,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_429,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
if (__effectiveReadResponseAsString)
@@ -765,23 +839,25 @@ request.FontFileSmallname is null
{
__response.EnsureSuccessStatusCode();
- return
- global::Ideogram.LayeredImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ??
+ var __value = global::Ideogram.LayeredImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
else
@@ -795,9 +871,13 @@ request.FontFileSmallname is null
#endif
).ConfigureAwait(false);
- return
- await global::Ideogram.LayeredImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ var __value = await global::Ideogram.LayeredImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -814,17 +894,15 @@ request.FontFileSmallname is null
{
}
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
@@ -864,6 +942,9 @@ request.FontFileSmallname is null
/// Determine if MagicPrompt should be used in generating the request or not.
/// Example: ON
///
+ ///
+ /// A base64url-encoded magic prompt system prompt config ID to use for this request.
+ ///
///
/// Description of what to exclude from a design. Descriptions in the prompt take precedence
/// to descriptions in the negative prompt.
@@ -947,6 +1028,7 @@ request.FontFileSmallname is null
global::Ideogram.AspectRatioV3? aspectRatio = default,
global::Ideogram.RenderingSpeed? renderingSpeed = default,
global::Ideogram.MagicPromptOption? magicPrompt = default,
+ string? magicPromptSystemPromptConfigId = default,
string? negativePrompt = default,
int? numImages = default,
global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette = default,
@@ -979,6 +1061,7 @@ request.FontFileSmallname is null
AspectRatio = aspectRatio,
RenderingSpeed = renderingSpeed,
MagicPrompt = magicPrompt,
+ MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId,
NegativePrompt = negativePrompt,
NumImages = numImages,
ColorPalette = colorPalette,
diff --git a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostEditImageV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateDesignV4.g.cs
similarity index 55%
rename from src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostEditImageV3.g.cs
rename to src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateDesignV4.g.cs
index 517be4f..0696251 100644
--- a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostEditImageV3.g.cs
+++ b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateDesignV4.g.cs
@@ -7,7 +7,7 @@ public partial class GenerateClient
{
- private static readonly global::Ideogram.EndPointSecurityRequirement s_PostEditImageV3SecurityRequirement0 =
+ private static readonly global::Ideogram.EndPointSecurityRequirement s_PostGenerateDesignV4SecurityRequirement0 =
new global::Ideogram.EndPointSecurityRequirement
{
Authorizations = new global::Ideogram.EndPointAuthorizationRequirement[]
@@ -21,40 +21,64 @@ public partial class GenerateClient
},
},
};
- private static readonly global::Ideogram.EndPointSecurityRequirement[] s_PostEditImageV3SecurityRequirements =
+ private static readonly global::Ideogram.EndPointSecurityRequirement[] s_PostGenerateDesignV4SecurityRequirements =
new global::Ideogram.EndPointSecurityRequirement[]
- { s_PostEditImageV3SecurityRequirement0,
+ { s_PostGenerateDesignV4SecurityRequirement0,
};
- partial void PreparePostEditImageV3Arguments(
+ partial void PreparePostGenerateDesignV4Arguments(
global::System.Net.Http.HttpClient httpClient,
- global::Ideogram.EditImageRequestV3 request);
- partial void PreparePostEditImageV3Request(
+ global::Ideogram.GenerateDesignRequestV4 request);
+ partial void PreparePostGenerateDesignV4Request(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpRequestMessage httpRequestMessage,
- global::Ideogram.EditImageRequestV3 request);
- partial void ProcessPostEditImageV3Response(
+ global::Ideogram.GenerateDesignRequestV4 request);
+ partial void ProcessPostGenerateDesignV4Response(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage);
- partial void ProcessPostEditImageV3ResponseContent(
+ partial void ProcessPostGenerateDesignV4ResponseContent(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage,
ref string content);
///
- /// Edit with Ideogram 3.0
- /// Edit a given image synchronously using the provided mask with Ideogram 3.0. The mask indicates which part of the image
- /// should be edited, while the prompt and chosen style can further guide the edit.
- /// Supported image formats include JPEG, PNG, and WebP.
+ /// Generate an editable design with Ideogram 4.0 HTML
+ /// Experimental prototype endpoint for generating an editable V4 HTML design from a prompt.
+ /// Optionally accepts inspiration reference images to guide transferable visual style. Inspiration images are design/style references only and are not edit targets.
/// Images links are available for a limited period of time; if you would like to keep the image, you must download it.
///
///
/// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
- public async global::System.Threading.Tasks.Task PostEditImageV3Async(
+ public async global::System.Threading.Tasks.Task PostGenerateDesignV4Async(
- global::Ideogram.EditImageRequestV3 request,
+ global::Ideogram.GenerateDesignRequestV4 request,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await PostGenerateDesignV4AsResponseAsync(
+
+ request: request,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// Generate an editable design with Ideogram 4.0 HTML
+ /// Experimental prototype endpoint for generating an editable V4 HTML design from a prompt.
+ /// Optionally accepts inspiration reference images to guide transferable visual style. Inspiration images are design/style references only and are not edit targets.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it.
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> PostGenerateDesignV4AsResponseAsync(
+
+ global::Ideogram.GenerateDesignRequestV4 request,
global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
@@ -62,15 +86,15 @@ partial void ProcessPostEditImageV3ResponseContent(
PrepareArguments(
client: HttpClient);
- PreparePostEditImageV3Arguments(
+ PreparePostGenerateDesignV4Arguments(
httpClient: HttpClient,
request: request);
var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations(
availableAuthorizations: Authorizations,
- securityRequirements: s_PostEditImageV3SecurityRequirements,
- operationName: "PostEditImageV3Async");
+ securityRequirements: s_PostGenerateDesignV4SecurityRequirements,
+ operationName: "PostGenerateDesignV4Async");
using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
clientOptions: Options,
@@ -84,12 +108,13 @@ partial void ProcessPostEditImageV3ResponseContent(
var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts(
clientOptions: Options,
requestOptions: requestOptions,
- supportsRetry: true);
+ supportsRetry: false);
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Ideogram.PathBuilder(
- path: "/v1/ideogram-v3/edit",
+ path: "/v1/ideogram-v4/generate-design",
baseUri: HttpClient.BaseAddress);
var __path = __pathBuilder.ToString();
__path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters(
@@ -120,199 +145,89 @@ partial void ProcessPostEditImageV3ResponseContent(
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
}
}
+
var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
- var __contentImage = new global::System.Net.Http.ByteArrayContent(request.Image ?? global::System.Array.Empty());
- __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
- request.Imagename is null
- ? "application/octet-stream"
- : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch
- {
- ".aac" => "audio/aac",
- ".flac" => "audio/flac",
- ".gif" => "image/gif",
- ".jpeg" => "image/jpeg",
- ".jpg" => "image/jpeg",
- ".json" => "application/json",
- ".m4a" => "audio/mp4",
- ".mp3" => "audio/mpeg",
- ".mp4" => "video/mp4",
- ".mpeg" => "audio/mpeg",
- ".mpga" => "audio/mpeg",
- ".oga" => "audio/ogg",
- ".ogg" => "audio/ogg",
- ".opus" => "audio/ogg",
- ".pdf" => "application/pdf",
- ".png" => "image/png",
- ".txt" => "text/plain",
- ".wav" => "audio/wav",
- ".weba" => "audio/webm",
- ".webm" => "video/webm",
- ".webp" => "image/webp",
- _ => "application/octet-stream",
- });
- __httpRequestContent.Add(
- content: __contentImage,
- name: "\"image\"",
- fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty);
- if (__contentImage.Headers.ContentDisposition != null)
- {
- __contentImage.Headers.ContentDisposition.FileNameStar = null;
- }
- var __contentMask = new global::System.Net.Http.ByteArrayContent(request.Mask ?? global::System.Array.Empty());
- __contentMask.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
- request.Maskname is null
- ? "application/octet-stream"
- : (global::System.IO.Path.GetExtension(request.Maskname) ?? string.Empty).ToLowerInvariant() switch
- {
- ".aac" => "audio/aac",
- ".flac" => "audio/flac",
- ".gif" => "image/gif",
- ".jpeg" => "image/jpeg",
- ".jpg" => "image/jpeg",
- ".json" => "application/json",
- ".m4a" => "audio/mp4",
- ".mp3" => "audio/mpeg",
- ".mp4" => "video/mp4",
- ".mpeg" => "audio/mpeg",
- ".mpga" => "audio/mpeg",
- ".oga" => "audio/ogg",
- ".ogg" => "audio/ogg",
- ".opus" => "audio/ogg",
- ".pdf" => "application/pdf",
- ".png" => "image/png",
- ".txt" => "text/plain",
- ".wav" => "audio/wav",
- ".weba" => "audio/webm",
- ".webm" => "video/webm",
- ".webp" => "image/webp",
- _ => "application/octet-stream",
- });
- __httpRequestContent.Add(
- content: __contentMask,
- name: "\"mask\"",
- fileName: request.Maskname != null ? $"\"{request.Maskname}\"" : string.Empty);
- if (__contentMask.Headers.ContentDisposition != null)
- {
- __contentMask.Headers.ContentDisposition.FileNameStar = null;
- }
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty),
name: "\"prompt\"");
- if (request.MagicPrompt != default)
- {
-
- __httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent((request.MagicPrompt).HasValue ? (request.MagicPrompt).GetValueOrDefault().ToValueString() : string.Empty),
- name: "\"magic_prompt\"");
- }
- if (request.NumImages != default)
- {
- __httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
- name: "\"num_images\"");
- }
if (request.Seed != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
name: "\"seed\"");
- }
- if (request.RenderingSpeed != default)
- {
- __httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty),
- name: "\"rendering_speed\"");
- }
- if (request.StyleType != default)
+ }
+ if (request.MagicPromptOption != default)
{
__httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent((request.StyleType).HasValue ? (request.StyleType).GetValueOrDefault().ToValueString() : string.Empty),
- name: "\"style_type\"");
- }
- if (request.StylePreset != default)
- {
+ content: new global::System.Net.Http.StringContent((request.MagicPromptOption).HasValue ? (request.MagicPromptOption).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"magic_prompt_option\"");
- __httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent((request.StylePreset).HasValue ? (request.StylePreset).GetValueOrDefault().ToValueString() : string.Empty),
- name: "\"style_preset\"");
- }
- if (request.CustomModelUri != default)
+ }
+ if (request.MagicPromptSystemPromptConfigId != default)
{
__httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent(request.CustomModelUri ?? string.Empty),
- name: "\"custom_model_uri\"");
- }
- if (request.ColorPalette != default)
+ content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty),
+ name: "\"magic_prompt_system_prompt_config_id\"");
+
+ }
+ if (request.Resolution != default)
{
__httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent(request.ColorPalette.ToString() ?? string.Empty),
- name: "\"color_palette\"");
- }
- if (request.StyleCodes != default)
+ content: new global::System.Net.Http.StringContent((request.Resolution).HasValue ? (request.Resolution).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"resolution\"");
+
+ }
+ if (request.RenderingSpeed != default)
{
__httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.StyleCodes, x => x))}]"),
- name: "\"style_codes\"");
- }
- if (request.StyleReferenceImages != default)
+ content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"rendering_speed\"");
+
+ }
+ if (request.InspirationReferenceImages != default)
{
- for (var __iStyleReferenceImages = 0; __iStyleReferenceImages < request.StyleReferenceImages.Count; __iStyleReferenceImages++)
+ for (var __iInspirationReferenceImages = 0; __iInspirationReferenceImages < request.InspirationReferenceImages.Count; __iInspirationReferenceImages++)
{
- var __contentStyleReferenceImages = new global::System.Net.Http.ByteArrayContent(request.StyleReferenceImages[__iStyleReferenceImages]);
- __contentStyleReferenceImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue("application/octet-stream");
+ var __contentInspirationReferenceImages = new global::System.Net.Http.ByteArrayContent(request.InspirationReferenceImages[__iInspirationReferenceImages]);
+ __contentInspirationReferenceImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue("application/octet-stream");
__httpRequestContent.Add(
- content: __contentStyleReferenceImages,
- name: "\"style_reference_images\"",
- fileName: $"\"file{__iStyleReferenceImages}.bin\"");
- if (__contentStyleReferenceImages.Headers.ContentDisposition != null)
+ content: __contentInspirationReferenceImages,
+ name: "\"inspiration_reference_images\"",
+ fileName: $"\"file{__iInspirationReferenceImages}.bin\"");
+ if (__contentInspirationReferenceImages.Headers.ContentDisposition != null)
{
- __contentStyleReferenceImages.Headers.ContentDisposition.FileNameStar = null;
+ __contentInspirationReferenceImages.Headers.ContentDisposition.FileNameStar = null;
}
}
- }
- if (request.CharacterReferenceImages != default)
+
+ }
+ if (request.InspirationReferenceModel != default)
{
- for (var __iCharacterReferenceImages = 0; __iCharacterReferenceImages < request.CharacterReferenceImages.Count; __iCharacterReferenceImages++)
- {
- var __contentCharacterReferenceImages = new global::System.Net.Http.ByteArrayContent(request.CharacterReferenceImages[__iCharacterReferenceImages]);
- __contentCharacterReferenceImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue("application/octet-stream");
- __httpRequestContent.Add(
- content: __contentCharacterReferenceImages,
- name: "\"character_reference_images\"",
- fileName: $"\"file{__iCharacterReferenceImages}.bin\"");
- if (__contentCharacterReferenceImages.Headers.ContentDisposition != null)
- {
- __contentCharacterReferenceImages.Headers.ContentDisposition.FileNameStar = null;
- }
- }
- }
- if (request.CharacterReferenceImagesMask != default)
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.InspirationReferenceModel).HasValue ? (request.InspirationReferenceModel).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"inspiration_reference_model\"");
+
+ }
+ if (request.ArtifactGenerationModel != default)
{
- for (var __iCharacterReferenceImagesMask = 0; __iCharacterReferenceImagesMask < request.CharacterReferenceImagesMask.Count; __iCharacterReferenceImagesMask++)
- {
- var __contentCharacterReferenceImagesMask = new global::System.Net.Http.ByteArrayContent(request.CharacterReferenceImagesMask[__iCharacterReferenceImagesMask]);
- __contentCharacterReferenceImagesMask.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue("application/octet-stream");
- __httpRequestContent.Add(
- content: __contentCharacterReferenceImagesMask,
- name: "\"character_reference_images_mask\"",
- fileName: $"\"file{__iCharacterReferenceImagesMask}.bin\"");
- if (__contentCharacterReferenceImagesMask.Headers.ContentDisposition != null)
- {
- __contentCharacterReferenceImagesMask.Headers.ContentDisposition.FileNameStar = null;
- }
- }
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.ArtifactGenerationModel).HasValue ? (request.ArtifactGenerationModel).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"artifact_generation_model\"");
+
}
+
__httpRequest.Content = __httpRequestContent;
+
global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders(
request: __httpRequest,
clientHeaders: Options.Headers,
@@ -321,7 +236,7 @@ request.Maskname is null
PrepareRequest(
client: HttpClient,
request: __httpRequest);
- PreparePostEditImageV3Request(
+ PreparePostGenerateDesignV4Request(
httpClient: HttpClient,
httpRequestMessage: __httpRequest,
request: request);
@@ -341,9 +256,9 @@ request.Maskname is null
await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
clientOptions: Options,
context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
- operationId: "PostEditImageV3",
- methodName: "PostEditImageV3Async",
- pathTemplate: "\"/v1/ideogram-v3/edit\"",
+ operationId: "PostGenerateDesignV4",
+ methodName: "PostGenerateDesignV4Async",
+ pathTemplate: "\"/v1/ideogram-v4/generate-design\"",
httpMethod: "POST",
baseUri: BaseUri,
request: __httpRequest!,
@@ -354,6 +269,8 @@ request.Maskname is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -364,13 +281,18 @@ request.Maskname is null
}
catch (global::System.Net.Http.HttpRequestException __exception)
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
- operationId: "PostEditImageV3",
- methodName: "PostEditImageV3Async",
- pathTemplate: "\"/v1/ideogram-v3/edit\"",
+ operationId: "PostGenerateDesignV4",
+ methodName: "PostGenerateDesignV4Async",
+ pathTemplate: "\"/v1/ideogram-v4/generate-design\"",
httpMethod: "POST",
baseUri: BaseUri,
request: __httpRequest!,
@@ -381,6 +303,8 @@ request.Maskname is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -390,8 +314,7 @@ request.Maskname is null
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -400,12 +323,17 @@ request.Maskname is null
__attempt < __maxAttempts &&
global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
- operationId: "PostEditImageV3",
- methodName: "PostEditImageV3Async",
- pathTemplate: "\"/v1/ideogram-v3/edit\"",
+ operationId: "PostGenerateDesignV4",
+ methodName: "PostGenerateDesignV4Async",
+ pathTemplate: "\"/v1/ideogram-v4/generate-design\"",
httpMethod: "POST",
baseUri: BaseUri,
request: __httpRequest!,
@@ -416,14 +344,15 @@ request.Maskname is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
__response.Dispose();
__response = null;
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -442,7 +371,7 @@ request.Maskname is null
ProcessResponse(
client: HttpClient,
response: __response);
- ProcessPostEditImageV3Response(
+ ProcessPostGenerateDesignV4Response(
httpClient: HttpClient,
httpResponseMessage: __response);
if (__response.IsSuccessStatusCode)
@@ -450,9 +379,9 @@ request.Maskname is null
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
clientOptions: Options,
context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
- operationId: "PostEditImageV3",
- methodName: "PostEditImageV3Async",
- pathTemplate: "\"/v1/ideogram-v3/edit\"",
+ operationId: "PostGenerateDesignV4",
+ methodName: "PostGenerateDesignV4Async",
+ pathTemplate: "\"/v1/ideogram-v4/generate-design\"",
httpMethod: "POST",
baseUri: BaseUri,
request: __httpRequest!,
@@ -463,6 +392,8 @@ request.Maskname is null
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -470,9 +401,9 @@ request.Maskname is null
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
- operationId: "PostEditImageV3",
- methodName: "PostEditImageV3Async",
- pathTemplate: "\"/v1/ideogram-v3/edit\"",
+ operationId: "PostGenerateDesignV4",
+ methodName: "PostGenerateDesignV4Async",
+ pathTemplate: "\"/v1/ideogram-v4/generate-design\"",
httpMethod: "POST",
baseUri: BaseUri,
request: __httpRequest!,
@@ -483,6 +414,8 @@ request.Maskname is null
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
//
@@ -506,17 +439,16 @@ request.Maskname is null
__exception_400 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_400,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
//
if ((int)__response.StatusCode == 401)
@@ -539,19 +471,18 @@ request.Maskname is null
__exception_401 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_401,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_401,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_401,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
- // Prompt or Initial Image failed the safety checks.
+ // Prompt failed the safety check.
if ((int)__response.StatusCode == 422)
{
string? __content_422 = null;
@@ -576,18 +507,17 @@ request.Maskname is null
__exception_422 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_422,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_422,
+ responseObject: __value_422,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
//
if ((int)__response.StatusCode == 429)
@@ -610,17 +540,16 @@ request.Maskname is null
__exception_429 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_429,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_429,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_429,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
if (__effectiveReadResponseAsString)
@@ -635,7 +564,7 @@ request.Maskname is null
client: HttpClient,
response: __response,
content: ref __content);
- ProcessPostEditImageV3ResponseContent(
+ ProcessPostGenerateDesignV4ResponseContent(
httpClient: HttpClient,
httpResponseMessage: __response,
content: ref __content);
@@ -644,23 +573,25 @@ request.Maskname is null
{
__response.EnsureSuccessStatusCode();
- return
- global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ??
+ var __value = global::Ideogram.LayeredImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
else
@@ -674,9 +605,13 @@ request.Maskname is null
#endif
).ConfigureAwait(false);
- return
- await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ var __value = await global::Ideogram.LayeredImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -693,17 +628,15 @@ request.Maskname is null
{
}
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
@@ -715,120 +648,73 @@ request.Maskname is null
}
}
///
- /// Edit with Ideogram 3.0
- /// Edit a given image synchronously using the provided mask with Ideogram 3.0. The mask indicates which part of the image
- /// should be edited, while the prompt and chosen style can further guide the edit.
- /// Supported image formats include JPEG, PNG, and WebP.
+ /// Generate an editable design with Ideogram 4.0 HTML
+ /// Experimental prototype endpoint for generating an editable V4 HTML design from a prompt.
+ /// Optionally accepts inspiration reference images to guide transferable visual style. Inspiration images are design/style references only and are not edit targets.
/// Images links are available for a limited period of time; if you would like to keep the image, you must download it.
///
- ///
- /// The image being edited (max size 10MB); only JPEG, WebP and PNG formats are supported at this time.
- ///
- ///
- /// The image being edited (max size 10MB); only JPEG, WebP and PNG formats are supported at this time.
- ///
- ///
- /// A black and white image of the same size as the image being edited (max size 10MB). Black regions in the mask should match up with the regions of the image that you would like to edit; only JPEG, WebP and PNG formats are supported at this time.
- ///
- ///
- /// A black and white image of the same size as the image being edited (max size 10MB). Black regions in the mask should match up with the regions of the image that you would like to edit; only JPEG, WebP and PNG formats are supported at this time.
- ///
///
- /// The prompt used to describe the edited result.
- /// Example: A photo of a cat.
+ /// The text prompt for editable design generation.
+ ///
+ ///
+ /// Random seed for reproducibility.
///
- ///
+ ///
/// Determine if MagicPrompt should be used in generating the request or not.
/// Example: ON
///
- ///
- /// The number of images to generate.
- /// Default Value: 1
+ ///
+ /// A base64url-encoded magic prompt system prompt config ID to use for this request.
///
- ///
- /// Random seed. Set for reproducible generation.
- /// Example: 12345
+ ///
+ /// The resolutions supported for Ideogram 4.0.
+ /// Example: 1280x800
///
///
/// The rendering speed to use.
/// Default Value: DEFAULT
///
- ///
- /// The style type to generate with.
- /// Default Value: GENERAL
- /// Example: GENERAL
- ///
- ///
- /// A predefined style preset that applies a specific artistic style to the generated image.
- /// Example: BRIGHT_ART
- ///
- ///
- /// A custom model URI in the format model/<model_name>/version/<version_name>.
- /// When provided, the model version and style will be resolved from this URI, and style_type is not required.
- /// Example: model/my-custom-model/version/1
- ///
- ///
- /// A color palette for generation, must EITHER be specified via one of the presets (name) or explicitly via hexadecimal representations of the color with optional weights (members). Not supported by V_1, V_1_TURBO, V_2A and V_2A_TURBO models.
- ///
- ///
- /// A list of 8 character hexadecimal codes representing the style of the image. Cannot be used in conjunction with style_reference_images or style_type.
- /// Example: [AAFF5733, 0133FF57, DE3357FF]
- ///
- ///
- /// A set of images to use as style references (maximum total size 10MB across all style references). The images should be in JPEG, PNG or WebP format.
+ ///
+ /// Experimental. Up to 4 static inspiration images used as transferable visual style references for V4 layout-to-image design. Images are not edit targets and are not inserted into the generated HTML layout. Supported formats are JPEG, PNG, and WebP (max size 10MB each). Animated images are not supported.
///
- ///
- /// Generations with character reference are subject to the character reference pricing. A set of images to use as character references (maximum total size 10MB across all character references), currently only supports 1 character reference image. The images should be in JPEG, PNG or WebP format.
+ ///
+ /// Experimental. Model to use for the inspiration vision prepass.
+ /// Default Value: claude-sonnet-4-6
///
- ///
- /// Optional masks for character reference images. When provided, must match the number of character_reference_images. Each mask should be a grayscale image of the same dimensions as the corresponding character reference image. The images should be in JPEG, PNG or WebP format.
+ ///
+ /// Experimental. Model to use for the HTML/layout and base-plate handoff generation call.
+ /// Default Value: claude-sonnet-4-6
///
/// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
- public async global::System.Threading.Tasks.Task PostEditImageV3Async(
- byte[] image,
- string imagename,
- byte[] mask,
- string maskname,
+ public async global::System.Threading.Tasks.Task PostGenerateDesignV4Async(
string prompt,
- global::Ideogram.MagicPromptOption? magicPrompt = default,
- int? numImages = default,
int? seed = default,
+ global::Ideogram.MagicPromptOption? magicPromptOption = default,
+ string? magicPromptSystemPromptConfigId = default,
+ global::Ideogram.ResolutionV4? resolution = default,
global::Ideogram.RenderingSpeed? renderingSpeed = default,
- global::Ideogram.StyleTypeV3? styleType = default,
- global::Ideogram.StylePresetV3? stylePreset = default,
- string? customModelUri = default,
- global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette = default,
- global::System.Collections.Generic.IList? styleCodes = default,
- global::System.Collections.Generic.IList? styleReferenceImages = default,
- global::System.Collections.Generic.IList? characterReferenceImages = default,
- global::System.Collections.Generic.IList? characterReferenceImagesMask = default,
+ global::System.Collections.Generic.IList? inspirationReferenceImages = default,
+ global::Ideogram.GenerateDesignRequestV4InspirationReferenceModel? inspirationReferenceModel = default,
+ global::Ideogram.GenerateDesignRequestV4ArtifactGenerationModel? artifactGenerationModel = default,
global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
- var __request = new global::Ideogram.EditImageRequestV3
+ var __request = new global::Ideogram.GenerateDesignRequestV4
{
- Image = image,
- Imagename = imagename,
- Mask = mask,
- Maskname = maskname,
Prompt = prompt,
- MagicPrompt = magicPrompt,
- NumImages = numImages,
Seed = seed,
+ MagicPromptOption = magicPromptOption,
+ MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId,
+ Resolution = resolution,
RenderingSpeed = renderingSpeed,
- StyleType = styleType,
- StylePreset = stylePreset,
- CustomModelUri = customModelUri,
- ColorPalette = colorPalette,
- StyleCodes = styleCodes,
- StyleReferenceImages = styleReferenceImages,
- CharacterReferenceImages = characterReferenceImages,
- CharacterReferenceImagesMask = characterReferenceImagesMask,
+ InspirationReferenceImages = inspirationReferenceImages,
+ InspirationReferenceModel = inspirationReferenceModel,
+ ArtifactGenerationModel = artifactGenerationModel,
};
- return await PostEditImageV3Async(
+ return await PostGenerateDesignV4Async(
request: __request,
requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
diff --git a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateImage.g.cs b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateImage.g.cs
index 4220d0a..8b65465 100644
--- a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateImage.g.cs
+++ b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateImage.g.cs
@@ -52,6 +52,30 @@ partial void ProcessPostGenerateImageResponseContent(
///
public async global::System.Threading.Tasks.Task PostGenerateImageAsync(
+ global::Ideogram.GenerateImageRequest request,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await PostGenerateImageAsResponseAsync(
+
+ request: request,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// Generate (legacy)
+ /// Generates images synchronously based on a given prompt and optional parameters.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it.
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> PostGenerateImageAsResponseAsync(
+
global::Ideogram.GenerateImageRequest request,
global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
@@ -86,6 +110,7 @@ partial void ProcessPostGenerateImageResponseContent(
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Ideogram.PathBuilder(
path: "/generate",
baseUri: HttpClient.BaseAddress);
@@ -165,6 +190,8 @@ partial void ProcessPostGenerateImageResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -175,6 +202,11 @@ partial void ProcessPostGenerateImageResponseContent(
}
catch (global::System.Net.Http.HttpRequestException __exception)
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
@@ -192,6 +224,8 @@ partial void ProcessPostGenerateImageResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -201,8 +235,7 @@ partial void ProcessPostGenerateImageResponseContent(
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -211,6 +244,11 @@ partial void ProcessPostGenerateImageResponseContent(
__attempt < __maxAttempts &&
global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
@@ -227,14 +265,15 @@ partial void ProcessPostGenerateImageResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
__response.Dispose();
__response = null;
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -274,6 +313,8 @@ partial void ProcessPostGenerateImageResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -294,6 +335,8 @@ partial void ProcessPostGenerateImageResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
//
@@ -317,17 +360,16 @@ partial void ProcessPostGenerateImageResponseContent(
__exception_400 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_400,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
//
if ((int)__response.StatusCode == 401)
@@ -350,17 +392,16 @@ partial void ProcessPostGenerateImageResponseContent(
__exception_401 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_401,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_401,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_401,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
// Prompt failed the safety check.
if ((int)__response.StatusCode == 422)
@@ -387,18 +428,17 @@ partial void ProcessPostGenerateImageResponseContent(
__exception_422 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_422,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_422,
+ responseObject: __value_422,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
//
if ((int)__response.StatusCode == 429)
@@ -421,17 +461,16 @@ partial void ProcessPostGenerateImageResponseContent(
__exception_429 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_429,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_429,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_429,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
if (__effectiveReadResponseAsString)
@@ -455,23 +494,25 @@ partial void ProcessPostGenerateImageResponseContent(
{
__response.EnsureSuccessStatusCode();
- return
- global::Ideogram.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ??
+ var __value = global::Ideogram.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
else
@@ -485,9 +526,13 @@ partial void ProcessPostGenerateImageResponseContent(
#endif
).ConfigureAwait(false);
- return
- await global::Ideogram.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ var __value = await global::Ideogram.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -504,17 +549,15 @@ partial void ProcessPostGenerateImageResponseContent(
{
}
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
diff --git a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateImageV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateImageV3.g.cs
index d8b9e2a..a051baf 100644
--- a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateImageV3.g.cs
+++ b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateImageV3.g.cs
@@ -52,6 +52,30 @@ partial void ProcessPostGenerateImageV3ResponseContent(
///
public async global::System.Threading.Tasks.Task PostGenerateImageV3Async(
+ global::Ideogram.GenerateImageRequestV3 request,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await PostGenerateImageV3AsResponseAsync(
+
+ request: request,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// Generate with Ideogram 3.0
+ /// Generates images synchronously based on a given prompt and optional parameters using the Ideogram 3.0 model.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it.
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> PostGenerateImageV3AsResponseAsync(
+
global::Ideogram.GenerateImageRequestV3 request,
global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
@@ -82,10 +106,11 @@ partial void ProcessPostGenerateImageV3ResponseContent(
var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts(
clientOptions: Options,
requestOptions: requestOptions,
- supportsRetry: true);
+ supportsRetry: false);
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Ideogram.PathBuilder(
path: "/v1/ideogram-v3/generate",
baseUri: HttpClient.BaseAddress);
@@ -118,94 +143,116 @@ partial void ProcessPostGenerateImageV3ResponseContent(
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
}
}
+
var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty),
name: "\"prompt\"");
+
if (request.Seed != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
name: "\"seed\"");
- }
+
+ }
if (request.Resolution != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.Resolution).HasValue ? (request.Resolution).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"resolution\"");
- }
+
+ }
if (request.AspectRatio != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.AspectRatio).HasValue ? (request.AspectRatio).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"aspect_ratio\"");
- }
+
+ }
if (request.RenderingSpeed != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"rendering_speed\"");
- }
+
+ }
if (request.MagicPrompt != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.MagicPrompt).HasValue ? (request.MagicPrompt).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"magic_prompt\"");
- }
+
+ }
+ if (request.MagicPromptSystemPromptConfigId != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty),
+ name: "\"magic_prompt_system_prompt_config_id\"");
+
+ }
if (request.NegativePrompt != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.NegativePrompt ?? string.Empty),
name: "\"negative_prompt\"");
- }
+
+ }
if (request.NumImages != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
name: "\"num_images\"");
- }
+
+ }
if (request.ColorPalette != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.ColorPalette.ToString() ?? string.Empty),
name: "\"color_palette\"");
- }
+
+ }
if (request.StyleCodes != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.StyleCodes, x => x))}]"),
name: "\"style_codes\"");
- }
+
+ }
if (request.StyleType != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.StyleType).HasValue ? (request.StyleType).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"style_type\"");
- }
+
+ }
if (request.StylePreset != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.StylePreset).HasValue ? (request.StylePreset).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"style_preset\"");
- }
+
+ }
if (request.CustomModelUri != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.CustomModelUri ?? string.Empty),
name: "\"custom_model_uri\"");
- }
+
+ }
if (request.StyleReferenceImages != default)
{
@@ -222,7 +269,8 @@ partial void ProcessPostGenerateImageV3ResponseContent(
__contentStyleReferenceImages.Headers.ContentDisposition.FileNameStar = null;
}
}
- }
+
+ }
if (request.CharacterReferenceImages != default)
{
@@ -239,7 +287,8 @@ partial void ProcessPostGenerateImageV3ResponseContent(
__contentCharacterReferenceImages.Headers.ContentDisposition.FileNameStar = null;
}
}
- }
+
+ }
if (request.CharacterReferenceImagesMask != default)
{
@@ -256,8 +305,19 @@ partial void ProcessPostGenerateImageV3ResponseContent(
__contentCharacterReferenceImagesMask.Headers.ContentDisposition.FileNameStar = null;
}
}
+
+ }
+ if (request.EnableCopyrightDetection != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.EnableCopyrightDetection, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()),
+ name: "\"enable_copyright_detection\"");
+
}
+
__httpRequest.Content = __httpRequestContent;
+
global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders(
request: __httpRequest,
clientHeaders: Options.Headers,
@@ -299,6 +359,8 @@ partial void ProcessPostGenerateImageV3ResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -309,6 +371,11 @@ partial void ProcessPostGenerateImageV3ResponseContent(
}
catch (global::System.Net.Http.HttpRequestException __exception)
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
@@ -326,6 +393,8 @@ partial void ProcessPostGenerateImageV3ResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -335,8 +404,7 @@ partial void ProcessPostGenerateImageV3ResponseContent(
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -345,6 +413,11 @@ partial void ProcessPostGenerateImageV3ResponseContent(
__attempt < __maxAttempts &&
global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
@@ -361,14 +434,15 @@ partial void ProcessPostGenerateImageV3ResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
__response.Dispose();
__response = null;
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -408,6 +482,8 @@ partial void ProcessPostGenerateImageV3ResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -428,6 +504,8 @@ partial void ProcessPostGenerateImageV3ResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
//
@@ -451,17 +529,16 @@ partial void ProcessPostGenerateImageV3ResponseContent(
__exception_400 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_400,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
//
if ((int)__response.StatusCode == 401)
@@ -484,17 +561,16 @@ partial void ProcessPostGenerateImageV3ResponseContent(
__exception_401 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_401,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_401,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_401,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
// Prompt failed the safety check.
if ((int)__response.StatusCode == 422)
@@ -521,18 +597,17 @@ partial void ProcessPostGenerateImageV3ResponseContent(
__exception_422 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_422,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_422,
+ responseObject: __value_422,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
//
if ((int)__response.StatusCode == 429)
@@ -555,17 +630,16 @@ partial void ProcessPostGenerateImageV3ResponseContent(
__exception_429 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_429,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_429,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_429,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
if (__effectiveReadResponseAsString)
@@ -589,23 +663,25 @@ partial void ProcessPostGenerateImageV3ResponseContent(
{
__response.EnsureSuccessStatusCode();
- return
- global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ??
+ var __value = global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
else
@@ -619,9 +695,13 @@ partial void ProcessPostGenerateImageV3ResponseContent(
#endif
).ConfigureAwait(false);
- return
- await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ var __value = await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -638,17 +718,15 @@ partial void ProcessPostGenerateImageV3ResponseContent(
{
}
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
@@ -687,6 +765,9 @@ partial void ProcessPostGenerateImageV3ResponseContent(
/// Determine if MagicPrompt should be used in generating the request or not.
/// Example: ON
///
+ ///
+ /// A base64url-encoded magic prompt system prompt config ID to use for this request.
+ ///
///
/// Description of what to exclude from an image. Descriptions in the prompt take precedence
/// to descriptions in the negative prompt.
@@ -726,6 +807,13 @@ partial void ProcessPostGenerateImageV3ResponseContent(
///
/// Optional masks for character reference images. When provided, must match the number of character_reference_images. Each mask should be a grayscale image of the same dimensions as the corresponding character reference image. The images should be in JPEG, PNG or WebP format.
///
+ ///
+ /// Optional. Opt this request into post-generation copyright detection (Hive likeness + logo
+ /// checks). The effective gate is the OR of this field and the organization's
+ /// `copyright_detection_enabled` setting on `/api`: if the org has it on, this is ignored;
+ /// if the org has it off, setting this `true` enables detection for this request only.
+ /// Adds detection latency. Flagged images come back with `is_image_safe: false`.
+ ///
/// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
@@ -736,6 +824,7 @@ partial void ProcessPostGenerateImageV3ResponseContent(
global::Ideogram.AspectRatioV3? aspectRatio = default,
global::Ideogram.RenderingSpeed? renderingSpeed = default,
global::Ideogram.MagicPromptOption? magicPrompt = default,
+ string? magicPromptSystemPromptConfigId = default,
string? negativePrompt = default,
int? numImages = default,
global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette = default,
@@ -746,6 +835,7 @@ partial void ProcessPostGenerateImageV3ResponseContent(
global::System.Collections.Generic.IList? styleReferenceImages = default,
global::System.Collections.Generic.IList? characterReferenceImages = default,
global::System.Collections.Generic.IList? characterReferenceImagesMask = default,
+ bool? enableCopyrightDetection = default,
global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
@@ -757,6 +847,7 @@ partial void ProcessPostGenerateImageV3ResponseContent(
AspectRatio = aspectRatio,
RenderingSpeed = renderingSpeed,
MagicPrompt = magicPrompt,
+ MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId,
NegativePrompt = negativePrompt,
NumImages = numImages,
ColorPalette = colorPalette,
@@ -767,6 +858,7 @@ partial void ProcessPostGenerateImageV3ResponseContent(
StyleReferenceImages = styleReferenceImages,
CharacterReferenceImages = characterReferenceImages,
CharacterReferenceImagesMask = characterReferenceImagesMask,
+ EnableCopyrightDetection = enableCopyrightDetection,
};
return await PostGenerateImageV3Async(
diff --git a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateImageV3Transparent.g.cs b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateImageV3Transparent.g.cs
index c66170c..981808d 100644
--- a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateImageV3Transparent.g.cs
+++ b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateImageV3Transparent.g.cs
@@ -47,6 +47,8 @@ partial void ProcessPostGenerateImageV3TransparentResponseContent(
/// the Ideogram 3.0 model. Images will be generated using maximum supported resolution at the specified aspect ratio
/// to allow best results with upscaler. The selected resolution is written to the response, not the upscaled final
/// resolution.
+ /// `rendering_speed=FLASH` is not supported for transparent-background generation; the request will return a 400.
+ /// Use `TURBO`, `DEFAULT`, or `QUALITY` instead.
/// Images links are available for a limited period of time; if you would like to keep the image, you must download it.
///
///
@@ -55,6 +57,35 @@ partial void ProcessPostGenerateImageV3TransparentResponseContent(
///
public async global::System.Threading.Tasks.Task PostGenerateImageV3TransparentAsync(
+ global::Ideogram.GenerateTransparentImageRequestV3 request,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await PostGenerateImageV3TransparentAsResponseAsync(
+
+ request: request,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// Generate with Ideogram 3.0 (Transparent Background)
+ /// Generates images with transparent background synchronously based on a given prompt and optional parameters using
+ /// the Ideogram 3.0 model. Images will be generated using maximum supported resolution at the specified aspect ratio
+ /// to allow best results with upscaler. The selected resolution is written to the response, not the upscaled final
+ /// resolution.
+ /// `rendering_speed=FLASH` is not supported for transparent-background generation; the request will return a 400.
+ /// Use `TURBO`, `DEFAULT`, or `QUALITY` instead.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it.
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> PostGenerateImageV3TransparentAsResponseAsync(
+
global::Ideogram.GenerateTransparentImageRequestV3 request,
global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
@@ -85,10 +116,11 @@ partial void ProcessPostGenerateImageV3TransparentResponseContent(
var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts(
clientOptions: Options,
requestOptions: requestOptions,
- supportsRetry: true);
+ supportsRetry: false);
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Ideogram.PathBuilder(
path: "/v1/ideogram-v3/generate-transparent",
baseUri: HttpClient.BaseAddress);
@@ -121,67 +153,87 @@ partial void ProcessPostGenerateImageV3TransparentResponseContent(
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
}
}
+
var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty),
name: "\"prompt\"");
+
if (request.Seed != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
name: "\"seed\"");
- }
+
+ }
if (request.UpscaleFactor != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.UpscaleFactor).HasValue ? (request.UpscaleFactor).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"upscale_factor\"");
- }
+
+ }
if (request.AspectRatio != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.AspectRatio).HasValue ? (request.AspectRatio).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"aspect_ratio\"");
- }
+
+ }
if (request.RenderingSpeed != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"rendering_speed\"");
- }
+
+ }
if (request.MagicPrompt != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.MagicPrompt).HasValue ? (request.MagicPrompt).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"magic_prompt\"");
- }
+
+ }
+ if (request.MagicPromptSystemPromptConfigId != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty),
+ name: "\"magic_prompt_system_prompt_config_id\"");
+
+ }
if (request.NegativePrompt != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.NegativePrompt ?? string.Empty),
name: "\"negative_prompt\"");
- }
+
+ }
if (request.NumImages != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
name: "\"num_images\"");
- }
+
+ }
if (request.CustomModelUri != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.CustomModelUri ?? string.Empty),
name: "\"custom_model_uri\"");
+
}
+
__httpRequest.Content = __httpRequestContent;
+
global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders(
request: __httpRequest,
clientHeaders: Options.Headers,
@@ -223,6 +275,8 @@ partial void ProcessPostGenerateImageV3TransparentResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -233,6 +287,11 @@ partial void ProcessPostGenerateImageV3TransparentResponseContent(
}
catch (global::System.Net.Http.HttpRequestException __exception)
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
@@ -250,6 +309,8 @@ partial void ProcessPostGenerateImageV3TransparentResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -259,8 +320,7 @@ partial void ProcessPostGenerateImageV3TransparentResponseContent(
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -269,6 +329,11 @@ partial void ProcessPostGenerateImageV3TransparentResponseContent(
__attempt < __maxAttempts &&
global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
@@ -285,14 +350,15 @@ partial void ProcessPostGenerateImageV3TransparentResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
__response.Dispose();
__response = null;
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -332,6 +398,8 @@ partial void ProcessPostGenerateImageV3TransparentResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -352,6 +420,8 @@ partial void ProcessPostGenerateImageV3TransparentResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
//
@@ -375,17 +445,16 @@ partial void ProcessPostGenerateImageV3TransparentResponseContent(
__exception_400 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_400,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
//
if ((int)__response.StatusCode == 401)
@@ -408,17 +477,16 @@ partial void ProcessPostGenerateImageV3TransparentResponseContent(
__exception_401 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_401,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_401,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_401,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
// Prompt failed the safety check.
if ((int)__response.StatusCode == 422)
@@ -445,18 +513,17 @@ partial void ProcessPostGenerateImageV3TransparentResponseContent(
__exception_422 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_422,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_422,
+ responseObject: __value_422,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
//
if ((int)__response.StatusCode == 429)
@@ -479,17 +546,16 @@ partial void ProcessPostGenerateImageV3TransparentResponseContent(
__exception_429 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_429,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_429,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_429,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
if (__effectiveReadResponseAsString)
@@ -513,23 +579,25 @@ partial void ProcessPostGenerateImageV3TransparentResponseContent(
{
__response.EnsureSuccessStatusCode();
- return
- global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ??
+ var __value = global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
else
@@ -543,9 +611,13 @@ partial void ProcessPostGenerateImageV3TransparentResponseContent(
#endif
).ConfigureAwait(false);
- return
- await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ var __value = await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -562,17 +634,15 @@ partial void ProcessPostGenerateImageV3TransparentResponseContent(
{
}
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
@@ -589,6 +659,8 @@ partial void ProcessPostGenerateImageV3TransparentResponseContent(
/// the Ideogram 3.0 model. Images will be generated using maximum supported resolution at the specified aspect ratio
/// to allow best results with upscaler. The selected resolution is written to the response, not the upscaled final
/// resolution.
+ /// `rendering_speed=FLASH` is not supported for transparent-background generation; the request will return a 400.
+ /// Use `TURBO`, `DEFAULT`, or `QUALITY` instead.
/// Images links are available for a limited period of time; if you would like to keep the image, you must download it.
///
///
@@ -615,6 +687,9 @@ partial void ProcessPostGenerateImageV3TransparentResponseContent(
/// Determine if MagicPrompt should be used in generating the request or not.
/// Example: ON
///
+ ///
+ /// A base64url-encoded magic prompt system prompt config ID to use for this request.
+ ///
///
/// Description of what to exclude from an image. Descriptions in the prompt take precedence
/// to descriptions in the negative prompt.
@@ -640,6 +715,7 @@ partial void ProcessPostGenerateImageV3TransparentResponseContent(
global::Ideogram.AspectRatioV3? aspectRatio = default,
global::Ideogram.RenderingSpeed? renderingSpeed = default,
global::Ideogram.MagicPromptOption? magicPrompt = default,
+ string? magicPromptSystemPromptConfigId = default,
string? negativePrompt = default,
int? numImages = default,
string? customModelUri = default,
@@ -654,6 +730,7 @@ partial void ProcessPostGenerateImageV3TransparentResponseContent(
AspectRatio = aspectRatio,
RenderingSpeed = renderingSpeed,
MagicPrompt = magicPrompt,
+ MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId,
NegativePrompt = negativePrompt,
NumImages = numImages,
CustomModelUri = customModelUri,
diff --git a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateImageV4.g.cs b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateImageV4.g.cs
index 222fc4e..503a488 100644
--- a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateImageV4.g.cs
+++ b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateImageV4.g.cs
@@ -52,6 +52,30 @@ partial void ProcessPostGenerateImageV4ResponseContent(
///
public async global::System.Threading.Tasks.Task PostGenerateImageV4Async(
+ global::Ideogram.GenerateImageRequestV4 request,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await PostGenerateImageV4AsResponseAsync(
+
+ request: request,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// Generate with Ideogram 4.0
+ /// Generates images synchronously using the Ideogram 4.0 model.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it.
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> PostGenerateImageV4AsResponseAsync(
+
global::Ideogram.GenerateImageRequestV4 request,
global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
@@ -82,10 +106,11 @@ partial void ProcessPostGenerateImageV4ResponseContent(
var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts(
clientOptions: Options,
requestOptions: requestOptions,
- supportsRetry: true);
+ supportsRetry: false);
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Ideogram.PathBuilder(
path: "/v1/ideogram-v4/generate",
baseUri: HttpClient.BaseAddress);
@@ -118,32 +143,79 @@ partial void ProcessPostGenerateImageV4ResponseContent(
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
}
}
+
var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty),
name: "\"prompt\"");
+
if (request.Seed != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
name: "\"seed\"");
- }
+
+ }
if (request.MagicPromptOption != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.MagicPromptOption).HasValue ? (request.MagicPromptOption).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"magic_prompt_option\"");
- }
+
+ }
+ if (request.MagicPromptSystemPromptConfigId != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty),
+ name: "\"magic_prompt_system_prompt_config_id\"");
+
+ }
+ if (request.MagicPromptVersion != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.MagicPromptVersion).HasValue ? (request.MagicPromptVersion).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"magic_prompt_version\"");
+
+ }
if (request.CustomModelUri != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.CustomModelUri ?? string.Empty),
name: "\"custom_model_uri\"");
+
+ }
+ if (request.Resolution != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.Resolution).HasValue ? (request.Resolution).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"resolution\"");
+
+ }
+ if (request.RenderingSpeed != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"rendering_speed\"");
+
}
+ if (request.EnableCopyrightDetection != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.EnableCopyrightDetection, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()),
+ name: "\"enable_copyright_detection\"");
+
+ }
+
__httpRequest.Content = __httpRequestContent;
+
global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders(
request: __httpRequest,
clientHeaders: Options.Headers,
@@ -185,6 +257,8 @@ partial void ProcessPostGenerateImageV4ResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -195,6 +269,11 @@ partial void ProcessPostGenerateImageV4ResponseContent(
}
catch (global::System.Net.Http.HttpRequestException __exception)
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
@@ -212,6 +291,8 @@ partial void ProcessPostGenerateImageV4ResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -221,8 +302,7 @@ partial void ProcessPostGenerateImageV4ResponseContent(
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -231,6 +311,11 @@ partial void ProcessPostGenerateImageV4ResponseContent(
__attempt < __maxAttempts &&
global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
@@ -247,14 +332,15 @@ partial void ProcessPostGenerateImageV4ResponseContent(
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
__response.Dispose();
__response = null;
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -294,6 +380,8 @@ partial void ProcessPostGenerateImageV4ResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -314,6 +402,8 @@ partial void ProcessPostGenerateImageV4ResponseContent(
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
//
@@ -337,17 +427,16 @@ partial void ProcessPostGenerateImageV4ResponseContent(
__exception_400 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_400,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
//
if ((int)__response.StatusCode == 401)
@@ -370,17 +459,16 @@ partial void ProcessPostGenerateImageV4ResponseContent(
__exception_401 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_401,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_401,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_401,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
// Prompt failed the safety check.
if ((int)__response.StatusCode == 422)
@@ -407,18 +495,17 @@ partial void ProcessPostGenerateImageV4ResponseContent(
__exception_422 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_422,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_422,
+ responseObject: __value_422,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
//
if ((int)__response.StatusCode == 429)
@@ -441,17 +528,16 @@ partial void ProcessPostGenerateImageV4ResponseContent(
__exception_429 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_429,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_429,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_429,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
if (__effectiveReadResponseAsString)
@@ -475,23 +561,25 @@ partial void ProcessPostGenerateImageV4ResponseContent(
{
__response.EnsureSuccessStatusCode();
- return
- global::Ideogram.ImageGenerationResponseV4.FromJson(__content, JsonSerializerContext) ??
+ var __value = global::Ideogram.ImageGenerationResponseV4.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
else
@@ -505,9 +593,13 @@ partial void ProcessPostGenerateImageV4ResponseContent(
#endif
).ConfigureAwait(false);
- return
- await global::Ideogram.ImageGenerationResponseV4.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ var __value = await global::Ideogram.ImageGenerationResponseV4.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -524,17 +616,15 @@ partial void ProcessPostGenerateImageV4ResponseContent(
{
}
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
@@ -560,11 +650,31 @@ partial void ProcessPostGenerateImageV4ResponseContent(
/// Determine if MagicPrompt should be used in generating the request or not.
/// Example: ON
///
+ ///
+ /// A base64url-encoded magic prompt system prompt config ID to use for this request.
+ ///
+ ///
+ /// Deprecated — pin a registered magic-prompt system prompt via
+ /// `magic_prompt_system_prompt_config_id` instead.
+ ///
///
/// A custom model URI in the format model/<model_name>/version/<version_name>.
/// When provided, the model version and style will be resolved from this URI.
/// Example: model/my-custom-model/version/0
///
+ ///
+ /// The resolutions supported for Ideogram 4.0.
+ /// Example: 1280x800
+ ///
+ ///
+ /// The rendering speed to use.
+ /// Default Value: DEFAULT
+ ///
+ ///
+ /// Optional. Opt this request into post-generation copyright detection (Hive likeness + logo
+ /// checks). The effective gate is the OR of this field and the organization's
+ /// `copyright_detection_enabled` setting on `/api`. See GenerateImageRequestV3 for details.
+ ///
/// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
@@ -572,7 +682,12 @@ partial void ProcessPostGenerateImageV4ResponseContent(
string prompt,
int? seed = default,
global::Ideogram.MagicPromptOption? magicPromptOption = default,
+ string? magicPromptSystemPromptConfigId = default,
+ global::Ideogram.MagicPromptVersionEnum? magicPromptVersion = default,
string? customModelUri = default,
+ global::Ideogram.ResolutionV4? resolution = default,
+ global::Ideogram.RenderingSpeed? renderingSpeed = default,
+ bool? enableCopyrightDetection = default,
global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
@@ -581,7 +696,12 @@ partial void ProcessPostGenerateImageV4ResponseContent(
Prompt = prompt,
Seed = seed,
MagicPromptOption = magicPromptOption,
+ MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId,
+ MagicPromptVersion = magicPromptVersion,
CustomModelUri = customModelUri,
+ Resolution = resolution,
+ RenderingSpeed = renderingSpeed,
+ EnableCopyrightDetection = enableCopyrightDetection,
};
return await PostGenerateImageV4Async(
diff --git a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateImageV4Im2Im.g.cs b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateImageV4Im2Im.g.cs
new file mode 100644
index 0000000..9495445
--- /dev/null
+++ b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostGenerateImageV4Im2Im.g.cs
@@ -0,0 +1,2021 @@
+
+#nullable enable
+
+namespace Ideogram
+{
+ public partial class GenerateClient
+ {
+
+
+ private static readonly global::Ideogram.EndPointSecurityRequirement s_PostGenerateImageV4Im2ImSecurityRequirement0 =
+ new global::Ideogram.EndPointSecurityRequirement
+ {
+ Authorizations = new global::Ideogram.EndPointAuthorizationRequirement[]
+ { new global::Ideogram.EndPointAuthorizationRequirement
+ {
+ Type = "Http",
+ SchemeId = "HttpBearer",
+ Location = "Header",
+ Name = "Bearer",
+ FriendlyName = "Bearer",
+ },
+ },
+ };
+ private static readonly global::Ideogram.EndPointSecurityRequirement[] s_PostGenerateImageV4Im2ImSecurityRequirements =
+ new global::Ideogram.EndPointSecurityRequirement[]
+ { s_PostGenerateImageV4Im2ImSecurityRequirement0,
+ };
+ partial void PreparePostGenerateImageV4Im2ImArguments(
+ global::System.Net.Http.HttpClient httpClient,
+ global::Ideogram.GenerateImageRequestV4Im2Im request);
+ partial void PreparePostGenerateImageV4Im2ImRequest(
+ global::System.Net.Http.HttpClient httpClient,
+ global::System.Net.Http.HttpRequestMessage httpRequestMessage,
+ global::Ideogram.GenerateImageRequestV4Im2Im request);
+ partial void ProcessPostGenerateImageV4Im2ImResponse(
+ global::System.Net.Http.HttpClient httpClient,
+ global::System.Net.Http.HttpResponseMessage httpResponseMessage);
+
+ partial void ProcessPostGenerateImageV4Im2ImResponseContent(
+ global::System.Net.Http.HttpClient httpClient,
+ global::System.Net.Http.HttpResponseMessage httpResponseMessage,
+ ref string content);
+
+ ///
+ /// Image-to-image with Ideogram 4.0
+ /// Generates images synchronously using the Ideogram 4.0 model with an initial image as input.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it.
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task PostGenerateImageV4Im2ImAsync(
+
+ global::Ideogram.GenerateImageRequestV4Im2Im request,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await PostGenerateImageV4Im2ImAsResponseAsync(
+
+ request: request,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// Image-to-image with Ideogram 4.0
+ /// Generates images synchronously using the Ideogram 4.0 model with an initial image as input.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it.
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> PostGenerateImageV4Im2ImAsResponseAsync(
+
+ global::Ideogram.GenerateImageRequestV4Im2Im request,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ request = request ?? throw new global::System.ArgumentNullException(nameof(request));
+
+ PrepareArguments(
+ client: HttpClient);
+ PreparePostGenerateImageV4Im2ImArguments(
+ httpClient: HttpClient,
+ request: request);
+
+
+ var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations(
+ availableAuthorizations: Authorizations,
+ securityRequirements: s_PostGenerateImageV4Im2ImSecurityRequirements,
+ operationName: "PostGenerateImageV4Im2ImAsync");
+
+ using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: false);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+
+ var __pathBuilder = new global::Ideogram.PathBuilder(
+ path: "/v1/ideogram-v4/image-to-image",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+#endif
+
+ foreach (var __authorization in __authorizations)
+ {
+ if (__authorization.Type == "Http" ||
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
+ {
+ __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
+ scheme: __authorization.Name,
+ parameter: __authorization.Value);
+ }
+ else if (__authorization.Type == "ApiKey" &&
+ __authorization.Location == "Header")
+ {
+ __httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
+ }
+ }
+
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ var __contentImage = new global::System.Net.Http.ByteArrayContent(request.Image ?? global::System.Array.Empty());
+ __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.Imagename is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentImage,
+ name: "\"image\"",
+ fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty);
+ if (__contentImage.Headers.ContentDisposition != null)
+ {
+ __contentImage.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ if (request.Prompt != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty),
+ name: "\"prompt\"");
+
+ }
+ if (request.Seed != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"seed\"");
+
+ }
+ if (request.MagicPromptOption != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.MagicPromptOption).HasValue ? (request.MagicPromptOption).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"magic_prompt_option\"");
+
+ }
+ if (request.MagicPromptSystemPromptConfigId != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty),
+ name: "\"magic_prompt_system_prompt_config_id\"");
+
+ }
+ if (request.Resolution != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.Resolution).HasValue ? (request.Resolution).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"resolution\"");
+
+ }
+ if (request.RenderingSpeed != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"rendering_speed\"");
+
+ }
+ if (request.EnableCopyrightDetection != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.EnableCopyrightDetection, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()),
+ name: "\"enable_copyright_detection\"");
+
+ }
+
+ __httpRequest.Content = __httpRequestContent;
+
+ global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PreparePostGenerateImageV4Im2ImRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
+
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostGenerateImageV4Im2Im",
+ methodName: "PostGenerateImageV4Im2ImAsync",
+ pathTemplate: "\"/v1/ideogram-v4/image-to-image\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ catch (global::System.Net.Http.HttpRequestException __exception)
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostGenerateImageV4Im2Im",
+ methodName: "PostGenerateImageV4Im2ImAsync",
+ pathTemplate: "\"/v1/ideogram-v4/image-to-image\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostGenerateImageV4Im2Im",
+ methodName: "PostGenerateImageV4Im2ImAsync",
+ pathTemplate: "\"/v1/ideogram-v4/image-to-image\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessPostGenerateImageV4Im2ImResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostGenerateImageV4Im2Im",
+ methodName: "PostGenerateImageV4Im2ImAsync",
+ pathTemplate: "\"/v1/ideogram-v4/image-to-image\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostGenerateImageV4Im2Im",
+ methodName: "PostGenerateImageV4Im2ImAsync",
+ pathTemplate: "\"/v1/ideogram-v4/image-to-image\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ //
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ responseBody: __content_401,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ // Prompt failed the safety check.
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Ideogram.GenerateImageSafetyError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ responseBody: __content_422,
+ responseObject: __value_422,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ responseBody: __content_429,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessPostGenerateImageV4Im2ImResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ var __value = global::Ideogram.ImageGenerationResponseV4.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ var __value = await global::Ideogram.ImageGenerationResponseV4.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
+ }
+ ///
+ /// Image-to-image with Ideogram 4.0
+ /// Generates images synchronously using the Ideogram 4.0 model with an initial image as input.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it.
+ ///
+ ///
+ /// The initial image binary (max 10MB); only JPEG, WebP and PNG formats are supported.
+ ///
+ ///
+ /// The initial image binary (max 10MB); only JPEG, WebP and PNG formats are supported.
+ ///
+ ///
+ /// An optional text prompt to guide the generation.
+ ///
+ ///
+ /// Random seed. Set for reproducible generation.
+ /// Example: 12345
+ ///
+ ///
+ /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON
+ ///
+ ///
+ /// A base64url-encoded magic prompt system prompt config ID to use for this request.
+ ///
+ ///
+ /// The resolutions supported for Ideogram 4.0.
+ /// Example: 1280x800
+ ///
+ ///
+ /// The rendering speed to use.
+ /// Default Value: DEFAULT
+ ///
+ ///
+ /// Optional. Opt this request into post-generation copyright detection (Hive likeness + logo
+ /// checks). See GenerateImageRequestV3 for details.
+ ///
+ /// 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 PostGenerateImageV4Im2ImAsync(
+ byte[] image,
+ string imagename,
+ string? prompt = default,
+ int? seed = default,
+ global::Ideogram.MagicPromptOption? magicPromptOption = default,
+ string? magicPromptSystemPromptConfigId = default,
+ global::Ideogram.ResolutionV4? resolution = default,
+ global::Ideogram.RenderingSpeed? renderingSpeed = default,
+ bool? enableCopyrightDetection = default,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __request = new global::Ideogram.GenerateImageRequestV4Im2Im
+ {
+ Image = image,
+ Imagename = imagename,
+ Prompt = prompt,
+ Seed = seed,
+ MagicPromptOption = magicPromptOption,
+ MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId,
+ Resolution = resolution,
+ RenderingSpeed = renderingSpeed,
+ EnableCopyrightDetection = enableCopyrightDetection,
+ };
+
+ return await PostGenerateImageV4Im2ImAsync(
+ request: __request,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken).ConfigureAwait(false);
+ }
+
+ ///
+ /// Image-to-image with Ideogram 4.0
+ /// Generates images synchronously using the Ideogram 4.0 model with an initial image as input.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it.
+ ///
+ ///
+ /// The initial image binary (max 10MB); only JPEG, WebP and PNG formats are supported.
+ ///
+ ///
+ /// The initial image binary (max 10MB); only JPEG, WebP and PNG formats are supported.
+ ///
+ ///
+ /// An optional text prompt to guide the generation.
+ ///
+ ///
+ /// Random seed. Set for reproducible generation.
+ /// Example: 12345
+ ///
+ ///
+ /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON
+ ///
+ ///
+ /// A base64url-encoded magic prompt system prompt config ID to use for this request.
+ ///
+ ///
+ /// The resolutions supported for Ideogram 4.0.
+ /// Example: 1280x800
+ ///
+ ///
+ /// The rendering speed to use.
+ /// Default Value: DEFAULT
+ ///
+ ///
+ /// Optional. Opt this request into post-generation copyright detection (Hive likeness + logo
+ /// checks). See GenerateImageRequestV3 for details.
+ ///
+ /// 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 PostGenerateImageV4Im2ImAsync(
+ global::System.IO.Stream image,
+ string imagename,
+ string? prompt = default,
+ int? seed = default,
+ global::Ideogram.MagicPromptOption? magicPromptOption = default,
+ string? magicPromptSystemPromptConfigId = default,
+ global::Ideogram.ResolutionV4? resolution = default,
+ global::Ideogram.RenderingSpeed? renderingSpeed = default,
+ bool? enableCopyrightDetection = default,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+
+ image = image ?? throw new global::System.ArgumentNullException(nameof(image));
+ var request = new global::Ideogram.GenerateImageRequestV4Im2Im
+ {
+ Image = global::System.Array.Empty(),
+ Imagename = imagename,
+ Prompt = prompt,
+ Seed = seed,
+ MagicPromptOption = magicPromptOption,
+ MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId,
+ Resolution = resolution,
+ RenderingSpeed = renderingSpeed,
+ EnableCopyrightDetection = enableCopyrightDetection,
+ };
+ PrepareArguments(
+ client: HttpClient);
+ PreparePostGenerateImageV4Im2ImArguments(
+ httpClient: HttpClient,
+ request: request);
+
+
+ var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations(
+ availableAuthorizations: Authorizations,
+ securityRequirements: s_PostGenerateImageV4Im2ImSecurityRequirements,
+ operationName: "PostGenerateImageV4Im2ImAsync");
+
+ using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: false);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+
+ var __pathBuilder = new global::Ideogram.PathBuilder(
+ path: "/v1/ideogram-v4/image-to-image",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+#endif
+
+ foreach (var __authorization in __authorizations)
+ {
+ if (__authorization.Type == "Http" ||
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
+ {
+ __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
+ scheme: __authorization.Name,
+ parameter: __authorization.Value);
+ }
+ else if (__authorization.Type == "ApiKey" &&
+ __authorization.Location == "Header")
+ {
+ __httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
+ }
+ }
+
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ var __contentImage = new global::System.Net.Http.StreamContent(image);
+ __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.Imagename is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentImage,
+ name: "\"image\"",
+ fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty);
+ if (__contentImage.Headers.ContentDisposition != null)
+ {
+ __contentImage.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ if (request.Prompt != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty),
+ name: "\"prompt\"");
+
+ }
+ if (request.Seed != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"seed\"");
+
+ }
+ if (request.MagicPromptOption != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.MagicPromptOption).HasValue ? (request.MagicPromptOption).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"magic_prompt_option\"");
+
+ }
+ if (request.MagicPromptSystemPromptConfigId != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty),
+ name: "\"magic_prompt_system_prompt_config_id\"");
+
+ }
+ if (request.Resolution != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.Resolution).HasValue ? (request.Resolution).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"resolution\"");
+
+ }
+ if (request.RenderingSpeed != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"rendering_speed\"");
+
+ }
+ if (request.EnableCopyrightDetection != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.EnableCopyrightDetection, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()),
+ name: "\"enable_copyright_detection\"");
+
+ }
+
+ __httpRequest.Content = __httpRequestContent;
+
+ global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PreparePostGenerateImageV4Im2ImRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
+
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostGenerateImageV4Im2Im",
+ methodName: "PostGenerateImageV4Im2ImAsync",
+ pathTemplate: "\"/v1/ideogram-v4/image-to-image\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ catch (global::System.Net.Http.HttpRequestException __exception)
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostGenerateImageV4Im2Im",
+ methodName: "PostGenerateImageV4Im2ImAsync",
+ pathTemplate: "\"/v1/ideogram-v4/image-to-image\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostGenerateImageV4Im2Im",
+ methodName: "PostGenerateImageV4Im2ImAsync",
+ pathTemplate: "\"/v1/ideogram-v4/image-to-image\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessPostGenerateImageV4Im2ImResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostGenerateImageV4Im2Im",
+ methodName: "PostGenerateImageV4Im2ImAsync",
+ pathTemplate: "\"/v1/ideogram-v4/image-to-image\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostGenerateImageV4Im2Im",
+ methodName: "PostGenerateImageV4Im2ImAsync",
+ pathTemplate: "\"/v1/ideogram-v4/image-to-image\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ //
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ responseBody: __content_401,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ // Prompt failed the safety check.
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Ideogram.GenerateImageSafetyError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ responseBody: __content_422,
+ responseObject: __value_422,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ responseBody: __content_429,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessPostGenerateImageV4Im2ImResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Ideogram.ImageGenerationResponseV4.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Ideogram.ImageGenerationResponseV4.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 global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
+ }
+ ///
+ /// Image-to-image with Ideogram 4.0
+ /// Generates images synchronously using the Ideogram 4.0 model with an initial image as input.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it.
+ ///
+ ///
+ /// The initial image binary (max 10MB); only JPEG, WebP and PNG formats are supported.
+ ///
+ ///
+ /// The initial image binary (max 10MB); only JPEG, WebP and PNG formats are supported.
+ ///
+ ///
+ /// An optional text prompt to guide the generation.
+ ///
+ ///
+ /// Random seed. Set for reproducible generation.
+ /// Example: 12345
+ ///
+ ///
+ /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON
+ ///
+ ///
+ /// A base64url-encoded magic prompt system prompt config ID to use for this request.
+ ///
+ ///
+ /// The resolutions supported for Ideogram 4.0.
+ /// Example: 1280x800
+ ///
+ ///
+ /// The rendering speed to use.
+ /// Default Value: DEFAULT
+ ///
+ ///
+ /// Optional. Opt this request into post-generation copyright detection (Hive likeness + logo
+ /// checks). See GenerateImageRequestV3 for details.
+ ///
+ /// 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> PostGenerateImageV4Im2ImAsResponseAsync(
+ global::System.IO.Stream image,
+ string imagename,
+ string? prompt = default,
+ int? seed = default,
+ global::Ideogram.MagicPromptOption? magicPromptOption = default,
+ string? magicPromptSystemPromptConfigId = default,
+ global::Ideogram.ResolutionV4? resolution = default,
+ global::Ideogram.RenderingSpeed? renderingSpeed = default,
+ bool? enableCopyrightDetection = default,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+
+ image = image ?? throw new global::System.ArgumentNullException(nameof(image));
+ var request = new global::Ideogram.GenerateImageRequestV4Im2Im
+ {
+ Image = global::System.Array.Empty(),
+ Imagename = imagename,
+ Prompt = prompt,
+ Seed = seed,
+ MagicPromptOption = magicPromptOption,
+ MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId,
+ Resolution = resolution,
+ RenderingSpeed = renderingSpeed,
+ EnableCopyrightDetection = enableCopyrightDetection,
+ };
+ PrepareArguments(
+ client: HttpClient);
+ PreparePostGenerateImageV4Im2ImArguments(
+ httpClient: HttpClient,
+ request: request);
+
+
+ var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations(
+ availableAuthorizations: Authorizations,
+ securityRequirements: s_PostGenerateImageV4Im2ImSecurityRequirements,
+ operationName: "PostGenerateImageV4Im2ImAsync");
+
+ using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: false);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+
+ var __pathBuilder = new global::Ideogram.PathBuilder(
+ path: "/v1/ideogram-v4/image-to-image",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+#endif
+
+ foreach (var __authorization in __authorizations)
+ {
+ if (__authorization.Type == "Http" ||
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
+ {
+ __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
+ scheme: __authorization.Name,
+ parameter: __authorization.Value);
+ }
+ else if (__authorization.Type == "ApiKey" &&
+ __authorization.Location == "Header")
+ {
+ __httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
+ }
+ }
+
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ var __contentImage = new global::System.Net.Http.StreamContent(image);
+ __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.Imagename is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentImage,
+ name: "\"image\"",
+ fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty);
+ if (__contentImage.Headers.ContentDisposition != null)
+ {
+ __contentImage.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ if (request.Prompt != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty),
+ name: "\"prompt\"");
+
+ }
+ if (request.Seed != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"seed\"");
+
+ }
+ if (request.MagicPromptOption != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.MagicPromptOption).HasValue ? (request.MagicPromptOption).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"magic_prompt_option\"");
+
+ }
+ if (request.MagicPromptSystemPromptConfigId != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty),
+ name: "\"magic_prompt_system_prompt_config_id\"");
+
+ }
+ if (request.Resolution != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.Resolution).HasValue ? (request.Resolution).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"resolution\"");
+
+ }
+ if (request.RenderingSpeed != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"rendering_speed\"");
+
+ }
+ if (request.EnableCopyrightDetection != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.EnableCopyrightDetection, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()),
+ name: "\"enable_copyright_detection\"");
+
+ }
+
+ __httpRequest.Content = __httpRequestContent;
+
+ global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PreparePostGenerateImageV4Im2ImRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
+
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostGenerateImageV4Im2Im",
+ methodName: "PostGenerateImageV4Im2ImAsync",
+ pathTemplate: "\"/v1/ideogram-v4/image-to-image\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ catch (global::System.Net.Http.HttpRequestException __exception)
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostGenerateImageV4Im2Im",
+ methodName: "PostGenerateImageV4Im2ImAsync",
+ pathTemplate: "\"/v1/ideogram-v4/image-to-image\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostGenerateImageV4Im2Im",
+ methodName: "PostGenerateImageV4Im2ImAsync",
+ pathTemplate: "\"/v1/ideogram-v4/image-to-image\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessPostGenerateImageV4Im2ImResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostGenerateImageV4Im2Im",
+ methodName: "PostGenerateImageV4Im2ImAsync",
+ pathTemplate: "\"/v1/ideogram-v4/image-to-image\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostGenerateImageV4Im2Im",
+ methodName: "PostGenerateImageV4Im2ImAsync",
+ pathTemplate: "\"/v1/ideogram-v4/image-to-image\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ //
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ responseBody: __content_401,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ // Prompt failed the safety check.
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Ideogram.GenerateImageSafetyError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ responseBody: __content_422,
+ responseObject: __value_422,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ responseBody: __content_429,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessPostGenerateImageV4Im2ImResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ var __value = global::Ideogram.ImageGenerationResponseV4.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ var __value = await global::Ideogram.ImageGenerationResponseV4.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostInpaintImageV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostInpaintImageV3.g.cs
index c527a47..6b941ba 100644
--- a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostInpaintImageV3.g.cs
+++ b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostInpaintImageV3.g.cs
@@ -54,6 +54,32 @@ partial void ProcessPostInpaintImageV3ResponseContent(
///
public async global::System.Threading.Tasks.Task PostInpaintImageV3Async(
+ global::Ideogram.EditImageRequestV3 request,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await PostInpaintImageV3AsResponseAsync(
+
+ request: request,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// Inpaint with Ideogram 3.0
+ /// Inpaint a given image synchronously using the provided mask with Ideogram 3.0. The mask indicates which part of the image
+ /// should be edited, while the prompt and chosen style can further guide the edit.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it.
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> PostInpaintImageV3AsResponseAsync(
+
global::Ideogram.EditImageRequestV3 request,
global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
@@ -84,10 +110,11 @@ partial void ProcessPostInpaintImageV3ResponseContent(
var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts(
clientOptions: Options,
requestOptions: requestOptions,
- supportsRetry: true);
+ supportsRetry: false);
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Ideogram.PathBuilder(
path: "/v1/ideogram-v3/inpaint",
baseUri: HttpClient.BaseAddress);
@@ -120,6 +147,7 @@ partial void ProcessPostInpaintImageV3ResponseContent(
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
}
}
+
var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
var __contentImage = new global::System.Net.Http.ByteArrayContent(request.Image ?? global::System.Array.Empty());
__contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
@@ -158,6 +186,7 @@ request.Imagename is null
{
__contentImage.Headers.ContentDisposition.FileNameStar = null;
}
+
var __contentMask = new global::System.Net.Http.ByteArrayContent(request.Mask ?? global::System.Array.Empty());
__contentMask.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
request.Maskname is null
@@ -195,72 +224,91 @@ request.Maskname is null
{
__contentMask.Headers.ContentDisposition.FileNameStar = null;
}
+
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty),
name: "\"prompt\"");
+
if (request.MagicPrompt != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.MagicPrompt).HasValue ? (request.MagicPrompt).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"magic_prompt\"");
- }
+
+ }
+ if (request.MagicPromptSystemPromptConfigId != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty),
+ name: "\"magic_prompt_system_prompt_config_id\"");
+
+ }
if (request.NumImages != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
name: "\"num_images\"");
- }
+
+ }
if (request.Seed != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
name: "\"seed\"");
- }
+
+ }
if (request.RenderingSpeed != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"rendering_speed\"");
- }
+
+ }
if (request.StyleType != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.StyleType).HasValue ? (request.StyleType).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"style_type\"");
- }
+
+ }
if (request.StylePreset != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.StylePreset).HasValue ? (request.StylePreset).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"style_preset\"");
- }
+
+ }
if (request.CustomModelUri != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.CustomModelUri ?? string.Empty),
name: "\"custom_model_uri\"");
- }
+
+ }
if (request.ColorPalette != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.ColorPalette.ToString() ?? string.Empty),
name: "\"color_palette\"");
- }
+
+ }
if (request.StyleCodes != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.StyleCodes, x => x))}]"),
name: "\"style_codes\"");
- }
+
+ }
if (request.StyleReferenceImages != default)
{
@@ -277,7 +325,8 @@ request.Maskname is null
__contentStyleReferenceImages.Headers.ContentDisposition.FileNameStar = null;
}
}
- }
+
+ }
if (request.CharacterReferenceImages != default)
{
@@ -294,7 +343,8 @@ request.Maskname is null
__contentCharacterReferenceImages.Headers.ContentDisposition.FileNameStar = null;
}
}
- }
+
+ }
if (request.CharacterReferenceImagesMask != default)
{
@@ -311,8 +361,11 @@ request.Maskname is null
__contentCharacterReferenceImagesMask.Headers.ContentDisposition.FileNameStar = null;
}
}
+
}
+
__httpRequest.Content = __httpRequestContent;
+
global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders(
request: __httpRequest,
clientHeaders: Options.Headers,
@@ -354,6 +407,8 @@ request.Maskname is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -364,6 +419,11 @@ request.Maskname is null
}
catch (global::System.Net.Http.HttpRequestException __exception)
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
@@ -381,6 +441,8 @@ request.Maskname is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -390,8 +452,7 @@ request.Maskname is null
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -400,6 +461,11 @@ request.Maskname is null
__attempt < __maxAttempts &&
global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
@@ -416,14 +482,15 @@ request.Maskname is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
__response.Dispose();
__response = null;
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -463,6 +530,8 @@ request.Maskname is null
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -483,6 +552,8 @@ request.Maskname is null
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
//
@@ -506,17 +577,16 @@ request.Maskname is null
__exception_400 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_400,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
//
if ((int)__response.StatusCode == 401)
@@ -539,17 +609,16 @@ request.Maskname is null
__exception_401 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_401,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_401,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_401,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
// Prompt or Initial Image failed the safety checks.
if ((int)__response.StatusCode == 422)
@@ -576,18 +645,17 @@ request.Maskname is null
__exception_422 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_422,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_422,
+ responseObject: __value_422,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
//
if ((int)__response.StatusCode == 429)
@@ -610,17 +678,16 @@ request.Maskname is null
__exception_429 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_429,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_429,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_429,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
if (__effectiveReadResponseAsString)
@@ -644,23 +711,25 @@ request.Maskname is null
{
__response.EnsureSuccessStatusCode();
- return
- global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ??
+ var __value = global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
else
@@ -674,9 +743,13 @@ request.Maskname is null
#endif
).ConfigureAwait(false);
- return
- await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ var __value = await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -693,17 +766,15 @@ request.Maskname is null
{
}
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
@@ -741,6 +812,9 @@ request.Maskname is null
/// Determine if MagicPrompt should be used in generating the request or not.
/// Example: ON
///
+ ///
+ /// A base64url-encoded magic prompt system prompt config ID to use for this request.
+ ///
///
/// The number of images to generate.
/// Default Value: 1
@@ -793,6 +867,7 @@ request.Maskname is null
string maskname,
string prompt,
global::Ideogram.MagicPromptOption? magicPrompt = default,
+ string? magicPromptSystemPromptConfigId = default,
int? numImages = default,
int? seed = default,
global::Ideogram.RenderingSpeed? renderingSpeed = default,
@@ -815,6 +890,7 @@ request.Maskname is null
Maskname = maskname,
Prompt = prompt,
MagicPrompt = magicPrompt,
+ MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId,
NumImages = numImages,
Seed = seed,
RenderingSpeed = renderingSpeed,
@@ -833,5 +909,1854 @@ request.Maskname is null
requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
+
+ ///
+ /// Inpaint with Ideogram 3.0
+ /// Inpaint a given image synchronously using the provided mask with Ideogram 3.0. The mask indicates which part of the image
+ /// should be edited, while the prompt and chosen style can further guide the edit.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it.
+ ///
+ ///
+ /// The image being edited (max size 10MB); only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ ///
+ /// The image being edited (max size 10MB); only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ ///
+ /// A black and white image of the same size as the image being edited (max size 10MB). Black regions in the mask should match up with the regions of the image that you would like to edit; only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ ///
+ /// A black and white image of the same size as the image being edited (max size 10MB). Black regions in the mask should match up with the regions of the image that you would like to edit; only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ ///
+ /// The prompt used to describe the edited result.
+ /// Example: A photo of a cat.
+ ///
+ ///
+ /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON
+ ///
+ ///
+ /// A base64url-encoded magic prompt system prompt config ID to use for this request.
+ ///
+ ///
+ /// The number of images to generate.
+ /// Default Value: 1
+ ///
+ ///
+ /// Random seed. Set for reproducible generation.
+ /// Example: 12345
+ ///
+ ///
+ /// The rendering speed to use.
+ /// Default Value: DEFAULT
+ ///
+ ///
+ /// The style type to generate with.
+ /// Default Value: GENERAL
+ /// Example: GENERAL
+ ///
+ ///
+ /// A predefined style preset that applies a specific artistic style to the generated image.
+ /// Example: BRIGHT_ART
+ ///
+ ///
+ /// A custom model URI in the format model/<model_name>/version/<version_name>.
+ /// When provided, the model version and style will be resolved from this URI, and style_type is not required.
+ /// Example: model/my-custom-model/version/1
+ ///
+ ///
+ /// A color palette for generation, must EITHER be specified via one of the presets (name) or explicitly via hexadecimal representations of the color with optional weights (members). Not supported by V_1, V_1_TURBO, V_2A and V_2A_TURBO models.
+ ///
+ ///
+ /// A list of 8 character hexadecimal codes representing the style of the image. Cannot be used in conjunction with style_reference_images or style_type.
+ /// Example: [AAFF5733, 0133FF57, DE3357FF]
+ ///
+ ///
+ /// A set of images to use as style references (maximum total size 10MB across all style references). The images should be in JPEG, PNG or WebP format.
+ ///
+ ///
+ /// Optional file names to use for the multipart 'style_reference_images' file parts.
+ ///
+ ///
+ /// Generations with character reference are subject to the character reference pricing. A set of images to use as character references (maximum total size 10MB across all character references), currently only supports 1 character reference image. The images should be in JPEG, PNG or WebP format.
+ ///
+ ///
+ /// Optional file names to use for the multipart 'character_reference_images' file parts.
+ ///
+ ///
+ /// Optional masks for character reference images. When provided, must match the number of character_reference_images. Each mask should be a grayscale image of the same dimensions as the corresponding character reference image. The images should be in JPEG, PNG or WebP format.
+ ///
+ ///
+ /// Optional file names to use for the multipart 'character_reference_images_mask' file parts.
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task PostInpaintImageV3Async(
+ global::System.IO.Stream image,
+ string imagename,
+ global::System.IO.Stream mask,
+ string maskname,
+ string prompt,
+ global::Ideogram.MagicPromptOption? magicPrompt = default,
+ string? magicPromptSystemPromptConfigId = default,
+ int? numImages = default,
+ int? seed = default,
+ global::Ideogram.RenderingSpeed? renderingSpeed = default,
+ global::Ideogram.StyleTypeV3? styleType = default,
+ global::Ideogram.StylePresetV3? stylePreset = default,
+ string? customModelUri = default,
+ global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette = default,
+ global::System.Collections.Generic.IList? styleCodes = default,
+ global::System.Collections.Generic.IReadOnlyList? styleReferenceImages = default,
+ global::System.Collections.Generic.IReadOnlyList? styleReferenceImagesFileNames = default,
+ global::System.Collections.Generic.IReadOnlyList? characterReferenceImages = default,
+ global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesFileNames = default,
+ global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesMask = default,
+ global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesMaskFileNames = default,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+
+ image = image ?? throw new global::System.ArgumentNullException(nameof(image));
+ mask = mask ?? throw new global::System.ArgumentNullException(nameof(mask));
+ var request = new global::Ideogram.EditImageRequestV3
+ {
+ Image = global::System.Array.Empty(),
+ Imagename = imagename,
+ Mask = global::System.Array.Empty(),
+ Maskname = maskname,
+ Prompt = prompt,
+ MagicPrompt = magicPrompt,
+ MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId,
+ NumImages = numImages,
+ Seed = seed,
+ RenderingSpeed = renderingSpeed,
+ StyleType = styleType,
+ StylePreset = stylePreset,
+ CustomModelUri = customModelUri,
+ ColorPalette = colorPalette,
+ StyleCodes = styleCodes,
+ StyleReferenceImages = new global::System.Collections.Generic.List(),
+ CharacterReferenceImages = new global::System.Collections.Generic.List(),
+ CharacterReferenceImagesMask = new global::System.Collections.Generic.List(),
+ };
+ PrepareArguments(
+ client: HttpClient);
+ PreparePostInpaintImageV3Arguments(
+ httpClient: HttpClient,
+ request: request);
+
+
+ var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations(
+ availableAuthorizations: Authorizations,
+ securityRequirements: s_PostInpaintImageV3SecurityRequirements,
+ operationName: "PostInpaintImageV3Async");
+
+ using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: false);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+
+ var __pathBuilder = new global::Ideogram.PathBuilder(
+ path: "/v1/ideogram-v3/inpaint",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+#endif
+
+ foreach (var __authorization in __authorizations)
+ {
+ if (__authorization.Type == "Http" ||
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
+ {
+ __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
+ scheme: __authorization.Name,
+ parameter: __authorization.Value);
+ }
+ else if (__authorization.Type == "ApiKey" &&
+ __authorization.Location == "Header")
+ {
+ __httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
+ }
+ }
+
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ var __contentImage = new global::System.Net.Http.StreamContent(image);
+ __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.Imagename is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentImage,
+ name: "\"image\"",
+ fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty);
+ if (__contentImage.Headers.ContentDisposition != null)
+ {
+ __contentImage.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ var __contentMask = new global::System.Net.Http.StreamContent(mask);
+ __contentMask.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.Maskname is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.Maskname) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentMask,
+ name: "\"mask\"",
+ fileName: request.Maskname != null ? $"\"{request.Maskname}\"" : string.Empty);
+ if (__contentMask.Headers.ContentDisposition != null)
+ {
+ __contentMask.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty),
+ name: "\"prompt\"");
+
+ if (request.MagicPrompt != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.MagicPrompt).HasValue ? (request.MagicPrompt).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"magic_prompt\"");
+
+ }
+ if (request.MagicPromptSystemPromptConfigId != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty),
+ name: "\"magic_prompt_system_prompt_config_id\"");
+
+ }
+ if (request.NumImages != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"num_images\"");
+
+ }
+ if (request.Seed != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"seed\"");
+
+ }
+ if (request.RenderingSpeed != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"rendering_speed\"");
+
+ }
+ if (request.StyleType != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.StyleType).HasValue ? (request.StyleType).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"style_type\"");
+
+ }
+ if (request.StylePreset != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.StylePreset).HasValue ? (request.StylePreset).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"style_preset\"");
+
+ }
+ if (request.CustomModelUri != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.CustomModelUri ?? string.Empty),
+ name: "\"custom_model_uri\"");
+
+ }
+ if (request.ColorPalette != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.ColorPalette.ToString() ?? string.Empty),
+ name: "\"color_palette\"");
+
+ }
+ if (request.StyleCodes != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.StyleCodes, x => x))}]"),
+ name: "\"style_codes\"");
+
+ }
+ if (styleReferenceImages != default)
+ {
+
+ for (var __iStyleReferenceImages = 0; __iStyleReferenceImages < styleReferenceImages.Count; __iStyleReferenceImages++)
+ {
+ var __fileNameStyleReferenceImages = styleReferenceImagesFileNames != null &&
+ __iStyleReferenceImages < styleReferenceImagesFileNames.Count &&
+ styleReferenceImagesFileNames[__iStyleReferenceImages] != null
+ ? styleReferenceImagesFileNames[__iStyleReferenceImages]
+ : $"file{__iStyleReferenceImages}.bin";
+ var __contentStyleReferenceImages = new global::System.Net.Http.StreamContent(styleReferenceImages[__iStyleReferenceImages]);
+ __contentStyleReferenceImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ __fileNameStyleReferenceImages is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(__fileNameStyleReferenceImages) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentStyleReferenceImages,
+ name: "\"style_reference_images\"",
+ fileName: $"\"{__fileNameStyleReferenceImages}\"");
+ if (__contentStyleReferenceImages.Headers.ContentDisposition != null)
+ {
+ __contentStyleReferenceImages.Headers.ContentDisposition.FileNameStar = null;
+ }
+ }
+
+ }
+ if (characterReferenceImages != default)
+ {
+
+ for (var __iCharacterReferenceImages = 0; __iCharacterReferenceImages < characterReferenceImages.Count; __iCharacterReferenceImages++)
+ {
+ var __fileNameCharacterReferenceImages = characterReferenceImagesFileNames != null &&
+ __iCharacterReferenceImages < characterReferenceImagesFileNames.Count &&
+ characterReferenceImagesFileNames[__iCharacterReferenceImages] != null
+ ? characterReferenceImagesFileNames[__iCharacterReferenceImages]
+ : $"file{__iCharacterReferenceImages}.bin";
+ var __contentCharacterReferenceImages = new global::System.Net.Http.StreamContent(characterReferenceImages[__iCharacterReferenceImages]);
+ __contentCharacterReferenceImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ __fileNameCharacterReferenceImages is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(__fileNameCharacterReferenceImages) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentCharacterReferenceImages,
+ name: "\"character_reference_images\"",
+ fileName: $"\"{__fileNameCharacterReferenceImages}\"");
+ if (__contentCharacterReferenceImages.Headers.ContentDisposition != null)
+ {
+ __contentCharacterReferenceImages.Headers.ContentDisposition.FileNameStar = null;
+ }
+ }
+
+ }
+ if (characterReferenceImagesMask != default)
+ {
+
+ for (var __iCharacterReferenceImagesMask = 0; __iCharacterReferenceImagesMask < characterReferenceImagesMask.Count; __iCharacterReferenceImagesMask++)
+ {
+ var __fileNameCharacterReferenceImagesMask = characterReferenceImagesMaskFileNames != null &&
+ __iCharacterReferenceImagesMask < characterReferenceImagesMaskFileNames.Count &&
+ characterReferenceImagesMaskFileNames[__iCharacterReferenceImagesMask] != null
+ ? characterReferenceImagesMaskFileNames[__iCharacterReferenceImagesMask]
+ : $"file{__iCharacterReferenceImagesMask}.bin";
+ var __contentCharacterReferenceImagesMask = new global::System.Net.Http.StreamContent(characterReferenceImagesMask[__iCharacterReferenceImagesMask]);
+ __contentCharacterReferenceImagesMask.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ __fileNameCharacterReferenceImagesMask is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(__fileNameCharacterReferenceImagesMask) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentCharacterReferenceImagesMask,
+ name: "\"character_reference_images_mask\"",
+ fileName: $"\"{__fileNameCharacterReferenceImagesMask}\"");
+ if (__contentCharacterReferenceImagesMask.Headers.ContentDisposition != null)
+ {
+ __contentCharacterReferenceImagesMask.Headers.ContentDisposition.FileNameStar = null;
+ }
+ }
+
+ }
+
+ __httpRequest.Content = __httpRequestContent;
+
+ global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PreparePostInpaintImageV3Request(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
+
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostInpaintImageV3",
+ methodName: "PostInpaintImageV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/inpaint\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ catch (global::System.Net.Http.HttpRequestException __exception)
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostInpaintImageV3",
+ methodName: "PostInpaintImageV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/inpaint\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostInpaintImageV3",
+ methodName: "PostInpaintImageV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/inpaint\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessPostInpaintImageV3Response(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostInpaintImageV3",
+ methodName: "PostInpaintImageV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/inpaint\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostInpaintImageV3",
+ methodName: "PostInpaintImageV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/inpaint\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ //
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ responseBody: __content_401,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ // Prompt or Initial Image failed the safety checks.
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Ideogram.GenerateImageSafetyError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ responseBody: __content_422,
+ responseObject: __value_422,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ responseBody: __content_429,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessPostInpaintImageV3ResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
+ }
+ ///
+ /// Inpaint with Ideogram 3.0
+ /// Inpaint a given image synchronously using the provided mask with Ideogram 3.0. The mask indicates which part of the image
+ /// should be edited, while the prompt and chosen style can further guide the edit.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it.
+ ///
+ ///
+ /// The image being edited (max size 10MB); only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ ///
+ /// The image being edited (max size 10MB); only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ ///
+ /// A black and white image of the same size as the image being edited (max size 10MB). Black regions in the mask should match up with the regions of the image that you would like to edit; only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ ///
+ /// A black and white image of the same size as the image being edited (max size 10MB). Black regions in the mask should match up with the regions of the image that you would like to edit; only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ ///
+ /// The prompt used to describe the edited result.
+ /// Example: A photo of a cat.
+ ///
+ ///
+ /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON
+ ///
+ ///
+ /// A base64url-encoded magic prompt system prompt config ID to use for this request.
+ ///
+ ///
+ /// The number of images to generate.
+ /// Default Value: 1
+ ///
+ ///
+ /// Random seed. Set for reproducible generation.
+ /// Example: 12345
+ ///
+ ///
+ /// The rendering speed to use.
+ /// Default Value: DEFAULT
+ ///
+ ///
+ /// The style type to generate with.
+ /// Default Value: GENERAL
+ /// Example: GENERAL
+ ///
+ ///
+ /// A predefined style preset that applies a specific artistic style to the generated image.
+ /// Example: BRIGHT_ART
+ ///
+ ///
+ /// A custom model URI in the format model/<model_name>/version/<version_name>.
+ /// When provided, the model version and style will be resolved from this URI, and style_type is not required.
+ /// Example: model/my-custom-model/version/1
+ ///
+ ///
+ /// A color palette for generation, must EITHER be specified via one of the presets (name) or explicitly via hexadecimal representations of the color with optional weights (members). Not supported by V_1, V_1_TURBO, V_2A and V_2A_TURBO models.
+ ///
+ ///
+ /// A list of 8 character hexadecimal codes representing the style of the image. Cannot be used in conjunction with style_reference_images or style_type.
+ /// Example: [AAFF5733, 0133FF57, DE3357FF]
+ ///
+ ///
+ /// A set of images to use as style references (maximum total size 10MB across all style references). The images should be in JPEG, PNG or WebP format.
+ ///
+ ///
+ /// Optional file names to use for the multipart 'style_reference_images' file parts.
+ ///
+ ///
+ /// Generations with character reference are subject to the character reference pricing. A set of images to use as character references (maximum total size 10MB across all character references), currently only supports 1 character reference image. The images should be in JPEG, PNG or WebP format.
+ ///
+ ///
+ /// Optional file names to use for the multipart 'character_reference_images' file parts.
+ ///
+ ///
+ /// Optional masks for character reference images. When provided, must match the number of character_reference_images. Each mask should be a grayscale image of the same dimensions as the corresponding character reference image. The images should be in JPEG, PNG or WebP format.
+ ///
+ ///
+ /// Optional file names to use for the multipart 'character_reference_images_mask' file parts.
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> PostInpaintImageV3AsResponseAsync(
+ global::System.IO.Stream image,
+ string imagename,
+ global::System.IO.Stream mask,
+ string maskname,
+ string prompt,
+ global::Ideogram.MagicPromptOption? magicPrompt = default,
+ string? magicPromptSystemPromptConfigId = default,
+ int? numImages = default,
+ int? seed = default,
+ global::Ideogram.RenderingSpeed? renderingSpeed = default,
+ global::Ideogram.StyleTypeV3? styleType = default,
+ global::Ideogram.StylePresetV3? stylePreset = default,
+ string? customModelUri = default,
+ global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette = default,
+ global::System.Collections.Generic.IList? styleCodes = default,
+ global::System.Collections.Generic.IReadOnlyList? styleReferenceImages = default,
+ global::System.Collections.Generic.IReadOnlyList? styleReferenceImagesFileNames = default,
+ global::System.Collections.Generic.IReadOnlyList? characterReferenceImages = default,
+ global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesFileNames = default,
+ global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesMask = default,
+ global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesMaskFileNames = default,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+
+ image = image ?? throw new global::System.ArgumentNullException(nameof(image));
+ mask = mask ?? throw new global::System.ArgumentNullException(nameof(mask));
+ var request = new global::Ideogram.EditImageRequestV3
+ {
+ Image = global::System.Array.Empty(),
+ Imagename = imagename,
+ Mask = global::System.Array.Empty(),
+ Maskname = maskname,
+ Prompt = prompt,
+ MagicPrompt = magicPrompt,
+ MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId,
+ NumImages = numImages,
+ Seed = seed,
+ RenderingSpeed = renderingSpeed,
+ StyleType = styleType,
+ StylePreset = stylePreset,
+ CustomModelUri = customModelUri,
+ ColorPalette = colorPalette,
+ StyleCodes = styleCodes,
+ StyleReferenceImages = new global::System.Collections.Generic.List(),
+ CharacterReferenceImages = new global::System.Collections.Generic.List(),
+ CharacterReferenceImagesMask = new global::System.Collections.Generic.List(),
+ };
+ PrepareArguments(
+ client: HttpClient);
+ PreparePostInpaintImageV3Arguments(
+ httpClient: HttpClient,
+ request: request);
+
+
+ var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations(
+ availableAuthorizations: Authorizations,
+ securityRequirements: s_PostInpaintImageV3SecurityRequirements,
+ operationName: "PostInpaintImageV3Async");
+
+ using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: false);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+
+ var __pathBuilder = new global::Ideogram.PathBuilder(
+ path: "/v1/ideogram-v3/inpaint",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+#endif
+
+ foreach (var __authorization in __authorizations)
+ {
+ if (__authorization.Type == "Http" ||
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
+ {
+ __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
+ scheme: __authorization.Name,
+ parameter: __authorization.Value);
+ }
+ else if (__authorization.Type == "ApiKey" &&
+ __authorization.Location == "Header")
+ {
+ __httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
+ }
+ }
+
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ var __contentImage = new global::System.Net.Http.StreamContent(image);
+ __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.Imagename is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentImage,
+ name: "\"image\"",
+ fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty);
+ if (__contentImage.Headers.ContentDisposition != null)
+ {
+ __contentImage.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ var __contentMask = new global::System.Net.Http.StreamContent(mask);
+ __contentMask.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.Maskname is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.Maskname) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentMask,
+ name: "\"mask\"",
+ fileName: request.Maskname != null ? $"\"{request.Maskname}\"" : string.Empty);
+ if (__contentMask.Headers.ContentDisposition != null)
+ {
+ __contentMask.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty),
+ name: "\"prompt\"");
+
+ if (request.MagicPrompt != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.MagicPrompt).HasValue ? (request.MagicPrompt).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"magic_prompt\"");
+
+ }
+ if (request.MagicPromptSystemPromptConfigId != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty),
+ name: "\"magic_prompt_system_prompt_config_id\"");
+
+ }
+ if (request.NumImages != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"num_images\"");
+
+ }
+ if (request.Seed != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"seed\"");
+
+ }
+ if (request.RenderingSpeed != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"rendering_speed\"");
+
+ }
+ if (request.StyleType != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.StyleType).HasValue ? (request.StyleType).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"style_type\"");
+
+ }
+ if (request.StylePreset != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.StylePreset).HasValue ? (request.StylePreset).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"style_preset\"");
+
+ }
+ if (request.CustomModelUri != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.CustomModelUri ?? string.Empty),
+ name: "\"custom_model_uri\"");
+
+ }
+ if (request.ColorPalette != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.ColorPalette.ToString() ?? string.Empty),
+ name: "\"color_palette\"");
+
+ }
+ if (request.StyleCodes != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.StyleCodes, x => x))}]"),
+ name: "\"style_codes\"");
+
+ }
+ if (styleReferenceImages != default)
+ {
+
+ for (var __iStyleReferenceImages = 0; __iStyleReferenceImages < styleReferenceImages.Count; __iStyleReferenceImages++)
+ {
+ var __fileNameStyleReferenceImages = styleReferenceImagesFileNames != null &&
+ __iStyleReferenceImages < styleReferenceImagesFileNames.Count &&
+ styleReferenceImagesFileNames[__iStyleReferenceImages] != null
+ ? styleReferenceImagesFileNames[__iStyleReferenceImages]
+ : $"file{__iStyleReferenceImages}.bin";
+ var __contentStyleReferenceImages = new global::System.Net.Http.StreamContent(styleReferenceImages[__iStyleReferenceImages]);
+ __contentStyleReferenceImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ __fileNameStyleReferenceImages is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(__fileNameStyleReferenceImages) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentStyleReferenceImages,
+ name: "\"style_reference_images\"",
+ fileName: $"\"{__fileNameStyleReferenceImages}\"");
+ if (__contentStyleReferenceImages.Headers.ContentDisposition != null)
+ {
+ __contentStyleReferenceImages.Headers.ContentDisposition.FileNameStar = null;
+ }
+ }
+
+ }
+ if (characterReferenceImages != default)
+ {
+
+ for (var __iCharacterReferenceImages = 0; __iCharacterReferenceImages < characterReferenceImages.Count; __iCharacterReferenceImages++)
+ {
+ var __fileNameCharacterReferenceImages = characterReferenceImagesFileNames != null &&
+ __iCharacterReferenceImages < characterReferenceImagesFileNames.Count &&
+ characterReferenceImagesFileNames[__iCharacterReferenceImages] != null
+ ? characterReferenceImagesFileNames[__iCharacterReferenceImages]
+ : $"file{__iCharacterReferenceImages}.bin";
+ var __contentCharacterReferenceImages = new global::System.Net.Http.StreamContent(characterReferenceImages[__iCharacterReferenceImages]);
+ __contentCharacterReferenceImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ __fileNameCharacterReferenceImages is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(__fileNameCharacterReferenceImages) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentCharacterReferenceImages,
+ name: "\"character_reference_images\"",
+ fileName: $"\"{__fileNameCharacterReferenceImages}\"");
+ if (__contentCharacterReferenceImages.Headers.ContentDisposition != null)
+ {
+ __contentCharacterReferenceImages.Headers.ContentDisposition.FileNameStar = null;
+ }
+ }
+
+ }
+ if (characterReferenceImagesMask != default)
+ {
+
+ for (var __iCharacterReferenceImagesMask = 0; __iCharacterReferenceImagesMask < characterReferenceImagesMask.Count; __iCharacterReferenceImagesMask++)
+ {
+ var __fileNameCharacterReferenceImagesMask = characterReferenceImagesMaskFileNames != null &&
+ __iCharacterReferenceImagesMask < characterReferenceImagesMaskFileNames.Count &&
+ characterReferenceImagesMaskFileNames[__iCharacterReferenceImagesMask] != null
+ ? characterReferenceImagesMaskFileNames[__iCharacterReferenceImagesMask]
+ : $"file{__iCharacterReferenceImagesMask}.bin";
+ var __contentCharacterReferenceImagesMask = new global::System.Net.Http.StreamContent(characterReferenceImagesMask[__iCharacterReferenceImagesMask]);
+ __contentCharacterReferenceImagesMask.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ __fileNameCharacterReferenceImagesMask is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(__fileNameCharacterReferenceImagesMask) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentCharacterReferenceImagesMask,
+ name: "\"character_reference_images_mask\"",
+ fileName: $"\"{__fileNameCharacterReferenceImagesMask}\"");
+ if (__contentCharacterReferenceImagesMask.Headers.ContentDisposition != null)
+ {
+ __contentCharacterReferenceImagesMask.Headers.ContentDisposition.FileNameStar = null;
+ }
+ }
+
+ }
+
+ __httpRequest.Content = __httpRequestContent;
+
+ global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PreparePostInpaintImageV3Request(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
+
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostInpaintImageV3",
+ methodName: "PostInpaintImageV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/inpaint\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ catch (global::System.Net.Http.HttpRequestException __exception)
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostInpaintImageV3",
+ methodName: "PostInpaintImageV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/inpaint\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostInpaintImageV3",
+ methodName: "PostInpaintImageV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/inpaint\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessPostInpaintImageV3Response(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostInpaintImageV3",
+ methodName: "PostInpaintImageV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/inpaint\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostInpaintImageV3",
+ methodName: "PostInpaintImageV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/inpaint\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ //
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ responseBody: __content_401,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ // Prompt or Initial Image failed the safety checks.
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Ideogram.GenerateImageSafetyError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ responseBody: __content_422,
+ responseObject: __value_422,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ responseBody: __content_429,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessPostInpaintImageV3ResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ var __value = global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ var __value = await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
+ }
}
}
\ No newline at end of file
diff --git a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostLayerizeDesignV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostLayerizeDesignV3.g.cs
index 02f4868..56c4c09 100644
--- a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostLayerizeDesignV3.g.cs
+++ b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostLayerizeDesignV3.g.cs
@@ -54,6 +54,32 @@ partial void ProcessPostLayerizeDesignV3ResponseContent(
///
public async global::System.Threading.Tasks.Task PostLayerizeDesignV3Async(
+ global::Ideogram.LayerizeDesignRequestV3 request,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await PostLayerizeDesignV3AsResponseAsync(
+
+ request: request,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// Layerize an existing flat graphic image with text detection and correction
+ /// Processes an existing flat graphic image to detect and correct text layers without generating a new image from scratch.
+ /// The uploaded image is analyzed for text content, which is then removed and returned as structured text layers with font matching, sizing, and color information.
+ /// Supported image formats include JPEG, PNG, and WebP (max size 10MB).
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it.
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> PostLayerizeDesignV3AsResponseAsync(
+
global::Ideogram.LayerizeDesignRequestV3 request,
global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
@@ -84,10 +110,11 @@ partial void ProcessPostLayerizeDesignV3ResponseContent(
var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts(
clientOptions: Options,
requestOptions: requestOptions,
- supportsRetry: true);
+ supportsRetry: false);
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Ideogram.PathBuilder(
path: "/v1/ideogram-v3/layerize-design",
baseUri: HttpClient.BaseAddress);
@@ -120,6 +147,7 @@ partial void ProcessPostLayerizeDesignV3ResponseContent(
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
}
}
+
var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
var __contentFlatGraphicImage = new global::System.Net.Http.ByteArrayContent(request.FlatGraphicImage ?? global::System.Array.Empty());
__contentFlatGraphicImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
@@ -158,20 +186,23 @@ request.FlatGraphicImagename is null
{
__contentFlatGraphicImage.Headers.ContentDisposition.FileNameStar = null;
}
+
if (request.Prompt != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty),
name: "\"prompt\"");
- }
+
+ }
if (request.Seed != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
name: "\"seed\"");
- }
+
+ }
if (request.FontFileH1 != default)
{
@@ -212,14 +243,16 @@ request.FontFileH1name is null
{
__contentFontFileH1.Headers.ContentDisposition.FileNameStar = null;
}
- }
+
+ }
if (request.FontNameH1 != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.FontNameH1 ?? string.Empty),
name: "\"font_name_h1\"");
- }
+
+ }
if (request.FontFileH2 != default)
{
@@ -260,14 +293,16 @@ request.FontFileH2name is null
{
__contentFontFileH2.Headers.ContentDisposition.FileNameStar = null;
}
- }
+
+ }
if (request.FontNameH2 != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.FontNameH2 ?? string.Empty),
name: "\"font_name_h2\"");
- }
+
+ }
if (request.FontFileBody != default)
{
@@ -308,14 +343,16 @@ request.FontFileBodyname is null
{
__contentFontFileBody.Headers.ContentDisposition.FileNameStar = null;
}
- }
+
+ }
if (request.FontNameBody != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.FontNameBody ?? string.Empty),
name: "\"font_name_body\"");
- }
+
+ }
if (request.FontFileSmall != default)
{
@@ -356,14 +393,16 @@ request.FontFileSmallname is null
{
__contentFontFileSmall.Headers.ContentDisposition.FileNameStar = null;
}
- }
+
+ }
if (request.FontNameSmall != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.FontNameSmall ?? string.Empty),
name: "\"font_name_small\"");
- }
+
+ }
if (request.ReferenceAssetImages != default)
{
@@ -380,8 +419,11 @@ request.FontFileSmallname is null
__contentReferenceAssetImages.Headers.ContentDisposition.FileNameStar = null;
}
}
+
}
+
__httpRequest.Content = __httpRequestContent;
+
global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders(
request: __httpRequest,
clientHeaders: Options.Headers,
@@ -423,6 +465,8 @@ request.FontFileSmallname is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -433,6 +477,11 @@ request.FontFileSmallname is null
}
catch (global::System.Net.Http.HttpRequestException __exception)
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
@@ -450,6 +499,8 @@ request.FontFileSmallname is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -459,8 +510,7 @@ request.FontFileSmallname is null
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -469,6 +519,11 @@ request.FontFileSmallname is null
__attempt < __maxAttempts &&
global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
@@ -485,14 +540,15 @@ request.FontFileSmallname is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
__response.Dispose();
__response = null;
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -532,6 +588,8 @@ request.FontFileSmallname is null
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -552,6 +610,8 @@ request.FontFileSmallname is null
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
//
@@ -575,17 +635,16 @@ request.FontFileSmallname is null
__exception_400 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_400,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
//
if ((int)__response.StatusCode == 401)
@@ -608,17 +667,16 @@ request.FontFileSmallname is null
__exception_401 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_401,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_401,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_401,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
//
if ((int)__response.StatusCode == 429)
@@ -641,17 +699,16 @@ request.FontFileSmallname is null
__exception_429 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_429,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_429,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_429,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
if (__effectiveReadResponseAsString)
@@ -675,23 +732,25 @@ request.FontFileSmallname is null
{
__response.EnsureSuccessStatusCode();
- return
- global::Ideogram.LayeredImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ??
+ var __value = global::Ideogram.LayeredImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
else
@@ -705,9 +764,13 @@ request.FontFileSmallname is null
#endif
).ConfigureAwait(false);
- return
- await global::Ideogram.LayeredImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ var __value = await global::Ideogram.LayeredImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -724,17 +787,15 @@ request.FontFileSmallname is null
{
}
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
@@ -855,5 +916,1722 @@ request.FontFileSmallname is null
requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
+
+ ///
+ /// Layerize an existing flat graphic image with text detection and correction
+ /// Processes an existing flat graphic image to detect and correct text layers without generating a new image from scratch.
+ /// The uploaded image is analyzed for text content, which is then removed and returned as structured text layers with font matching, sizing, and color information.
+ /// Supported image formats include JPEG, PNG, and WebP (max size 10MB).
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it.
+ ///
+ ///
+ /// The flat graphic image to process for text detection and correction. The image should be in JPEG, PNG or WebP format (max size 10MB).
+ ///
+ ///
+ /// The flat graphic image to process for text detection and correction. The image should be in JPEG, PNG or WebP format (max size 10MB).
+ ///
+ ///
+ /// An optional prompt to describe the image. If not provided, a prompt will be auto-generated from the image via captioning.
+ ///
+ ///
+ /// Random seed. Set for reproducible generation.
+ /// Example: 12345
+ ///
+ ///
+ /// Custom font file for H1 (heading) text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_h1.
+ ///
+ ///
+ /// Custom font file for H1 (heading) text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_h1.
+ ///
+ ///
+ /// Font name from the available font library for H1 text. Ignored if font_file_h1 is provided.
+ /// Example: Ubuntu-Bold.ttf
+ ///
+ ///
+ /// Custom font file for H2 (subheading) text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_h2.
+ ///
+ ///
+ /// Custom font file for H2 (subheading) text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_h2.
+ ///
+ ///
+ /// Font name from the available font library for H2 text. Ignored if font_file_h2 is provided.
+ ///
+ ///
+ /// Custom font file for body text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_body.
+ ///
+ ///
+ /// Custom font file for body text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_body.
+ ///
+ ///
+ /// Font name from the available font library for body text. Ignored if font_file_body is provided.
+ ///
+ ///
+ /// Custom font file for small/caption text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_small.
+ ///
+ ///
+ /// Custom font file for small/caption text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_small.
+ ///
+ ///
+ /// Font name from the available font library for small text. Ignored if font_file_small is provided.
+ ///
+ ///
+ /// A set of asset images (e.g., logos, icons) to use as references for detection and replacement (maximum 10 images). The images should be in JPEG, PNG or WebP format.
+ ///
+ ///
+ /// Optional file names to use for the multipart 'reference_asset_images' file parts.
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task PostLayerizeDesignV3Async(
+ global::System.IO.Stream flatGraphicImage,
+ string flatGraphicImagename,
+ string? prompt = default,
+ int? seed = default,
+ global::System.IO.Stream? fontFileH1 = default,
+ string? fontFileH1name = default,
+ string? fontNameH1 = default,
+ global::System.IO.Stream? fontFileH2 = default,
+ string? fontFileH2name = default,
+ string? fontNameH2 = default,
+ global::System.IO.Stream? fontFileBody = default,
+ string? fontFileBodyname = default,
+ string? fontNameBody = default,
+ global::System.IO.Stream? fontFileSmall = default,
+ string? fontFileSmallname = default,
+ string? fontNameSmall = default,
+ global::System.Collections.Generic.IReadOnlyList? referenceAssetImages = default,
+ global::System.Collections.Generic.IReadOnlyList? referenceAssetImagesFileNames = default,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+
+ flatGraphicImage = flatGraphicImage ?? throw new global::System.ArgumentNullException(nameof(flatGraphicImage));
+ var request = new global::Ideogram.LayerizeDesignRequestV3
+ {
+ FlatGraphicImage = global::System.Array.Empty(),
+ FlatGraphicImagename = flatGraphicImagename,
+ Prompt = prompt,
+ Seed = seed,
+ FontFileH1 = global::System.Array.Empty(),
+ FontFileH1name = fontFileH1name,
+ FontNameH1 = fontNameH1,
+ FontFileH2 = global::System.Array.Empty(),
+ FontFileH2name = fontFileH2name,
+ FontNameH2 = fontNameH2,
+ FontFileBody = global::System.Array.Empty(),
+ FontFileBodyname = fontFileBodyname,
+ FontNameBody = fontNameBody,
+ FontFileSmall = global::System.Array.Empty(),
+ FontFileSmallname = fontFileSmallname,
+ FontNameSmall = fontNameSmall,
+ ReferenceAssetImages = new global::System.Collections.Generic.List(),
+ };
+ PrepareArguments(
+ client: HttpClient);
+ PreparePostLayerizeDesignV3Arguments(
+ httpClient: HttpClient,
+ request: request);
+
+
+ var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations(
+ availableAuthorizations: Authorizations,
+ securityRequirements: s_PostLayerizeDesignV3SecurityRequirements,
+ operationName: "PostLayerizeDesignV3Async");
+
+ using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: false);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+
+ var __pathBuilder = new global::Ideogram.PathBuilder(
+ path: "/v1/ideogram-v3/layerize-design",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+#endif
+
+ foreach (var __authorization in __authorizations)
+ {
+ if (__authorization.Type == "Http" ||
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
+ {
+ __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
+ scheme: __authorization.Name,
+ parameter: __authorization.Value);
+ }
+ else if (__authorization.Type == "ApiKey" &&
+ __authorization.Location == "Header")
+ {
+ __httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
+ }
+ }
+
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ var __contentFlatGraphicImage = new global::System.Net.Http.StreamContent(flatGraphicImage);
+ __contentFlatGraphicImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.FlatGraphicImagename is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.FlatGraphicImagename) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentFlatGraphicImage,
+ name: "\"flat_graphic_image\"",
+ fileName: request.FlatGraphicImagename != null ? $"\"{request.FlatGraphicImagename}\"" : string.Empty);
+ if (__contentFlatGraphicImage.Headers.ContentDisposition != null)
+ {
+ __contentFlatGraphicImage.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ if (request.Prompt != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty),
+ name: "\"prompt\"");
+
+ }
+ if (request.Seed != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"seed\"");
+
+ }
+ if (fontFileH1 != default)
+ {
+
+ var __contentFontFileH1 = new global::System.Net.Http.StreamContent(fontFileH1);
+ __contentFontFileH1.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.FontFileH1name is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.FontFileH1name) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentFontFileH1,
+ name: "\"font_file_h1\"",
+ fileName: request.FontFileH1name != null ? $"\"{request.FontFileH1name}\"" : string.Empty);
+ if (__contentFontFileH1.Headers.ContentDisposition != null)
+ {
+ __contentFontFileH1.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ }
+ if (request.FontNameH1 != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.FontNameH1 ?? string.Empty),
+ name: "\"font_name_h1\"");
+
+ }
+ if (fontFileH2 != default)
+ {
+
+ var __contentFontFileH2 = new global::System.Net.Http.StreamContent(fontFileH2);
+ __contentFontFileH2.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.FontFileH2name is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.FontFileH2name) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentFontFileH2,
+ name: "\"font_file_h2\"",
+ fileName: request.FontFileH2name != null ? $"\"{request.FontFileH2name}\"" : string.Empty);
+ if (__contentFontFileH2.Headers.ContentDisposition != null)
+ {
+ __contentFontFileH2.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ }
+ if (request.FontNameH2 != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.FontNameH2 ?? string.Empty),
+ name: "\"font_name_h2\"");
+
+ }
+ if (fontFileBody != default)
+ {
+
+ var __contentFontFileBody = new global::System.Net.Http.StreamContent(fontFileBody);
+ __contentFontFileBody.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.FontFileBodyname is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.FontFileBodyname) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentFontFileBody,
+ name: "\"font_file_body\"",
+ fileName: request.FontFileBodyname != null ? $"\"{request.FontFileBodyname}\"" : string.Empty);
+ if (__contentFontFileBody.Headers.ContentDisposition != null)
+ {
+ __contentFontFileBody.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ }
+ if (request.FontNameBody != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.FontNameBody ?? string.Empty),
+ name: "\"font_name_body\"");
+
+ }
+ if (fontFileSmall != default)
+ {
+
+ var __contentFontFileSmall = new global::System.Net.Http.StreamContent(fontFileSmall);
+ __contentFontFileSmall.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.FontFileSmallname is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.FontFileSmallname) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentFontFileSmall,
+ name: "\"font_file_small\"",
+ fileName: request.FontFileSmallname != null ? $"\"{request.FontFileSmallname}\"" : string.Empty);
+ if (__contentFontFileSmall.Headers.ContentDisposition != null)
+ {
+ __contentFontFileSmall.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ }
+ if (request.FontNameSmall != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.FontNameSmall ?? string.Empty),
+ name: "\"font_name_small\"");
+
+ }
+ if (referenceAssetImages != default)
+ {
+
+ for (var __iReferenceAssetImages = 0; __iReferenceAssetImages < referenceAssetImages.Count; __iReferenceAssetImages++)
+ {
+ var __fileNameReferenceAssetImages = referenceAssetImagesFileNames != null &&
+ __iReferenceAssetImages < referenceAssetImagesFileNames.Count &&
+ referenceAssetImagesFileNames[__iReferenceAssetImages] != null
+ ? referenceAssetImagesFileNames[__iReferenceAssetImages]
+ : $"file{__iReferenceAssetImages}.bin";
+ var __contentReferenceAssetImages = new global::System.Net.Http.StreamContent(referenceAssetImages[__iReferenceAssetImages]);
+ __contentReferenceAssetImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ __fileNameReferenceAssetImages is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(__fileNameReferenceAssetImages) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentReferenceAssetImages,
+ name: "\"reference_asset_images\"",
+ fileName: $"\"{__fileNameReferenceAssetImages}\"");
+ if (__contentReferenceAssetImages.Headers.ContentDisposition != null)
+ {
+ __contentReferenceAssetImages.Headers.ContentDisposition.FileNameStar = null;
+ }
+ }
+
+ }
+
+ __httpRequest.Content = __httpRequestContent;
+
+ global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PreparePostLayerizeDesignV3Request(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
+
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostLayerizeDesignV3",
+ methodName: "PostLayerizeDesignV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/layerize-design\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ catch (global::System.Net.Http.HttpRequestException __exception)
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostLayerizeDesignV3",
+ methodName: "PostLayerizeDesignV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/layerize-design\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostLayerizeDesignV3",
+ methodName: "PostLayerizeDesignV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/layerize-design\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessPostLayerizeDesignV3Response(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostLayerizeDesignV3",
+ methodName: "PostLayerizeDesignV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/layerize-design\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostLayerizeDesignV3",
+ methodName: "PostLayerizeDesignV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/layerize-design\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ //
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ responseBody: __content_401,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ responseBody: __content_429,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessPostLayerizeDesignV3ResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Ideogram.LayeredImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Ideogram.LayeredImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
+ }
+ ///
+ /// Layerize an existing flat graphic image with text detection and correction
+ /// Processes an existing flat graphic image to detect and correct text layers without generating a new image from scratch.
+ /// The uploaded image is analyzed for text content, which is then removed and returned as structured text layers with font matching, sizing, and color information.
+ /// Supported image formats include JPEG, PNG, and WebP (max size 10MB).
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it.
+ ///
+ ///
+ /// The flat graphic image to process for text detection and correction. The image should be in JPEG, PNG or WebP format (max size 10MB).
+ ///
+ ///
+ /// The flat graphic image to process for text detection and correction. The image should be in JPEG, PNG or WebP format (max size 10MB).
+ ///
+ ///
+ /// An optional prompt to describe the image. If not provided, a prompt will be auto-generated from the image via captioning.
+ ///
+ ///
+ /// Random seed. Set for reproducible generation.
+ /// Example: 12345
+ ///
+ ///
+ /// Custom font file for H1 (heading) text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_h1.
+ ///
+ ///
+ /// Custom font file for H1 (heading) text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_h1.
+ ///
+ ///
+ /// Font name from the available font library for H1 text. Ignored if font_file_h1 is provided.
+ /// Example: Ubuntu-Bold.ttf
+ ///
+ ///
+ /// Custom font file for H2 (subheading) text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_h2.
+ ///
+ ///
+ /// Custom font file for H2 (subheading) text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_h2.
+ ///
+ ///
+ /// Font name from the available font library for H2 text. Ignored if font_file_h2 is provided.
+ ///
+ ///
+ /// Custom font file for body text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_body.
+ ///
+ ///
+ /// Custom font file for body text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_body.
+ ///
+ ///
+ /// Font name from the available font library for body text. Ignored if font_file_body is provided.
+ ///
+ ///
+ /// Custom font file for small/caption text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_small.
+ ///
+ ///
+ /// Custom font file for small/caption text. Supported formats .ttf, .otf, .woff, .woff2 (max 5MB). Takes priority over font_name_small.
+ ///
+ ///
+ /// Font name from the available font library for small text. Ignored if font_file_small is provided.
+ ///
+ ///
+ /// A set of asset images (e.g., logos, icons) to use as references for detection and replacement (maximum 10 images). The images should be in JPEG, PNG or WebP format.
+ ///
+ ///
+ /// Optional file names to use for the multipart 'reference_asset_images' file parts.
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> PostLayerizeDesignV3AsResponseAsync(
+ global::System.IO.Stream flatGraphicImage,
+ string flatGraphicImagename,
+ string? prompt = default,
+ int? seed = default,
+ global::System.IO.Stream? fontFileH1 = default,
+ string? fontFileH1name = default,
+ string? fontNameH1 = default,
+ global::System.IO.Stream? fontFileH2 = default,
+ string? fontFileH2name = default,
+ string? fontNameH2 = default,
+ global::System.IO.Stream? fontFileBody = default,
+ string? fontFileBodyname = default,
+ string? fontNameBody = default,
+ global::System.IO.Stream? fontFileSmall = default,
+ string? fontFileSmallname = default,
+ string? fontNameSmall = default,
+ global::System.Collections.Generic.IReadOnlyList? referenceAssetImages = default,
+ global::System.Collections.Generic.IReadOnlyList? referenceAssetImagesFileNames = default,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+
+ flatGraphicImage = flatGraphicImage ?? throw new global::System.ArgumentNullException(nameof(flatGraphicImage));
+ var request = new global::Ideogram.LayerizeDesignRequestV3
+ {
+ FlatGraphicImage = global::System.Array.Empty(),
+ FlatGraphicImagename = flatGraphicImagename,
+ Prompt = prompt,
+ Seed = seed,
+ FontFileH1 = global::System.Array.Empty(),
+ FontFileH1name = fontFileH1name,
+ FontNameH1 = fontNameH1,
+ FontFileH2 = global::System.Array.Empty(),
+ FontFileH2name = fontFileH2name,
+ FontNameH2 = fontNameH2,
+ FontFileBody = global::System.Array.Empty(),
+ FontFileBodyname = fontFileBodyname,
+ FontNameBody = fontNameBody,
+ FontFileSmall = global::System.Array.Empty(),
+ FontFileSmallname = fontFileSmallname,
+ FontNameSmall = fontNameSmall,
+ ReferenceAssetImages = new global::System.Collections.Generic.List(),
+ };
+ PrepareArguments(
+ client: HttpClient);
+ PreparePostLayerizeDesignV3Arguments(
+ httpClient: HttpClient,
+ request: request);
+
+
+ var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations(
+ availableAuthorizations: Authorizations,
+ securityRequirements: s_PostLayerizeDesignV3SecurityRequirements,
+ operationName: "PostLayerizeDesignV3Async");
+
+ using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: false);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+
+ var __pathBuilder = new global::Ideogram.PathBuilder(
+ path: "/v1/ideogram-v3/layerize-design",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+#endif
+
+ foreach (var __authorization in __authorizations)
+ {
+ if (__authorization.Type == "Http" ||
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
+ {
+ __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
+ scheme: __authorization.Name,
+ parameter: __authorization.Value);
+ }
+ else if (__authorization.Type == "ApiKey" &&
+ __authorization.Location == "Header")
+ {
+ __httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
+ }
+ }
+
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ var __contentFlatGraphicImage = new global::System.Net.Http.StreamContent(flatGraphicImage);
+ __contentFlatGraphicImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.FlatGraphicImagename is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.FlatGraphicImagename) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentFlatGraphicImage,
+ name: "\"flat_graphic_image\"",
+ fileName: request.FlatGraphicImagename != null ? $"\"{request.FlatGraphicImagename}\"" : string.Empty);
+ if (__contentFlatGraphicImage.Headers.ContentDisposition != null)
+ {
+ __contentFlatGraphicImage.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ if (request.Prompt != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty),
+ name: "\"prompt\"");
+
+ }
+ if (request.Seed != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"seed\"");
+
+ }
+ if (fontFileH1 != default)
+ {
+
+ var __contentFontFileH1 = new global::System.Net.Http.StreamContent(fontFileH1);
+ __contentFontFileH1.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.FontFileH1name is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.FontFileH1name) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentFontFileH1,
+ name: "\"font_file_h1\"",
+ fileName: request.FontFileH1name != null ? $"\"{request.FontFileH1name}\"" : string.Empty);
+ if (__contentFontFileH1.Headers.ContentDisposition != null)
+ {
+ __contentFontFileH1.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ }
+ if (request.FontNameH1 != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.FontNameH1 ?? string.Empty),
+ name: "\"font_name_h1\"");
+
+ }
+ if (fontFileH2 != default)
+ {
+
+ var __contentFontFileH2 = new global::System.Net.Http.StreamContent(fontFileH2);
+ __contentFontFileH2.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.FontFileH2name is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.FontFileH2name) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentFontFileH2,
+ name: "\"font_file_h2\"",
+ fileName: request.FontFileH2name != null ? $"\"{request.FontFileH2name}\"" : string.Empty);
+ if (__contentFontFileH2.Headers.ContentDisposition != null)
+ {
+ __contentFontFileH2.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ }
+ if (request.FontNameH2 != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.FontNameH2 ?? string.Empty),
+ name: "\"font_name_h2\"");
+
+ }
+ if (fontFileBody != default)
+ {
+
+ var __contentFontFileBody = new global::System.Net.Http.StreamContent(fontFileBody);
+ __contentFontFileBody.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.FontFileBodyname is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.FontFileBodyname) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentFontFileBody,
+ name: "\"font_file_body\"",
+ fileName: request.FontFileBodyname != null ? $"\"{request.FontFileBodyname}\"" : string.Empty);
+ if (__contentFontFileBody.Headers.ContentDisposition != null)
+ {
+ __contentFontFileBody.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ }
+ if (request.FontNameBody != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.FontNameBody ?? string.Empty),
+ name: "\"font_name_body\"");
+
+ }
+ if (fontFileSmall != default)
+ {
+
+ var __contentFontFileSmall = new global::System.Net.Http.StreamContent(fontFileSmall);
+ __contentFontFileSmall.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.FontFileSmallname is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.FontFileSmallname) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentFontFileSmall,
+ name: "\"font_file_small\"",
+ fileName: request.FontFileSmallname != null ? $"\"{request.FontFileSmallname}\"" : string.Empty);
+ if (__contentFontFileSmall.Headers.ContentDisposition != null)
+ {
+ __contentFontFileSmall.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ }
+ if (request.FontNameSmall != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.FontNameSmall ?? string.Empty),
+ name: "\"font_name_small\"");
+
+ }
+ if (referenceAssetImages != default)
+ {
+
+ for (var __iReferenceAssetImages = 0; __iReferenceAssetImages < referenceAssetImages.Count; __iReferenceAssetImages++)
+ {
+ var __fileNameReferenceAssetImages = referenceAssetImagesFileNames != null &&
+ __iReferenceAssetImages < referenceAssetImagesFileNames.Count &&
+ referenceAssetImagesFileNames[__iReferenceAssetImages] != null
+ ? referenceAssetImagesFileNames[__iReferenceAssetImages]
+ : $"file{__iReferenceAssetImages}.bin";
+ var __contentReferenceAssetImages = new global::System.Net.Http.StreamContent(referenceAssetImages[__iReferenceAssetImages]);
+ __contentReferenceAssetImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ __fileNameReferenceAssetImages is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(__fileNameReferenceAssetImages) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentReferenceAssetImages,
+ name: "\"reference_asset_images\"",
+ fileName: $"\"{__fileNameReferenceAssetImages}\"");
+ if (__contentReferenceAssetImages.Headers.ContentDisposition != null)
+ {
+ __contentReferenceAssetImages.Headers.ContentDisposition.FileNameStar = null;
+ }
+ }
+
+ }
+
+ __httpRequest.Content = __httpRequestContent;
+
+ global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PreparePostLayerizeDesignV3Request(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
+
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostLayerizeDesignV3",
+ methodName: "PostLayerizeDesignV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/layerize-design\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ catch (global::System.Net.Http.HttpRequestException __exception)
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostLayerizeDesignV3",
+ methodName: "PostLayerizeDesignV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/layerize-design\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostLayerizeDesignV3",
+ methodName: "PostLayerizeDesignV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/layerize-design\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessPostLayerizeDesignV3Response(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostLayerizeDesignV3",
+ methodName: "PostLayerizeDesignV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/layerize-design\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostLayerizeDesignV3",
+ methodName: "PostLayerizeDesignV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/layerize-design\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ //
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ responseBody: __content_401,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ responseBody: __content_429,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessPostLayerizeDesignV3ResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ var __value = global::Ideogram.LayeredImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ var __value = await global::Ideogram.LayeredImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
+ }
}
}
\ No newline at end of file
diff --git a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostLayerizeTextV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostLayerizeTextV3.g.cs
index 43359a9..ddef91e 100644
--- a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostLayerizeTextV3.g.cs
+++ b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostLayerizeTextV3.g.cs
@@ -54,6 +54,32 @@ partial void ProcessPostLayerizeTextV3ResponseContent(
///
public async global::System.Threading.Tasks.Task PostLayerizeTextV3Async(
+ global::Ideogram.LayerizeTextRequest request,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await PostLayerizeTextV3AsResponseAsync(
+
+ request: request,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// Layerize Text
+ /// Analyzes an image to detect text regions, then returns each detected text block with its position, content, font information, and styling.
+ /// The response includes a text-erased base image (background with all text removed) and a flat list of detected text blocks.
+ /// Supported image formats include JPEG, PNG, and WebP (max size 10MB).
+ /// Image links are available for a limited period of time; if you would like to keep the image, you must download it.
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> PostLayerizeTextV3AsResponseAsync(
+
global::Ideogram.LayerizeTextRequest request,
global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
@@ -84,10 +110,11 @@ partial void ProcessPostLayerizeTextV3ResponseContent(
var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts(
clientOptions: Options,
requestOptions: requestOptions,
- supportsRetry: true);
+ supportsRetry: false);
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Ideogram.PathBuilder(
path: "/v1/ideogram-v3/layerize-text",
baseUri: HttpClient.BaseAddress);
@@ -120,6 +147,7 @@ partial void ProcessPostLayerizeTextV3ResponseContent(
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
}
}
+
var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
var __contentImage = new global::System.Net.Http.ByteArrayContent(request.Image ?? global::System.Array.Empty());
__contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
@@ -158,21 +186,26 @@ request.Imagename is null
{
__contentImage.Headers.ContentDisposition.FileNameStar = null;
}
+
if (request.Prompt != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty),
name: "\"prompt\"");
- }
+
+ }
if (request.Seed != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
name: "\"seed\"");
+
}
+
__httpRequest.Content = __httpRequestContent;
+
global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders(
request: __httpRequest,
clientHeaders: Options.Headers,
@@ -214,6 +247,8 @@ request.Imagename is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -224,6 +259,11 @@ request.Imagename is null
}
catch (global::System.Net.Http.HttpRequestException __exception)
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
@@ -241,6 +281,8 @@ request.Imagename is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -250,8 +292,7 @@ request.Imagename is null
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -260,6 +301,11 @@ request.Imagename is null
__attempt < __maxAttempts &&
global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
@@ -276,14 +322,15 @@ request.Imagename is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
__response.Dispose();
__response = null;
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -323,6 +370,8 @@ request.Imagename is null
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -343,6 +392,8 @@ request.Imagename is null
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
//
@@ -366,17 +417,16 @@ request.Imagename is null
__exception_400 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_400,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
//
if ((int)__response.StatusCode == 401)
@@ -399,17 +449,16 @@ request.Imagename is null
__exception_401 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_401,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_401,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_401,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
//
if ((int)__response.StatusCode == 429)
@@ -432,17 +481,16 @@ request.Imagename is null
__exception_429 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_429,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_429,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_429,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
if (__effectiveReadResponseAsString)
@@ -466,23 +514,25 @@ request.Imagename is null
{
__response.EnsureSuccessStatusCode();
- return
- global::Ideogram.LayerizeTextResponse.FromJson(__content, JsonSerializerContext) ??
+ var __value = global::Ideogram.LayerizeTextResponse.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
else
@@ -496,9 +546,13 @@ request.Imagename is null
#endif
).ConfigureAwait(false);
- return
- await global::Ideogram.LayerizeTextResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ var __value = await global::Ideogram.LayerizeTextResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -515,17 +569,15 @@ request.Imagename is null
{
}
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
@@ -580,5 +632,1082 @@ request.Imagename is null
requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
+
+ ///
+ /// Layerize Text
+ /// Analyzes an image to detect text regions, then returns each detected text block with its position, content, font information, and styling.
+ /// The response includes a text-erased base image (background with all text removed) and a flat list of detected text blocks.
+ /// Supported image formats include JPEG, PNG, and WebP (max size 10MB).
+ /// Image links are available for a limited period of time; if you would like to keep the image, you must download it.
+ ///
+ ///
+ /// The image to analyze for text detection. The image should be in JPEG, PNG, or WebP format (max size 10MB).
+ ///
+ ///
+ /// The image to analyze for text detection. The image should be in JPEG, PNG, or WebP format (max size 10MB).
+ ///
+ ///
+ /// An optional text description of the image. If not provided, a description will be auto-generated from the image.
+ ///
+ ///
+ /// Random seed. Set for reproducible generation.
+ /// Example: 12345
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task PostLayerizeTextV3Async(
+ global::System.IO.Stream image,
+ string imagename,
+ string? prompt = default,
+ int? seed = default,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+
+ image = image ?? throw new global::System.ArgumentNullException(nameof(image));
+ var request = new global::Ideogram.LayerizeTextRequest
+ {
+ Image = global::System.Array.Empty(),
+ Imagename = imagename,
+ Prompt = prompt,
+ Seed = seed,
+ };
+ PrepareArguments(
+ client: HttpClient);
+ PreparePostLayerizeTextV3Arguments(
+ httpClient: HttpClient,
+ request: request);
+
+
+ var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations(
+ availableAuthorizations: Authorizations,
+ securityRequirements: s_PostLayerizeTextV3SecurityRequirements,
+ operationName: "PostLayerizeTextV3Async");
+
+ using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: false);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+
+ var __pathBuilder = new global::Ideogram.PathBuilder(
+ path: "/v1/ideogram-v3/layerize-text",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+#endif
+
+ foreach (var __authorization in __authorizations)
+ {
+ if (__authorization.Type == "Http" ||
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
+ {
+ __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
+ scheme: __authorization.Name,
+ parameter: __authorization.Value);
+ }
+ else if (__authorization.Type == "ApiKey" &&
+ __authorization.Location == "Header")
+ {
+ __httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
+ }
+ }
+
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ var __contentImage = new global::System.Net.Http.StreamContent(image);
+ __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.Imagename is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentImage,
+ name: "\"image\"",
+ fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty);
+ if (__contentImage.Headers.ContentDisposition != null)
+ {
+ __contentImage.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ if (request.Prompt != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty),
+ name: "\"prompt\"");
+
+ }
+ if (request.Seed != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"seed\"");
+
+ }
+
+ __httpRequest.Content = __httpRequestContent;
+
+ global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PreparePostLayerizeTextV3Request(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
+
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostLayerizeTextV3",
+ methodName: "PostLayerizeTextV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/layerize-text\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ catch (global::System.Net.Http.HttpRequestException __exception)
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostLayerizeTextV3",
+ methodName: "PostLayerizeTextV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/layerize-text\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostLayerizeTextV3",
+ methodName: "PostLayerizeTextV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/layerize-text\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessPostLayerizeTextV3Response(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostLayerizeTextV3",
+ methodName: "PostLayerizeTextV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/layerize-text\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostLayerizeTextV3",
+ methodName: "PostLayerizeTextV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/layerize-text\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ //
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ responseBody: __content_401,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ responseBody: __content_429,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessPostLayerizeTextV3ResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Ideogram.LayerizeTextResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Ideogram.LayerizeTextResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
+ }
+ ///
+ /// Layerize Text
+ /// Analyzes an image to detect text regions, then returns each detected text block with its position, content, font information, and styling.
+ /// The response includes a text-erased base image (background with all text removed) and a flat list of detected text blocks.
+ /// Supported image formats include JPEG, PNG, and WebP (max size 10MB).
+ /// Image links are available for a limited period of time; if you would like to keep the image, you must download it.
+ ///
+ ///
+ /// The image to analyze for text detection. The image should be in JPEG, PNG, or WebP format (max size 10MB).
+ ///
+ ///
+ /// The image to analyze for text detection. The image should be in JPEG, PNG, or WebP format (max size 10MB).
+ ///
+ ///
+ /// An optional text description of the image. If not provided, a description will be auto-generated from the image.
+ ///
+ ///
+ /// Random seed. Set for reproducible generation.
+ /// Example: 12345
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> PostLayerizeTextV3AsResponseAsync(
+ global::System.IO.Stream image,
+ string imagename,
+ string? prompt = default,
+ int? seed = default,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+
+ image = image ?? throw new global::System.ArgumentNullException(nameof(image));
+ var request = new global::Ideogram.LayerizeTextRequest
+ {
+ Image = global::System.Array.Empty(),
+ Imagename = imagename,
+ Prompt = prompt,
+ Seed = seed,
+ };
+ PrepareArguments(
+ client: HttpClient);
+ PreparePostLayerizeTextV3Arguments(
+ httpClient: HttpClient,
+ request: request);
+
+
+ var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations(
+ availableAuthorizations: Authorizations,
+ securityRequirements: s_PostLayerizeTextV3SecurityRequirements,
+ operationName: "PostLayerizeTextV3Async");
+
+ using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: false);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+
+ var __pathBuilder = new global::Ideogram.PathBuilder(
+ path: "/v1/ideogram-v3/layerize-text",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+#endif
+
+ foreach (var __authorization in __authorizations)
+ {
+ if (__authorization.Type == "Http" ||
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
+ {
+ __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
+ scheme: __authorization.Name,
+ parameter: __authorization.Value);
+ }
+ else if (__authorization.Type == "ApiKey" &&
+ __authorization.Location == "Header")
+ {
+ __httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
+ }
+ }
+
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ var __contentImage = new global::System.Net.Http.StreamContent(image);
+ __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.Imagename is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentImage,
+ name: "\"image\"",
+ fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty);
+ if (__contentImage.Headers.ContentDisposition != null)
+ {
+ __contentImage.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ if (request.Prompt != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty),
+ name: "\"prompt\"");
+
+ }
+ if (request.Seed != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"seed\"");
+
+ }
+
+ __httpRequest.Content = __httpRequestContent;
+
+ global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PreparePostLayerizeTextV3Request(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
+
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostLayerizeTextV3",
+ methodName: "PostLayerizeTextV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/layerize-text\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ catch (global::System.Net.Http.HttpRequestException __exception)
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostLayerizeTextV3",
+ methodName: "PostLayerizeTextV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/layerize-text\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostLayerizeTextV3",
+ methodName: "PostLayerizeTextV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/layerize-text\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessPostLayerizeTextV3Response(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostLayerizeTextV3",
+ methodName: "PostLayerizeTextV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/layerize-text\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostLayerizeTextV3",
+ methodName: "PostLayerizeTextV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/layerize-text\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ //
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ responseBody: __content_401,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ responseBody: __content_429,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessPostLayerizeTextV3ResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ var __value = global::Ideogram.LayerizeTextResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ var __value = await global::Ideogram.LayerizeTextResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
+ }
}
}
\ No newline at end of file
diff --git a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostReframeImage.g.cs b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostReframeImage.g.cs
index 41aeea2..98fd7a4 100644
--- a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostReframeImage.g.cs
+++ b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostReframeImage.g.cs
@@ -52,6 +52,30 @@ partial void ProcessPostReframeImageResponseContent(
///
public async global::System.Threading.Tasks.Task PostReframeImageAsync(
+ global::Ideogram.ReframeImageRequest request,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await PostReframeImageAsResponseAsync(
+
+ request: request,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// Reframe (legacy)
+ /// Reframe a square image to a chosen resolution. The supported image formats include JPEG, PNG, and WebP.
+ /// Image links are available for a limited period of time; if you would like to keep the image, you must download it.
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> PostReframeImageAsResponseAsync(
+
global::Ideogram.ReframeImageRequest request,
global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
@@ -82,10 +106,11 @@ partial void ProcessPostReframeImageResponseContent(
var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts(
clientOptions: Options,
requestOptions: requestOptions,
- supportsRetry: true);
+ supportsRetry: false);
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Ideogram.PathBuilder(
path: "/reframe",
baseUri: HttpClient.BaseAddress);
@@ -118,6 +143,7 @@ partial void ProcessPostReframeImageResponseContent(
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
}
}
+
var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
var __contentImageFile = new global::System.Net.Http.ByteArrayContent(request.ImageFile ?? global::System.Array.Empty());
__contentImageFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
@@ -156,34 +182,42 @@ request.ImageFilename is null
{
__contentImageFile.Headers.ContentDisposition.FileNameStar = null;
}
+
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.Resolution.ToValueString()),
name: "\"resolution\"");
+
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.Model.ToValueString()),
name: "\"model\"");
+
if (request.NumImages != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
name: "\"num_images\"");
- }
+
+ }
if (request.Seed != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
name: "\"seed\"");
- }
+
+ }
if (request.StyleType != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.StyleType).HasValue ? (request.StyleType).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"style_type\"");
+
}
+
__httpRequest.Content = __httpRequestContent;
+
global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders(
request: __httpRequest,
clientHeaders: Options.Headers,
@@ -225,6 +259,8 @@ request.ImageFilename is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -235,6 +271,11 @@ request.ImageFilename is null
}
catch (global::System.Net.Http.HttpRequestException __exception)
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
@@ -252,6 +293,8 @@ request.ImageFilename is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -261,8 +304,7 @@ request.ImageFilename is null
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -271,6 +313,11 @@ request.ImageFilename is null
__attempt < __maxAttempts &&
global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
@@ -287,14 +334,15 @@ request.ImageFilename is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
__response.Dispose();
__response = null;
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -334,6 +382,8 @@ request.ImageFilename is null
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -354,6 +404,8 @@ request.ImageFilename is null
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
//
@@ -377,17 +429,16 @@ request.ImageFilename is null
__exception_400 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_400,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
//
if ((int)__response.StatusCode == 401)
@@ -410,17 +461,16 @@ request.ImageFilename is null
__exception_401 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_401,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_401,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_401,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
// Prompt or Image failed the safety checks.
if ((int)__response.StatusCode == 422)
@@ -447,18 +497,17 @@ request.ImageFilename is null
__exception_422 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_422,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_422,
+ responseObject: __value_422,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
//
if ((int)__response.StatusCode == 429)
@@ -481,17 +530,16 @@ request.ImageFilename is null
__exception_429 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_429,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_429,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_429,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
if (__effectiveReadResponseAsString)
@@ -515,23 +563,25 @@ request.ImageFilename is null
{
__response.EnsureSuccessStatusCode();
- return
- global::Ideogram.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ??
+ var __value = global::Ideogram.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
else
@@ -545,9 +595,13 @@ request.ImageFilename is null
#endif
).ConfigureAwait(false);
- return
- await global::Ideogram.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ var __value = await global::Ideogram.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -564,17 +618,15 @@ request.ImageFilename is null
{
}
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
@@ -647,5 +699,1224 @@ request.ImageFilename is null
requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
+
+ ///
+ /// Reframe (legacy)
+ /// Reframe a square image to a chosen resolution. The supported image formats include JPEG, PNG, and WebP.
+ /// Image links are available for a limited period of time; if you would like to keep the image, you must download it.
+ ///
+ ///
+ /// The image being reframed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ ///
+ /// The image being reframed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ ///
+ /// (For model_version for 2.0 only, cannot be used in conjunction with aspect_ratio) The resolution to use for image generation, represented in width x height. If not specified, defaults to using aspect_ratio.
+ /// Example: RESOLUTION_1024_1024
+ ///
+ ///
+ /// The model used to generate an image or edit one. /generate and /remix supports all model types, however, /edit is only supported for V_2 and V_2_TURBO.
+ /// Default Value: V_2
+ /// Example: V_2_TURBO
+ ///
+ ///
+ /// The number of images to generate.
+ /// Default Value: 1
+ ///
+ ///
+ /// Random seed. Set for reproducible generation.
+ /// Example: 12345
+ ///
+ ///
+ /// The style type to generate with; this is only applicable for models V_2 and above and should not be specified for model versions V_1.
+ /// Example: REALISTIC
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task PostReframeImageAsync(
+ global::System.IO.Stream imageFile,
+ string imageFilename,
+ global::Ideogram.Resolution resolution,
+ global::Ideogram.ModelEnum model = global::Ideogram.ModelEnum.V2,
+ int? numImages = default,
+ int? seed = default,
+ global::Ideogram.StyleType? styleType = default,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+
+ imageFile = imageFile ?? throw new global::System.ArgumentNullException(nameof(imageFile));
+ var request = new global::Ideogram.ReframeImageRequest
+ {
+ ImageFile = global::System.Array.Empty(),
+ ImageFilename = imageFilename,
+ Resolution = resolution,
+ Model = model,
+ NumImages = numImages,
+ Seed = seed,
+ StyleType = styleType,
+ };
+ PrepareArguments(
+ client: HttpClient);
+ PreparePostReframeImageArguments(
+ httpClient: HttpClient,
+ request: request);
+
+
+ var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations(
+ availableAuthorizations: Authorizations,
+ securityRequirements: s_PostReframeImageSecurityRequirements,
+ operationName: "PostReframeImageAsync");
+
+ using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: false);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+
+ var __pathBuilder = new global::Ideogram.PathBuilder(
+ path: "/reframe",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+#endif
+
+ foreach (var __authorization in __authorizations)
+ {
+ if (__authorization.Type == "Http" ||
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
+ {
+ __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
+ scheme: __authorization.Name,
+ parameter: __authorization.Value);
+ }
+ else if (__authorization.Type == "ApiKey" &&
+ __authorization.Location == "Header")
+ {
+ __httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
+ }
+ }
+
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ var __contentImageFile = new global::System.Net.Http.StreamContent(imageFile);
+ __contentImageFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.ImageFilename is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.ImageFilename) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentImageFile,
+ name: "\"image_file\"",
+ fileName: request.ImageFilename != null ? $"\"{request.ImageFilename}\"" : string.Empty);
+ if (__contentImageFile.Headers.ContentDisposition != null)
+ {
+ __contentImageFile.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Resolution.ToValueString()),
+ name: "\"resolution\"");
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Model.ToValueString()),
+ name: "\"model\"");
+
+ if (request.NumImages != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"num_images\"");
+
+ }
+ if (request.Seed != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"seed\"");
+
+ }
+ if (request.StyleType != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.StyleType).HasValue ? (request.StyleType).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"style_type\"");
+
+ }
+
+ __httpRequest.Content = __httpRequestContent;
+
+ global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PreparePostReframeImageRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
+
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostReframeImage",
+ methodName: "PostReframeImageAsync",
+ pathTemplate: "\"/reframe\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ catch (global::System.Net.Http.HttpRequestException __exception)
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostReframeImage",
+ methodName: "PostReframeImageAsync",
+ pathTemplate: "\"/reframe\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostReframeImage",
+ methodName: "PostReframeImageAsync",
+ pathTemplate: "\"/reframe\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessPostReframeImageResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostReframeImage",
+ methodName: "PostReframeImageAsync",
+ pathTemplate: "\"/reframe\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostReframeImage",
+ methodName: "PostReframeImageAsync",
+ pathTemplate: "\"/reframe\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ //
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ responseBody: __content_401,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ // Prompt or Image failed the safety checks.
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Ideogram.GenerateImageSafetyError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ responseBody: __content_422,
+ responseObject: __value_422,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ responseBody: __content_429,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessPostReframeImageResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Ideogram.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Ideogram.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
+ }
+ ///
+ /// Reframe (legacy)
+ /// Reframe a square image to a chosen resolution. The supported image formats include JPEG, PNG, and WebP.
+ /// Image links are available for a limited period of time; if you would like to keep the image, you must download it.
+ ///
+ ///
+ /// The image being reframed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ ///
+ /// The image being reframed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ ///
+ /// (For model_version for 2.0 only, cannot be used in conjunction with aspect_ratio) The resolution to use for image generation, represented in width x height. If not specified, defaults to using aspect_ratio.
+ /// Example: RESOLUTION_1024_1024
+ ///
+ ///
+ /// The model used to generate an image or edit one. /generate and /remix supports all model types, however, /edit is only supported for V_2 and V_2_TURBO.
+ /// Default Value: V_2
+ /// Example: V_2_TURBO
+ ///
+ ///
+ /// The number of images to generate.
+ /// Default Value: 1
+ ///
+ ///
+ /// Random seed. Set for reproducible generation.
+ /// Example: 12345
+ ///
+ ///
+ /// The style type to generate with; this is only applicable for models V_2 and above and should not be specified for model versions V_1.
+ /// Example: REALISTIC
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> PostReframeImageAsResponseAsync(
+ global::System.IO.Stream imageFile,
+ string imageFilename,
+ global::Ideogram.Resolution resolution,
+ global::Ideogram.ModelEnum model = global::Ideogram.ModelEnum.V2,
+ int? numImages = default,
+ int? seed = default,
+ global::Ideogram.StyleType? styleType = default,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+
+ imageFile = imageFile ?? throw new global::System.ArgumentNullException(nameof(imageFile));
+ var request = new global::Ideogram.ReframeImageRequest
+ {
+ ImageFile = global::System.Array.Empty(),
+ ImageFilename = imageFilename,
+ Resolution = resolution,
+ Model = model,
+ NumImages = numImages,
+ Seed = seed,
+ StyleType = styleType,
+ };
+ PrepareArguments(
+ client: HttpClient);
+ PreparePostReframeImageArguments(
+ httpClient: HttpClient,
+ request: request);
+
+
+ var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations(
+ availableAuthorizations: Authorizations,
+ securityRequirements: s_PostReframeImageSecurityRequirements,
+ operationName: "PostReframeImageAsync");
+
+ using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: false);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+
+ var __pathBuilder = new global::Ideogram.PathBuilder(
+ path: "/reframe",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+#endif
+
+ foreach (var __authorization in __authorizations)
+ {
+ if (__authorization.Type == "Http" ||
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
+ {
+ __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
+ scheme: __authorization.Name,
+ parameter: __authorization.Value);
+ }
+ else if (__authorization.Type == "ApiKey" &&
+ __authorization.Location == "Header")
+ {
+ __httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
+ }
+ }
+
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ var __contentImageFile = new global::System.Net.Http.StreamContent(imageFile);
+ __contentImageFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.ImageFilename is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.ImageFilename) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentImageFile,
+ name: "\"image_file\"",
+ fileName: request.ImageFilename != null ? $"\"{request.ImageFilename}\"" : string.Empty);
+ if (__contentImageFile.Headers.ContentDisposition != null)
+ {
+ __contentImageFile.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Resolution.ToValueString()),
+ name: "\"resolution\"");
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Model.ToValueString()),
+ name: "\"model\"");
+
+ if (request.NumImages != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"num_images\"");
+
+ }
+ if (request.Seed != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"seed\"");
+
+ }
+ if (request.StyleType != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.StyleType).HasValue ? (request.StyleType).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"style_type\"");
+
+ }
+
+ __httpRequest.Content = __httpRequestContent;
+
+ global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PreparePostReframeImageRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
+
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostReframeImage",
+ methodName: "PostReframeImageAsync",
+ pathTemplate: "\"/reframe\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ catch (global::System.Net.Http.HttpRequestException __exception)
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostReframeImage",
+ methodName: "PostReframeImageAsync",
+ pathTemplate: "\"/reframe\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostReframeImage",
+ methodName: "PostReframeImageAsync",
+ pathTemplate: "\"/reframe\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessPostReframeImageResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostReframeImage",
+ methodName: "PostReframeImageAsync",
+ pathTemplate: "\"/reframe\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostReframeImage",
+ methodName: "PostReframeImageAsync",
+ pathTemplate: "\"/reframe\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ //
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ responseBody: __content_401,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ // Prompt or Image failed the safety checks.
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Ideogram.GenerateImageSafetyError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ responseBody: __content_422,
+ responseObject: __value_422,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ responseBody: __content_429,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessPostReframeImageResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ var __value = global::Ideogram.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ var __value = await global::Ideogram.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
+ }
}
}
\ No newline at end of file
diff --git a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostReframeImageV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostReframeImageV3.g.cs
index eb523a9..560cc28 100644
--- a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostReframeImageV3.g.cs
+++ b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostReframeImageV3.g.cs
@@ -52,6 +52,30 @@ partial void ProcessPostReframeImageV3ResponseContent(
///
public async global::System.Threading.Tasks.Task PostReframeImageV3Async(
+ global::Ideogram.ReframeImageRequestV3 request,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await PostReframeImageV3AsResponseAsync(
+
+ request: request,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// Reframe with Ideogram 3.0
+ /// Reframe a square image to a chosen resolution with Ideogram 3.0. The supported image formats include JPEG, PNG, and WebP.
+ /// Image links are available for a limited period of time; if you would like to keep the image, you must download it.
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> PostReframeImageV3AsResponseAsync(
+
global::Ideogram.ReframeImageRequestV3 request,
global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
@@ -82,10 +106,11 @@ partial void ProcessPostReframeImageV3ResponseContent(
var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts(
clientOptions: Options,
requestOptions: requestOptions,
- supportsRetry: true);
+ supportsRetry: false);
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Ideogram.PathBuilder(
path: "/v1/ideogram-v3/reframe",
baseUri: HttpClient.BaseAddress);
@@ -118,6 +143,7 @@ partial void ProcessPostReframeImageV3ResponseContent(
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
}
}
+
var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
var __contentImage = new global::System.Net.Http.ByteArrayContent(request.Image ?? global::System.Array.Empty());
__contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
@@ -156,51 +182,59 @@ request.Imagename is null
{
__contentImage.Headers.ContentDisposition.FileNameStar = null;
}
+
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.Resolution.ToValueString()),
name: "\"resolution\"");
+
if (request.NumImages != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
name: "\"num_images\"");
- }
+
+ }
if (request.Seed != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
name: "\"seed\"");
- }
+
+ }
if (request.RenderingSpeed != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"rendering_speed\"");
- }
+
+ }
if (request.StylePreset != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.StylePreset).HasValue ? (request.StylePreset).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"style_preset\"");
- }
+
+ }
if (request.ColorPalette != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.ColorPalette.ToString() ?? string.Empty),
name: "\"color_palette\"");
- }
+
+ }
if (request.StyleCodes != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.StyleCodes, x => x))}]"),
name: "\"style_codes\"");
- }
+
+ }
if (request.StyleReferenceImages != default)
{
@@ -217,8 +251,11 @@ request.Imagename is null
__contentStyleReferenceImages.Headers.ContentDisposition.FileNameStar = null;
}
}
+
}
+
__httpRequest.Content = __httpRequestContent;
+
global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders(
request: __httpRequest,
clientHeaders: Options.Headers,
@@ -260,6 +297,8 @@ request.Imagename is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -270,6 +309,11 @@ request.Imagename is null
}
catch (global::System.Net.Http.HttpRequestException __exception)
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
@@ -287,6 +331,8 @@ request.Imagename is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -296,8 +342,7 @@ request.Imagename is null
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -306,6 +351,11 @@ request.Imagename is null
__attempt < __maxAttempts &&
global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
@@ -322,14 +372,15 @@ request.Imagename is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
__response.Dispose();
__response = null;
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -369,6 +420,8 @@ request.Imagename is null
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -389,6 +442,8 @@ request.Imagename is null
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
//
@@ -412,17 +467,16 @@ request.Imagename is null
__exception_400 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_400,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
//
if ((int)__response.StatusCode == 401)
@@ -445,17 +499,16 @@ request.Imagename is null
__exception_401 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_401,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_401,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_401,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
// Prompt or Image failed the safety checks.
if ((int)__response.StatusCode == 422)
@@ -482,18 +535,17 @@ request.Imagename is null
__exception_422 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_422,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_422,
+ responseObject: __value_422,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
//
if ((int)__response.StatusCode == 429)
@@ -516,17 +568,16 @@ request.Imagename is null
__exception_429 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_429,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_429,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_429,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
if (__effectiveReadResponseAsString)
@@ -550,23 +601,25 @@ request.Imagename is null
{
__response.EnsureSuccessStatusCode();
- return
- global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ??
+ var __value = global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
else
@@ -580,9 +633,13 @@ request.Imagename is null
#endif
).ConfigureAwait(false);
- return
- await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ var __value = await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -599,17 +656,15 @@ request.Imagename is null
{
}
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
@@ -697,5 +752,1402 @@ request.Imagename is null
requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
+
+ ///
+ /// Reframe with Ideogram 3.0
+ /// Reframe a square image to a chosen resolution with Ideogram 3.0. The supported image formats include JPEG, PNG, and WebP.
+ /// Image links are available for a limited period of time; if you would like to keep the image, you must download it.
+ ///
+ ///
+ /// The image being reframed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ ///
+ /// The image being reframed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ ///
+ /// The resolutions supported for Ideogram 3.0.
+ /// Example: 1280x800
+ ///
+ ///
+ /// The number of images to generate.
+ /// Default Value: 1
+ ///
+ ///
+ /// Random seed. Set for reproducible generation.
+ /// Example: 12345
+ ///
+ ///
+ /// The rendering speed to use.
+ /// Default Value: DEFAULT
+ ///
+ ///
+ /// A predefined style preset that applies a specific artistic style to the generated image.
+ /// Example: BRIGHT_ART
+ ///
+ ///
+ /// A color palette for generation, must EITHER be specified via one of the presets (name) or explicitly via hexadecimal representations of the color with optional weights (members). Not supported by V_1, V_1_TURBO, V_2A and V_2A_TURBO models.
+ ///
+ ///
+ /// A list of 8 character hexadecimal codes representing the style of the image. Cannot be used in conjunction with style_reference_images or style_type.
+ /// Example: [AAFF5733, 0133FF57, DE3357FF]
+ ///
+ ///
+ /// A set of images to use as style references (maximum total size 10MB across all style references). The images should be in JPEG, PNG or WebP format.
+ ///
+ ///
+ /// Optional file names to use for the multipart 'style_reference_images' file parts.
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task PostReframeImageV3Async(
+ global::System.IO.Stream image,
+ string imagename,
+ global::Ideogram.ResolutionV3 resolution,
+ int? numImages = default,
+ int? seed = default,
+ global::Ideogram.RenderingSpeed? renderingSpeed = default,
+ global::Ideogram.StylePresetV3? stylePreset = default,
+ global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette = default,
+ global::System.Collections.Generic.IList? styleCodes = default,
+ global::System.Collections.Generic.IReadOnlyList? styleReferenceImages = default,
+ global::System.Collections.Generic.IReadOnlyList? styleReferenceImagesFileNames = default,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+
+ image = image ?? throw new global::System.ArgumentNullException(nameof(image));
+ var request = new global::Ideogram.ReframeImageRequestV3
+ {
+ Image = global::System.Array.Empty(),
+ Imagename = imagename,
+ Resolution = resolution,
+ NumImages = numImages,
+ Seed = seed,
+ RenderingSpeed = renderingSpeed,
+ StylePreset = stylePreset,
+ ColorPalette = colorPalette,
+ StyleCodes = styleCodes,
+ StyleReferenceImages = new global::System.Collections.Generic.List(),
+ };
+ PrepareArguments(
+ client: HttpClient);
+ PreparePostReframeImageV3Arguments(
+ httpClient: HttpClient,
+ request: request);
+
+
+ var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations(
+ availableAuthorizations: Authorizations,
+ securityRequirements: s_PostReframeImageV3SecurityRequirements,
+ operationName: "PostReframeImageV3Async");
+
+ using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: false);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+
+ var __pathBuilder = new global::Ideogram.PathBuilder(
+ path: "/v1/ideogram-v3/reframe",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+#endif
+
+ foreach (var __authorization in __authorizations)
+ {
+ if (__authorization.Type == "Http" ||
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
+ {
+ __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
+ scheme: __authorization.Name,
+ parameter: __authorization.Value);
+ }
+ else if (__authorization.Type == "ApiKey" &&
+ __authorization.Location == "Header")
+ {
+ __httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
+ }
+ }
+
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ var __contentImage = new global::System.Net.Http.StreamContent(image);
+ __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.Imagename is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentImage,
+ name: "\"image\"",
+ fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty);
+ if (__contentImage.Headers.ContentDisposition != null)
+ {
+ __contentImage.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Resolution.ToValueString()),
+ name: "\"resolution\"");
+
+ if (request.NumImages != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"num_images\"");
+
+ }
+ if (request.Seed != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"seed\"");
+
+ }
+ if (request.RenderingSpeed != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"rendering_speed\"");
+
+ }
+ if (request.StylePreset != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.StylePreset).HasValue ? (request.StylePreset).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"style_preset\"");
+
+ }
+ if (request.ColorPalette != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.ColorPalette.ToString() ?? string.Empty),
+ name: "\"color_palette\"");
+
+ }
+ if (request.StyleCodes != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.StyleCodes, x => x))}]"),
+ name: "\"style_codes\"");
+
+ }
+ if (styleReferenceImages != default)
+ {
+
+ for (var __iStyleReferenceImages = 0; __iStyleReferenceImages < styleReferenceImages.Count; __iStyleReferenceImages++)
+ {
+ var __fileNameStyleReferenceImages = styleReferenceImagesFileNames != null &&
+ __iStyleReferenceImages < styleReferenceImagesFileNames.Count &&
+ styleReferenceImagesFileNames[__iStyleReferenceImages] != null
+ ? styleReferenceImagesFileNames[__iStyleReferenceImages]
+ : $"file{__iStyleReferenceImages}.bin";
+ var __contentStyleReferenceImages = new global::System.Net.Http.StreamContent(styleReferenceImages[__iStyleReferenceImages]);
+ __contentStyleReferenceImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ __fileNameStyleReferenceImages is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(__fileNameStyleReferenceImages) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentStyleReferenceImages,
+ name: "\"style_reference_images\"",
+ fileName: $"\"{__fileNameStyleReferenceImages}\"");
+ if (__contentStyleReferenceImages.Headers.ContentDisposition != null)
+ {
+ __contentStyleReferenceImages.Headers.ContentDisposition.FileNameStar = null;
+ }
+ }
+
+ }
+
+ __httpRequest.Content = __httpRequestContent;
+
+ global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PreparePostReframeImageV3Request(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
+
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostReframeImageV3",
+ methodName: "PostReframeImageV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/reframe\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ catch (global::System.Net.Http.HttpRequestException __exception)
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostReframeImageV3",
+ methodName: "PostReframeImageV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/reframe\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostReframeImageV3",
+ methodName: "PostReframeImageV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/reframe\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessPostReframeImageV3Response(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostReframeImageV3",
+ methodName: "PostReframeImageV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/reframe\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostReframeImageV3",
+ methodName: "PostReframeImageV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/reframe\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ //
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ responseBody: __content_401,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ // Prompt or Image failed the safety checks.
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Ideogram.GenerateImageSafetyError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ responseBody: __content_422,
+ responseObject: __value_422,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ responseBody: __content_429,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessPostReframeImageV3ResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
+ }
+ ///
+ /// Reframe with Ideogram 3.0
+ /// Reframe a square image to a chosen resolution with Ideogram 3.0. The supported image formats include JPEG, PNG, and WebP.
+ /// Image links are available for a limited period of time; if you would like to keep the image, you must download it.
+ ///
+ ///
+ /// The image being reframed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ ///
+ /// The image being reframed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ ///
+ /// The resolutions supported for Ideogram 3.0.
+ /// Example: 1280x800
+ ///
+ ///
+ /// The number of images to generate.
+ /// Default Value: 1
+ ///
+ ///
+ /// Random seed. Set for reproducible generation.
+ /// Example: 12345
+ ///
+ ///
+ /// The rendering speed to use.
+ /// Default Value: DEFAULT
+ ///
+ ///
+ /// A predefined style preset that applies a specific artistic style to the generated image.
+ /// Example: BRIGHT_ART
+ ///
+ ///
+ /// A color palette for generation, must EITHER be specified via one of the presets (name) or explicitly via hexadecimal representations of the color with optional weights (members). Not supported by V_1, V_1_TURBO, V_2A and V_2A_TURBO models.
+ ///
+ ///
+ /// A list of 8 character hexadecimal codes representing the style of the image. Cannot be used in conjunction with style_reference_images or style_type.
+ /// Example: [AAFF5733, 0133FF57, DE3357FF]
+ ///
+ ///
+ /// A set of images to use as style references (maximum total size 10MB across all style references). The images should be in JPEG, PNG or WebP format.
+ ///
+ ///
+ /// Optional file names to use for the multipart 'style_reference_images' file parts.
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> PostReframeImageV3AsResponseAsync(
+ global::System.IO.Stream image,
+ string imagename,
+ global::Ideogram.ResolutionV3 resolution,
+ int? numImages = default,
+ int? seed = default,
+ global::Ideogram.RenderingSpeed? renderingSpeed = default,
+ global::Ideogram.StylePresetV3? stylePreset = default,
+ global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette = default,
+ global::System.Collections.Generic.IList? styleCodes = default,
+ global::System.Collections.Generic.IReadOnlyList? styleReferenceImages = default,
+ global::System.Collections.Generic.IReadOnlyList? styleReferenceImagesFileNames = default,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+
+ image = image ?? throw new global::System.ArgumentNullException(nameof(image));
+ var request = new global::Ideogram.ReframeImageRequestV3
+ {
+ Image = global::System.Array.Empty(),
+ Imagename = imagename,
+ Resolution = resolution,
+ NumImages = numImages,
+ Seed = seed,
+ RenderingSpeed = renderingSpeed,
+ StylePreset = stylePreset,
+ ColorPalette = colorPalette,
+ StyleCodes = styleCodes,
+ StyleReferenceImages = new global::System.Collections.Generic.List(),
+ };
+ PrepareArguments(
+ client: HttpClient);
+ PreparePostReframeImageV3Arguments(
+ httpClient: HttpClient,
+ request: request);
+
+
+ var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations(
+ availableAuthorizations: Authorizations,
+ securityRequirements: s_PostReframeImageV3SecurityRequirements,
+ operationName: "PostReframeImageV3Async");
+
+ using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: false);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+
+ var __pathBuilder = new global::Ideogram.PathBuilder(
+ path: "/v1/ideogram-v3/reframe",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+#endif
+
+ foreach (var __authorization in __authorizations)
+ {
+ if (__authorization.Type == "Http" ||
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
+ {
+ __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
+ scheme: __authorization.Name,
+ parameter: __authorization.Value);
+ }
+ else if (__authorization.Type == "ApiKey" &&
+ __authorization.Location == "Header")
+ {
+ __httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
+ }
+ }
+
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ var __contentImage = new global::System.Net.Http.StreamContent(image);
+ __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.Imagename is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentImage,
+ name: "\"image\"",
+ fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty);
+ if (__contentImage.Headers.ContentDisposition != null)
+ {
+ __contentImage.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Resolution.ToValueString()),
+ name: "\"resolution\"");
+
+ if (request.NumImages != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"num_images\"");
+
+ }
+ if (request.Seed != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"seed\"");
+
+ }
+ if (request.RenderingSpeed != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"rendering_speed\"");
+
+ }
+ if (request.StylePreset != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.StylePreset).HasValue ? (request.StylePreset).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"style_preset\"");
+
+ }
+ if (request.ColorPalette != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.ColorPalette.ToString() ?? string.Empty),
+ name: "\"color_palette\"");
+
+ }
+ if (request.StyleCodes != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.StyleCodes, x => x))}]"),
+ name: "\"style_codes\"");
+
+ }
+ if (styleReferenceImages != default)
+ {
+
+ for (var __iStyleReferenceImages = 0; __iStyleReferenceImages < styleReferenceImages.Count; __iStyleReferenceImages++)
+ {
+ var __fileNameStyleReferenceImages = styleReferenceImagesFileNames != null &&
+ __iStyleReferenceImages < styleReferenceImagesFileNames.Count &&
+ styleReferenceImagesFileNames[__iStyleReferenceImages] != null
+ ? styleReferenceImagesFileNames[__iStyleReferenceImages]
+ : $"file{__iStyleReferenceImages}.bin";
+ var __contentStyleReferenceImages = new global::System.Net.Http.StreamContent(styleReferenceImages[__iStyleReferenceImages]);
+ __contentStyleReferenceImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ __fileNameStyleReferenceImages is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(__fileNameStyleReferenceImages) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentStyleReferenceImages,
+ name: "\"style_reference_images\"",
+ fileName: $"\"{__fileNameStyleReferenceImages}\"");
+ if (__contentStyleReferenceImages.Headers.ContentDisposition != null)
+ {
+ __contentStyleReferenceImages.Headers.ContentDisposition.FileNameStar = null;
+ }
+ }
+
+ }
+
+ __httpRequest.Content = __httpRequestContent;
+
+ global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PreparePostReframeImageV3Request(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
+
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostReframeImageV3",
+ methodName: "PostReframeImageV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/reframe\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ catch (global::System.Net.Http.HttpRequestException __exception)
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostReframeImageV3",
+ methodName: "PostReframeImageV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/reframe\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostReframeImageV3",
+ methodName: "PostReframeImageV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/reframe\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessPostReframeImageV3Response(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostReframeImageV3",
+ methodName: "PostReframeImageV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/reframe\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostReframeImageV3",
+ methodName: "PostReframeImageV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/reframe\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ //
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ responseBody: __content_401,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ // Prompt or Image failed the safety checks.
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Ideogram.GenerateImageSafetyError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ responseBody: __content_422,
+ responseObject: __value_422,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ responseBody: __content_429,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessPostReframeImageV3ResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ var __value = global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ var __value = await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
+ }
}
}
\ No newline at end of file
diff --git a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostRemixImage.g.cs b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostRemixImage.g.cs
index 6bd933f..c980bd0 100644
--- a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostRemixImage.g.cs
+++ b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostRemixImage.g.cs
@@ -54,6 +54,32 @@ partial void ProcessPostRemixImageResponseContent(
///
public async global::System.Threading.Tasks.Task PostRemixImageAsync(
+ global::Ideogram.RemixImageRequest request,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await PostRemixImageAsResponseAsync(
+
+ request: request,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// Remix (legacy)
+ /// Remix provided images synchronously based on a given prompt and optional parameters.
+ /// Input images are cropped to the chosen aspect ratio before being remixed.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it.
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> PostRemixImageAsResponseAsync(
+
global::Ideogram.RemixImageRequest request,
global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
@@ -84,10 +110,11 @@ partial void ProcessPostRemixImageResponseContent(
var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts(
clientOptions: Options,
requestOptions: requestOptions,
- supportsRetry: true);
+ supportsRetry: false);
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Ideogram.PathBuilder(
path: "/remix",
baseUri: HttpClient.BaseAddress);
@@ -120,10 +147,12 @@ partial void ProcessPostRemixImageResponseContent(
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
}
}
+
var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.ImageRequest.ToJson(JsonSerializerContext)),
name: "\"image_request\"");
+
var __contentImageFile = new global::System.Net.Http.ByteArrayContent(request.ImageFile ?? global::System.Array.Empty());
__contentImageFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
request.ImageFilename is null
@@ -161,7 +190,9 @@ request.ImageFilename is null
{
__contentImageFile.Headers.ContentDisposition.FileNameStar = null;
}
+
__httpRequest.Content = __httpRequestContent;
+
global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders(
request: __httpRequest,
clientHeaders: Options.Headers,
@@ -203,6 +234,8 @@ request.ImageFilename is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -213,6 +246,11 @@ request.ImageFilename is null
}
catch (global::System.Net.Http.HttpRequestException __exception)
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
@@ -230,6 +268,8 @@ request.ImageFilename is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -239,8 +279,7 @@ request.ImageFilename is null
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -249,6 +288,11 @@ request.ImageFilename is null
__attempt < __maxAttempts &&
global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
@@ -265,14 +309,15 @@ request.ImageFilename is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
__response.Dispose();
__response = null;
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -312,6 +357,8 @@ request.ImageFilename is null
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -332,6 +379,8 @@ request.ImageFilename is null
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
//
@@ -355,17 +404,16 @@ request.ImageFilename is null
__exception_400 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_400,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
//
if ((int)__response.StatusCode == 403)
@@ -388,17 +436,16 @@ request.ImageFilename is null
__exception_403 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_403,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_403,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_403,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
// Prompt or provided image failed safety check.
if ((int)__response.StatusCode == 422)
@@ -425,18 +472,17 @@ request.ImageFilename is null
__exception_422 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_422,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_422,
+ responseObject: __value_422,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
//
if ((int)__response.StatusCode == 429)
@@ -459,17 +505,16 @@ request.ImageFilename is null
__exception_429 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_429,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_429,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_429,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
if (__effectiveReadResponseAsString)
@@ -493,23 +538,25 @@ request.ImageFilename is null
{
__response.EnsureSuccessStatusCode();
- return
- global::Ideogram.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ??
+ var __value = global::Ideogram.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
else
@@ -523,9 +570,13 @@ request.ImageFilename is null
#endif
).ConfigureAwait(false);
- return
- await global::Ideogram.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ var __value = await global::Ideogram.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -542,17 +593,15 @@ request.ImageFilename is null
{
}
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
@@ -602,5 +651,1120 @@ request.ImageFilename is null
requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
+
+ ///
+ /// Remix (legacy)
+ /// Remix provided images synchronously based on a given prompt and optional parameters.
+ /// Input images are cropped to the chosen aspect ratio before being remixed.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it.
+ ///
+ ///
+ /// A request to generate a new image using a provided image and a prompt.
+ /// Example: {"aspect_ratio":"ASPECT_10_16","magic_prompt_option":"ON","model":"V_2","prompt":"A serene tropical beach scene. Dominating the foreground are tall palm trees with lush green leaves, standing tall against a backdrop of a sandy beach. The beach leads to the azure waters of the sea, which gently kisses the shoreline. In the distance, there is an island or landmass with a silhouette of what appears to be a lighthouse or tower. The sky above is painted with fluffy white clouds, some of which are tinged with hues of pink and orange, suggesting either a sunrise or sunset.","image_weight":50}
+ ///
+ ///
+ /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ ///
+ /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task PostRemixImageAsync(
+ global::Ideogram.InitialImageRequest imageRequest,
+ global::System.IO.Stream imageFile,
+ string imageFilename,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+
+ imageFile = imageFile ?? throw new global::System.ArgumentNullException(nameof(imageFile));
+ var request = new global::Ideogram.RemixImageRequest
+ {
+ ImageRequest = imageRequest,
+ ImageFile = global::System.Array.Empty(),
+ ImageFilename = imageFilename,
+ };
+ PrepareArguments(
+ client: HttpClient);
+ PreparePostRemixImageArguments(
+ httpClient: HttpClient,
+ request: request);
+
+
+ var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations(
+ availableAuthorizations: Authorizations,
+ securityRequirements: s_PostRemixImageSecurityRequirements,
+ operationName: "PostRemixImageAsync");
+
+ using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: false);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+
+ var __pathBuilder = new global::Ideogram.PathBuilder(
+ path: "/remix",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+#endif
+
+ foreach (var __authorization in __authorizations)
+ {
+ if (__authorization.Type == "Http" ||
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
+ {
+ __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
+ scheme: __authorization.Name,
+ parameter: __authorization.Value);
+ }
+ else if (__authorization.Type == "ApiKey" &&
+ __authorization.Location == "Header")
+ {
+ __httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
+ }
+ }
+
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.ImageRequest.ToJson(JsonSerializerContext)),
+ name: "\"image_request\"");
+
+ var __contentImageFile = new global::System.Net.Http.StreamContent(imageFile);
+ __contentImageFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.ImageFilename is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.ImageFilename) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentImageFile,
+ name: "\"image_file\"",
+ fileName: request.ImageFilename != null ? $"\"{request.ImageFilename}\"" : string.Empty);
+ if (__contentImageFile.Headers.ContentDisposition != null)
+ {
+ __contentImageFile.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ __httpRequest.Content = __httpRequestContent;
+
+ global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PreparePostRemixImageRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
+
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostRemixImage",
+ methodName: "PostRemixImageAsync",
+ pathTemplate: "\"/remix\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ catch (global::System.Net.Http.HttpRequestException __exception)
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostRemixImage",
+ methodName: "PostRemixImageAsync",
+ pathTemplate: "\"/remix\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostRemixImage",
+ methodName: "PostRemixImageAsync",
+ pathTemplate: "\"/remix\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessPostRemixImageResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostRemixImage",
+ methodName: "PostRemixImageAsync",
+ pathTemplate: "\"/remix\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostRemixImage",
+ methodName: "PostRemixImageAsync",
+ pathTemplate: "\"/remix\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ //
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 403)
+ {
+ string? __content_403 = null;
+ global::System.Exception? __exception_403 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_403 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_403,
+ responseBody: __content_403,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ // Prompt or provided image failed safety check.
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Ideogram.GenerateImageSafetyError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ responseBody: __content_422,
+ responseObject: __value_422,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ responseBody: __content_429,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessPostRemixImageResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Ideogram.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Ideogram.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
+ }
+ ///
+ /// Remix (legacy)
+ /// Remix provided images synchronously based on a given prompt and optional parameters.
+ /// Input images are cropped to the chosen aspect ratio before being remixed.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it.
+ ///
+ ///
+ /// A request to generate a new image using a provided image and a prompt.
+ /// Example: {"aspect_ratio":"ASPECT_10_16","magic_prompt_option":"ON","model":"V_2","prompt":"A serene tropical beach scene. Dominating the foreground are tall palm trees with lush green leaves, standing tall against a backdrop of a sandy beach. The beach leads to the azure waters of the sea, which gently kisses the shoreline. In the distance, there is an island or landmass with a silhouette of what appears to be a lighthouse or tower. The sky above is painted with fluffy white clouds, some of which are tinged with hues of pink and orange, suggesting either a sunrise or sunset.","image_weight":50}
+ ///
+ ///
+ /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ ///
+ /// An image binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> PostRemixImageAsResponseAsync(
+ global::Ideogram.InitialImageRequest imageRequest,
+ global::System.IO.Stream imageFile,
+ string imageFilename,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+
+ imageFile = imageFile ?? throw new global::System.ArgumentNullException(nameof(imageFile));
+ var request = new global::Ideogram.RemixImageRequest
+ {
+ ImageRequest = imageRequest,
+ ImageFile = global::System.Array.Empty(),
+ ImageFilename = imageFilename,
+ };
+ PrepareArguments(
+ client: HttpClient);
+ PreparePostRemixImageArguments(
+ httpClient: HttpClient,
+ request: request);
+
+
+ var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations(
+ availableAuthorizations: Authorizations,
+ securityRequirements: s_PostRemixImageSecurityRequirements,
+ operationName: "PostRemixImageAsync");
+
+ using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: false);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+
+ var __pathBuilder = new global::Ideogram.PathBuilder(
+ path: "/remix",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+#endif
+
+ foreach (var __authorization in __authorizations)
+ {
+ if (__authorization.Type == "Http" ||
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
+ {
+ __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
+ scheme: __authorization.Name,
+ parameter: __authorization.Value);
+ }
+ else if (__authorization.Type == "ApiKey" &&
+ __authorization.Location == "Header")
+ {
+ __httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
+ }
+ }
+
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.ImageRequest.ToJson(JsonSerializerContext)),
+ name: "\"image_request\"");
+
+ var __contentImageFile = new global::System.Net.Http.StreamContent(imageFile);
+ __contentImageFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.ImageFilename is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.ImageFilename) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentImageFile,
+ name: "\"image_file\"",
+ fileName: request.ImageFilename != null ? $"\"{request.ImageFilename}\"" : string.Empty);
+ if (__contentImageFile.Headers.ContentDisposition != null)
+ {
+ __contentImageFile.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ __httpRequest.Content = __httpRequestContent;
+
+ global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PreparePostRemixImageRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
+
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostRemixImage",
+ methodName: "PostRemixImageAsync",
+ pathTemplate: "\"/remix\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ catch (global::System.Net.Http.HttpRequestException __exception)
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostRemixImage",
+ methodName: "PostRemixImageAsync",
+ pathTemplate: "\"/remix\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostRemixImage",
+ methodName: "PostRemixImageAsync",
+ pathTemplate: "\"/remix\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessPostRemixImageResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostRemixImage",
+ methodName: "PostRemixImageAsync",
+ pathTemplate: "\"/remix\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostRemixImage",
+ methodName: "PostRemixImageAsync",
+ pathTemplate: "\"/remix\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ //
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 403)
+ {
+ string? __content_403 = null;
+ global::System.Exception? __exception_403 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_403 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_403,
+ responseBody: __content_403,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ // Prompt or provided image failed safety check.
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Ideogram.GenerateImageSafetyError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ responseBody: __content_422,
+ responseObject: __value_422,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ responseBody: __content_429,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessPostRemixImageResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ var __value = global::Ideogram.GenerateImageResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ var __value = await global::Ideogram.GenerateImageResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
+ }
}
}
\ No newline at end of file
diff --git a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostRemixImageV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostRemixImageV3.g.cs
index 2dc9bdf..9d36250 100644
--- a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostRemixImageV3.g.cs
+++ b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostRemixImageV3.g.cs
@@ -54,6 +54,32 @@ partial void ProcessPostRemixImageV3ResponseContent(
///
public async global::System.Threading.Tasks.Task PostRemixImageV3Async(
+ global::Ideogram.RemixImageRequestV3 request,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await PostRemixImageV3AsResponseAsync(
+
+ request: request,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// Remix with Ideogram 3.0
+ /// Remix provided images synchronously based on a given prompt and optional parameters with the Ideogram 3.0 model.
+ /// Input images are cropped to the chosen aspect ratio before being remixed.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it.
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> PostRemixImageV3AsResponseAsync(
+
global::Ideogram.RemixImageRequestV3 request,
global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
@@ -84,10 +110,11 @@ partial void ProcessPostRemixImageV3ResponseContent(
var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts(
clientOptions: Options,
requestOptions: requestOptions,
- supportsRetry: true);
+ supportsRetry: false);
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Ideogram.PathBuilder(
path: "/v1/ideogram-v3/remix",
baseUri: HttpClient.BaseAddress);
@@ -120,6 +147,7 @@ partial void ProcessPostRemixImageV3ResponseContent(
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
}
}
+
var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
var __contentImage = new global::System.Net.Http.ByteArrayContent(request.Image ?? global::System.Array.Empty());
__contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
@@ -158,100 +186,123 @@ request.Imagename is null
{
__contentImage.Headers.ContentDisposition.FileNameStar = null;
}
+
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty),
name: "\"prompt\"");
+
if (request.ImageWeight != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.ImageWeight, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
name: "\"image_weight\"");
- }
+
+ }
if (request.Seed != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
name: "\"seed\"");
- }
+
+ }
if (request.Resolution != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.Resolution).HasValue ? (request.Resolution).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"resolution\"");
- }
+
+ }
if (request.AspectRatio != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.AspectRatio).HasValue ? (request.AspectRatio).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"aspect_ratio\"");
- }
+
+ }
if (request.RenderingSpeed != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"rendering_speed\"");
- }
+
+ }
if (request.MagicPrompt != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.MagicPrompt).HasValue ? (request.MagicPrompt).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"magic_prompt\"");
- }
+
+ }
+ if (request.MagicPromptSystemPromptConfigId != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty),
+ name: "\"magic_prompt_system_prompt_config_id\"");
+
+ }
if (request.NegativePrompt != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.NegativePrompt ?? string.Empty),
name: "\"negative_prompt\"");
- }
+
+ }
if (request.NumImages != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
name: "\"num_images\"");
- }
+
+ }
if (request.ColorPalette != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.ColorPalette.ToString() ?? string.Empty),
name: "\"color_palette\"");
- }
+
+ }
if (request.StyleCodes != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.StyleCodes, x => x))}]"),
name: "\"style_codes\"");
- }
+
+ }
if (request.StyleType != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.StyleType).HasValue ? (request.StyleType).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"style_type\"");
- }
+
+ }
if (request.StylePreset != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.StylePreset).HasValue ? (request.StylePreset).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"style_preset\"");
- }
+
+ }
if (request.CustomModelUri != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.CustomModelUri ?? string.Empty),
name: "\"custom_model_uri\"");
- }
+
+ }
if (request.StyleReferenceImages != default)
{
@@ -268,7 +319,8 @@ request.Imagename is null
__contentStyleReferenceImages.Headers.ContentDisposition.FileNameStar = null;
}
}
- }
+
+ }
if (request.CharacterReferenceImages != default)
{
@@ -285,7 +337,8 @@ request.Imagename is null
__contentCharacterReferenceImages.Headers.ContentDisposition.FileNameStar = null;
}
}
- }
+
+ }
if (request.CharacterReferenceImagesMask != default)
{
@@ -302,8 +355,11 @@ request.Imagename is null
__contentCharacterReferenceImagesMask.Headers.ContentDisposition.FileNameStar = null;
}
}
+
}
+
__httpRequest.Content = __httpRequestContent;
+
global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders(
request: __httpRequest,
clientHeaders: Options.Headers,
@@ -345,6 +401,8 @@ request.Imagename is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -355,6 +413,11 @@ request.Imagename is null
}
catch (global::System.Net.Http.HttpRequestException __exception)
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
@@ -372,6 +435,8 @@ request.Imagename is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -381,8 +446,7 @@ request.Imagename is null
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -391,6 +455,11 @@ request.Imagename is null
__attempt < __maxAttempts &&
global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
@@ -407,14 +476,15 @@ request.Imagename is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
__response.Dispose();
__response = null;
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -454,6 +524,8 @@ request.Imagename is null
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -474,6 +546,8 @@ request.Imagename is null
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
//
@@ -497,17 +571,16 @@ request.Imagename is null
__exception_400 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_400,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
//
if ((int)__response.StatusCode == 403)
@@ -530,17 +603,16 @@ request.Imagename is null
__exception_403 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_403,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_403,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_403,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
// Prompt or provided image failed safety check.
if ((int)__response.StatusCode == 422)
@@ -567,18 +639,17 @@ request.Imagename is null
__exception_422 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_422,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_422,
+ responseObject: __value_422,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
//
if ((int)__response.StatusCode == 429)
@@ -601,17 +672,16 @@ request.Imagename is null
__exception_429 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_429,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_429,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_429,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
if (__effectiveReadResponseAsString)
@@ -635,23 +705,25 @@ request.Imagename is null
{
__response.EnsureSuccessStatusCode();
- return
- global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ??
+ var __value = global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
else
@@ -665,9 +737,13 @@ request.Imagename is null
#endif
).ConfigureAwait(false);
- return
- await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ var __value = await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -684,17 +760,15 @@ request.Imagename is null
{
}
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
@@ -745,6 +819,9 @@ request.Imagename is null
/// Determine if MagicPrompt should be used in generating the request or not.
/// Example: ON
///
+ ///
+ /// A base64url-encoded magic prompt system prompt config ID to use for this request.
+ ///
///
/// Description of what to exclude from an image. Descriptions in the prompt take precedence
/// to descriptions in the negative prompt.
@@ -797,6 +874,7 @@ request.Imagename is null
global::Ideogram.AspectRatioV3? aspectRatio = default,
global::Ideogram.RenderingSpeed? renderingSpeed = default,
global::Ideogram.MagicPromptOption? magicPrompt = default,
+ string? magicPromptSystemPromptConfigId = default,
string? negativePrompt = default,
int? numImages = default,
global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette = default,
@@ -821,6 +899,7 @@ request.Imagename is null
AspectRatio = aspectRatio,
RenderingSpeed = renderingSpeed,
MagicPrompt = magicPrompt,
+ MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId,
NegativePrompt = negativePrompt,
NumImages = numImages,
ColorPalette = colorPalette,
@@ -838,5 +917,1868 @@ request.Imagename is null
requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
+
+ ///
+ /// Remix with Ideogram 3.0
+ /// Remix provided images synchronously based on a given prompt and optional parameters with the Ideogram 3.0 model.
+ /// Input images are cropped to the chosen aspect ratio before being remixed.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it.
+ ///
+ ///
+ /// The image to remix binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ ///
+ /// The image to remix binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ ///
+ /// The prompt to use to generate the image.
+ /// Example: A photo of a cat
+ ///
+ ///
+ /// Default Value: 50
+ /// Example: 50
+ ///
+ ///
+ /// Random seed. Set for reproducible generation.
+ /// Example: 12345
+ ///
+ ///
+ /// The resolutions supported for Ideogram 3.0.
+ /// Example: 1280x800
+ ///
+ ///
+ /// The aspect ratio to use for image generation, which determines the image's resolution. Cannot be used in conjunction with resolution. Defaults to 1x1.
+ ///
+ ///
+ /// The rendering speed to use.
+ /// Default Value: DEFAULT
+ ///
+ ///
+ /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON
+ ///
+ ///
+ /// A base64url-encoded magic prompt system prompt config ID to use for this request.
+ ///
+ ///
+ /// Description of what to exclude from an image. Descriptions in the prompt take precedence
+ /// to descriptions in the negative prompt.
+ /// Example: brush strokes, painting
+ ///
+ ///
+ /// Number of images to generate.
+ /// Default Value: 1
+ ///
+ ///
+ /// A color palette for generation, must EITHER be specified via one of the presets (name) or explicitly via hexadecimal representations of the color with optional weights (members). Not supported by V_1, V_1_TURBO, V_2A and V_2A_TURBO models.
+ ///
+ ///
+ /// A list of 8 character hexadecimal codes representing the style of the image. Cannot be used in conjunction with style_reference_images or style_type.
+ /// Example: [AAFF5733, 0133FF57, DE3357FF]
+ ///
+ ///
+ /// The style type to generate with.
+ /// Default Value: GENERAL
+ /// Example: GENERAL
+ ///
+ ///
+ /// A predefined style preset that applies a specific artistic style to the generated image.
+ /// Example: BRIGHT_ART
+ ///
+ ///
+ /// A custom model URI in the format model/<model_name>/version/<version_name>.
+ /// When provided, the model version and style will be resolved from this URI, and style_type is not required.
+ /// Example: model/my-custom-model/version/1
+ ///
+ ///
+ /// A set of images to use as style references (maximum total size 10MB across all style references). The images should be in JPEG, PNG or WebP format.
+ ///
+ ///
+ /// Optional file names to use for the multipart 'style_reference_images' file parts.
+ ///
+ ///
+ /// Generations with character reference are subject to the character reference pricing. A set of images to use as character references (maximum total size 10MB across all character references), currently only supports 1 character reference image. The images should be in JPEG, PNG or WebP format.
+ ///
+ ///
+ /// Optional file names to use for the multipart 'character_reference_images' file parts.
+ ///
+ ///
+ /// Optional masks for character reference images. When provided, must match the number of character_reference_images. Each mask should be a grayscale image of the same dimensions as the corresponding character reference image. The images should be in JPEG, PNG or WebP format.
+ ///
+ ///
+ /// Optional file names to use for the multipart 'character_reference_images_mask' file parts.
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task PostRemixImageV3Async(
+ global::System.IO.Stream image,
+ string imagename,
+ string prompt,
+ int? imageWeight = default,
+ int? seed = default,
+ global::Ideogram.ResolutionV3? resolution = default,
+ global::Ideogram.AspectRatioV3? aspectRatio = default,
+ global::Ideogram.RenderingSpeed? renderingSpeed = default,
+ global::Ideogram.MagicPromptOption? magicPrompt = default,
+ string? magicPromptSystemPromptConfigId = default,
+ string? negativePrompt = default,
+ int? numImages = default,
+ global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette = default,
+ global::System.Collections.Generic.IList? styleCodes = default,
+ global::Ideogram.StyleTypeV3? styleType = default,
+ global::Ideogram.StylePresetV3? stylePreset = default,
+ string? customModelUri = default,
+ global::System.Collections.Generic.IReadOnlyList? styleReferenceImages = default,
+ global::System.Collections.Generic.IReadOnlyList? styleReferenceImagesFileNames = default,
+ global::System.Collections.Generic.IReadOnlyList? characterReferenceImages = default,
+ global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesFileNames = default,
+ global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesMask = default,
+ global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesMaskFileNames = default,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+
+ image = image ?? throw new global::System.ArgumentNullException(nameof(image));
+ var request = new global::Ideogram.RemixImageRequestV3
+ {
+ Image = global::System.Array.Empty(),
+ Imagename = imagename,
+ Prompt = prompt,
+ ImageWeight = imageWeight,
+ Seed = seed,
+ Resolution = resolution,
+ AspectRatio = aspectRatio,
+ RenderingSpeed = renderingSpeed,
+ MagicPrompt = magicPrompt,
+ MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId,
+ NegativePrompt = negativePrompt,
+ NumImages = numImages,
+ ColorPalette = colorPalette,
+ StyleCodes = styleCodes,
+ StyleType = styleType,
+ StylePreset = stylePreset,
+ CustomModelUri = customModelUri,
+ StyleReferenceImages = new global::System.Collections.Generic.List(),
+ CharacterReferenceImages = new global::System.Collections.Generic.List(),
+ CharacterReferenceImagesMask = new global::System.Collections.Generic.List(),
+ };
+ PrepareArguments(
+ client: HttpClient);
+ PreparePostRemixImageV3Arguments(
+ httpClient: HttpClient,
+ request: request);
+
+
+ var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations(
+ availableAuthorizations: Authorizations,
+ securityRequirements: s_PostRemixImageV3SecurityRequirements,
+ operationName: "PostRemixImageV3Async");
+
+ using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: false);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+
+ var __pathBuilder = new global::Ideogram.PathBuilder(
+ path: "/v1/ideogram-v3/remix",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+#endif
+
+ foreach (var __authorization in __authorizations)
+ {
+ if (__authorization.Type == "Http" ||
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
+ {
+ __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
+ scheme: __authorization.Name,
+ parameter: __authorization.Value);
+ }
+ else if (__authorization.Type == "ApiKey" &&
+ __authorization.Location == "Header")
+ {
+ __httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
+ }
+ }
+
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ var __contentImage = new global::System.Net.Http.StreamContent(image);
+ __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.Imagename is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentImage,
+ name: "\"image\"",
+ fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty);
+ if (__contentImage.Headers.ContentDisposition != null)
+ {
+ __contentImage.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty),
+ name: "\"prompt\"");
+
+ if (request.ImageWeight != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.ImageWeight, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"image_weight\"");
+
+ }
+ if (request.Seed != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"seed\"");
+
+ }
+ if (request.Resolution != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.Resolution).HasValue ? (request.Resolution).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"resolution\"");
+
+ }
+ if (request.AspectRatio != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.AspectRatio).HasValue ? (request.AspectRatio).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"aspect_ratio\"");
+
+ }
+ if (request.RenderingSpeed != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"rendering_speed\"");
+
+ }
+ if (request.MagicPrompt != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.MagicPrompt).HasValue ? (request.MagicPrompt).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"magic_prompt\"");
+
+ }
+ if (request.MagicPromptSystemPromptConfigId != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty),
+ name: "\"magic_prompt_system_prompt_config_id\"");
+
+ }
+ if (request.NegativePrompt != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.NegativePrompt ?? string.Empty),
+ name: "\"negative_prompt\"");
+
+ }
+ if (request.NumImages != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"num_images\"");
+
+ }
+ if (request.ColorPalette != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.ColorPalette.ToString() ?? string.Empty),
+ name: "\"color_palette\"");
+
+ }
+ if (request.StyleCodes != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.StyleCodes, x => x))}]"),
+ name: "\"style_codes\"");
+
+ }
+ if (request.StyleType != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.StyleType).HasValue ? (request.StyleType).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"style_type\"");
+
+ }
+ if (request.StylePreset != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.StylePreset).HasValue ? (request.StylePreset).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"style_preset\"");
+
+ }
+ if (request.CustomModelUri != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.CustomModelUri ?? string.Empty),
+ name: "\"custom_model_uri\"");
+
+ }
+ if (styleReferenceImages != default)
+ {
+
+ for (var __iStyleReferenceImages = 0; __iStyleReferenceImages < styleReferenceImages.Count; __iStyleReferenceImages++)
+ {
+ var __fileNameStyleReferenceImages = styleReferenceImagesFileNames != null &&
+ __iStyleReferenceImages < styleReferenceImagesFileNames.Count &&
+ styleReferenceImagesFileNames[__iStyleReferenceImages] != null
+ ? styleReferenceImagesFileNames[__iStyleReferenceImages]
+ : $"file{__iStyleReferenceImages}.bin";
+ var __contentStyleReferenceImages = new global::System.Net.Http.StreamContent(styleReferenceImages[__iStyleReferenceImages]);
+ __contentStyleReferenceImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ __fileNameStyleReferenceImages is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(__fileNameStyleReferenceImages) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentStyleReferenceImages,
+ name: "\"style_reference_images\"",
+ fileName: $"\"{__fileNameStyleReferenceImages}\"");
+ if (__contentStyleReferenceImages.Headers.ContentDisposition != null)
+ {
+ __contentStyleReferenceImages.Headers.ContentDisposition.FileNameStar = null;
+ }
+ }
+
+ }
+ if (characterReferenceImages != default)
+ {
+
+ for (var __iCharacterReferenceImages = 0; __iCharacterReferenceImages < characterReferenceImages.Count; __iCharacterReferenceImages++)
+ {
+ var __fileNameCharacterReferenceImages = characterReferenceImagesFileNames != null &&
+ __iCharacterReferenceImages < characterReferenceImagesFileNames.Count &&
+ characterReferenceImagesFileNames[__iCharacterReferenceImages] != null
+ ? characterReferenceImagesFileNames[__iCharacterReferenceImages]
+ : $"file{__iCharacterReferenceImages}.bin";
+ var __contentCharacterReferenceImages = new global::System.Net.Http.StreamContent(characterReferenceImages[__iCharacterReferenceImages]);
+ __contentCharacterReferenceImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ __fileNameCharacterReferenceImages is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(__fileNameCharacterReferenceImages) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentCharacterReferenceImages,
+ name: "\"character_reference_images\"",
+ fileName: $"\"{__fileNameCharacterReferenceImages}\"");
+ if (__contentCharacterReferenceImages.Headers.ContentDisposition != null)
+ {
+ __contentCharacterReferenceImages.Headers.ContentDisposition.FileNameStar = null;
+ }
+ }
+
+ }
+ if (characterReferenceImagesMask != default)
+ {
+
+ for (var __iCharacterReferenceImagesMask = 0; __iCharacterReferenceImagesMask < characterReferenceImagesMask.Count; __iCharacterReferenceImagesMask++)
+ {
+ var __fileNameCharacterReferenceImagesMask = characterReferenceImagesMaskFileNames != null &&
+ __iCharacterReferenceImagesMask < characterReferenceImagesMaskFileNames.Count &&
+ characterReferenceImagesMaskFileNames[__iCharacterReferenceImagesMask] != null
+ ? characterReferenceImagesMaskFileNames[__iCharacterReferenceImagesMask]
+ : $"file{__iCharacterReferenceImagesMask}.bin";
+ var __contentCharacterReferenceImagesMask = new global::System.Net.Http.StreamContent(characterReferenceImagesMask[__iCharacterReferenceImagesMask]);
+ __contentCharacterReferenceImagesMask.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ __fileNameCharacterReferenceImagesMask is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(__fileNameCharacterReferenceImagesMask) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentCharacterReferenceImagesMask,
+ name: "\"character_reference_images_mask\"",
+ fileName: $"\"{__fileNameCharacterReferenceImagesMask}\"");
+ if (__contentCharacterReferenceImagesMask.Headers.ContentDisposition != null)
+ {
+ __contentCharacterReferenceImagesMask.Headers.ContentDisposition.FileNameStar = null;
+ }
+ }
+
+ }
+
+ __httpRequest.Content = __httpRequestContent;
+
+ global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PreparePostRemixImageV3Request(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
+
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostRemixImageV3",
+ methodName: "PostRemixImageV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/remix\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ catch (global::System.Net.Http.HttpRequestException __exception)
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostRemixImageV3",
+ methodName: "PostRemixImageV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/remix\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostRemixImageV3",
+ methodName: "PostRemixImageV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/remix\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessPostRemixImageV3Response(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostRemixImageV3",
+ methodName: "PostRemixImageV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/remix\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostRemixImageV3",
+ methodName: "PostRemixImageV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/remix\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ //
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 403)
+ {
+ string? __content_403 = null;
+ global::System.Exception? __exception_403 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_403 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_403,
+ responseBody: __content_403,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ // Prompt or provided image failed safety check.
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Ideogram.GenerateImageSafetyError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ responseBody: __content_422,
+ responseObject: __value_422,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ responseBody: __content_429,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessPostRemixImageV3ResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
+ }
+ ///
+ /// Remix with Ideogram 3.0
+ /// Remix provided images synchronously based on a given prompt and optional parameters with the Ideogram 3.0 model.
+ /// Input images are cropped to the chosen aspect ratio before being remixed.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it.
+ ///
+ ///
+ /// The image to remix binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ ///
+ /// The image to remix binary (max size 10MB); only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ ///
+ /// The prompt to use to generate the image.
+ /// Example: A photo of a cat
+ ///
+ ///
+ /// Default Value: 50
+ /// Example: 50
+ ///
+ ///
+ /// Random seed. Set for reproducible generation.
+ /// Example: 12345
+ ///
+ ///
+ /// The resolutions supported for Ideogram 3.0.
+ /// Example: 1280x800
+ ///
+ ///
+ /// The aspect ratio to use for image generation, which determines the image's resolution. Cannot be used in conjunction with resolution. Defaults to 1x1.
+ ///
+ ///
+ /// The rendering speed to use.
+ /// Default Value: DEFAULT
+ ///
+ ///
+ /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON
+ ///
+ ///
+ /// A base64url-encoded magic prompt system prompt config ID to use for this request.
+ ///
+ ///
+ /// Description of what to exclude from an image. Descriptions in the prompt take precedence
+ /// to descriptions in the negative prompt.
+ /// Example: brush strokes, painting
+ ///
+ ///
+ /// Number of images to generate.
+ /// Default Value: 1
+ ///
+ ///
+ /// A color palette for generation, must EITHER be specified via one of the presets (name) or explicitly via hexadecimal representations of the color with optional weights (members). Not supported by V_1, V_1_TURBO, V_2A and V_2A_TURBO models.
+ ///
+ ///
+ /// A list of 8 character hexadecimal codes representing the style of the image. Cannot be used in conjunction with style_reference_images or style_type.
+ /// Example: [AAFF5733, 0133FF57, DE3357FF]
+ ///
+ ///
+ /// The style type to generate with.
+ /// Default Value: GENERAL
+ /// Example: GENERAL
+ ///
+ ///
+ /// A predefined style preset that applies a specific artistic style to the generated image.
+ /// Example: BRIGHT_ART
+ ///
+ ///
+ /// A custom model URI in the format model/<model_name>/version/<version_name>.
+ /// When provided, the model version and style will be resolved from this URI, and style_type is not required.
+ /// Example: model/my-custom-model/version/1
+ ///
+ ///
+ /// A set of images to use as style references (maximum total size 10MB across all style references). The images should be in JPEG, PNG or WebP format.
+ ///
+ ///
+ /// Optional file names to use for the multipart 'style_reference_images' file parts.
+ ///
+ ///
+ /// Generations with character reference are subject to the character reference pricing. A set of images to use as character references (maximum total size 10MB across all character references), currently only supports 1 character reference image. The images should be in JPEG, PNG or WebP format.
+ ///
+ ///
+ /// Optional file names to use for the multipart 'character_reference_images' file parts.
+ ///
+ ///
+ /// Optional masks for character reference images. When provided, must match the number of character_reference_images. Each mask should be a grayscale image of the same dimensions as the corresponding character reference image. The images should be in JPEG, PNG or WebP format.
+ ///
+ ///
+ /// Optional file names to use for the multipart 'character_reference_images_mask' file parts.
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> PostRemixImageV3AsResponseAsync(
+ global::System.IO.Stream image,
+ string imagename,
+ string prompt,
+ int? imageWeight = default,
+ int? seed = default,
+ global::Ideogram.ResolutionV3? resolution = default,
+ global::Ideogram.AspectRatioV3? aspectRatio = default,
+ global::Ideogram.RenderingSpeed? renderingSpeed = default,
+ global::Ideogram.MagicPromptOption? magicPrompt = default,
+ string? magicPromptSystemPromptConfigId = default,
+ string? negativePrompt = default,
+ int? numImages = default,
+ global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette = default,
+ global::System.Collections.Generic.IList? styleCodes = default,
+ global::Ideogram.StyleTypeV3? styleType = default,
+ global::Ideogram.StylePresetV3? stylePreset = default,
+ string? customModelUri = default,
+ global::System.Collections.Generic.IReadOnlyList? styleReferenceImages = default,
+ global::System.Collections.Generic.IReadOnlyList? styleReferenceImagesFileNames = default,
+ global::System.Collections.Generic.IReadOnlyList? characterReferenceImages = default,
+ global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesFileNames = default,
+ global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesMask = default,
+ global::System.Collections.Generic.IReadOnlyList? characterReferenceImagesMaskFileNames = default,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+
+ image = image ?? throw new global::System.ArgumentNullException(nameof(image));
+ var request = new global::Ideogram.RemixImageRequestV3
+ {
+ Image = global::System.Array.Empty(),
+ Imagename = imagename,
+ Prompt = prompt,
+ ImageWeight = imageWeight,
+ Seed = seed,
+ Resolution = resolution,
+ AspectRatio = aspectRatio,
+ RenderingSpeed = renderingSpeed,
+ MagicPrompt = magicPrompt,
+ MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId,
+ NegativePrompt = negativePrompt,
+ NumImages = numImages,
+ ColorPalette = colorPalette,
+ StyleCodes = styleCodes,
+ StyleType = styleType,
+ StylePreset = stylePreset,
+ CustomModelUri = customModelUri,
+ StyleReferenceImages = new global::System.Collections.Generic.List(),
+ CharacterReferenceImages = new global::System.Collections.Generic.List(),
+ CharacterReferenceImagesMask = new global::System.Collections.Generic.List(),
+ };
+ PrepareArguments(
+ client: HttpClient);
+ PreparePostRemixImageV3Arguments(
+ httpClient: HttpClient,
+ request: request);
+
+
+ var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations(
+ availableAuthorizations: Authorizations,
+ securityRequirements: s_PostRemixImageV3SecurityRequirements,
+ operationName: "PostRemixImageV3Async");
+
+ using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: false);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+
+ var __pathBuilder = new global::Ideogram.PathBuilder(
+ path: "/v1/ideogram-v3/remix",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+#endif
+
+ foreach (var __authorization in __authorizations)
+ {
+ if (__authorization.Type == "Http" ||
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
+ {
+ __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
+ scheme: __authorization.Name,
+ parameter: __authorization.Value);
+ }
+ else if (__authorization.Type == "ApiKey" &&
+ __authorization.Location == "Header")
+ {
+ __httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
+ }
+ }
+
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ var __contentImage = new global::System.Net.Http.StreamContent(image);
+ __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.Imagename is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentImage,
+ name: "\"image\"",
+ fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty);
+ if (__contentImage.Headers.ContentDisposition != null)
+ {
+ __contentImage.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty),
+ name: "\"prompt\"");
+
+ if (request.ImageWeight != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.ImageWeight, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"image_weight\"");
+
+ }
+ if (request.Seed != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"seed\"");
+
+ }
+ if (request.Resolution != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.Resolution).HasValue ? (request.Resolution).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"resolution\"");
+
+ }
+ if (request.AspectRatio != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.AspectRatio).HasValue ? (request.AspectRatio).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"aspect_ratio\"");
+
+ }
+ if (request.RenderingSpeed != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"rendering_speed\"");
+
+ }
+ if (request.MagicPrompt != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.MagicPrompt).HasValue ? (request.MagicPrompt).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"magic_prompt\"");
+
+ }
+ if (request.MagicPromptSystemPromptConfigId != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty),
+ name: "\"magic_prompt_system_prompt_config_id\"");
+
+ }
+ if (request.NegativePrompt != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.NegativePrompt ?? string.Empty),
+ name: "\"negative_prompt\"");
+
+ }
+ if (request.NumImages != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"num_images\"");
+
+ }
+ if (request.ColorPalette != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.ColorPalette.ToString() ?? string.Empty),
+ name: "\"color_palette\"");
+
+ }
+ if (request.StyleCodes != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.StyleCodes, x => x))}]"),
+ name: "\"style_codes\"");
+
+ }
+ if (request.StyleType != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.StyleType).HasValue ? (request.StyleType).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"style_type\"");
+
+ }
+ if (request.StylePreset != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.StylePreset).HasValue ? (request.StylePreset).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"style_preset\"");
+
+ }
+ if (request.CustomModelUri != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.CustomModelUri ?? string.Empty),
+ name: "\"custom_model_uri\"");
+
+ }
+ if (styleReferenceImages != default)
+ {
+
+ for (var __iStyleReferenceImages = 0; __iStyleReferenceImages < styleReferenceImages.Count; __iStyleReferenceImages++)
+ {
+ var __fileNameStyleReferenceImages = styleReferenceImagesFileNames != null &&
+ __iStyleReferenceImages < styleReferenceImagesFileNames.Count &&
+ styleReferenceImagesFileNames[__iStyleReferenceImages] != null
+ ? styleReferenceImagesFileNames[__iStyleReferenceImages]
+ : $"file{__iStyleReferenceImages}.bin";
+ var __contentStyleReferenceImages = new global::System.Net.Http.StreamContent(styleReferenceImages[__iStyleReferenceImages]);
+ __contentStyleReferenceImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ __fileNameStyleReferenceImages is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(__fileNameStyleReferenceImages) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentStyleReferenceImages,
+ name: "\"style_reference_images\"",
+ fileName: $"\"{__fileNameStyleReferenceImages}\"");
+ if (__contentStyleReferenceImages.Headers.ContentDisposition != null)
+ {
+ __contentStyleReferenceImages.Headers.ContentDisposition.FileNameStar = null;
+ }
+ }
+
+ }
+ if (characterReferenceImages != default)
+ {
+
+ for (var __iCharacterReferenceImages = 0; __iCharacterReferenceImages < characterReferenceImages.Count; __iCharacterReferenceImages++)
+ {
+ var __fileNameCharacterReferenceImages = characterReferenceImagesFileNames != null &&
+ __iCharacterReferenceImages < characterReferenceImagesFileNames.Count &&
+ characterReferenceImagesFileNames[__iCharacterReferenceImages] != null
+ ? characterReferenceImagesFileNames[__iCharacterReferenceImages]
+ : $"file{__iCharacterReferenceImages}.bin";
+ var __contentCharacterReferenceImages = new global::System.Net.Http.StreamContent(characterReferenceImages[__iCharacterReferenceImages]);
+ __contentCharacterReferenceImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ __fileNameCharacterReferenceImages is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(__fileNameCharacterReferenceImages) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentCharacterReferenceImages,
+ name: "\"character_reference_images\"",
+ fileName: $"\"{__fileNameCharacterReferenceImages}\"");
+ if (__contentCharacterReferenceImages.Headers.ContentDisposition != null)
+ {
+ __contentCharacterReferenceImages.Headers.ContentDisposition.FileNameStar = null;
+ }
+ }
+
+ }
+ if (characterReferenceImagesMask != default)
+ {
+
+ for (var __iCharacterReferenceImagesMask = 0; __iCharacterReferenceImagesMask < characterReferenceImagesMask.Count; __iCharacterReferenceImagesMask++)
+ {
+ var __fileNameCharacterReferenceImagesMask = characterReferenceImagesMaskFileNames != null &&
+ __iCharacterReferenceImagesMask < characterReferenceImagesMaskFileNames.Count &&
+ characterReferenceImagesMaskFileNames[__iCharacterReferenceImagesMask] != null
+ ? characterReferenceImagesMaskFileNames[__iCharacterReferenceImagesMask]
+ : $"file{__iCharacterReferenceImagesMask}.bin";
+ var __contentCharacterReferenceImagesMask = new global::System.Net.Http.StreamContent(characterReferenceImagesMask[__iCharacterReferenceImagesMask]);
+ __contentCharacterReferenceImagesMask.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ __fileNameCharacterReferenceImagesMask is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(__fileNameCharacterReferenceImagesMask) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentCharacterReferenceImagesMask,
+ name: "\"character_reference_images_mask\"",
+ fileName: $"\"{__fileNameCharacterReferenceImagesMask}\"");
+ if (__contentCharacterReferenceImagesMask.Headers.ContentDisposition != null)
+ {
+ __contentCharacterReferenceImagesMask.Headers.ContentDisposition.FileNameStar = null;
+ }
+ }
+
+ }
+
+ __httpRequest.Content = __httpRequestContent;
+
+ global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PreparePostRemixImageV3Request(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
+
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostRemixImageV3",
+ methodName: "PostRemixImageV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/remix\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ catch (global::System.Net.Http.HttpRequestException __exception)
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostRemixImageV3",
+ methodName: "PostRemixImageV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/remix\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostRemixImageV3",
+ methodName: "PostRemixImageV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/remix\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessPostRemixImageV3Response(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostRemixImageV3",
+ methodName: "PostRemixImageV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/remix\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostRemixImageV3",
+ methodName: "PostRemixImageV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/remix\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ //
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 403)
+ {
+ string? __content_403 = null;
+ global::System.Exception? __exception_403 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_403 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_403 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_403 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_403,
+ responseBody: __content_403,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ // Prompt or provided image failed safety check.
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Ideogram.GenerateImageSafetyError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ responseBody: __content_422,
+ responseObject: __value_422,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ responseBody: __content_429,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessPostRemixImageV3ResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ var __value = global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ var __value = await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
+ }
}
}
\ No newline at end of file
diff --git a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostRemoveBackground.g.cs b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostRemoveBackground.g.cs
new file mode 100644
index 0000000..d59dcbd
--- /dev/null
+++ b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostRemoveBackground.g.cs
@@ -0,0 +1,1745 @@
+
+#nullable enable
+
+namespace Ideogram
+{
+ public partial class GenerateClient
+ {
+
+
+ private static readonly global::Ideogram.EndPointSecurityRequirement s_PostRemoveBackgroundSecurityRequirement0 =
+ new global::Ideogram.EndPointSecurityRequirement
+ {
+ Authorizations = new global::Ideogram.EndPointAuthorizationRequirement[]
+ { new global::Ideogram.EndPointAuthorizationRequirement
+ {
+ Type = "Http",
+ SchemeId = "HttpBearer",
+ Location = "Header",
+ Name = "Bearer",
+ FriendlyName = "Bearer",
+ },
+ },
+ };
+ private static readonly global::Ideogram.EndPointSecurityRequirement[] s_PostRemoveBackgroundSecurityRequirements =
+ new global::Ideogram.EndPointSecurityRequirement[]
+ { s_PostRemoveBackgroundSecurityRequirement0,
+ };
+ partial void PreparePostRemoveBackgroundArguments(
+ global::System.Net.Http.HttpClient httpClient,
+ global::Ideogram.RemoveBackgroundRequest request);
+ partial void PreparePostRemoveBackgroundRequest(
+ global::System.Net.Http.HttpClient httpClient,
+ global::System.Net.Http.HttpRequestMessage httpRequestMessage,
+ global::Ideogram.RemoveBackgroundRequest request);
+ partial void ProcessPostRemoveBackgroundResponse(
+ global::System.Net.Http.HttpClient httpClient,
+ global::System.Net.Http.HttpResponseMessage httpResponseMessage);
+
+ partial void ProcessPostRemoveBackgroundResponseContent(
+ global::System.Net.Http.HttpClient httpClient,
+ global::System.Net.Http.HttpResponseMessage httpResponseMessage,
+ ref string content);
+
+ ///
+ /// Remove Background
+ /// Remove the background of a given image synchronously. The foreground subject
+ /// is identified and returned on a transparent background. Supported image formats include JPEG,
+ /// PNG, and WebP.
+ /// Image links are available for a limited period of time; if you would like to keep the image,
+ /// you must download it.
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task PostRemoveBackgroundAsync(
+
+ global::Ideogram.RemoveBackgroundRequest request,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await PostRemoveBackgroundAsResponseAsync(
+
+ request: request,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// Remove Background
+ /// Remove the background of a given image synchronously. The foreground subject
+ /// is identified and returned on a transparent background. Supported image formats include JPEG,
+ /// PNG, and WebP.
+ /// Image links are available for a limited period of time; if you would like to keep the image,
+ /// you must download it.
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> PostRemoveBackgroundAsResponseAsync(
+
+ global::Ideogram.RemoveBackgroundRequest request,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ request = request ?? throw new global::System.ArgumentNullException(nameof(request));
+
+ PrepareArguments(
+ client: HttpClient);
+ PreparePostRemoveBackgroundArguments(
+ httpClient: HttpClient,
+ request: request);
+
+
+ var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations(
+ availableAuthorizations: Authorizations,
+ securityRequirements: s_PostRemoveBackgroundSecurityRequirements,
+ operationName: "PostRemoveBackgroundAsync");
+
+ using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: false);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+
+ var __pathBuilder = new global::Ideogram.PathBuilder(
+ path: "/v1/remove-background",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+#endif
+
+ foreach (var __authorization in __authorizations)
+ {
+ if (__authorization.Type == "Http" ||
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
+ {
+ __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
+ scheme: __authorization.Name,
+ parameter: __authorization.Value);
+ }
+ else if (__authorization.Type == "ApiKey" &&
+ __authorization.Location == "Header")
+ {
+ __httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
+ }
+ }
+
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ var __contentImage = new global::System.Net.Http.ByteArrayContent(request.Image ?? global::System.Array.Empty());
+ __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.Imagename is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentImage,
+ name: "\"image\"",
+ fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty);
+ if (__contentImage.Headers.ContentDisposition != null)
+ {
+ __contentImage.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ __httpRequest.Content = __httpRequestContent;
+
+ global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PreparePostRemoveBackgroundRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
+
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostRemoveBackground",
+ methodName: "PostRemoveBackgroundAsync",
+ pathTemplate: "\"/v1/remove-background\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ catch (global::System.Net.Http.HttpRequestException __exception)
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostRemoveBackground",
+ methodName: "PostRemoveBackgroundAsync",
+ pathTemplate: "\"/v1/remove-background\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostRemoveBackground",
+ methodName: "PostRemoveBackgroundAsync",
+ pathTemplate: "\"/v1/remove-background\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessPostRemoveBackgroundResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostRemoveBackground",
+ methodName: "PostRemoveBackgroundAsync",
+ pathTemplate: "\"/v1/remove-background\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostRemoveBackground",
+ methodName: "PostRemoveBackgroundAsync",
+ pathTemplate: "\"/v1/remove-background\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ //
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ responseBody: __content_401,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ // Initial image failed the safety checks.
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Ideogram.GenerateImageSafetyError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ responseBody: __content_422,
+ responseObject: __value_422,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ responseBody: __content_429,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessPostRemoveBackgroundResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ var __value = global::Ideogram.RemoveBackgroundResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ var __value = await global::Ideogram.RemoveBackgroundResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
+ }
+ ///
+ /// Remove Background
+ /// Remove the background of a given image synchronously. The foreground subject
+ /// is identified and returned on a transparent background. Supported image formats include JPEG,
+ /// PNG, and WebP.
+ /// Image links are available for a limited period of time; if you would like to keep the image,
+ /// you must download it.
+ ///
+ ///
+ /// The image whose background is being removed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ ///
+ /// The image whose background is being removed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task PostRemoveBackgroundAsync(
+ byte[] image,
+ string imagename,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __request = new global::Ideogram.RemoveBackgroundRequest
+ {
+ Image = image,
+ Imagename = imagename,
+ };
+
+ return await PostRemoveBackgroundAsync(
+ request: __request,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken).ConfigureAwait(false);
+ }
+
+ ///
+ /// Remove Background
+ /// Remove the background of a given image synchronously. The foreground subject
+ /// is identified and returned on a transparent background. Supported image formats include JPEG,
+ /// PNG, and WebP.
+ /// Image links are available for a limited period of time; if you would like to keep the image,
+ /// you must download it.
+ ///
+ ///
+ /// The image whose background is being removed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ ///
+ /// The image whose background is being removed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task PostRemoveBackgroundAsync(
+ global::System.IO.Stream image,
+ string imagename,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+
+ image = image ?? throw new global::System.ArgumentNullException(nameof(image));
+ var request = new global::Ideogram.RemoveBackgroundRequest
+ {
+ Image = global::System.Array.Empty(),
+ Imagename = imagename,
+ };
+ PrepareArguments(
+ client: HttpClient);
+ PreparePostRemoveBackgroundArguments(
+ httpClient: HttpClient,
+ request: request);
+
+
+ var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations(
+ availableAuthorizations: Authorizations,
+ securityRequirements: s_PostRemoveBackgroundSecurityRequirements,
+ operationName: "PostRemoveBackgroundAsync");
+
+ using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: false);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+
+ var __pathBuilder = new global::Ideogram.PathBuilder(
+ path: "/v1/remove-background",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+#endif
+
+ foreach (var __authorization in __authorizations)
+ {
+ if (__authorization.Type == "Http" ||
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
+ {
+ __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
+ scheme: __authorization.Name,
+ parameter: __authorization.Value);
+ }
+ else if (__authorization.Type == "ApiKey" &&
+ __authorization.Location == "Header")
+ {
+ __httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
+ }
+ }
+
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ var __contentImage = new global::System.Net.Http.StreamContent(image);
+ __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.Imagename is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentImage,
+ name: "\"image\"",
+ fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty);
+ if (__contentImage.Headers.ContentDisposition != null)
+ {
+ __contentImage.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ __httpRequest.Content = __httpRequestContent;
+
+ global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PreparePostRemoveBackgroundRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
+
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostRemoveBackground",
+ methodName: "PostRemoveBackgroundAsync",
+ pathTemplate: "\"/v1/remove-background\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ catch (global::System.Net.Http.HttpRequestException __exception)
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostRemoveBackground",
+ methodName: "PostRemoveBackgroundAsync",
+ pathTemplate: "\"/v1/remove-background\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostRemoveBackground",
+ methodName: "PostRemoveBackgroundAsync",
+ pathTemplate: "\"/v1/remove-background\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessPostRemoveBackgroundResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostRemoveBackground",
+ methodName: "PostRemoveBackgroundAsync",
+ pathTemplate: "\"/v1/remove-background\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostRemoveBackground",
+ methodName: "PostRemoveBackgroundAsync",
+ pathTemplate: "\"/v1/remove-background\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ //
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ responseBody: __content_401,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ // Initial image failed the safety checks.
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Ideogram.GenerateImageSafetyError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ responseBody: __content_422,
+ responseObject: __value_422,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ responseBody: __content_429,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessPostRemoveBackgroundResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Ideogram.RemoveBackgroundResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Ideogram.RemoveBackgroundResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
+ }
+ ///
+ /// Remove Background
+ /// Remove the background of a given image synchronously. The foreground subject
+ /// is identified and returned on a transparent background. Supported image formats include JPEG,
+ /// PNG, and WebP.
+ /// Image links are available for a limited period of time; if you would like to keep the image,
+ /// you must download it.
+ ///
+ ///
+ /// The image whose background is being removed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ ///
+ /// The image whose background is being removed (max size 10MB); only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> PostRemoveBackgroundAsResponseAsync(
+ global::System.IO.Stream image,
+ string imagename,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+
+ image = image ?? throw new global::System.ArgumentNullException(nameof(image));
+ var request = new global::Ideogram.RemoveBackgroundRequest
+ {
+ Image = global::System.Array.Empty(),
+ Imagename = imagename,
+ };
+ PrepareArguments(
+ client: HttpClient);
+ PreparePostRemoveBackgroundArguments(
+ httpClient: HttpClient,
+ request: request);
+
+
+ var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations(
+ availableAuthorizations: Authorizations,
+ securityRequirements: s_PostRemoveBackgroundSecurityRequirements,
+ operationName: "PostRemoveBackgroundAsync");
+
+ using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: false);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+
+ var __pathBuilder = new global::Ideogram.PathBuilder(
+ path: "/v1/remove-background",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+#endif
+
+ foreach (var __authorization in __authorizations)
+ {
+ if (__authorization.Type == "Http" ||
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
+ {
+ __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
+ scheme: __authorization.Name,
+ parameter: __authorization.Value);
+ }
+ else if (__authorization.Type == "ApiKey" &&
+ __authorization.Location == "Header")
+ {
+ __httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
+ }
+ }
+
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ var __contentImage = new global::System.Net.Http.StreamContent(image);
+ __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.Imagename is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentImage,
+ name: "\"image\"",
+ fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty);
+ if (__contentImage.Headers.ContentDisposition != null)
+ {
+ __contentImage.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ __httpRequest.Content = __httpRequestContent;
+
+ global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PreparePostRemoveBackgroundRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
+
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostRemoveBackground",
+ methodName: "PostRemoveBackgroundAsync",
+ pathTemplate: "\"/v1/remove-background\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ catch (global::System.Net.Http.HttpRequestException __exception)
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostRemoveBackground",
+ methodName: "PostRemoveBackgroundAsync",
+ pathTemplate: "\"/v1/remove-background\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostRemoveBackground",
+ methodName: "PostRemoveBackgroundAsync",
+ pathTemplate: "\"/v1/remove-background\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessPostRemoveBackgroundResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostRemoveBackground",
+ methodName: "PostRemoveBackgroundAsync",
+ pathTemplate: "\"/v1/remove-background\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostRemoveBackground",
+ methodName: "PostRemoveBackgroundAsync",
+ pathTemplate: "\"/v1/remove-background\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ //
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ responseBody: __content_401,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ // Initial image failed the safety checks.
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Ideogram.GenerateImageSafetyError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ responseBody: __content_422,
+ responseObject: __value_422,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ responseBody: __content_429,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessPostRemoveBackgroundResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ var __value = global::Ideogram.RemoveBackgroundResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ var __value = await global::Ideogram.RemoveBackgroundResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostReplaceBackgroundV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostReplaceBackgroundV3.g.cs
index 1cb24fd..7261954 100644
--- a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostReplaceBackgroundV3.g.cs
+++ b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostReplaceBackgroundV3.g.cs
@@ -54,6 +54,32 @@ partial void ProcessPostReplaceBackgroundV3ResponseContent(
///
public async global::System.Threading.Tasks.Task PostReplaceBackgroundV3Async(
+ global::Ideogram.ReplaceBackgroundRequestV3 request,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await PostReplaceBackgroundV3AsResponseAsync(
+
+ request: request,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// Replace Background with Ideogram 3.0
+ /// Replace the background of a given image synchronously using a prompt with Ideogram 3.0. The foreground subject
+ /// will be identified and kept, while the background is replaced based on the prompt and chosen style.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it.
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> PostReplaceBackgroundV3AsResponseAsync(
+
global::Ideogram.ReplaceBackgroundRequestV3 request,
global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
@@ -84,10 +110,11 @@ partial void ProcessPostReplaceBackgroundV3ResponseContent(
var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts(
clientOptions: Options,
requestOptions: requestOptions,
- supportsRetry: true);
+ supportsRetry: false);
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Ideogram.PathBuilder(
path: "/v1/ideogram-v3/replace-background",
baseUri: HttpClient.BaseAddress);
@@ -120,6 +147,7 @@ partial void ProcessPostReplaceBackgroundV3ResponseContent(
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
}
}
+
var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
var __contentImage = new global::System.Net.Http.ByteArrayContent(request.Image ?? global::System.Array.Empty());
__contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
@@ -158,58 +186,75 @@ request.Imagename is null
{
__contentImage.Headers.ContentDisposition.FileNameStar = null;
}
+
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty),
name: "\"prompt\"");
+
if (request.MagicPrompt != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.MagicPrompt).HasValue ? (request.MagicPrompt).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"magic_prompt\"");
- }
+
+ }
+ if (request.MagicPromptSystemPromptConfigId != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty),
+ name: "\"magic_prompt_system_prompt_config_id\"");
+
+ }
if (request.NumImages != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
name: "\"num_images\"");
- }
+
+ }
if (request.Seed != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
name: "\"seed\"");
- }
+
+ }
if (request.RenderingSpeed != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"rendering_speed\"");
- }
+
+ }
if (request.StylePreset != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.StylePreset).HasValue ? (request.StylePreset).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"style_preset\"");
- }
+
+ }
if (request.ColorPalette != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.ColorPalette.ToString() ?? string.Empty),
name: "\"color_palette\"");
- }
+
+ }
if (request.StyleCodes != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.StyleCodes, x => x))}]"),
name: "\"style_codes\"");
- }
+
+ }
if (request.StyleReferenceImages != default)
{
@@ -226,8 +271,11 @@ request.Imagename is null
__contentStyleReferenceImages.Headers.ContentDisposition.FileNameStar = null;
}
}
+
}
+
__httpRequest.Content = __httpRequestContent;
+
global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders(
request: __httpRequest,
clientHeaders: Options.Headers,
@@ -269,6 +317,8 @@ request.Imagename is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -279,6 +329,11 @@ request.Imagename is null
}
catch (global::System.Net.Http.HttpRequestException __exception)
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
@@ -296,6 +351,8 @@ request.Imagename is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -305,8 +362,7 @@ request.Imagename is null
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -315,6 +371,11 @@ request.Imagename is null
__attempt < __maxAttempts &&
global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
@@ -331,14 +392,15 @@ request.Imagename is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
__response.Dispose();
__response = null;
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -378,6 +440,8 @@ request.Imagename is null
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -398,6 +462,8 @@ request.Imagename is null
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
//
@@ -421,17 +487,16 @@ request.Imagename is null
__exception_400 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_400,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
//
if ((int)__response.StatusCode == 401)
@@ -454,17 +519,16 @@ request.Imagename is null
__exception_401 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_401,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_401,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_401,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
// Prompt or Initial Image failed the safety checks.
if ((int)__response.StatusCode == 422)
@@ -491,18 +555,17 @@ request.Imagename is null
__exception_422 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_422,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_422,
+ responseObject: __value_422,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
//
if ((int)__response.StatusCode == 429)
@@ -525,17 +588,16 @@ request.Imagename is null
__exception_429 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_429,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_429,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_429,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
if (__effectiveReadResponseAsString)
@@ -559,23 +621,25 @@ request.Imagename is null
{
__response.EnsureSuccessStatusCode();
- return
- global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ??
+ var __value = global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
else
@@ -589,9 +653,13 @@ request.Imagename is null
#endif
).ConfigureAwait(false);
- return
- await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ var __value = await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -608,17 +676,15 @@ request.Imagename is null
{
}
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
@@ -650,6 +716,9 @@ request.Imagename is null
/// Determine if MagicPrompt should be used in generating the request or not.
/// Example: ON
///
+ ///
+ /// A base64url-encoded magic prompt system prompt config ID to use for this request.
+ ///
///
/// The number of images to generate.
/// Default Value: 1
@@ -684,6 +753,7 @@ request.Imagename is null
string imagename,
string prompt,
global::Ideogram.MagicPromptOption? magicPrompt = default,
+ string? magicPromptSystemPromptConfigId = default,
int? numImages = default,
int? seed = default,
global::Ideogram.RenderingSpeed? renderingSpeed = default,
@@ -700,6 +770,7 @@ request.Imagename is null
Imagename = imagename,
Prompt = prompt,
MagicPrompt = magicPrompt,
+ MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId,
NumImages = numImages,
Seed = seed,
RenderingSpeed = renderingSpeed,
@@ -714,5 +785,1460 @@ request.Imagename is null
requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
+
+ ///
+ /// Replace Background with Ideogram 3.0
+ /// Replace the background of a given image synchronously using a prompt with Ideogram 3.0. The foreground subject
+ /// will be identified and kept, while the background is replaced based on the prompt and chosen style.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it.
+ ///
+ ///
+ /// The image whose background is being replaced (max size 10MB); only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ ///
+ /// The image whose background is being replaced (max size 10MB); only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ ///
+ /// The prompt describing the desired new background.
+ /// Example: A vibrant cityscape at night.
+ ///
+ ///
+ /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON
+ ///
+ ///
+ /// A base64url-encoded magic prompt system prompt config ID to use for this request.
+ ///
+ ///
+ /// The number of images to generate.
+ /// Default Value: 1
+ ///
+ ///
+ /// Random seed. Set for reproducible generation.
+ /// Example: 12345
+ ///
+ ///
+ /// The rendering speed to use.
+ /// Default Value: DEFAULT
+ ///
+ ///
+ /// A predefined style preset that applies a specific artistic style to the generated image.
+ /// Example: BRIGHT_ART
+ ///
+ ///
+ /// A color palette for generation, must EITHER be specified via one of the presets (name) or explicitly via hexadecimal representations of the color with optional weights (members). Not supported by V_1, V_1_TURBO, V_2A and V_2A_TURBO models.
+ ///
+ ///
+ /// A list of 8 character hexadecimal codes representing the style of the image. Cannot be used in conjunction with style_reference_images or style_type.
+ /// Example: [AAFF5733, 0133FF57, DE3357FF]
+ ///
+ ///
+ /// A set of images to use as style references (maximum total size 10MB across all style references). The images should be in JPEG, PNG or WebP format.
+ ///
+ ///
+ /// Optional file names to use for the multipart 'style_reference_images' file parts.
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task PostReplaceBackgroundV3Async(
+ global::System.IO.Stream image,
+ string imagename,
+ string prompt,
+ global::Ideogram.MagicPromptOption? magicPrompt = default,
+ string? magicPromptSystemPromptConfigId = default,
+ int? numImages = default,
+ int? seed = default,
+ global::Ideogram.RenderingSpeed? renderingSpeed = default,
+ global::Ideogram.StylePresetV3? stylePreset = default,
+ global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette = default,
+ global::System.Collections.Generic.IList? styleCodes = default,
+ global::System.Collections.Generic.IReadOnlyList? styleReferenceImages = default,
+ global::System.Collections.Generic.IReadOnlyList? styleReferenceImagesFileNames = default,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+
+ image = image ?? throw new global::System.ArgumentNullException(nameof(image));
+ var request = new global::Ideogram.ReplaceBackgroundRequestV3
+ {
+ Image = global::System.Array.Empty(),
+ Imagename = imagename,
+ Prompt = prompt,
+ MagicPrompt = magicPrompt,
+ MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId,
+ NumImages = numImages,
+ Seed = seed,
+ RenderingSpeed = renderingSpeed,
+ StylePreset = stylePreset,
+ ColorPalette = colorPalette,
+ StyleCodes = styleCodes,
+ StyleReferenceImages = new global::System.Collections.Generic.List(),
+ };
+ PrepareArguments(
+ client: HttpClient);
+ PreparePostReplaceBackgroundV3Arguments(
+ httpClient: HttpClient,
+ request: request);
+
+
+ var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations(
+ availableAuthorizations: Authorizations,
+ securityRequirements: s_PostReplaceBackgroundV3SecurityRequirements,
+ operationName: "PostReplaceBackgroundV3Async");
+
+ using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: false);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+
+ var __pathBuilder = new global::Ideogram.PathBuilder(
+ path: "/v1/ideogram-v3/replace-background",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+#endif
+
+ foreach (var __authorization in __authorizations)
+ {
+ if (__authorization.Type == "Http" ||
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
+ {
+ __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
+ scheme: __authorization.Name,
+ parameter: __authorization.Value);
+ }
+ else if (__authorization.Type == "ApiKey" &&
+ __authorization.Location == "Header")
+ {
+ __httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
+ }
+ }
+
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ var __contentImage = new global::System.Net.Http.StreamContent(image);
+ __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.Imagename is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentImage,
+ name: "\"image\"",
+ fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty);
+ if (__contentImage.Headers.ContentDisposition != null)
+ {
+ __contentImage.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty),
+ name: "\"prompt\"");
+
+ if (request.MagicPrompt != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.MagicPrompt).HasValue ? (request.MagicPrompt).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"magic_prompt\"");
+
+ }
+ if (request.MagicPromptSystemPromptConfigId != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty),
+ name: "\"magic_prompt_system_prompt_config_id\"");
+
+ }
+ if (request.NumImages != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"num_images\"");
+
+ }
+ if (request.Seed != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"seed\"");
+
+ }
+ if (request.RenderingSpeed != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"rendering_speed\"");
+
+ }
+ if (request.StylePreset != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.StylePreset).HasValue ? (request.StylePreset).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"style_preset\"");
+
+ }
+ if (request.ColorPalette != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.ColorPalette.ToString() ?? string.Empty),
+ name: "\"color_palette\"");
+
+ }
+ if (request.StyleCodes != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.StyleCodes, x => x))}]"),
+ name: "\"style_codes\"");
+
+ }
+ if (styleReferenceImages != default)
+ {
+
+ for (var __iStyleReferenceImages = 0; __iStyleReferenceImages < styleReferenceImages.Count; __iStyleReferenceImages++)
+ {
+ var __fileNameStyleReferenceImages = styleReferenceImagesFileNames != null &&
+ __iStyleReferenceImages < styleReferenceImagesFileNames.Count &&
+ styleReferenceImagesFileNames[__iStyleReferenceImages] != null
+ ? styleReferenceImagesFileNames[__iStyleReferenceImages]
+ : $"file{__iStyleReferenceImages}.bin";
+ var __contentStyleReferenceImages = new global::System.Net.Http.StreamContent(styleReferenceImages[__iStyleReferenceImages]);
+ __contentStyleReferenceImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ __fileNameStyleReferenceImages is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(__fileNameStyleReferenceImages) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentStyleReferenceImages,
+ name: "\"style_reference_images\"",
+ fileName: $"\"{__fileNameStyleReferenceImages}\"");
+ if (__contentStyleReferenceImages.Headers.ContentDisposition != null)
+ {
+ __contentStyleReferenceImages.Headers.ContentDisposition.FileNameStar = null;
+ }
+ }
+
+ }
+
+ __httpRequest.Content = __httpRequestContent;
+
+ global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PreparePostReplaceBackgroundV3Request(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
+
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostReplaceBackgroundV3",
+ methodName: "PostReplaceBackgroundV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/replace-background\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ catch (global::System.Net.Http.HttpRequestException __exception)
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostReplaceBackgroundV3",
+ methodName: "PostReplaceBackgroundV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/replace-background\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostReplaceBackgroundV3",
+ methodName: "PostReplaceBackgroundV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/replace-background\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessPostReplaceBackgroundV3Response(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostReplaceBackgroundV3",
+ methodName: "PostReplaceBackgroundV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/replace-background\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostReplaceBackgroundV3",
+ methodName: "PostReplaceBackgroundV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/replace-background\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ //
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ responseBody: __content_401,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ // Prompt or Initial Image failed the safety checks.
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Ideogram.GenerateImageSafetyError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ responseBody: __content_422,
+ responseObject: __value_422,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ responseBody: __content_429,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessPostReplaceBackgroundV3ResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
+ }
+ ///
+ /// Replace Background with Ideogram 3.0
+ /// Replace the background of a given image synchronously using a prompt with Ideogram 3.0. The foreground subject
+ /// will be identified and kept, while the background is replaced based on the prompt and chosen style.
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it.
+ ///
+ ///
+ /// The image whose background is being replaced (max size 10MB); only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ ///
+ /// The image whose background is being replaced (max size 10MB); only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ ///
+ /// The prompt describing the desired new background.
+ /// Example: A vibrant cityscape at night.
+ ///
+ ///
+ /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON
+ ///
+ ///
+ /// A base64url-encoded magic prompt system prompt config ID to use for this request.
+ ///
+ ///
+ /// The number of images to generate.
+ /// Default Value: 1
+ ///
+ ///
+ /// Random seed. Set for reproducible generation.
+ /// Example: 12345
+ ///
+ ///
+ /// The rendering speed to use.
+ /// Default Value: DEFAULT
+ ///
+ ///
+ /// A predefined style preset that applies a specific artistic style to the generated image.
+ /// Example: BRIGHT_ART
+ ///
+ ///
+ /// A color palette for generation, must EITHER be specified via one of the presets (name) or explicitly via hexadecimal representations of the color with optional weights (members). Not supported by V_1, V_1_TURBO, V_2A and V_2A_TURBO models.
+ ///
+ ///
+ /// A list of 8 character hexadecimal codes representing the style of the image. Cannot be used in conjunction with style_reference_images or style_type.
+ /// Example: [AAFF5733, 0133FF57, DE3357FF]
+ ///
+ ///
+ /// A set of images to use as style references (maximum total size 10MB across all style references). The images should be in JPEG, PNG or WebP format.
+ ///
+ ///
+ /// Optional file names to use for the multipart 'style_reference_images' file parts.
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> PostReplaceBackgroundV3AsResponseAsync(
+ global::System.IO.Stream image,
+ string imagename,
+ string prompt,
+ global::Ideogram.MagicPromptOption? magicPrompt = default,
+ string? magicPromptSystemPromptConfigId = default,
+ int? numImages = default,
+ int? seed = default,
+ global::Ideogram.RenderingSpeed? renderingSpeed = default,
+ global::Ideogram.StylePresetV3? stylePreset = default,
+ global::Ideogram.ColorPaletteWithPresetNameOrMembers? colorPalette = default,
+ global::System.Collections.Generic.IList? styleCodes = default,
+ global::System.Collections.Generic.IReadOnlyList? styleReferenceImages = default,
+ global::System.Collections.Generic.IReadOnlyList? styleReferenceImagesFileNames = default,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+
+ image = image ?? throw new global::System.ArgumentNullException(nameof(image));
+ var request = new global::Ideogram.ReplaceBackgroundRequestV3
+ {
+ Image = global::System.Array.Empty(),
+ Imagename = imagename,
+ Prompt = prompt,
+ MagicPrompt = magicPrompt,
+ MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId,
+ NumImages = numImages,
+ Seed = seed,
+ RenderingSpeed = renderingSpeed,
+ StylePreset = stylePreset,
+ ColorPalette = colorPalette,
+ StyleCodes = styleCodes,
+ StyleReferenceImages = new global::System.Collections.Generic.List(),
+ };
+ PrepareArguments(
+ client: HttpClient);
+ PreparePostReplaceBackgroundV3Arguments(
+ httpClient: HttpClient,
+ request: request);
+
+
+ var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations(
+ availableAuthorizations: Authorizations,
+ securityRequirements: s_PostReplaceBackgroundV3SecurityRequirements,
+ operationName: "PostReplaceBackgroundV3Async");
+
+ using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: false);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+
+ var __pathBuilder = new global::Ideogram.PathBuilder(
+ path: "/v1/ideogram-v3/replace-background",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+#endif
+
+ foreach (var __authorization in __authorizations)
+ {
+ if (__authorization.Type == "Http" ||
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
+ {
+ __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
+ scheme: __authorization.Name,
+ parameter: __authorization.Value);
+ }
+ else if (__authorization.Type == "ApiKey" &&
+ __authorization.Location == "Header")
+ {
+ __httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
+ }
+ }
+
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ var __contentImage = new global::System.Net.Http.StreamContent(image);
+ __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.Imagename is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentImage,
+ name: "\"image\"",
+ fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty);
+ if (__contentImage.Headers.ContentDisposition != null)
+ {
+ __contentImage.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty),
+ name: "\"prompt\"");
+
+ if (request.MagicPrompt != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.MagicPrompt).HasValue ? (request.MagicPrompt).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"magic_prompt\"");
+
+ }
+ if (request.MagicPromptSystemPromptConfigId != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty),
+ name: "\"magic_prompt_system_prompt_config_id\"");
+
+ }
+ if (request.NumImages != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"num_images\"");
+
+ }
+ if (request.Seed != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"seed\"");
+
+ }
+ if (request.RenderingSpeed != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"rendering_speed\"");
+
+ }
+ if (request.StylePreset != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.StylePreset).HasValue ? (request.StylePreset).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"style_preset\"");
+
+ }
+ if (request.ColorPalette != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.ColorPalette.ToString() ?? string.Empty),
+ name: "\"color_palette\"");
+
+ }
+ if (request.StyleCodes != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.StyleCodes, x => x))}]"),
+ name: "\"style_codes\"");
+
+ }
+ if (styleReferenceImages != default)
+ {
+
+ for (var __iStyleReferenceImages = 0; __iStyleReferenceImages < styleReferenceImages.Count; __iStyleReferenceImages++)
+ {
+ var __fileNameStyleReferenceImages = styleReferenceImagesFileNames != null &&
+ __iStyleReferenceImages < styleReferenceImagesFileNames.Count &&
+ styleReferenceImagesFileNames[__iStyleReferenceImages] != null
+ ? styleReferenceImagesFileNames[__iStyleReferenceImages]
+ : $"file{__iStyleReferenceImages}.bin";
+ var __contentStyleReferenceImages = new global::System.Net.Http.StreamContent(styleReferenceImages[__iStyleReferenceImages]);
+ __contentStyleReferenceImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ __fileNameStyleReferenceImages is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(__fileNameStyleReferenceImages) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentStyleReferenceImages,
+ name: "\"style_reference_images\"",
+ fileName: $"\"{__fileNameStyleReferenceImages}\"");
+ if (__contentStyleReferenceImages.Headers.ContentDisposition != null)
+ {
+ __contentStyleReferenceImages.Headers.ContentDisposition.FileNameStar = null;
+ }
+ }
+
+ }
+
+ __httpRequest.Content = __httpRequestContent;
+
+ global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PreparePostReplaceBackgroundV3Request(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
+
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostReplaceBackgroundV3",
+ methodName: "PostReplaceBackgroundV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/replace-background\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ catch (global::System.Net.Http.HttpRequestException __exception)
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostReplaceBackgroundV3",
+ methodName: "PostReplaceBackgroundV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/replace-background\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostReplaceBackgroundV3",
+ methodName: "PostReplaceBackgroundV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/replace-background\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessPostReplaceBackgroundV3Response(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostReplaceBackgroundV3",
+ methodName: "PostReplaceBackgroundV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/replace-background\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostReplaceBackgroundV3",
+ methodName: "PostReplaceBackgroundV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/replace-background\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ //
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ responseBody: __content_401,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ // Prompt or Initial Image failed the safety checks.
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Ideogram.GenerateImageSafetyError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ responseBody: __content_422,
+ responseObject: __value_422,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ responseBody: __content_429,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessPostReplaceBackgroundV3ResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ var __value = global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ var __value = await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
+ }
}
}
\ No newline at end of file
diff --git a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostTryOnV3.g.cs b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostTryOnV3.g.cs
index 554a4e8..743fc9f 100644
--- a/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostTryOnV3.g.cs
+++ b/src/libs/Ideogram/Generated/Ideogram.GenerateClient.PostTryOnV3.g.cs
@@ -55,6 +55,33 @@ partial void ProcessPostTryOnV3ResponseContent(
///
public async global::System.Threading.Tasks.Task PostTryOnV3Async(
+ global::Ideogram.TryOnRequestV3 request,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+ var __response = await PostTryOnV3AsResponseAsync(
+
+ request: request,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken
+ ).ConfigureAwait(false);
+
+ return __response.Body;
+ }
+ ///
+ /// Virtual Try-On with Ideogram 3.0
+ /// Performs virtual clothing try-on by automatically segmenting the clothing in the provided image
+ /// and replacing it based on the prompt. The user provides an image and an optional prompt describing
+ /// the desired clothing change (e.g., "change his shirt to a pink shirt").
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it.
+ ///
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> PostTryOnV3AsResponseAsync(
+
global::Ideogram.TryOnRequestV3 request,
global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
@@ -85,10 +112,11 @@ partial void ProcessPostTryOnV3ResponseContent(
var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts(
clientOptions: Options,
requestOptions: requestOptions,
- supportsRetry: true);
+ supportsRetry: false);
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
{
+
var __pathBuilder = new global::Ideogram.PathBuilder(
path: "/v1/ideogram-v3/try-on",
baseUri: HttpClient.BaseAddress);
@@ -121,6 +149,7 @@ partial void ProcessPostTryOnV3ResponseContent(
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
}
}
+
var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
var __contentImage = new global::System.Net.Http.ByteArrayContent(request.Image ?? global::System.Array.Empty());
__contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
@@ -159,54 +188,70 @@ request.Imagename is null
{
__contentImage.Headers.ContentDisposition.FileNameStar = null;
}
+
if (request.Prompt != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty),
name: "\"prompt\"");
- }
+
+ }
if (request.MagicPrompt != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.MagicPrompt).HasValue ? (request.MagicPrompt).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"magic_prompt\"");
- }
+
+ }
+ if (request.MagicPromptSystemPromptConfigId != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty),
+ name: "\"magic_prompt_system_prompt_config_id\"");
+
+ }
if (request.NumImages != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
name: "\"num_images\"");
- }
+
+ }
if (request.Seed != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
name: "\"seed\"");
- }
+
+ }
if (request.RenderingSpeed != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"rendering_speed\"");
- }
+
+ }
if (request.StyleType != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.StyleType).HasValue ? (request.StyleType).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"style_type\"");
- }
+
+ }
if (request.StylePreset != default)
{
__httpRequestContent.Add(
content: new global::System.Net.Http.StringContent((request.StylePreset).HasValue ? (request.StylePreset).GetValueOrDefault().ToValueString() : string.Empty),
name: "\"style_preset\"");
+
}
for (var __iProductReferenceImages = 0; __iProductReferenceImages < request.ProductReferenceImages.Count; __iProductReferenceImages++)
{
@@ -221,7 +266,9 @@ request.Imagename is null
__contentProductReferenceImages.Headers.ContentDisposition.FileNameStar = null;
}
}
+
__httpRequest.Content = __httpRequestContent;
+
global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders(
request: __httpRequest,
clientHeaders: Options.Headers,
@@ -263,6 +310,8 @@ request.Imagename is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
try
{
@@ -273,6 +322,11 @@ request.Imagename is null
}
catch (global::System.Net.Http.HttpRequestException __exception)
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
@@ -290,6 +344,8 @@ request.Imagename is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
if (!__willRetry)
{
@@ -299,8 +355,7 @@ request.Imagename is null
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -309,6 +364,11 @@ request.Imagename is null
__attempt < __maxAttempts &&
global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
clientOptions: Options,
context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
@@ -325,14 +385,15 @@ request.Imagename is null
attempt: __attempt,
maxAttempts: __maxAttempts,
willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
__response.Dispose();
__response = null;
__httpRequest.Dispose();
__httpRequest = null;
await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
- clientOptions: Options,
- requestOptions: requestOptions,
+ retryDelay: __retryDelay,
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
continue;
}
@@ -372,6 +433,8 @@ request.Imagename is null
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
else
@@ -392,6 +455,8 @@ request.Imagename is null
attempt: __attemptNumber,
maxAttempts: __maxAttempts,
willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
//
@@ -415,17 +480,16 @@ request.Imagename is null
__exception_400 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_400,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_400,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
//
if ((int)__response.StatusCode == 401)
@@ -448,17 +512,16 @@ request.Imagename is null
__exception_401 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_401,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_401,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_401,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
// Prompt or provided image failed safety check, or clothing segmentation failed.
if ((int)__response.StatusCode == 422)
@@ -485,18 +548,17 @@ request.Imagename is null
__exception_422 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_422,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_422,
+ responseObject: __value_422,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
//
if ((int)__response.StatusCode == 429)
@@ -519,17 +581,16 @@ request.Imagename is null
__exception_429 = __ex;
}
- throw new global::Ideogram.ApiException(
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
innerException: __exception_429,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_429,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content_429,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
if (__effectiveReadResponseAsString)
@@ -553,23 +614,25 @@ request.Imagename is null
{
__response.EnsureSuccessStatusCode();
- return
- global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ??
+ var __value = global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
else
@@ -583,9 +646,13 @@ request.Imagename is null
#endif
).ConfigureAwait(false);
- return
- await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ var __value = await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
+ return new global::Ideogram.AutoSDKHttpResponse(
+ statusCode: __response.StatusCode,
+ headers: global::Ideogram.AutoSDKHttpResponse.CreateHeaders(__response),
+ requestUri: __response.RequestMessage?.RequestUri,
+ body: __value);
}
catch (global::System.Exception __ex)
{
@@ -602,17 +669,15 @@ request.Imagename is null
{
}
- throw new global::Ideogram.ApiException(
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
- h => h.Value),
- };
+ h => h.Value));
}
}
@@ -646,6 +711,9 @@ request.Imagename is null
/// Determine if MagicPrompt should be used in generating the request or not.
/// Example: ON
///
+ ///
+ /// A base64url-encoded magic prompt system prompt config ID to use for this request.
+ ///
///
/// The number of images to generate.
/// Default Value: 1
@@ -679,6 +747,7 @@ request.Imagename is null
global::System.Collections.Generic.IList productReferenceImages,
string? prompt = default,
global::Ideogram.MagicPromptOption? magicPrompt = default,
+ string? magicPromptSystemPromptConfigId = default,
int? numImages = default,
int? seed = default,
global::Ideogram.RenderingSpeed? renderingSpeed = default,
@@ -693,6 +762,7 @@ request.Imagename is null
Imagename = imagename,
Prompt = prompt,
MagicPrompt = magicPrompt,
+ MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId,
NumImages = numImages,
Seed = seed,
RenderingSpeed = renderingSpeed,
@@ -706,5 +776,1440 @@ request.Imagename is null
requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
+
+ ///
+ /// Virtual Try-On with Ideogram 3.0
+ /// Performs virtual clothing try-on by automatically segmenting the clothing in the provided image
+ /// and replacing it based on the prompt. The user provides an image and an optional prompt describing
+ /// the desired clothing change (e.g., "change his shirt to a pink shirt").
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it.
+ ///
+ ///
+ /// The image containing a person wearing clothing to be modified (max size 10MB); only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ ///
+ /// The image containing a person wearing clothing to be modified (max size 10MB); only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ ///
+ /// The prompt describing the desired clothing change. Defaults to "Person wearing this piece of clothing" if omitted or empty.
+ /// Default Value: Person wearing this piece of clothing
+ /// Example: Change his shirt to a pink shirt
+ ///
+ ///
+ /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON
+ ///
+ ///
+ /// A base64url-encoded magic prompt system prompt config ID to use for this request.
+ ///
+ ///
+ /// The number of images to generate.
+ /// Default Value: 1
+ ///
+ ///
+ /// Random seed. Set for reproducible generation.
+ /// Example: 12345
+ ///
+ ///
+ /// The rendering speed to use.
+ /// Default Value: DEFAULT
+ ///
+ ///
+ /// The style type to generate with.
+ /// Default Value: GENERAL
+ /// Example: GENERAL
+ ///
+ ///
+ /// A predefined style preset that applies a specific artistic style to the generated image.
+ /// Example: BRIGHT_ART
+ ///
+ ///
+ /// An image to use as the product reference for the try-on (exactly 1 image required). The image should be in JPEG, PNG or WebP format.
+ ///
+ ///
+ /// Optional file names to use for the multipart 'product_reference_images' file parts.
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task PostTryOnV3Async(
+ global::System.IO.Stream image,
+ string imagename,
+ global::System.Collections.Generic.IReadOnlyList productReferenceImages,
+ string? prompt = default,
+ global::Ideogram.MagicPromptOption? magicPrompt = default,
+ string? magicPromptSystemPromptConfigId = default,
+ int? numImages = default,
+ int? seed = default,
+ global::Ideogram.RenderingSpeed? renderingSpeed = default,
+ global::Ideogram.StyleTypeV3? styleType = default,
+ global::Ideogram.StylePresetV3? stylePreset = default,
+ global::System.Collections.Generic.IReadOnlyList? productReferenceImagesFileNames = default,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+
+ image = image ?? throw new global::System.ArgumentNullException(nameof(image));
+ productReferenceImages = productReferenceImages ?? throw new global::System.ArgumentNullException(nameof(productReferenceImages));
+ var request = new global::Ideogram.TryOnRequestV3
+ {
+ Image = global::System.Array.Empty(),
+ Imagename = imagename,
+ Prompt = prompt,
+ MagicPrompt = magicPrompt,
+ MagicPromptSystemPromptConfigId = magicPromptSystemPromptConfigId,
+ NumImages = numImages,
+ Seed = seed,
+ RenderingSpeed = renderingSpeed,
+ StyleType = styleType,
+ StylePreset = stylePreset,
+ ProductReferenceImages = new global::System.Collections.Generic.List(),
+ };
+ PrepareArguments(
+ client: HttpClient);
+ PreparePostTryOnV3Arguments(
+ httpClient: HttpClient,
+ request: request);
+
+
+ var __authorizations = global::Ideogram.EndPointSecurityResolver.ResolveAuthorizations(
+ availableAuthorizations: Authorizations,
+ securityRequirements: s_PostTryOnV3SecurityRequirements,
+ operationName: "PostTryOnV3Async");
+
+ using var __timeoutCancellationTokenSource = global::Ideogram.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Ideogram.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Ideogram.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: false);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+
+ var __pathBuilder = new global::Ideogram.PathBuilder(
+ path: "/v1/ideogram-v3/try-on",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Ideogram.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+#if NET6_0_OR_GREATER
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+#endif
+
+ foreach (var __authorization in __authorizations)
+ {
+ if (__authorization.Type == "Http" ||
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
+ {
+ __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
+ scheme: __authorization.Name,
+ parameter: __authorization.Value);
+ }
+ else if (__authorization.Type == "ApiKey" &&
+ __authorization.Location == "Header")
+ {
+ __httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
+ }
+ }
+
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ var __contentImage = new global::System.Net.Http.StreamContent(image);
+ __contentImage.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ request.Imagename is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(request.Imagename) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentImage,
+ name: "\"image\"",
+ fileName: request.Imagename != null ? $"\"{request.Imagename}\"" : string.Empty);
+ if (__contentImage.Headers.ContentDisposition != null)
+ {
+ __contentImage.Headers.ContentDisposition.FileNameStar = null;
+ }
+
+ if (request.Prompt != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty),
+ name: "\"prompt\"");
+
+ }
+ if (request.MagicPrompt != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.MagicPrompt).HasValue ? (request.MagicPrompt).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"magic_prompt\"");
+
+ }
+ if (request.MagicPromptSystemPromptConfigId != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(request.MagicPromptSystemPromptConfigId ?? string.Empty),
+ name: "\"magic_prompt_system_prompt_config_id\"");
+
+ }
+ if (request.NumImages != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.NumImages, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"num_images\"");
+
+ }
+ if (request.Seed != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent(global::System.Convert.ToString(request.Seed, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty),
+ name: "\"seed\"");
+
+ }
+ if (request.RenderingSpeed != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.RenderingSpeed).HasValue ? (request.RenderingSpeed).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"rendering_speed\"");
+
+ }
+ if (request.StyleType != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.StyleType).HasValue ? (request.StyleType).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"style_type\"");
+
+ }
+ if (request.StylePreset != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent((request.StylePreset).HasValue ? (request.StylePreset).GetValueOrDefault().ToValueString() : string.Empty),
+ name: "\"style_preset\"");
+
+ }
+ for (var __iProductReferenceImages = 0; __iProductReferenceImages < productReferenceImages.Count; __iProductReferenceImages++)
+ {
+ var __fileNameProductReferenceImages = productReferenceImagesFileNames != null &&
+ __iProductReferenceImages < productReferenceImagesFileNames.Count &&
+ productReferenceImagesFileNames[__iProductReferenceImages] != null
+ ? productReferenceImagesFileNames[__iProductReferenceImages]
+ : $"file{__iProductReferenceImages}.bin";
+ var __contentProductReferenceImages = new global::System.Net.Http.StreamContent(productReferenceImages[__iProductReferenceImages]);
+ __contentProductReferenceImages.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(
+ __fileNameProductReferenceImages is null
+ ? "application/octet-stream"
+ : (global::System.IO.Path.GetExtension(__fileNameProductReferenceImages) ?? string.Empty).ToLowerInvariant() switch
+ {
+ ".aac" => "audio/aac",
+ ".flac" => "audio/flac",
+ ".gif" => "image/gif",
+ ".jpeg" => "image/jpeg",
+ ".jpg" => "image/jpeg",
+ ".json" => "application/json",
+ ".m4a" => "audio/mp4",
+ ".mp3" => "audio/mpeg",
+ ".mp4" => "video/mp4",
+ ".mpeg" => "audio/mpeg",
+ ".mpga" => "audio/mpeg",
+ ".oga" => "audio/ogg",
+ ".ogg" => "audio/ogg",
+ ".opus" => "audio/ogg",
+ ".pdf" => "application/pdf",
+ ".png" => "image/png",
+ ".txt" => "text/plain",
+ ".wav" => "audio/wav",
+ ".weba" => "audio/webm",
+ ".webm" => "video/webm",
+ ".webp" => "image/webp",
+ _ => "application/octet-stream",
+ });
+ __httpRequestContent.Add(
+ content: __contentProductReferenceImages,
+ name: "\"product_reference_images\"",
+ fileName: $"\"{__fileNameProductReferenceImages}\"");
+ if (__contentProductReferenceImages.Headers.ContentDisposition != null)
+ {
+ __contentProductReferenceImages.Headers.ContentDisposition.FileNameStar = null;
+ }
+ }
+
+ __httpRequest.Content = __httpRequestContent;
+
+ global::Ideogram.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PreparePostTryOnV3Request(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
+
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
+ {
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostTryOnV3",
+ methodName: "PostTryOnV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/try-on\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ catch (global::System.Net.Http.HttpRequestException __exception)
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: null,
+ attempt: __attempt);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostTryOnV3",
+ methodName: "PostTryOnV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/try-on\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
+ retryReason: "exception",
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Ideogram.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ var __retryDelay = global::Ideogram.AutoSDKRequestOptionsSupport.GetRetryDelay(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ response: __response,
+ attempt: __attempt);
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostTryOnV3",
+ methodName: "PostTryOnV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/try-on\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ retryDelay: __retryDelay,
+ retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Ideogram.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ retryDelay: __retryDelay,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
+ }
+
+ if (__response == null)
+ {
+ throw new global::System.InvalidOperationException("No response received.");
+ }
+
+ using (__response)
+ {
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessPostTryOnV3Response(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostTryOnV3",
+ methodName: "PostTryOnV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/try-on\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ else
+ {
+ await global::Ideogram.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Ideogram.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PostTryOnV3",
+ methodName: "PostTryOnV3Async",
+ pathTemplate: "\"/v1/ideogram-v3/try-on\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ retryDelay: null,
+ retryReason: global::System.String.Empty,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+ //
+ if ((int)__response.StatusCode == 400)
+ {
+ string? __content_400 = null;
+ global::System.Exception? __exception_400 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_400 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_400 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_400,
+ responseBody: __content_400,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 401)
+ {
+ string? __content_401 = null;
+ global::System.Exception? __exception_401 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_401 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_401 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_401 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_401,
+ responseBody: __content_401,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ // Prompt or provided image failed safety check, or clothing segmentation failed.
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Ideogram.GenerateImageSafetyError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_422 = global::Ideogram.GenerateImageSafetyError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ responseBody: __content_422,
+ responseObject: __value_422,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ //
+ if ((int)__response.StatusCode == 429)
+ {
+ string? __content_429 = null;
+ global::System.Exception? __exception_429 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_429 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_429 = __ex;
+ }
+
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content_429 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_429,
+ responseBody: __content_429,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessPostTryOnV3ResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Ideogram.ImageGenerationResponseV3.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Ideogram.ImageGenerationResponseV3.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw global::Ideogram.ApiException.Create(
+ statusCode: __response.StatusCode,
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ responseBody: __content,
+ responseHeaders: global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value));
+ }
+ }
+
+ }
+ }
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
+ }
+ ///
+ /// Virtual Try-On with Ideogram 3.0
+ /// Performs virtual clothing try-on by automatically segmenting the clothing in the provided image
+ /// and replacing it based on the prompt. The user provides an image and an optional prompt describing
+ /// the desired clothing change (e.g., "change his shirt to a pink shirt").
+ /// Supported image formats include JPEG, PNG, and WebP.
+ /// Images links are available for a limited period of time; if you would like to keep the image, you must download it.
+ ///
+ ///
+ /// The image containing a person wearing clothing to be modified (max size 10MB); only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ ///
+ /// The image containing a person wearing clothing to be modified (max size 10MB); only JPEG, WebP and PNG formats are supported at this time.
+ ///
+ ///
+ /// The prompt describing the desired clothing change. Defaults to "Person wearing this piece of clothing" if omitted or empty.
+ /// Default Value: Person wearing this piece of clothing
+ /// Example: Change his shirt to a pink shirt
+ ///
+ ///
+ /// Determine if MagicPrompt should be used in generating the request or not.
+ /// Example: ON
+ ///
+ ///
+ /// A base64url-encoded magic prompt system prompt config ID to use for this request.
+ ///
+ ///
+ /// The number of images to generate.
+ /// Default Value: 1
+ ///
+ ///
+ /// Random seed. Set for reproducible generation.
+ /// Example: 12345
+ ///
+ ///
+ /// The rendering speed to use.
+ /// Default Value: DEFAULT
+ ///
+ ///
+ /// The style type to generate with.
+ /// Default Value: GENERAL
+ /// Example: GENERAL
+ ///
+ ///
+ /// A predefined style preset that applies a specific artistic style to the generated image.
+ /// Example: BRIGHT_ART
+ ///
+ ///
+ /// An image to use as the product reference for the try-on (exactly 1 image required). The image should be in JPEG, PNG or WebP format.
+ ///
+ ///
+ /// Optional file names to use for the multipart 'product_reference_images' file parts.
+ ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
+ /// The token to cancel the operation with
+ ///
+ public async global::System.Threading.Tasks.Task> PostTryOnV3AsResponseAsync(
+ global::System.IO.Stream image,
+ string imagename,
+ global::System.Collections.Generic.IReadOnlyList productReferenceImages,
+ string? prompt = default,
+ global::Ideogram.MagicPromptOption? magicPrompt = default,
+ string? magicPromptSystemPromptConfigId = default,
+ int? numImages = default,
+ int? seed = default,
+ global::Ideogram.RenderingSpeed? renderingSpeed = default,
+ global::Ideogram.StyleTypeV3? styleType = default,
+ global::Ideogram.StylePresetV3? stylePreset = default,
+ global::System.Collections.Generic.IReadOnlyList? productReferenceImagesFileNames = default,
+ global::Ideogram.AutoSDKRequestOptions? requestOptions = default,
+ global::System.Threading.CancellationToken cancellationToken = default)
+ {
+
+ image = image ?? throw new global::System.ArgumentNullException(nameof(image));
+ productReferenceImages = productReferenceImages ?? throw new global::System.ArgumentNullException(nameof(productReferenceImages));
+ var request = new global::Ideogram.TryOnRequestV3
+ {
+ Image = global::System.Array.Empty