Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@

#nullable enable

namespace StabilityAI
{
/// <summary>
/// Represents a successful HTTP response with status code and headers.
/// </summary>
public partial class AutoSDKHttpResponse
{
/// <summary>
/// Initializes a new instance of the <see cref="AutoSDKHttpResponse"/> class.
/// </summary>
public AutoSDKHttpResponse(
global::System.Net.HttpStatusCode statusCode,
global::System.Collections.Generic.Dictionary<string, global::System.Collections.Generic.IEnumerable<string>> headers)
{
StatusCode = statusCode;
Headers = headers ?? throw new global::System.ArgumentNullException(nameof(headers));
}

/// <summary>
/// Gets the HTTP status code.
/// </summary>
public global::System.Net.HttpStatusCode StatusCode { get; }
/// <summary>
/// Gets the response headers.
/// </summary>
public global::System.Collections.Generic.Dictionary<string, global::System.Collections.Generic.IEnumerable<string>> Headers { get; }

internal static global::System.Collections.Generic.Dictionary<string, global::System.Collections.Generic.IEnumerable<string>> 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<string>)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;
}
}

/// <summary>
/// Represents a successful HTTP response with status code, headers, and body.
/// </summary>
public partial class AutoSDKHttpResponse<T> : AutoSDKHttpResponse
{
/// <summary>
/// Initializes a new instance of the <see cref="AutoSDKHttpResponse{T}"/> class.
/// </summary>
public AutoSDKHttpResponse(
global::System.Net.HttpStatusCode statusCode,
global::System.Collections.Generic.Dictionary<string, global::System.Collections.Generic.IEnumerable<string>> headers,
T body)
: base(statusCode, headers)
{
Body = body;
}

/// <summary>
/// Gets the response body.
/// </summary>
public T Body { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,49 @@ public partial interface IV1GenerationClient
/// Default Value: application/json
/// </param>
/// <param name="organization"></param>
/// <param name="request"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::StabilityAI.ApiException"></exception>
/// <remarks>
/// if [ -z "$STABILITY_API_KEY" ]; then<br/>
/// echo "STABILITY_API_KEY environment variable is not set"<br/>
/// exit 1<br/>
/// fi<br/>
/// OUTPUT_FILE=./out/v1_img2img.png<br/>
/// BASE_URL=${API_HOST:-https://api.stability.ai}<br/>
/// URL="$BASE_URL/v1/generation/stable-diffusion-v1-5/image-to-image"<br/>
/// curl -f -sS -X POST "$URL" \<br/>
/// -H 'Content-Type: multipart/form-data' \<br/>
/// -H 'Accept: image/png' \<br/>
/// -H "Authorization: Bearer $STABILITY_API_KEY" \<br/>
/// -F 'init_image=@"../init_image.png"' \<br/>
/// -F 'init_image_mode=IMAGE_STRENGTH' \<br/>
/// -F 'image_strength=0.35' \<br/>
/// -F 'text_prompts[0][text]=A galactic dog in space' \<br/>
/// -F 'cfg_scale=7' \<br/>
/// -F 'clip_guidance_preset=FAST_BLUE' \<br/>
/// -F 'samples=1' \<br/>
/// -F 'steps=30' \<br/>
/// -o "$OUTPUT_FILE"
/// </remarks>
global::System.Threading.Tasks.Task<global::StabilityAI.AutoSDKHttpResponse<global::System.Collections.Generic.IList<global::StabilityAI.Image>>> ImageToImageAsResponseAsync(
string engineId,

global::StabilityAI.ImageToImageRequestBody request,
global::StabilityAI.ImageToImageAccept? accept = default,
string? organization = default,
global::System.Threading.CancellationToken cancellationToken = default);
/// <summary>
/// image-to-image<br/>
/// Modify an image based on a text prompt
/// </summary>
/// <param name="engineId">
/// Example: stable-diffusion-v1-5
/// </param>
/// <param name="accept">
/// Default Value: application/json
/// </param>
/// <param name="organization"></param>
/// <param name="textPrompts">
/// An array of text prompts to use for generation.<br/>
/// Due to how arrays are represented in `multipart/form-data` requests, prompts must adhear to the format `text_prompts[index][text|weight]`,<br/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,49 @@ public partial interface IV1GenerationClient
/// Default Value: application/json
/// </param>
/// <param name="organization"></param>
/// <param name="request"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::StabilityAI.ApiException"></exception>
/// <remarks>
/// #!/bin/sh<br/>
/// set -e<br/>
/// if [ -z "$STABILITY_API_KEY" ]; then<br/>
/// echo "STABILITY_API_KEY environment variable is not set"<br/>
/// exit 1<br/>
/// fi<br/>
/// OUTPUT_FILE=./out/v1_img2img_masking.png<br/>
/// BASE_URL=${API_HOST:-https://api.stability.ai}<br/>
/// URL="$BASE_URL/v1/generation/stable-inpainting-512-v2-0/image-to-image/masking"<br/>
/// curl -f -sS -X POST "$URL" \<br/>
/// -H 'Content-Type: multipart/form-data' \<br/>
/// -H 'Accept: image/png' \<br/>
/// -H "Authorization: Bearer $STABILITY_API_KEY" \<br/>
/// -F 'init_image=@"../init_image.png"' \<br/>
/// -F 'mask_image=@"../mask_image_white.png"' \<br/>
/// -F 'mask_source=MASK_IMAGE_WHITE' \<br/>
/// -F 'text_prompts[0][text]=A large spiral galaxy with a bright central bulge and a ring of stars around it' \<br/>
/// -F 'cfg_scale=7' \<br/>
/// -F 'clip_guidance_preset=FAST_BLUE' \<br/>
/// -F 'samples=1' \<br/>
/// -F 'steps=30' \<br/>
/// -o "$OUTPUT_FILE"
/// </remarks>
global::System.Threading.Tasks.Task<global::StabilityAI.AutoSDKHttpResponse<global::System.Collections.Generic.IList<global::StabilityAI.Image>>> MaskingAsResponseAsync(
string engineId,

global::StabilityAI.MaskingRequestBody request,
global::StabilityAI.MaskingAccept? accept = default,
string? organization = default,
global::System.Threading.CancellationToken cancellationToken = default);
/// <summary>
/// image-to-image/masking<br/>
/// Selectively modify portions of an image using a mask
/// </summary>
/// <param name="engineId"></param>
/// <param name="accept">
/// Default Value: application/json
/// </param>
/// <param name="organization"></param>
/// <param name="initImage">
/// Image used to initialize the diffusion process, in lieu of random noise.<br/>
/// Example: &lt;image binary&gt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,54 @@ public partial interface IV1GenerationClient
/// Default Value: application/json
/// </param>
/// <param name="organization"></param>
/// <param name="request"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::StabilityAI.ApiException"></exception>
/// <remarks>
/// if [ -z "$STABILITY_API_KEY" ]; then<br/>
/// echo "STABILITY_API_KEY environment variable is not set"<br/>
/// exit 1<br/>
/// fi<br/>
/// OUTPUT_FILE=./out/v1_txt2img.png<br/>
/// BASE_URL=${API_HOST:-https://api.stability.ai}<br/>
/// URL="$BASE_URL/v1/generation/stable-diffusion-v1-5/text-to-image"<br/>
/// curl -f -sS -X POST "$URL" \<br/>
/// -H 'Content-Type: application/json' \<br/>
/// -H 'Accept: image/png' \<br/>
/// -H "Authorization: Bearer $STABILITY_API_KEY" \<br/>
/// --data-raw '{<br/>
/// "text_prompts": [<br/>
/// {<br/>
/// "text": "A lighthouse on a cliff"<br/>
/// }<br/>
/// ],<br/>
/// "cfg_scale": 7,<br/>
/// "clip_guidance_preset": "FAST_BLUE",<br/>
/// "height": 512,<br/>
/// "width": 512,<br/>
/// "samples": 1,<br/>
/// "steps": 30<br/>
/// }' \<br/>
/// -o "$OUTPUT_FILE"
/// </remarks>
global::System.Threading.Tasks.Task<global::StabilityAI.AutoSDKHttpResponse<global::System.Collections.Generic.IList<global::StabilityAI.Image>>> TextToImageAsResponseAsync(
string engineId,

global::StabilityAI.TextToImageRequestBody request,
global::StabilityAI.TextToImageAccept? accept = default,
string? organization = default,
global::System.Threading.CancellationToken cancellationToken = default);
/// <summary>
/// text-to-image<br/>
/// Generate a new image from a text prompt
/// </summary>
/// <param name="engineId">
/// Example: stable-diffusion-v1-5
/// </param>
/// <param name="accept">
/// Default Value: application/json
/// </param>
/// <param name="organization"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
global::System.Threading.Tasks.Task<global::System.Collections.Generic.IList<global::StabilityAI.Image>> TextToImageAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,43 @@ public partial interface IV1GenerationClient
/// Default Value: application/json
/// </param>
/// <param name="organization"></param>
/// <param name="request"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::StabilityAI.ApiException"></exception>
/// <remarks>
/// if [ -z "$STABILITY_API_KEY" ]; then<br/>
/// echo "STABILITY_API_KEY environment variable is not set"<br/>
/// exit 1<br/>
/// fi<br/>
/// OUTPUT_FILE=./out/v1_upscaled_image.png<br/>
/// BASE_URL=${API_HOST:-https://api.stability.ai}<br/>
/// URL="$BASE_URL/v1/generation/esrgan-v1-x2plus/image-to-image/upscale"<br/>
/// curl -f -sS -X POST "$URL" \<br/>
/// -H 'Content-Type: multipart/form-data' \<br/>
/// -H 'Accept: image/png' \<br/>
/// -H "Authorization: Bearer $STABILITY_API_KEY" \<br/>
/// -F 'image=@"../init_image.png"' \<br/>
/// -F 'width=1024' \<br/>
/// -o "$OUTPUT_FILE"
/// </remarks>
global::System.Threading.Tasks.Task<global::StabilityAI.AutoSDKHttpResponse<global::System.Collections.Generic.IList<global::StabilityAI.Image>>> UpscaleImageAsResponseAsync(
string engineId,

global::StabilityAI.UpscaleImageRequestBody request,
global::StabilityAI.UpscaleImageAccept? accept = default,
string? organization = default,
global::System.Threading.CancellationToken cancellationToken = default);
/// <summary>
/// image-to-image/upscale<br/>
/// Create a higher resolution version of an input image.<br/>
/// This operation outputs an image with a maximum pixel count of **4,194,304**. This is equivalent to dimensions such as `2048x2048` and `4096x1024`.<br/>
/// By default, the input image will be upscaled by a factor of 2. For additional control over the output dimensions, a `width` or `height` parameter may be specified.
/// </summary>
/// <param name="engineId"></param>
/// <param name="accept">
/// Default Value: application/json
/// </param>
/// <param name="organization"></param>
/// <param name="image">
/// Example: &lt;image binary&gt;
/// </param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,61 @@ partial void ProcessImageToImageResponseContent(
public async global::System.Threading.Tasks.Task<global::System.Collections.Generic.IList<global::StabilityAI.Image>> ImageToImageAsync(
string engineId,

global::StabilityAI.ImageToImageRequestBody request,
global::StabilityAI.ImageToImageAccept? accept = default,
string? organization = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __response = await ImageToImageAsResponseAsync(
engineId: engineId,

request: request,
accept: accept,
organization: organization,
cancellationToken: cancellationToken
).ConfigureAwait(false);

return __response.Body;
}
/// <summary>
/// image-to-image<br/>
/// Modify an image based on a text prompt
/// </summary>
/// <param name="engineId">
/// Example: stable-diffusion-v1-5
/// </param>
/// <param name="accept">
/// Default Value: application/json
/// </param>
/// <param name="organization"></param>
/// <param name="request"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::StabilityAI.ApiException"></exception>
/// <remarks>
/// if [ -z "$STABILITY_API_KEY" ]; then<br/>
/// echo "STABILITY_API_KEY environment variable is not set"<br/>
/// exit 1<br/>
/// fi<br/>
/// OUTPUT_FILE=./out/v1_img2img.png<br/>
/// BASE_URL=${API_HOST:-https://api.stability.ai}<br/>
/// URL="$BASE_URL/v1/generation/stable-diffusion-v1-5/image-to-image"<br/>
/// curl -f -sS -X POST "$URL" \<br/>
/// -H 'Content-Type: multipart/form-data' \<br/>
/// -H 'Accept: image/png' \<br/>
/// -H "Authorization: Bearer $STABILITY_API_KEY" \<br/>
/// -F 'init_image=@"../init_image.png"' \<br/>
/// -F 'init_image_mode=IMAGE_STRENGTH' \<br/>
/// -F 'image_strength=0.35' \<br/>
/// -F 'text_prompts[0][text]=A galactic dog in space' \<br/>
/// -F 'cfg_scale=7' \<br/>
/// -F 'clip_guidance_preset=FAST_BLUE' \<br/>
/// -F 'samples=1' \<br/>
/// -F 'steps=30' \<br/>
/// -o "$OUTPUT_FILE"
/// </remarks>
public async global::System.Threading.Tasks.Task<global::StabilityAI.AutoSDKHttpResponse<global::System.Collections.Generic.IList<global::StabilityAI.Image>>> ImageToImageAsResponseAsync(
string engineId,

global::StabilityAI.ImageToImageRequestBody request,
global::StabilityAI.ImageToImageAccept? accept = default,
string? organization = default,
Expand Down Expand Up @@ -448,9 +503,12 @@ partial void ProcessImageToImageResponseContent(
{
__response.EnsureSuccessStatusCode();

return
(global::System.Collections.Generic.IList<global::StabilityAI.Image>?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList<global::StabilityAI.Image>), JsonSerializerContext) ??
var __value = (global::System.Collections.Generic.IList<global::StabilityAI.Image>?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList<global::StabilityAI.Image>), JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
return new global::StabilityAI.AutoSDKHttpResponse<global::System.Collections.Generic.IList<global::StabilityAI.Image>>(
statusCode: __response.StatusCode,
headers: global::StabilityAI.AutoSDKHttpResponse.CreateHeaders(__response),
body: __value);
}
catch (global::System.Exception __ex)
{
Expand Down Expand Up @@ -479,9 +537,12 @@ partial void ProcessImageToImageResponseContent(
#endif
).ConfigureAwait(false);

return
(global::System.Collections.Generic.IList<global::StabilityAI.Image>?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList<global::StabilityAI.Image>), JsonSerializerContext).ConfigureAwait(false) ??
var __value = (global::System.Collections.Generic.IList<global::StabilityAI.Image>?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList<global::StabilityAI.Image>), JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
return new global::StabilityAI.AutoSDKHttpResponse<global::System.Collections.Generic.IList<global::StabilityAI.Image>>(
statusCode: __response.StatusCode,
headers: global::StabilityAI.AutoSDKHttpResponse.CreateHeaders(__response),
body: __value);
}
catch (global::System.Exception __ex)
{
Expand Down
Loading
Loading