{"id":22675628,"url":"https://github.com/maxidonkey/delphistabilityai","last_synced_at":"2025-04-12T02:03:27.547Z","repository":{"id":265020312,"uuid":"893141509","full_name":"MaxiDonkey/DelphiStabilityAI","owner":"MaxiDonkey","description":"The Stability API wrapper for Delphi utilizes advanced models developed by Stability.ai to provide capabilities for seamless image, video, and 3D generation, as well as sophisticated editing and upscaling tools, tailored for creative and professional use.","archived":false,"fork":false,"pushed_at":"2025-03-14T09:50:29.000Z","size":236,"stargazers_count":13,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-12T02:03:06.081Z","etag":null,"topics":["api-wraper","delphi","image-prompting","image-to-3d","image-to-video","stability-ai","stable-diffusion","stable-diffusion-3","stable-diffusion-3-5","text-image-to-text","text-to-image"],"latest_commit_sha":null,"homepage":"","language":"Pascal","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MaxiDonkey.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-23T16:37:54.000Z","updated_at":"2025-03-14T09:49:47.000Z","dependencies_parsed_at":"2024-11-27T08:32:00.611Z","dependency_job_id":null,"html_url":"https://github.com/MaxiDonkey/DelphiStabilityAI","commit_stats":null,"previous_names":["maxidonkey/delphistabilityai"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaxiDonkey%2FDelphiStabilityAI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaxiDonkey%2FDelphiStabilityAI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaxiDonkey%2FDelphiStabilityAI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaxiDonkey%2FDelphiStabilityAI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MaxiDonkey","download_url":"https://codeload.github.com/MaxiDonkey/DelphiStabilityAI/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248505863,"owners_count":21115354,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-wraper","delphi","image-prompting","image-to-3d","image-to-video","stability-ai","stable-diffusion","stable-diffusion-3","stable-diffusion-3-5","text-image-to-text","text-to-image"],"created_at":"2024-12-09T17:57:56.845Z","updated_at":"2025-04-12T02:03:27.516Z","avatar_url":"https://github.com/MaxiDonkey.png","language":"Pascal","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Delphi StabilityAI API\n\n___\n![GitHub](https://img.shields.io/badge/IDE%20Version-Delphi%2010.3/11/12-yellow)\n![GitHub](https://img.shields.io/badge/platform-all%20platforms-green)\n![GitHub](https://img.shields.io/badge/Updated%20the%2011/23/2024-blue)\n\n\u003cbr/\u003e\n\u003cbr/\u003e\n\n- [Introduction](#Introduction)\n    - [Who is Stability AI](#Who-is-Stability-AI)\n    - [Remarks](#remarks)\n- [Stability AI console](#Stability-AI-console)\n- [Asynchronous callback mode management](#Asynchronous-callback-mode-management)\n- [Generate](#Generate)\n    - [Stable Image Ultra](#Stable-Image-Ultra)\n        - [Text to image](#Text-to-image)\n        - [Tools for simplifying this tutorial](#Tools-for-simplifying-this-tutorial)\n        - [Image and text to image](#Image-and-text-to-image)\n    - [Stable Image Core](#Stable-Image-Core)\n        - [Image Core Create](#Image-Core-Create)\n        - [Using a preset style](#Using-a-preset-style )\n    - [Stable Diffusion](#Stable-Diffusion)\n        - [Generating with a prompt](#Generating-with-a-prompt)\n        - [Generating with a prompt and an image](#Generating-with-a-prompt-and-an-image)\n        - [Optional Parameters](#Optional-Parameters)\n    - [SDXL and SD version 1](#SDXL-and-SD-version-1)\n        - [Text to image prompting](#Text-to-image-prompting)\n        - [Image to image with prompt](#Image-to-image-with-prompt)\n        - [Image to image with mask](#Image-to-image-with-mask)\n- [Upscale](#Upscale)\n    - [Conservative](#Conservative)\n    - [Creative Upscale](#Creative-Upscale)\n        - [Fetch async generation result](#Fetch-async-generation-result)\n    - [Fast](#Fast)\n- [Edit](#Edit)\n    - [Erase](#Erase)\n    - [Inpaint](#Inpaint)\n    - [Outpaint](#Outpaint)\n    - [Search and Replace](#Search-and-Replace)\n    - [Search and Recolor](#Search-Recolor)\n    - [Remove Background](#Remove-Background)\n    - [Replace Background and Relight](#Replace-Background-and-Relight)\n- [Control](#Control)\n    - [Sketch](#Sketch)\n    - [Structure](#Structure)\n    - [Style](#Style)\n- [Results](#Results)\n- [3D](#3D)\n- [Video](#Video)\n- [Other Features of Version 1](#Other-Features-of-Version-1)\n    - [Model list](#Model-list)\n    - [User account](#User-account)\n    - [User balance](#User-balance)\n- [New features announced](#New-features-announced)\n- [Contributing](#contributing)\n- [License](#license)\n \n\u003cbr/\u003e\n\u003cbr/\u003e\n\n# Introduction\n\n## Who is Stability AI\n\n`Stability.ai` is a well-established organization in artificial intelligence, known for its models that generate images and text from descriptions. Below is a summary of the key models they have developed, presented in chronological order of release:\n\nImage Generation Models:\n\n- `Stable Diffusion` (August 2022)\nThe first latent diffusion model, capable of generating images based on textual descriptions.\n\n- `Stable Diffusion 2.0` (November 2022)\nAn updated version with improved image quality, support for higher resolutions, and additional features.\n\n- `Stable Diffusion XL (SDXL)` (April 2023)\nFocused on photorealism, this version introduced improvements in image composition and face generation.\n\n- `Stable Diffusion 3.0` (February 2024)\nFeaturing a new architecture that combines diffusion transformers and flow matching, this version enhances performance for multi-subject queries and overall image quality.\n\n- `Stable Cascade` (February 2024)\nBuilt on the Würstchen architecture, this model improves accuracy and efficiency in text-to-image generation.\n\n- `Stable Diffusion 3.5` (October 2024)\nIncludes variants such as Stable Diffusion 3.5 Large and 3.5 Medium, offering more options for diverse generation tasks with optimized efficiency.\n\n\u003cbr/\u003e\n\n## Remarks\n\n\u003e [!IMPORTANT]\n\u003e\n\u003e This is an unofficial library. **Stability.ai** does not provide any official library for `Delphi`.\n\u003e This repository contains `Delphi` implementation over [Stability.ai](https://platform.stability.ai/docs/api-reference/) public API.\n\n\u003cbr/\u003e\n\n# Stability AI console\n\nYou can access the [Stability.ai console](https://platform.stability.ai/) to explore the available possibilities.\n\nTo obtain an API key, you need to create an account. A credit of 25 will be granted to you, and an initial key will be automatically generated. You can find this key [here](https://platform.stability.ai/account/keys).\n\nOnce you have a token, you can initialize `IStabilityAI` interface, which is an entry point to the API.\n\n\u003e [!NOTE]\n\u003e```Pascal\n\u003euses StabilityAI;\n\u003e\n\u003evar Stability := TStabilityAIFactory.CreateInstance(API_KEY);\n\u003e```\n\n\u003e[!Warning]\n\u003e To use the examples provided in this tutorial, especially to work with asynchronous methods, I recommend defining the stability interface with the widest possible scope.\n\u003e\u003cbr/\u003e\n\u003e So, set `Stability := TStabilityAIFactory.CreateInstance(API_KEY);` in the `OnCreate` event of your application.\n\u003e\u003cbr/\u003e \n\u003eWhere `Stability: IStabilityAI;`\n\n\u003cbr/\u003e\n\n# Asynchronous callback mode management\n\nIn the context of asynchronous methods, for a method that does not involve streaming, callbacks use the following generic record: `TAsynCallBack\u003cT\u003e = record` defined in the `StabilityAI.Async.Support.pas` unit. This record exposes the following properties:\n\n```Pascal\n   TAsynCallBack\u003cT\u003e = record\n   ... \n       Sender: TObject;\n       OnStart: TProc\u003cTObject\u003e;\n       OnSuccess: TProc\u003cTObject, T\u003e;\n       OnError: TProc\u003cTObject, string\u003e; \n```\n\u003cbr/\u003e\n\nThe name of each property is self-explanatory; if needed, refer to the internal documentation for more details.\n\n\u003e [!NOTE]\n\u003eIn the rest of the tutorial, we will primarily use anonymous methods unless otherwise specified, as working with APIs requires it due to processing times that can sometimes be quite long.\n\u003e\n\n\u003cbr/\u003e\n\n# Generate\n\n## Stable Image Ultra\n\n**Stable Image Ultra** use the Diffusion 3.5 model. This method is distinguished by:\n\n- **Advanced Prompt Understanding:** Fine and precise analysis of descriptions, even complex ones.\n- **Typography Mastery:** Ability to integrate readable and aesthetically pleasing text elements.\n- **Complex Compositions:** Harmonious management of detailed, multi-element scenes.\n- **Dynamic Lighting:** Rendering of natural, dramatic, or artistic lighting effects.\n- **Vibrant Colors:** Rich palettes, dynamic nuances, and visual depth.\n- **Cohesion and Structure:** Creation of balanced, well-structured images with no inconsistencies.\n\n### Text to image\n\n**Asynchronous Code Example**\n\n```Pascal\n//uses StabilityAI, StabilityAI.Types, StabilityAI.Common, StabilityAI.StableImage.Generate;\n\n  Stability.StableImage.Generate.ImageUltra(\n    procedure (Params: TStableImageUltra)\n    begin\n      Params.AspectRatio(ratio16x9);\n      Params.Prompt('Lighthouse on a cliff overlooking the ocean');\n      //A blurb of text describing what you do not wish to see in the output image.\n      //Params.NegativePrompt('...')\n      Params.OutputFormat(png);\n    end,\n    function : TAsynStableImage\n    begin\n      //Add a TImage on the form\n      //Add a TMemo on the form\n      Result.Sender := Image1;\n\n      Result.OnStart :=\n        procedure (Sender: TObject)\n        begin\n          Memo1.Lines.Text := Memo1.Text + 'The generation has started. Please wait...' + sLineBreak;\n        end;\n\n      Result.OnSuccess :=\n        procedure (Sender: TObject; Image: TStableImage)\n        begin\n          var Stream := Image.GetStream;\n          try\n            Image.SaveToFile('lighthouse.png');\n            //for VCL \n            Image1.Picture.LoadFromStream(Stream);\n            //for FMX\n            //Image1.Bitmap.LoadFromStream(Stream);\n            Memo1.Lines.Text := Memo1.Text + 'Generation ended successfully' + sLineBreak;\n          finally\n            Stream.Free;\n          end;\n        end;\n\n      Result.OnError :=\n        procedure (Sender: TObject; Error: String)\n        begin\n          Memo1.Lines.Text := Memo1.Text + Error + sLineBreak;\n        end;\n    end);\n```\nDetailed settings on the [official documentation](https://platform.stability.ai/docs/api-reference#tag/Generate/paths/~1v2beta~1stable-image~1generate~1ultra/post)\n\n\u003cbr/\u003e\n\n### Tools for simplifying this tutorial\n\nTo simplify the example codes provided in this tutorial, I have included two units in the source code: `VCL.Stability.Tutorial` and `FMX.Stability.Tutorial`. Depending on the option you choose to test the provided source code, you will need to instantiate either the `TVCLStabilitySender` or `TFMXStabilitySender` class in the application's `OnCreate` event, as follows:\n\n\u003e[!TIP]\n\u003e```Pascal\n\u003e//uses VCL.Stability.Tutorial;\n\u003e\n\u003e  StabilityResult := TVCLStabilitySender.Create(Memo1, Image1);\n\u003e```\n\u003e\n\u003eor\n\u003e\n\u003e```Pascal\n\u003e//uses FMX.Stability.Tutorial;\n\u003e\n\u003e  StabilityResult := TFMXStabilitySender.Create(Memo1, Image1);\n\u003e```\n\u003e\n\nMake sure to add a `TMemo` and a `TImage` component to your form beforehand.\n\n\u003cbr/\u003e\n\n### Image and text to image\n\nIt is also possible to provide a reference image to use as a starting point for generation. In this case, the `strength` parameter must be specified, as it determines the influence of the input image on the final output. A `strength` value of 0 will produce an image identical to the input, while a value of 1 indicates no influence from the initial image.\n\n```Pascal\n//uses StabilityAI, StabilityAI.Types, StabilityAI.Common, StabilityAI.StableImage.Generate, FMX.Stability.Tutorial;\n\n  StabilityResult.FileName := 'lighthouse1.png';\n\n  Stability.StableImage.Generate.ImageUltra(\n    procedure (Params: TStableImageUltra)\n    begin\n      Params.AspectRatio(ratio16x9);\n      Params.Prompt('There are many birds in the sky');\n      Params.Image('lighthouse.png');\n      Params.Strength(0.3);\n      Params.OutputFormat(png);\n    end,\n    function : TAsynStableImage\n    begin\n      Result.Sender := StabilityResult;\n      Result.OnStart := Start;\n      Result.OnSuccess := Display;\n      Result.OnError := Display;\n    end);\n```\n\n\u003cbr/\u003e\n\n## Stable Image Core\n**Specificity:**\n- `Stable Image Core` is a text-to-image generation service designed to deliver premium quality with speed. Unlike other similar tools, it requires no expertise in \"prompt engineering.\" Users simply describe a style, scene, or character, and the tool generates an image that aligns with their description.\n\n\u003cbr/\u003e\n\n**Key Points:**\n- **Premium Quality:** Produces high-quality images, perfect for creative and professional uses.\n- **Ease of Use:** No need for complex prompt-writing techniques.\n- **Speed:** Near-instant image generation, even for detailed descriptions.\n- **Flexibility:** Handles a wide range of requests, from artistic styles to specific scenes or characters.\n- **Reliability:** Delivers consistent results that align with provided descriptions without requiring adjustments.\n\n\u003cbr/\u003e\n\n**Applications Inventory:**\n- **Design and Creative Work:** Ideal for creating visuals for graphic design projects or illustrations.\n- **Communication and Marketing:** Quickly generates eye-catching visuals for campaigns.\n- **Creative Exploration:** Visualizes abstract ideas or concepts.\n- **Education and Training:** Produces illustrations for courses or educational materials.\n- **Rapid Prototyping:** Helps quickly design images for pitches or ongoing projects.\n\n\u003cbr/\u003e\n\n### Image Core Create\n\n**Asynchronous Code Example**\n\n```Pascal\n//uses StabilityAI, StabilityAI.Types, StabilityAI.Common, StabilityAI.StableImage.Generate, FMX.Stability.Tutorial;\n\n  StabilityResult.FileName := 'lighthouse2.png';\n\n  Stability.StableImage.Generate.ImageCore(\n    procedure (Params: TStableImageCore)\n    begin\n      Params.AspectRatio(ratio16x9);\n      Params.Prompt('Lighthouse on a cliff overlooking the ocean');\n      Params.OutputFormat(png);\n    end,\n    function : TAsynStableImage\n    begin\n      Result.Sender := StabilityResult;\n      Result.OnStart := Start;\n      Result.OnSuccess := Display;\n      Result.OnError := Display;\n    end);\n```\n\nDetailed settings on the [official documentation](https://platform.stability.ai/docs/api-reference#tag/Generate/paths/~1v2beta~1stable-image~1generate~1core/post)\n\n\u003cbr\u003e\n\n### Using a preset style\n\nYou can guide the image model toward a specific style by selecting from 17 available styles.\n\n```Pascal\n//uses StabilityAI, StabilityAI.Types, StabilityAI.Common, StabilityAI.StableImage.Generate, FMX.Stability.Tutorial;\n\n  StabilityResult.FileName := 'lighthouse3.png';\n\n  Stability.StableImage.Generate.ImageCore(\n    procedure (Params: TStableImageCore)\n    begin\n      Params.AspectRatio(ratio16x9);\n      Params.Prompt('Lighthouse on a cliff overlooking the ocean');\n      Params.StylePreset(TStylePreset.digitalArt);\n      Params.OutputFormat(png);\n    end,\n    function : TAsynStableImage\n    begin\n      Result.Sender := StabilityResult;\n      Result.OnStart := Start;\n      Result.OnSuccess := Display;\n      Result.OnError := Display;\n    end);\n```\n\n\u003cbr/\u003e\n\n## Stable Diffusion\n\nInventory of available models\n\n**Stable Diffusion 3.5**\n- **SD3.5 Large:** Flagship model with 8 billion parameters, delivering exceptional image quality and precise prompt adherence. Ideal for professional use at 1-megapixel resolution.\n- **SD3.5 Large Turbo:** A distilled version of **SD3.5 Large**, designed for fast image generation in just 4 steps, while maintaining high quality and excellent prompt fidelity. Perfect for projects requiring quick execution.\n- **SD3.5 Medium:** Mid-tier model with 2.5 billion parameters, offering an optimal balance between prompt accuracy and image quality. Best suited for fast and efficient performance.\n\n\u003cbr/\u003e\n\n**Stable Diffusion 3.0** (Fireworks AI)\n- **SD3 Large:** Model with 8 billion parameters, providing professional-grade performance similar to **SD3.5 Large**.\n- **SD3 Large Turbo:** Optimized version for faster execution while maintaining high-quality output.\n- **SD3 Medium:** Model with 2 billion parameters, balancing quality and speed for less intensive use cases.\n\n\u003cbr/\u003e\n\n**Key Points:**\n- **Parameter Count:** Indicates the model’s power (8B for Large, 2–2.5B for Medium).\n- **Speed:** `Turbo` versions generate images faster without sacrificing quality.\n- **Applications:** Large models are perfect for detailed and professional projects, while Medium models are ideal for quick, balanced tasks.\n\n\u003cbr/\u003e\n\n### Generating with a prompt\n\nThis mode creates an image based solely on a textual description. The `prompt` is the only mandatory input, but an optional `aspect_ratio` parameter is available to adjust the dimensions of the resulting image.\n\n**Asynchronous Code Example**\n\n```Pascal\n//uses StabilityAI, StabilityAI.Types, StabilityAI.Common, StabilityAI.StableImage.Generate, FMX.Stability.Tutorial;\n\n  StabilityResult.FileName := 'lighthouse4.png';\n\n  Stability.StableImage.Generate.Diffusion(\n    procedure (Params: TStableImageDiffusion)\n    begin\n      Params.AspectRatio(ratio16x9);\n      Params.Prompt('Lighthouse on a cliff overlooking the ocean');\n      Params.OutputFormat(png);\n    end,\n    function : TAsynStableImage\n    begin\n      Result.Sender := StabilityResult;\n      Result.OnStart := Start;\n      Result.OnSuccess := Display;\n      Result.OnError := Display;\n    end);\n```\n\nDetailed settings on the [official documentation](https://platform.stability.ai/docs/api-reference#tag/Generate/paths/~1v2beta~1stable-image~1generate~1sd3/post)\n\n\u003cbr/\u003e\n\n### Generating with a prompt and an image\n\nThis method generates an image based on text input while using an existing image as the initial reference. The necessary parameters include:\n- `prompt`: the descriptive text that guides the image generation.\n- `image`: the starting image that serves as the foundation for the output.\n- `strength`: determines the degree to which the starting image influences the final result.\n- `mode`: should be set to \"image-to-image\".\n\n**Asynchronous Code Example**\n\n```Pascal\n//uses StabilityAI, StabilityAI.Types, StabilityAI.Common, StabilityAI.StableImage.Generate, FMX.Stability.Tutorial;\n\n  StabilityResult.FileName := 'lighthouse5.png';\n\n  Stability.StableImage.Generate.Diffusion(\n    procedure (Params: TStableImageDiffusion)\n    begin\n      Params.Prompt('There are many birds in the sky');\n      Params.Mode(imageToImage);\n      Params.Image('lighthouse4.png');\n      Params.Strength(0.6);\n      Params.OutputFormat(png);\n    end,\n    function : TAsynStableImage\n    begin\n      Result.Sender := StabilityResult;\n      Result.OnStart := Start;\n      Result.OnSuccess := Display;\n      Result.OnError := Display;\n    end);\n```\n\n\u003e[!NOTE]\n\u003e Note: maximum request size is 10MiB.\n\u003e\n\n\u003cbr/\u003e\n\n### Optional Parameters\n\nBoth modes allow the use of these optional parameters:\n- `model`: Specifies the model to utilize, such as **SD3 Large**, **SD3 Large Turbo**, or **SD3 Medium**.\n- `output_format`: Determines the desired format of the resulting image.\n- `seed`: Sets the randomness seed for the generation process.\n- `negative_prompt`: Defines keywords to exclude from the generated image.\n- `cfg_scale`: Adjusts the level of adherence to the prompt text during the diffusion process.\n\n\u003cbr/\u003e\n\n## SDXL and SD version 1\n\n### Text to image prompting\n\n**Using SDXL 1.0:** Use `stable-diffusion-xl-1024-v1-0` as the `engine_id` for your request, and specify the dimensions (`height` and `width`) with one of the following combinations:\n- **1024x1024** (default)\n- **1152x896**\n- **896x1152**\n- **1216x832**\n- **1344x768**\n- **768x1344**\n- **1536x640**\n- **640x1536**\n\n\u003cbr/\u003e\n\n**Using SD 1.6**: SD 1.6 is a flexible-resolution base model designed for generating images with non-standard aspect ratios. The model is optimized for a resolution of 512 x 512 pixels. To create outputs with a resolution of 1 megapixel, we recommend using SDXL 1.0, which is available at the same price.\n\nTo use this model, set `stable-diffusion-v1-6` as the `engine_id` in your request and ensure the `height` and `width` meet the following requirements:\n- Each dimension must be at least 320 pixels.\n- No dimension can exceed 1536 pixels.\n- Dimensions must be in increments of 64.\n- The default resolution is 512 x 512 pixels.\n\n\u003cbr/\u003e\n\n**Asynchronous Code Example**\n\n```Pascal\n//uses \n//  StabilityAI, StabilityAI.Types, StabilityAI.Common, StabilityAI.StableImage.Generate, \n//  StabilityAI.Version1.SDXL1AndSD1_6, FMX.Stability.Tutorial; \n\n  StabilityResult.FileName := 'lighthouse6.png';\n\n  Stability.Version1.SDXLAndSDL.TextToImage('stable-diffusion-xl-1024-v1-0',\n    procedure (Params: TPayload)\n    begin\n      Params.TextPrompts([TPrompt.New(1, 'A lighthouse on a cliff') ]);\n      Params.CfgScale(7);\n      Params.Height(1216);\n      Params.Width(832);\n      Params.Sampler(TSamplerType.K_DPMPP_2S_ANCESTRAL);\n      Params.Samples(1);\n      Params.Steps(30);\n    end,\n    function : TAsynArtifacts\n    begin\n      Result.Sender := StabilityResult;\n      Result.OnStart := Start;\n      Result.OnSuccess := Display;\n      Result.OnError := Display;\n    end);\n```\nDetailed settings on the [official documentation](https://platform.stability.ai/docs/api-reference#tag/SDXL-1.0-and-SD1.6/operation/textToImage)\n\n\u003cbr/\u003e\n\n### Image to image with prompt\n\n**Adjusting the Degree of Transformation**\n- To retain approximately 35% of the original image in the final output, you can use either of these approaches: set `init_image_mode=IMAGE_STRENGTH` with `image_strength=0.35`, or use `init_image_mode=STEP_SCHEDULE` with `step_schedule_start=0.65`. Both methods yield similar results, but the `step_schedule` mode offers additional flexibility by allowing you to specify a `step_schedule_end` value, giving more nuanced control if needed. For further details, refer to the specific parameter descriptions below.\n\n**Asynchronous Code Example**\n\n```Pascal\n//uses \n//  StabilityAI, StabilityAI.Types, StabilityAI.Common, StabilityAI.StableImage.Generate, \n//  StabilityAI.Version1.SDXL1AndSD1_6, FMX.Stability.Tutorial; \n\n  StabilityResult.FileName := 'lighthouse7.png';\n\n  Stability.Version1.SDXLAndSDL.ImageToImageWithPrompt('stable-diffusion-v1-6',\n    procedure (Params: TPayloadPrompt)\n    begin\n      Params.TextPrompts([TPromptMultipart.New(1, 'A dog space commander') ]);\n      Params.InitImage('lighthouse6.png');\n      Params.ImageStrength(0.45);\n      Params.CfgScale(7);\n      Params.Sampler(TSamplerType.K_DPMPP_2S_ANCESTRAL);\n      Params.Samples(3);\n      Params.Steps(30);\n    end,\n    function : TAsynArtifacts\n    begin\n      Result.Sender := StabilityResult;\n      Result.OnStart := Start;\n      Result.OnSuccess := Display;\n      Result.OnError := Display;\n    end);\n```\n\n\u003e[!TIP]\n\u003e In our code example, the value of the Samples parameter is 3, which means that three images were generated. Only the first one is displayed. The other two were saved with indexed file names as follows: lighthouse701.png and lighthouse702.png.\n\u003e\n\nDetailed settings on the [official documentation](https://platform.stability.ai/docs/api-reference#tag/SDXL-1.0-and-SD1.6/operation/imageToImage)\n\n\u003cbr/\u003e\n\n### Image to image with mask\n\nModify specific parts of an image using a mask. The mask must match the dimensions and shape of the original image. This functionality also supports images with alpha channels. \n\nuse the métode:\n```Pascal\n  ImageToImageWithMask(const Model: string; ParamProc: TProc\u003cTPayloadMask\u003e; \n     CallBacks: TFunc\u003cTAsynArtifacts\u003e);\n```\n\n\u003cbr/\u003e\n\n# Upscale\n\nTools to Enhance the Size and Resolution of Your Images\n\n**Conservative Upscaler**\n- Upscale images by 20 to 40 times while preserving their original appearance, delivering outputs up to 4 megapixels. This tool works effectively even with images as small as 64x64 pixels, directly scaling them up to 4 megapixels. Choose this option when you need a straightforward 4-megapixel result.\n\n**Creative Upscaler**\n- Designed for heavily degraded images (less than 1 megapixel), this service applies a creative approach to generate high-resolution outputs with a unique touch.\n\n**Fast Upscaler**\n- This quick and efficient tool is perfect for improving the quality of compressed images, making it a great choice for social media posts and other similar uses.\n\n \u003cbr/\u003e\n\n## Conservative\n\nAccepts images ranging in size from 64x64 pixels up to 1 megapixel and enhances their resolution to 4K. More broadly, it can upscale images by approximately 20 to 40 times while maintaining their original details. The Conservative Upscale option focuses on preserving the image's integrity with minimal modifications and is not intended for reinterpreting the image's content.\n\n**Asynchronous Code Example**\n\n```Pascal\n//uses \n//  StabilityAI, StabilityAI.Types, StabilityAI.Common, FMX.Stability.Tutorial,\n//  StabilityAI.StableImage.Upscale;\n\n  StabilityResult.FileName := 'Upscalelighthouse1.png';\n\n  Stability.StableImage.Upscale.Conservative(\n    procedure (Params: TUpscaleConservative)\n    begin\n      Params.Image('lighthouse.png');\n      Params.Prompt('The light house');\n      Params.OutputFormat(png);\n    end,\n    function : TAsynStableImage\n    begin\n      Result.Sender := StabilityResult;\n      Result.OnStart := Start;\n      Result.OnSuccess := Display;\n      Result.OnError := Display;\n    end);\n```\n\nDetailed settings on the [official documentation](https://platform.stability.ai/docs/api-reference#tag/Upscale/paths/~1v2beta~1stable-image~1upscale~1conservative/post)\n\n\u003cbr/\u003e\n\n## Creative Upscale\n\nAccepts images ranging from 64x64 pixels to a maximum of 1 megapixel, enhancing their resolution up to 4K. More broadly, it can upscale images by approximately 20 to 40 times while maintaining—and often improving—their quality. The Creative Upscale feature is particularly effective for heavily degraded images, but it is not suited for photos larger than 1 megapixel, as it applies significant reinterpretation (adjustable via the creativity scale).\n\n\u003e[!WARNING]\n\u003e This function is labeled as asynchronous by the editor, but in reality, it doesn't behave as such for a third-party application utilizing it. It operates more like a caching mechanism for a slightly delayed processing.\n\u003e\n\n**Asynchronous Code Example**\n\n```Pascal\n//uses \n//  StabilityAI, StabilityAI.Types, StabilityAI.Common, FMX.Stability.Tutorial,\n//  StabilityAI.StableImage.Upscale;\n\n  Stability.StableImage.Upscale.Creative(\n    procedure (Params: TUpscaleCreative)\n    begin\n      Params.Image('lighthouse.png');\n      Params.Prompt('The gray light house');\n      Params.OutputFormat(png);\n    end,\n    function : TAsynResults\n    begin\n      Result.Sender := StabilityResult;\n      Result.OnStart := Start;\n      Result.OnSuccess := Display;\n      Result.OnError := Display;\n    end);\n```\n\nDetailed settings on the [official documentation](https://platform.stability.ai/docs/api-reference#tag/Upscale/paths/~1v2beta~1stable-image~1upscale~1creative/post)\n\nWe retrieve the job ID, and in the next step, we need to load the image unless the status retrieved is \"in-progress.\" In that case, the operation should be retried.\n\n### Fetch async generation result\n\n```Pascal\n//uses \n//  StabilityAI, StabilityAI.Types, StabilityAI.Common, FMX.Stability.Tutorial,\n//  StabilityAI.StableImage.Results,\n\n  // e.g. Id ---\u003e ea771536f066b7fd03d62384581982ecd8b54a932a6378d5809d43f6e5aa789a\n  StabilityResult.FileName := 'Upscalelighthouse2.png';\n  \n  Stability.StableImage.Results.Fetch(StabilityResult.Id,\n    function : TAsynResults\n    begin\n      Result.Sender := StabilityResult;\n      Result.OnStart := Start;\n      Result.OnSuccess := Display;\n      Result.OnError := Display;\n    end);\n```\n\nDetailed settings on the [official documentation](https://platform.stability.ai/docs/api-reference#tag/Results/paths/~1v2beta~1results~1%7Bid%7D/get)\n\n\u003cbr/\u003e\n\n## Fast\n\nThe Fast Upscaler serviceincrease image resolution by 400%. Designed for speed and efficiency, it processes images in approximately one second, making it an excellent tool for improving the clarity of compressed visuals, perfect for social media posts and various other uses.\n\n**Asynchronous Code Example**\n\n```Pascal\n//uses \n//  StabilityAI, StabilityAI.Types, StabilityAI.Common, FMX.Stability.Tutorial,\n//  StabilityAI.StableImage.Upscale;\n\n  StabilityResult.FileName := 'Upscalelighthouse3.png';\n\n  Stability.StableImage.Upscale.Fast(\n    procedure (Params: TUpscaleFast)\n    begin\n      Params.Image('lighthouse.png');\n      Params.OutputFormat(png);\n    end,\n    function : TAsynStableImage\n    begin\n      Result.Sender := StabilityResult;\n      Result.OnStart := Start;\n      Result.OnSuccess := Display;\n      Result.OnError := Display;\n    end);\n```\n\nDetailed settings on the [official documentation](https://platform.stability.ai/docs/api-reference#tag/Upscale/paths/~1v2beta~1stable-image~1upscale~1fast/post) \n\n\u003cbr/\u003e\n\n# Edit\n\n**Feature Inventory**\n- **Erase:** Removes unwanted elements.\n- **Outpaint:** Extends the image beyond its boundaries.\n- **Inpaint:** Edits or replaces specific defined areas.\n- **Search and Replace:** Changes objects based on textual instructions.\n- **Search and Recolor:** Adjusts the colors of specific objects.\n- **Remove Background:** Segments the foreground to eliminate the background.\n\n\u003cbr/\u003e\n\n## Erase\n\nThe Erase service is designed to eliminate unwanted elements from images, such as imperfections on faces or objects on surfaces, using masking techniques.\n\n`Masks` can be supplied in one of two methods:\n1. Directly, by providing a separate image through the `mask` parameter.\n2. Indirectly, by extracting it from the alpha channel of the image parameter.\n\n**Asynchronous Code Example**\n\n\u003e[!NOTE]\n\u003e- If no specific `mask` is supplied, a mask will automatically be generated based on the image's alpha channel. Transparent areas will be subject to inpainting, while opaque regions will remain unchanged.\n\u003e- If an image with an alpha channel is provided together with a `mask`, the `mask` will override the alpha channel.\n\u003e\n\n```Pascal\n//uses \n//  StabilityAI, StabilityAI.Types, StabilityAI.Common, FMX.Stability.Tutorial,\n//  StabilityAI.StableImage.Edit;\n\n  StabilityResult.FileName := 'EraseLighthouse.png';\n\n  Stability.StableImage.Edit.Erase(\n    procedure (Params: TErase)\n    begin\n      Params.Image('Lighthouse.png');\n      Params.OutputFormat(png);\n    end,\n    function: TAsynStableImage\n    begin\n      Result.Sender := StabilityResult;\n      Result.OnStart := Start;\n      Result.OnSuccess := Display;\n      Result.OnError := Display;\n    end);\n```\n\nWhen a mask is provided :\n\n\u003e[!NOTE]\n\u003e - The input for this parameter should be a black-and-white image where the intensity of each pixel determines the strength of the inpainting effect. Darker pixels indicate minimal or no inpainting, while lighter pixels represent maximum inpainting intensity, with completely black pixels having no effect and completely white pixels applying the strongest effect.\n\u003e - If the `mask`'s dimensions differ from those of the image parameter, it will be automatically adjusted to match the image size.\n\u003e\n\n```Pascal\n  Stability.StableImage.Edit.Erase(\n    procedure (Params: TErase)\n    begin\n      Params.Image('Lighthouse.png');\n      Params.Mask('MyMask01.png');\n      Params.GrowMask(6);\n      Params.OutputFormat(png);\n    end,\n   ...\n```\n\nDetailed settings on the [official documentation](https://platform.stability.ai/docs/api-reference#tag/Edit/paths/~1v2beta~1stable-image~1edit~1erase/post)\n\n\u003cbr/\u003e\n\n## Inpaint\n\nModify images intelligently by adding or replacing specific sections with new content, guided by a `mask` image.\n\nThis `mask` can be supplied in two ways:\n- By directly providing a separate image through the mask parameter.\n- By extracting it from the alpha channel of the image parameter.\n\n```Pascal\n//uses \n//  StabilityAI, StabilityAI.Types, StabilityAI.Common, FMX.Stability.Tutorial,\n//  StabilityAI.StableImage.Edit;\n\n  StabilityResult.FileName := 'InpaintLighthouse.png';\n\n  Stability.StableImage.Edit.Inpaint(\n    procedure (Params: TInpaint)\n    begin\n      Params.Image('Lighthouse.png');\n      Params.Mask('Mask01.png');\n      Params.Prompt('The lighthouse is bigger');\n      Params.OutputFormat(png);\n    end,\n    function: TAsynStableImage\n    begin\n      Result.Sender := StabilityResult;\n      Result.OnStart := Start;\n      Result.OnSuccess := Display;\n      Result.OnError := Display;\n    end);\n```\n\nThe use of the `mask` is identical to that described with the [erase](#Erase) API.\n\nDetailed settings on the [official documentation](https://platform.stability.ai/docs/api-reference#tag/Edit/paths/~1v2beta~1stable-image~1edit~1inpaint/post)\n\n\u003cbr/\u003e\n\n## Outpaint\n\nThe Outpaint service allows for the seamless extension of an image by adding content in any direction to fill the surrounding space. Unlike other methods, whether automated or manual, this service is designed to reduce visible artifacts and avoid noticeable indications of image editing.\n\n```Pascal\n//uses \n//  StabilityAI, StabilityAI.Types, StabilityAI.Common, FMX.Stability.Tutorial,\n//  StabilityAI.StableImage.Edit;\n\n  StabilityResult.FileName := 'OutpaintLighthouse.png';\n\n  Stability.StableImage.Edit.Outpaint(\n    procedure (Params: TOutpaint)\n    begin\n      Params.Image('Lighthouse.png');\n      Params.Right(200);\n      Params.Down(400);\n      Params.OutputFormat(png);\n    end,\n    function: TAsynStableImage\n    begin\n      Result.Sender := StabilityResult;\n      Result.OnStart := Start;\n      Result.OnSuccess := Display;\n      Result.OnError := Display;\n    end);\n```\n\nDetailed settings on the [official documentation](https://platform.stability.ai/docs/api-reference#tag/Edit/paths/~1v2beta~1stable-image~1edit~1outpaint/post)\n\n\u003cbr/\u003e\n\n## Search and Replace\n\nThe Search and Replace service offers a specialized form of inpainting that eliminates the need for a mask. Instead, users can specify an object to replace by describing it in plain language using a search_prompt. The service will then automatically detect and segment the specified object, seamlessly substituting it with the one described in the prompt.\n\n```Pascal\n//uses \n//  StabilityAI, StabilityAI.Types, StabilityAI.Common, FMX.Stability.Tutorial,\n//  StabilityAI.StableImage.Edit;\n\n  StabilityResult.FileName := 'SearchReplaceLighthouse.png';\n\n  Stability.StableImage.Edit.SearchAndReplace(\n    procedure (Params: TSearchAndReplace)\n    begin\n      Params.Image('Lighthouse.png');\n      Params.Prompt('Replace the lighthouse');\n      Params.SearchPrompt('Lighthouse');\n      Params.OutputFormat(png);\n    end,\n    function: TAsynStableImage\n    begin\n      Result.Sender := StabilityResult;\n      Result.OnStart := Start;\n      Result.OnSuccess := Display;\n      Result.OnError := Display;\n    end);\n```\n\nDetailed settings on the [official documentation](https://platform.stability.ai/docs/api-reference#tag/Edit/paths/~1v2beta~1stable-image~1edit~1search-and-replace/post)\n\n\u003cbr/\u003e\n\n## Search and Recolor\n\nBy utilizing the Search and Recolor service, you can change the color of a specific object in an image through a simple prompt. This specialized form of inpainting doesn't require a mask. Instead, the service automatically segments the object and applies the new colors as specified in your prompt.\n\n```Pascal\n//uses \n//  StabilityAI, StabilityAI.Types, StabilityAI.Common, FMX.Stability.Tutorial,\n//  StabilityAI.StableImage.Edit;\n\n  StabilityResult.FileName := 'SearchRecolorLighthouse.png';\n\n  Stability.StableImage.Edit.SearchAndRecolor(\n    procedure (Params: TSearchAndRecolor)\n    begin\n      Params.Image('Lighthouse.png');\n      Params.Prompt('The lighthouse is pink');\n      Params.SelectPrompt('Lighthouse');\n      Params.OutputFormat(png);\n    end,\n    function: TAsynStableImage\n    begin\n      Result.Sender := StabilityResult;\n      Result.OnStart := Start;\n      Result.OnSuccess := Display;\n      Result.OnError := Display;\n    end);\n```\n\nDetailed settings on the [official documentation](https://platform.stability.ai/docs/api-reference#tag/Edit/paths/~1v2beta~1stable-image~1edit~1search-and-recolor/post)\n\n\u003cbr/\u003e\n\n## Remove Background\n\nThe Remove Background service precisely identifies and isolates the foreground in an image, allowing for the background to be either removed or replaced as needed.\n\n```Pascal\n//uses \n//  StabilityAI, StabilityAI.Types, StabilityAI.Common, FMX.Stability.Tutorial,\n//  StabilityAI.StableImage.Edit;\n\n  StabilityResult.FileName := 'RemoveBackgroundLighthouse.png';\n\n  Stability.StableImage.Edit.RemoveBackground(\n    procedure (Params: TRemoveBackground)\n    begin\n      Params.Image('Lighthouse.png');\n      Params.OutputFormat(png);\n    end,\n    function: TAsynStableImage\n    begin\n      Result.Sender := StabilityResult;\n      Result.OnStart := Start;\n      Result.OnSuccess := Display;\n      Result.OnError := Display;\n    end);\n```\n\nDetailed settings on the [official documentation](https://platform.stability.ai/docs/api-reference#tag/Edit/paths/~1v2beta~1stable-image~1edit~1remove-background/post)\n\n\u003cbr/\u003e\n\n## Replace Background and Relight\n\nThe Replace Background and Relight editing service enables to effortlessly change backgrounds using AI-generated images or their own uploads, while seamlessly adjusting lighting to complement the subject. This API offers an efficient image editing solution tailored for various industries, including e-commerce, real estate, photography, and creative endeavors.\n\nKey features include:\n- **Background Replacement:** Effortlessly remove the current background and replace it with a new one.\n- **AI-Generated Backgrounds:** Generate unique backgrounds with AI based on your chosen prompts.\n- **Relighting:** Fine-tune the lighting of images to correct underexposure or overexposure.\n- **Customizable Inputs:** Opt for your own uploaded background or create one using AI.\n- **Lighting Controls:** Adjust the reference, direction, and intensity of lighting for a polished look.\n\n\u003e[!WARNING]\n\u003e This function is labeled as asynchronous by the editor, but in reality, it doesn't behave as such for a third-party application utilizing it. It operates more like a caching mechanism for a slightly delayed processing.\n\u003e\n\n```Pascal\n//uses \n//  StabilityAI, StabilityAI.Types, StabilityAI.Common, FMX.Stability.Tutorial,\n//  StabilityAI.StableImage.Edit;\n\n  Stability.StableImage.Edit.ReplaceBackgroundAndRelight(\n    procedure (Params: TReplaceBackgroundAndRelight)\n    begin\n      Params.SubjectImage('Lighthouse.png');\n      Params.BackgroundPrompt('cinematic lighting');\n      Params.OutputFormat(png);\n    end,\n    function: TAsynResults\n    begin\n      Result.Sender := StabilityResult;\n      Result.OnStart := Start;\n      Result.OnSuccess := Display;\n      Result.OnError := Display;\n    end);\n```\n\nThe API returns the ID of the ongoing task, just like the [Upscale Creative](#Creative-Upscale) API. You then need to use the [Fetch](#Fetch-async-generation-result) API, as previously mentioned.\n\nDetailed settings on the [official documentation](https://platform.stability.ai/docs/api-reference#tag/Edit/paths/~1v2beta~1stable-image~1edit~1replace-background-and-relight/post)\n\n\u003cbr/\u003e\n\n# Control\n\nTools for Creating Controlled Variations of Images and Sketches\n- **Sketch:** This feature transforms rough sketches into polished, refined outputs with a high level of precision. For non-sketch images, it offers advanced control over the final look by utilizing the image's contour lines and edges to guide adjustments.\n- **Structure:** Designed to maintain the structural integrity of an input image, this tool is ideal for sophisticated content creation tasks, such as reconstructing scenes or rendering characters based on existing models.\n- **Style:** By analyzing the stylistic elements of a reference image (control image), this service generates a new image aligned with the style of the reference, guided by the user's prompt. The result is an output that mirrors the artistic essence of the original.\n\n## Sketch\n\nThis tool is designed for development workflows involving iterative design and brainstorming. It transforms hand-drawn sketches into polished visuals with precise adjustments. Additionally, it enables fine-tuned control over the final appearance of non-sketch images by utilizing the image's contours and edges.\n\n```Pascal\n//uses \n//  StabilityAI, StabilityAI.Types, StabilityAI.Common, FMX.Stability.Tutorial,\n//  StabilityAI.StableImage.Control;\n\n  StabilityResult.FileName := 'Control01.png';\n\n  Stability.StableImage.Control.Sketch(\n    procedure (Params: TSketch)\n    begin\n      Params.Image('lighthouse.png');\n      Params.ControlStrength(0.7);\n      Params.Prompt('a medieval castle on a hill');\n      Params.OutputFormat(png);\n    end,\n    function : TAsynStableImage\n    begin\n      Result.Sender := StabilityResult;\n      Result.OnStart := Start;\n      Result.OnSuccess := Display;\n      Result.OnError := Display;\n    end);\n```\n\nDetailed settings on the [official documentation](https://platform.stability.ai/docs/api-reference#tag/Control/paths/~1v2beta~1stable-image~1control~1sketch/post)\n\n\u003cbr/\u003e\n\n## Structure\n\nThis service is designed to generate images while preserving the structure of an input image, making it particularly useful for tasks like replicating scenes or rendering characters based on predefined models.\n\n```Pascal\n//uses \n//  StabilityAI, StabilityAI.Types, StabilityAI.Common, FMX.Stability.Tutorial,\n//  StabilityAI.StableImage.Control;\n\n  StabilityResult.FileName := 'Control02.png';\n\n  Stability.StableImage.Control.Structure(\n    procedure (Params: TStructure)\n    begin\n      Params.Image('lighthouse.png');\n      Params.ControlStrength(0.7);\n      Params.Prompt('a well manicured shrub in an english garden');\n      Params.OutputFormat(png);\n    end,\n    function : TAsynStableImage\n    begin\n      Result.Sender := StabilityResult;\n      Result.OnStart := Start;\n      Result.OnSuccess := Display;\n      Result.OnError := Display;\n    end);\n```\n\nDetailed settings on the [official documentation](https://platform.stability.ai/docs/api-reference#tag/Control/paths/~1v2beta~1stable-image~1control~1structure/post)\n\n\u003cbr/\u003e\n\n## Style\n\nThis tool analyzes the stylistic features of a given input image (control image) and applies them to generate a new image guided by a specified prompt. The output image retains the visual style of the control image while incorporating the requested content.\n\n```Pascal\n//uses \n//  StabilityAI, StabilityAI.Types, StabilityAI.Common, FMX.Stability.Tutorial,\n//  StabilityAI.StableImage.Control;\n\n  StabilityResult.FileName := 'Control03.png';\n\n  Stability.StableImage.Control.Style(\n    procedure (Params: TStyle)\n    begin\n      Params.Image('lighthouse.png');\n      Params.Prompt('a majestic portrait of a chicken');\n      Params.Fidelity(0.7);\n      Params.OutputFormat(png);\n    end,\n    function : TAsynStableImage\n    begin\n      Result.Sender := StabilityResult;\n      Result.OnStart := Start;\n      Result.OnSuccess := Display;\n      Result.OnError := Display;\n    end);\n```\n\nDetailed settings on the [official documentation](https://platform.stability.ai/docs/api-reference#tag/Control/paths/~1v2beta~1stable-image~1control~1style/post)\n\n\u003cbr/\u003e\n\n# Results\n\nTools for fetching the results of your async generations.\n\nFor using, see [Fetch async generation result](#Fetch-async-generation-result) \n\n\u003cbr/\u003e\n\n# 3D\n\nStable Fast 3D generates high-quality 3D assets from a single 2D input image.\n\nSee the [GLB File Format](https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#glb-file-format-specification) Specification for more details.\n\n```Pascal\n//uses \n//  StabilityAI, StabilityAI.Types, StabilityAI.Common, FMX.Stability.Tutorial,\n// StabilityAI.VideoAnd3D.Stable3D;\n\n  StabilityResult.FileName := 'My_Result.gltf';\n\n  Stability.VideoAnd3D.Model3D.Fast3D(\n    procedure (Params: TStable3D)\n    begin\n      Params.Image('My_ImageTo3D.png');\n      Params.ForegroundRatio(0.85);\n    end,\n    function : TAsynModel3D\n    begin\n      Result.Sender := StabilityResult;\n      Result.OnStart := Start;\n      Result.OnSuccess := Display;\n      Result.OnError := Display;\n    end);\n```\n\nDetailed settings on the [official documentation](https://platform.stability.ai/docs/api-reference#tag/3D/paths/~1v2beta~13d~1stable-fast-3d/post)\n\n\u003cbr/\u003e\n\n# Video\n\nUse [**Stable Video Diffusion**](https://static1.squarespace.com/static/6213c340453c3f502425776e/t/655ce779b9d47d342a93c890/1700587395994/stable_video_diffusion.pdf), a latent video diffusion model, to generate a short video from an initial image.\n- After calling this endpoint with the required parameters, retrieve the `ID` from the response to check the results at the `image-to-video/result/{id}` endpoint. Be sure not to poll this endpoint more than once every 10 seconds to avoid errors or rate-limiting issues.\n\n```Pascal\n//uses \n//  StabilityAI, StabilityAI.Types, StabilityAI.Common, FMX.Stability.Tutorial,\n//  StabilityAI.VideoAnd3D.Video;\n\n  Stability.VideoAnd3D.ImageToVideo.Generation(\n    procedure (Params: TVideo)\n    begin\n      Params.Image('lighthouse1024x576.png');\n    end,\n    function : TAsynJobVideo\n    begin\n      Result.Sender := StabilityResult;\n      Result.OnStart := Start;\n      Result.OnSuccess := Display;\n      Result.OnError := Display;\n    end);\n```\n\nAt the end, we retrieve the ID (*e.g. d4fb4aa8301aee0b368a41b3c0a78018dfc28f1f959a3666be2e6951408fb8e3*) of the video creation task. Then, we simply retrieve the result in this way.\n\nDetailed settings on the [official documentation](https://platform.stability.ai/docs/api-reference#tag/Image-to-Video/paths/~1v2beta~1image-to-video/post)\n\n```Pascal\n//uses \n//  StabilityAI, StabilityAI.Types, StabilityAI.Common, FMX.Stability.Tutorial,\n//  StabilityAI.VideoAnd3D.Video;\n\n  var Id := 'd4fb4aa8301aee0b368a41b3c0a78018dfc28f1f959a3666be2e6951408fb8e3';\n  StabilityResult.FileName := 'lighthouse1024x576.mp4';\n\n  Stability.VideoAnd3D.ImageToVideo.Fetch(Id,\n    function : TAsynResults\n    begin\n      Result.Sender := StabilityResult;\n      Result.OnStart := Start;\n      Result.OnSuccess := Display;\n      Result.OnError := Display;\n    end);\n```\n\nDetailed settings on the [official documentation](https://platform.stability.ai/docs/api-reference#tag/Image-to-Video/paths/~1v2beta~1image-to-video~1result~1%7Bid%7D/get)\n\n\u003cbr/\u003e\n\n# Other Features of Version 1\n\n## Model list\n\nList the engines compatible with `Version 1` REST API endpoints.\n\n```Pascal\n//uses \n//  StabilityAI, StabilityAI.Types, StabilityAI.Common, FMX.Stability.Tutorial,\n//  StabilityAI.Version1.Engines;\n\n  Stability.Version1.Engines.List(\n    function : TAsynEngines\n    begin\n      Result.Sender := StabilityResult;\n      Result.OnStart := Start;\n      Result.OnSuccess := Display;\n      Result.OnError := Display;\n    end);\n```\n\nDetailed settings on the [official documentation](https://platform.stability.ai/docs/api-reference#tag/Engines/operation/listEngines)\n\n\u003cbr/\u003e\n\n## User account\n\nRetrieve details about the account linked to the specified API key\n\n```Pascal\n//uses \n//  StabilityAI, StabilityAI.Types, StabilityAI.Common, FMX.Stability.Tutorial,\n//  StabilityAI.Version1.User;\n\n  Stability.Version1.User.AccountDetails(\n    function : TAsynAccountDetails\n    begin\n      Result.Sender := StabilityResult;\n      Result.OnStart := Start;\n      Result.OnSuccess := Display;\n      Result.OnError := Display;\n    end);\n```\n\nDetailed settings on the [official documentation](https://platform.stability.ai/docs/api-reference#tag/User/operation/userAccount)\n\n\u003cbr/\u003e\n\n## User balance\n\nRetrieve the credit balance for the account or organization linked to the provided API key.\n\n```Pascal\n//uses \n//  StabilityAI, StabilityAI.Types, StabilityAI.Common, FMX.Stability.Tutorial,\n//  StabilityAI.Version1.User;\n\n  var Balance := Stability.Version1.User.AccountBalance;\n  try\n    Memo1.Lines.Text := Memo1.Text + Balance.Credits.ToString + sLineBreak;\n  finally\n    Balance.Free;\n  end;\n```\n\nDetailed settings on the [official documentation](https://platform.stability.ai/docs/api-reference#tag/User/operation/userBalance)\n\n\u003cbr/\u003e\n\n# New features announced\n\n**Stability.ai** has announced two upcoming features:\n- Language generation with its models: `Stable LLM 12B` and `Stable LLM 1.6B`.\n- `Audio Stable 2.0`. You can contact Stability.ai to test this model by [sending a message](https://stability.ai/contact).\n\n\u003cbr/\u003e\n\n# Contributing\n\nPull requests are welcome. If you're planning to make a major change, please open an issue first to discuss your proposed changes.\n\n\u003cbr/\u003e\n\n# License\n\nThis project is licensed under the [MIT](https://choosealicense.com/licenses/mit/) License.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxidonkey%2Fdelphistabilityai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaxidonkey%2Fdelphistabilityai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxidonkey%2Fdelphistabilityai/lists"}