AI Object
 
Syntax
 
lValue = AI.LastErrorCode
 
Type
AIErrorCode
Access
read-only
Description
Returns the AIErrorCode value of the most recent operation on the AI object. The property is updated by every method call that can fail (Ask, AttachFile, AttachRecordset, GetStatus, GetResultStr, and so on). A value of aiErrNone (0) indicates the last operation succeeded.
 
LastErrorCode reflects the object-level error state. It is set both by submission failures (where Ask returns 0) and by the most recent inspection of an asynchronous job. For an error that occurred during the asynchronous processing of a specific conversation handle, GetErrorCode(handle) returns the same value bound to that handle.
 
AIErrorCode constants:
   aiErrNone                = 0    ' last operation succeeded
   aiErrNotConfigured       = 1    ' Configure() not called
   aiErrNetwork             = 2    ' HTTP transport error (no connection)
   aiErrAuth                = 3    ' 401/403 - CBBS session invalid
   aiErrRateLimit           = 4    ' 429 - too many calls in a short time
   aiErrInvalidRequest      = 5    ' 400 or follow-up Ask on a busy handle
   aiErrModelError          = 6    ' 5xx or OpenAI error in async processing
   aiErrTimeout             = 7    ' TimeoutSeconds exceeded
   aiErrInvalidHandle       = 8    ' Get* called with an unknown handle
   aiErrInvalidResponse     = 9    ' could not parse XML/JSON response
   aiErrQuotaExceeded       = 10   ' Tradium quota exceeded (reserved, v2)
   aiErrJobFailed           = 11   ' usr_AI_Queue.Status = 9 (server-side fail)
   aiErrTooManyAttachments  = 12   ' more than 5 attachments on a handle
   aiErrAttachmentTooLarge  = 13   ' single file > 20 MB
   aiErrTotalSizeExceeded   = 14   ' total request > 30 MB
   aiErrUnsupportedMime     = 15   ' unknown or rejected file extension
   aiErrFileNotFound        = 16   ' filepath does not exist
   aiErrFileReadFailed      = 17   ' I/O error while reading the file
   aiErrNoRecordset         = 18   ' rs parameter is Nothing or not a recordset
   aiErrRecordsetClosed     = 19   ' recordset is closed / unusable
   aiErrUnknown             = 99   ' unclassified error
See Also
Example
 
Sub Main
Dim hConv As Long
 
hConv = AI.Ask("Test prompt", aiGeneral)
If hConv = 0 Then
Debug.Print "Submit failed. Code="; AI.LastErrorCode; " Msg="; AI.LastErrorMessage
Exit Sub
End If
End Sub