GDScript OpenAI API helper

An asset by Clemens Tolboom
The page banner background of a mountain and forest
GDScript OpenAI API helper thumbnail image
GDScript OpenAI API helper thumbnail image
GDScript OpenAI API helper hero image

Quick Information

0 ratings
GDScript OpenAI API helper icon image
Clemens Tolboom
GDScript OpenAI API helper

With this helper you can chat like ChatGPT, generate images like DALL-E and list all available models.

Supported Engine Version
4.0
Version String
0.3.1
License Version
MIT
Support Level
community
Modified Date
1 year ago
Git URL
Issue URL

GD Script OpenAI

Interfacing with the OpenAI API's using their API Key

With the gd-openai addon you can quickly create scenes interacting with the API of OpenAI. See the examples below.

Download the ZIP file from GitHub or install through the AssetLib when available.

User Data

The settings file open_ai_user_data.tres and all requests and responses are saved in user://.

The settings file for security reasons as it may not become part of the build.

The requests and responses for browsing back possibilities.

What calls are available?

API Key

The tool needs an API key from your OpenAI account.

Copy the open_ai_user_data.tres from the examples dir to your project root.

Then open it and replace the API Key field with your OpenAI API Key.

Then move the file out of your project to the game data directory using the menu `Project > Open User Data Folder.

You must move it to make sure not to expose your API Key to the world.

Examples

The are some examples available to list the models, start a chat/completions or fiddle with images/generations.

Building a scene

You need to add 3 parts to your scene:

OpenAiApiRequest

As a child in your tree.

@ready var openai_api_request:OpenAiApiRequest = $OpenAiApiRequest

func _ready():
    # Connect openai_api_request signals through the UI or code

func _on_open_ai_api_request_data_received(data):
  response = data

func _on_open_ai_api_request_error_response(error):
    print(error)

RequestData sub-class

RequestData sub-class like ModelsRequest, ChatCompletionsRequest, ImageGenerationsRequest, etc

@export var request:ChatCompletionsRequest

Then set it's value through the UI.

ResponseData sub-class

ResponseData sub-class like ModelsResponse.

var response:ChatCompletionsResponse = ChatCompletionsResponse.new()

Request/response

Initiate the call ie by a Button click

connector.do_post(request, response)

and wait for one of the two signals to appear.

Roadmap

References

Some other implementations

With this helper you can chat like ChatGPT, generate images like DALL-E and list all available models.

Reviews

0 ratings

Your Rating

Headline must be at least 3 characters but not more than 50
Review must be at least 5 characters but not more than 500
Please sign in to add a review

Quick Information

0 ratings
GDScript OpenAI API helper icon image
Clemens Tolboom
GDScript OpenAI API helper

With this helper you can chat like ChatGPT, generate images like DALL-E and list all available models.

Supported Engine Version
4.0
Version String
0.3.1
License Version
MIT
Support Level
community
Modified Date
1 year ago
Git URL
Issue URL

Open Source

Released under the AGPLv3 license

Plug and Play

Browse assets directly from Godot

Community Driven

Created by developers for developers