-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
github-actions[bot]
committed
Jan 23, 2025
1 parent
4f36ef7
commit 0c0b62e
Showing
14 changed files
with
1,208 additions
and
16 deletions.
There are no files selected for viewing
294 changes: 294 additions & 0 deletions
294
src/libs/DeepInfra/Generated/DeepInfra.DeepInfraApi.OpenaiImagesGenerations.g.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,294 @@ | ||
|
||
#nullable enable | ||
|
||
namespace DeepInfra | ||
{ | ||
public partial class DeepInfraApi | ||
{ | ||
partial void PrepareOpenaiImagesGenerationsArguments( | ||
global::System.Net.Http.HttpClient httpClient, | ||
ref string? xDeepinfraSource, | ||
ref string? userAgent, | ||
ref string? xiApiKey, | ||
global::DeepInfra.OpenAIImagesGenerationsIn request); | ||
partial void PrepareOpenaiImagesGenerationsRequest( | ||
global::System.Net.Http.HttpClient httpClient, | ||
global::System.Net.Http.HttpRequestMessage httpRequestMessage, | ||
string? xDeepinfraSource, | ||
string? userAgent, | ||
string? xiApiKey, | ||
global::DeepInfra.OpenAIImagesGenerationsIn request); | ||
partial void ProcessOpenaiImagesGenerationsResponse( | ||
global::System.Net.Http.HttpClient httpClient, | ||
global::System.Net.Http.HttpResponseMessage httpResponseMessage); | ||
|
||
partial void ProcessOpenaiImagesGenerationsResponseContent( | ||
global::System.Net.Http.HttpClient httpClient, | ||
global::System.Net.Http.HttpResponseMessage httpResponseMessage, | ||
ref string content); | ||
|
||
/// <summary> | ||
/// Openai Images Generations<br/> | ||
/// Generate image using OpenAI Images API | ||
/// </summary> | ||
/// <param name="xDeepinfraSource"></param> | ||
/// <param name="userAgent"></param> | ||
/// <param name="xiApiKey"></param> | ||
/// <param name="request"></param> | ||
/// <param name="cancellationToken">The token to cancel the operation with</param> | ||
/// <exception cref="global::DeepInfra.ApiException"></exception> | ||
public async global::System.Threading.Tasks.Task<global::DeepInfra.OpenAIImagesGenerationsOut> OpenaiImagesGenerationsAsync( | ||
global::DeepInfra.OpenAIImagesGenerationsIn request, | ||
string? xDeepinfraSource = default, | ||
string? userAgent = default, | ||
string? xiApiKey = default, | ||
global::System.Threading.CancellationToken cancellationToken = default) | ||
{ | ||
request = request ?? throw new global::System.ArgumentNullException(nameof(request)); | ||
|
||
PrepareArguments( | ||
client: HttpClient); | ||
PrepareOpenaiImagesGenerationsArguments( | ||
httpClient: HttpClient, | ||
xDeepinfraSource: ref xDeepinfraSource, | ||
userAgent: ref userAgent, | ||
xiApiKey: ref xiApiKey, | ||
request: request); | ||
|
||
var __pathBuilder = new PathBuilder( | ||
path: "/v1/openai/images/generations", | ||
baseUri: HttpClient.BaseAddress); | ||
var __path = __pathBuilder.ToString(); | ||
using 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") | ||
{ | ||
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( | ||
scheme: __authorization.Name, | ||
parameter: __authorization.Value); | ||
} | ||
else if (__authorization.Type == "ApiKey" && | ||
__authorization.Location == "Header") | ||
{ | ||
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value); | ||
} | ||
} | ||
|
||
if (xDeepinfraSource != default) | ||
{ | ||
__httpRequest.Headers.TryAddWithoutValidation("x-deepinfra-source", xDeepinfraSource.ToString()); | ||
} | ||
if (userAgent != default) | ||
{ | ||
__httpRequest.Headers.TryAddWithoutValidation("user-agent", userAgent.ToString()); | ||
} | ||
if (xiApiKey != default) | ||
{ | ||
__httpRequest.Headers.TryAddWithoutValidation("xi-api-key", xiApiKey.ToString()); | ||
} | ||
|
||
var __httpRequestContentBody = request.ToJson(JsonSerializerContext); | ||
var __httpRequestContent = new global::System.Net.Http.StringContent( | ||
content: __httpRequestContentBody, | ||
encoding: global::System.Text.Encoding.UTF8, | ||
mediaType: "application/json"); | ||
__httpRequest.Content = __httpRequestContent; | ||
|
||
PrepareRequest( | ||
client: HttpClient, | ||
request: __httpRequest); | ||
PrepareOpenaiImagesGenerationsRequest( | ||
httpClient: HttpClient, | ||
httpRequestMessage: __httpRequest, | ||
xDeepinfraSource: xDeepinfraSource, | ||
userAgent: userAgent, | ||
xiApiKey: xiApiKey, | ||
request: request); | ||
|
||
using var __response = await HttpClient.SendAsync( | ||
request: __httpRequest, | ||
completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, | ||
cancellationToken: cancellationToken).ConfigureAwait(false); | ||
|
||
ProcessResponse( | ||
client: HttpClient, | ||
response: __response); | ||
ProcessOpenaiImagesGenerationsResponse( | ||
httpClient: HttpClient, | ||
httpResponseMessage: __response); | ||
// Validation Error | ||
if ((int)__response.StatusCode == 422) | ||
{ | ||
string? __content_422 = null; | ||
global::DeepInfra.HTTPValidationError? __value_422 = null; | ||
if (ReadResponseAsString) | ||
{ | ||
__content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); | ||
__value_422 = global::DeepInfra.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); | ||
} | ||
else | ||
{ | ||
var __contentStream_422 = await __response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false); | ||
__value_422 = await global::DeepInfra.HTTPValidationError.FromJsonStreamAsync(__contentStream_422, JsonSerializerContext).ConfigureAwait(false); | ||
} | ||
|
||
throw new global::DeepInfra.ApiException<global::DeepInfra.HTTPValidationError>( | ||
message: __response.ReasonPhrase ?? string.Empty, | ||
statusCode: __response.StatusCode) | ||
{ | ||
ResponseBody = __content_422, | ||
ResponseObject = __value_422, | ||
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( | ||
__response.Headers, | ||
h => h.Key, | ||
h => h.Value), | ||
}; | ||
} | ||
|
||
if (ReadResponseAsString) | ||
{ | ||
var __content = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); | ||
|
||
ProcessResponseContent( | ||
client: HttpClient, | ||
response: __response, | ||
content: ref __content); | ||
ProcessOpenaiImagesGenerationsResponseContent( | ||
httpClient: HttpClient, | ||
httpResponseMessage: __response, | ||
content: ref __content); | ||
|
||
try | ||
{ | ||
__response.EnsureSuccessStatusCode(); | ||
} | ||
catch (global::System.Net.Http.HttpRequestException __ex) | ||
{ | ||
throw new global::DeepInfra.ApiException( | ||
message: __content ?? __response.ReasonPhrase ?? string.Empty, | ||
innerException: __ex, | ||
statusCode: __response.StatusCode) | ||
{ | ||
ResponseBody = __content, | ||
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( | ||
__response.Headers, | ||
h => h.Key, | ||
h => h.Value), | ||
}; | ||
} | ||
|
||
return | ||
global::DeepInfra.OpenAIImagesGenerationsOut.FromJson(__content, JsonSerializerContext) ?? | ||
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); | ||
} | ||
else | ||
{ | ||
try | ||
{ | ||
__response.EnsureSuccessStatusCode(); | ||
} | ||
catch (global::System.Net.Http.HttpRequestException __ex) | ||
{ | ||
throw new global::DeepInfra.ApiException( | ||
message: __response.ReasonPhrase ?? string.Empty, | ||
innerException: __ex, | ||
statusCode: __response.StatusCode) | ||
{ | ||
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( | ||
__response.Headers, | ||
h => h.Key, | ||
h => h.Value), | ||
}; | ||
} | ||
|
||
using var __content = await __response.Content.ReadAsStreamAsync(cancellationToken).ConfigureAwait(false); | ||
|
||
return | ||
await global::DeepInfra.OpenAIImagesGenerationsOut.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? | ||
throw new global::System.InvalidOperationException("Response deserialization failed."); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Openai Images Generations<br/> | ||
/// Generate image using OpenAI Images API | ||
/// </summary> | ||
/// <param name="xDeepinfraSource"></param> | ||
/// <param name="userAgent"></param> | ||
/// <param name="xiApiKey"></param> | ||
/// <param name="prompt"> | ||
/// A text description of desired image(s).<br/> | ||
/// Example: A photo of an astronaut riding a horse on Mars. | ||
/// </param> | ||
/// <param name="model"> | ||
/// The model to use for image generation.<br/> | ||
/// Default Value: black-forest-labs/FLUX-1-schnell<br/> | ||
/// Example: black-forest-labs/FLUX-1-schnell | ||
/// </param> | ||
/// <param name="n"> | ||
/// The number of images to generate.<br/> | ||
/// Default Value: 1 | ||
/// </param> | ||
/// <param name="quality"> | ||
/// The quality of the image that will be generated. | ||
/// </param> | ||
/// <param name="responseFormat"> | ||
/// The format in which the generated images are returned. Currently only b64_json is supported.<br/> | ||
/// Default Value: b64_json | ||
/// </param> | ||
/// <param name="size"> | ||
/// The size of the generated images. Available sizes depend on the model.<br/> | ||
/// Default Value: 1024x1024 | ||
/// </param> | ||
/// <param name="style"> | ||
/// The style of the generated images.' | ||
/// </param> | ||
/// <param name="user"> | ||
/// A unique identifier representing your end-user, which can help to monitor and detect abuse. | ||
/// </param> | ||
/// <param name="cancellationToken">The token to cancel the operation with</param> | ||
/// <exception cref="global::System.InvalidOperationException"></exception> | ||
public async global::System.Threading.Tasks.Task<global::DeepInfra.OpenAIImagesGenerationsOut> OpenaiImagesGenerationsAsync( | ||
string prompt, | ||
string? xDeepinfraSource = default, | ||
string? userAgent = default, | ||
string? xiApiKey = default, | ||
string? model = default, | ||
int? n = default, | ||
string? quality = default, | ||
global::DeepInfra.OpenAIImagesResponseFormat? responseFormat = default, | ||
string? size = default, | ||
string? style = default, | ||
string? user = default, | ||
global::System.Threading.CancellationToken cancellationToken = default) | ||
{ | ||
var __request = new global::DeepInfra.OpenAIImagesGenerationsIn | ||
{ | ||
Prompt = prompt, | ||
Model = model, | ||
N = n, | ||
Quality = quality, | ||
ResponseFormat = responseFormat, | ||
Size = size, | ||
Style = style, | ||
User = user, | ||
}; | ||
|
||
return await OpenaiImagesGenerationsAsync( | ||
xDeepinfraSource: xDeepinfraSource, | ||
userAgent: userAgent, | ||
xiApiKey: xiApiKey, | ||
request: __request, | ||
cancellationToken: cancellationToken).ConfigureAwait(false); | ||
} | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
src/libs/DeepInfra/Generated/DeepInfra.IDeepInfraApi.OpenaiImagesGenerations.g.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#nullable enable | ||
|
||
namespace DeepInfra | ||
{ | ||
public partial interface IDeepInfraApi | ||
{ | ||
/// <summary> | ||
/// Openai Images Generations<br/> | ||
/// Generate image using OpenAI Images API | ||
/// </summary> | ||
/// <param name="xDeepinfraSource"></param> | ||
/// <param name="userAgent"></param> | ||
/// <param name="xiApiKey"></param> | ||
/// <param name="request"></param> | ||
/// <param name="cancellationToken">The token to cancel the operation with</param> | ||
/// <exception cref="global::DeepInfra.ApiException"></exception> | ||
global::System.Threading.Tasks.Task<global::DeepInfra.OpenAIImagesGenerationsOut> OpenaiImagesGenerationsAsync( | ||
global::DeepInfra.OpenAIImagesGenerationsIn request, | ||
string? xDeepinfraSource = default, | ||
string? userAgent = default, | ||
string? xiApiKey = default, | ||
global::System.Threading.CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// Openai Images Generations<br/> | ||
/// Generate image using OpenAI Images API | ||
/// </summary> | ||
/// <param name="xDeepinfraSource"></param> | ||
/// <param name="userAgent"></param> | ||
/// <param name="xiApiKey"></param> | ||
/// <param name="prompt"> | ||
/// A text description of desired image(s).<br/> | ||
/// Example: A photo of an astronaut riding a horse on Mars. | ||
/// </param> | ||
/// <param name="model"> | ||
/// The model to use for image generation.<br/> | ||
/// Default Value: black-forest-labs/FLUX-1-schnell<br/> | ||
/// Example: black-forest-labs/FLUX-1-schnell | ||
/// </param> | ||
/// <param name="n"> | ||
/// The number of images to generate.<br/> | ||
/// Default Value: 1 | ||
/// </param> | ||
/// <param name="quality"> | ||
/// The quality of the image that will be generated. | ||
/// </param> | ||
/// <param name="responseFormat"> | ||
/// The format in which the generated images are returned. Currently only b64_json is supported.<br/> | ||
/// Default Value: b64_json | ||
/// </param> | ||
/// <param name="size"> | ||
/// The size of the generated images. Available sizes depend on the model.<br/> | ||
/// Default Value: 1024x1024 | ||
/// </param> | ||
/// <param name="style"> | ||
/// The style of the generated images.' | ||
/// </param> | ||
/// <param name="user"> | ||
/// A unique identifier representing your end-user, which can help to monitor and detect abuse. | ||
/// </param> | ||
/// <param name="cancellationToken">The token to cancel the operation with</param> | ||
/// <exception cref="global::System.InvalidOperationException"></exception> | ||
global::System.Threading.Tasks.Task<global::DeepInfra.OpenAIImagesGenerationsOut> OpenaiImagesGenerationsAsync( | ||
string prompt, | ||
string? xDeepinfraSource = default, | ||
string? userAgent = default, | ||
string? xiApiKey = default, | ||
string? model = default, | ||
int? n = default, | ||
string? quality = default, | ||
global::DeepInfra.OpenAIImagesResponseFormat? responseFormat = default, | ||
string? size = default, | ||
string? style = default, | ||
string? user = default, | ||
global::System.Threading.CancellationToken cancellationToken = default); | ||
} | ||
} |
Oops, something went wrong.