![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java JavaScript Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(DataFlex) Simple AI Image GenerationSee more AI ExamplesCreate an image by providing a text description.Note: This example requires Chilkat v11.4.0 or greater.
Use ChilkatAx-win32.pkg Procedure Test Boolean iSuccess Handle hoAi Variant vAskParams Handle hoAskParams Variant vBdImageData Handle hoBdImageData String sTemp1 Move False To iSuccess // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. Get Create (RefClass(cComChilkatAi)) To hoAi If (Not(IsComObjectCreated(hoAi))) Begin Send CreateComObject of hoAi End Set ComProvider Of hoAi To "openai" // Use your provider's API key. Set ComApiKey Of hoAi To "MY_API_KEY" // Choose a model. Set ComModel Of hoAi To "gpt-5" Get Create (RefClass(cComChilkatJsonObject)) To hoAskParams If (Not(IsComObjectCreated(hoAskParams))) Begin Send CreateComObject of hoAskParams End Get ComUpdateString Of hoAskParams "image.output_format" "jpeg" To iSuccess Get ComUpdateString Of hoAskParams "image.size" "1024x1024" To iSuccess Get ComUpdateString Of hoAskParams "image.quality" "low" To iSuccess Get pvComObject of hoAskParams to vAskParams Get ComSetAskParams Of hoAi vAskParams To iSuccess Get ComInputAddText Of hoAi "Generate a small, cute illustration of a gray tabby cat hugging a happy otter wearing an orange scarf" To iSuccess // Ask the AI for image output. Get ComAsk Of hoAi "image" To iSuccess If (iSuccess = False) Begin Get ComLastErrorText Of hoAi To sTemp1 Showln sTemp1 Procedure_Return End // Get the image response data. Get Create (RefClass(cComChilkatBinData)) To hoBdImageData If (Not(IsComObjectCreated(hoBdImageData))) Begin Send CreateComObject of hoBdImageData End Get pvComObject of hoBdImageData to vBdImageData Get ComGetOutputBd Of hoAi vBdImageData To iSuccess If (iSuccess = False) Begin Get ComLastErrorText Of hoAi To sTemp1 Showln sTemp1 Procedure_Return End Get ComWriteFile Of hoBdImageData "c:/aaworkarea/out.jpg" To iSuccess Showln "Success." End_Procedure |
||||
© 2000-2026 Chilkat Software, Inc. All Rights Reserved.