![]() |
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
(Tcl) Simple AI Image GenerationSee more AI ExamplesCreate an image by providing a text description.Note: This example requires Chilkat v11.4.0 or greater.
load ./chilkat.dll set success 0 # This example assumes the Chilkat API to have been previously unlocked. # See Global Unlock Sample for sample code. set ai [new_CkAi] CkAi_put_Provider $ai "openai" # Use your provider's API key. CkAi_put_ApiKey $ai "MY_API_KEY" # Choose a model. CkAi_put_Model $ai "gpt-5" set askParams [new_CkJsonObject] CkJsonObject_UpdateString $askParams "image.output_format" "jpeg" CkJsonObject_UpdateString $askParams "image.size" "1024x1024" CkJsonObject_UpdateString $askParams "image.quality" "low" CkAi_SetAskParams $ai $askParams CkAi_InputAddText $ai "Generate a small, cute illustration of a gray tabby cat hugging a happy otter wearing an orange scarf" # Ask the AI for image output. set success [CkAi_Ask $ai "image"] if {$success == 0} then { puts [CkAi_lastErrorText $ai] delete_CkAi $ai delete_CkJsonObject $askParams exit } # Get the image response data. set bdImageData [new_CkBinData] set success [CkAi_GetOutputBd $ai $bdImageData] if {$success == 0} then { puts [CkAi_lastErrorText $ai] delete_CkAi $ai delete_CkJsonObject $askParams delete_CkBinData $bdImageData exit } CkBinData_WriteFile $bdImageData "c:/aaworkarea/out.jpg" puts "Success." delete_CkAi $ai delete_CkJsonObject $askParams delete_CkBinData $bdImageData |
||||
© 2000-2026 Chilkat Software, Inc. All Rights Reserved.