Chilkat Examples

ChilkatHOMEAndroid™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi DLLGoJavaJavaScriptNode.jsObjective-CPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwiftTclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

PowerBuilder Examples
Web API Categories

AI
ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Box
CAdES
CSR
CSV
Cert Store
Certificates
Cloud Signature CSC
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP
HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
JavaScript
MHT / HTML Email
MIME
Markdown
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
Regular Expressions
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
Secrets
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
X
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

(PowerBuilder) Upload an Image File to an AI Provider (OpenAI, Google, Antropic, X)

See more AI Examples
Uploads an image file to an AI provider using the provider's File API and returns the id that can later be used to reference the file in an query. This currently works with ChatGPT and Gemini, but not other AI's. Most AI's currently don't have the ability to reference pre-uploaded image data in conversations.

Note: This example requires Chilkat v11.4.0 or greater.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

integer li_rc
integer li_Success
oleobject loo_Ai
string ls_ContentType
string ls_LocalFilePath
string ls_FilenameOnServer
string ls_File_id
oleobject loo_Bd

li_Success = 0

loo_Ai = create oleobject
li_rc = loo_Ai.ConnectToNewObject("Chilkat.Ai")
if li_rc < 0 then
    destroy loo_Ai
    MessageBox("Error","Connecting to COM object failed")
    return
end if

// Can currently be "openai" or "google" because these are the only AI's that can reference pre-loaded image data by file ID.
loo_Ai.Provider = "openai"
// Use your provider's API key.
loo_Ai.ApiKey = "MY_API_KEY"

// We can upload directly from a file in the filesystem, or from a Chilkat BinData.

ls_ContentType = "image/jpeg"
ls_LocalFilePath = "qa_data/jpg/starfish.jpg"
ls_FilenameOnServer = "starfish.jpg"

// Upload directly from a file.
ls_File_id = loo_Ai.UploadFile(ls_LocalFilePath,ls_ContentType)
if loo_Ai.LastMethodSuccess = 0 then
    Write-Debug loo_Ai.LastErrorText
    Write-Debug "AI File Upload Failed."
else
    Write-Debug "File ID: " + ls_File_id
    Write-Debug "File uploaded."
end if

// Upload from the contents of a Chilkat BinData
loo_Bd = create oleobject
li_rc = loo_Bd.ConnectToNewObject("Chilkat.BinData")

li_Success = loo_Bd.LoadFile(ls_LocalFilePath)
if li_Success = 0 then
    Write-Debug loo_Bd.LastErrorText
    destroy loo_Ai
    destroy loo_Bd
    return
end if

ls_File_id = loo_Ai.UploadFileBd(loo_Bd,ls_FilenameOnServer,ls_ContentType)
if loo_Ai.LastMethodSuccess = 0 then
    Write-Debug loo_Ai.LastErrorText
    Write-Debug "AI File Upload Failed."
else
    Write-Debug "File ID: " + ls_File_id
    Write-Debug "File uploaded."
end if



destroy loo_Ai
destroy loo_Bd

 

© 2000-2026 Chilkat Software, Inc. All Rights Reserved.