ExcaliBug
Available

LLM Toolkit

Talk to LM Studio, Ollama, OpenAI and Claude from GDScript. Replies stream in without freezing your game, and JSON comes back repaired and checked against your schema.

var llm := Llm.new(LlmProvider.lm_studio())
var task := llm.chat("You are the innkeeper. Greet a tired traveller.")
task.text_delta.connect(func(piece): $Speech.text += piece)
var result := await task.wait()

var potion := await llm.ask_json("A potion for the shop.", POTION_SCHEMA)
if potion.ok:
	shop.add(potion.value.name, potion.value.price)

Get it: $5 on itch.io, with the demo project, 201 automated tests and a full README.

Try it free: LLM Toolkit Lite talks to local models in plain text with the same API. Upgrading is replacing one folder, and your code keeps working. Lite's source is on GitHub.

Watch: the six-minute tutorial on YouTube: your first chat, conversations, JSON with schemas (and the 5000-gold potion the schema caught), errors, retries and thinking models, testing without a model, and Lite. Every reply in it comes from a real model, Qwen3 14B in LM Studio.

The LLM Toolkit tutorial on YouTube: Sir Debugalot answers in a speech bubble, and a potion's price is brought back inside its schema

Read: Your local model obeys your JSON schema's shape, not its limits, on why structured output lets a 5000-gold potion through, and the check that catches it.

GDScript on the left; the innkeeper's reply streaming into a speech bubble on the right

A messy model reply on the left; the clean, schema-checked JSON and the list of repairs on the right

One API for LM Studio, Ollama, llama.cpp, OpenAI, Claude and a mock provider for tests

What it does

  • One API, many models. LM Studio, Ollama, llama.cpp, vLLM, OpenAI, Claude, or any server with an OpenAI-style API. Switching doesn't change your game code.
  • Streaming that never blocks. Replies arrive piece by piece, ready to type into a speech bubble. No threads: requests poll once per frame, and text split across network packets comes out whole. Slow local models never hit a timeout; a server that goes silent does.
  • JSON you can trust. Give it a JSON schema. The server is asked to follow it the strongest way it accepts, and whatever comes back is repaired (code fences, prose around it, single quotes, trailing commas, Python's None, replies cut off part-way), adjusted to the schema ("12" read as a number, "Rare" matched to "rare", a 5000-gold potion brought down to the 100 your schema allows) and validated, with errors that say exactly what's wrong: $.abilities[2].power: 12 > maximum 10. If it still fails, the model is shown the problems and asked again.
  • Built for games. Retries with backoff for rate limits and busy servers, a queue so a local model handles one request at a time, cancelling, conversations that remember and save with your game, and thinking models' reasoning kept out of the reply.
  • Testable without a model. A mock provider plays back scripted replies or errors, streamed like a real server.
  • Pure GDScript. No plugins or binaries.

It started as the language-model layer of the character generator I'm building, where a model writes whole characters as JSON. Getting that reliable took more work than the requests themselves, so it's packaged here for your game.

The demo, the Rusty Flagon: talking to the innkeeper, with replies streaming in

The demo's Forge: a quest written by the model, every repair and adjustment listed