Haxe bindings for OpenAI API.
You can install it through Haxelib
haxelib install hxopenai_api
Or through Git
, if you want the latest updates
haxelib git hxopenai_api https://github.com/MAJigsaw77/hxopenai_api.git
package;
import hxopenai_api.OpenAI;
class Main
{
public static function main():Void
{
var client:OpenAI = new OpenAI('your key');
final request:ChatCompletionRequest = {
model: 'gpt-3.5-turbo',
messages: [
{
role: 'system',
content: 'You are a helpful assistant.'
},
{
role: 'user',
content: 'What is the capital of France?'
}
]
};
client.createChatCompletion(request, {
onSucceed: function(response:Dynamic):Void
{
trace('Success: $response');
},
onFail: function(message:String, data:Dynamic):Void
{
if (data != null && data.error != null && data.error.message != null)
trace('Error: $message, ${data.error.message}');
else
trace('Error: $message');
}
});
Sys.sleep(10);
}
}
hxopenai_api is made available under the MIT License. Check LICENSE for more information.