Skip to content

ToBase64

Returns Content encoded as UTF-8 and then as Base64, for example to store the answer as a file. Use the ToBase64 method of an item of Files for binary content.

1
myAICompletionResult.ToBase64():string

Returns

The content as Base64 text.

Examples

Save a generated text as a file

1
2
3
4
5
6
var result = $AI.Complete({
    Messages : [{ Role : 'user', Content : 'Write meeting minutes from these notes: ' + $Xml.Evaluate('Notes') }]
});

var file = $Files.AddBase64(result.ToBase64(), 'Minutes.txt', 'text/plain');
$Xml.SetValue('MinutesFile', file.Id);

See Also