hxopenai_api

Haxe bindings for OpenAI API.
https://github.com/MAJigsaw77/hxopenai_api

To install, run:

haxelib install hxopenai_api 1.0.0 

See using Haxelib in Haxelib documentation for more information.

README.md

hxopenai_api

Haxe bindings for OpenAI API.

Installation

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

Basic Usage Example

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);
	}
}

Licensing

hxopenai_api is made available under the MIT License. Check LICENSE for more information.

Contributors
MAJigsaw77
Version
1.0.0
Published
2 weeks ago
License
MIT

All libraries are free

Every month, more than a thousand developers use Haxelib to find, share, and reuse code — and assemble it in powerful new ways. Enjoy Haxe; It is great!

Explore Haxe

Haxe Manual

Haxe Code Cookbook

Haxe API documentation

You can try Haxe in the browser! try.haxe.org

Join us on GitHub!

Haxe is being developed on GitHub. Feel free to contribute or report issues to our projects.

Haxe on GitHub