C3 OpenAI-Compatible Client for Godot
A drop-in Godot 4 client node for OpenAI-compatible HTTP APIs. Works with OpenAI, LM Studio, speaches, and any other server that speaks the OpenAI REST API. This is a runtime addon for adding AI features to your game, not an editor assistant or Copilot-style tool.
Features
- Chat completions — non-streaming or streaming (token-by-token via signals)
- Vision (image input) support
"type": "json_schema"structured output support- Image generation (returns a decoded
Imagein the response object) - Text-to-speech (returns a ready-to-play
AudioStream) - Speech-to-text / transcription (
AudioStreamMP3andAudioStreamWAV) - List available models
custom_request()escape hatch for any endpoint the client doesn't cover- Every method returns a typed response object — check
.okto detect failure
Design philosophy
This library prioritizes being easy to use over 100% API coverage — it is not trying to be "the OpenAI SDK for Godot" the way the openai library is for Python. For example, the chat completion reply is available as res.content rather than res.choices[0].message.content.
When you need more than the defaults, every method accepts an extra_body dictionary that is merged into the request as-is, and every response carries a raw_body with the full server response. So if you do need choices[0].message.content, it's right there on res.raw_body. And for endpoints the client doesn't cover at all, custom_request() sends a request to any path on the server — same auth, same .ok pattern — and returns the parsed response on raw_body.
Compatibility
Tested on Godot 4.6.x with automated (GUT) and manual tests. Manually verified to work back to Godot 4.0.0.
Installation
To install C3OpenAIClient in your Godot project, simply click on the "Asset Store" tab on the top of the Godot editor window and search for "C3 OpenAI-Compatible Client". Then, click "Download" and "Install". The addon will be automatically added to your project, and the C3OpenAIClient node will be available in the "Create New Node" dialog.
Alternatively, you may download the latest release from GitHub and copy the contents of the addons/c3_openai_client folder into your project's addons/c3_openai_client directory.
Quick start
- In your scene, choose Add Child Node and search for
C3OpenAIClient. - Set Base URL in the Inspector (e.g.
https://api.openai.com/v1). - Reference it from your scene script:
@onready var client: C3OpenAIClient = $C3OpenAIClient func _ready() -> void: # Get the API key from an environment variable and set it on the client. # You can skip this step for servers that don't require authentication. client.api_key = OS.get_environment("OPENAI_API_KEY") var messages := [ C3OpenAIClient.make_system_msg("You are a poor villager."), C3OpenAIClient.make_user_msg("En garde!"), ] var opts := C3OpenAIClient.ChatOptions.new() opts.model = "gpt-5.4-mini" var res := await client.chat_completion(messages, opts) if res.ok: print(res.content) # *Gasps sharply, dropping my basket of half-rotten turnips... else: push_error("Chat failed: " + str(res.error))
Examples
C3OpenAIClientDemo — complete walkthrough covering model listing, chat (non-streaming and streaming), vision, structured output, image generation, text-to-speech, speech-to-text, and custom requests- Voice Chat Demo — real-time voice chat using microphone input, speech-to-text, chat, and text-to-speech
Changelog for version v0.2.3
No changelog provided for this version.