Getting started
Today the bot runs from its source code, in a terminal. A one-click app is planned. Until then, this page is the whole setup.
What you need
- Bun 1.3 or later. Bun runs the bot and reads its settings file. Node.js is not needed.
- A Minecraft Java Edition server, version 1.8 to 26.1. A world opened to LAN from your own game works too.
- An OpenAI API key. The bot asks OpenAI's model what to do with your chat messages and to plan its days. This costs money; you set the monthly cap.
- Your Minecraft username. The bot obeys one player only.
Install
- Get the code:
git clone https://github.com/TravnikovDev/Minecraft-GPT.git
cd Minecraft-GPT
- Install what it depends on:
bun install
- Make your settings file from the example:
cp .env.example .env
- Open
.envand fill in at least your OpenAI key and your Minecraft username:
OPENAI_API_KEY=your_openai_api_key
OWNER_USERNAME=YourMinecraftName
BOT_USERNAME=MinecraftGPT
SERVER_HOST=localhost
SERVER_PORT=25565
AUTH=offline
Start it
With your server running:
bun run src/index.ts
The bot joins the game, greets you, and waits 30 seconds for an order. With none, it starts living its own life. Say "stay with me" in chat if you'd rather it only did what you ask. Talking to the bot has the rest.
If a setting is missing or wrong, the bot stops at once with a message that names it.
Settings
All settings live in the .env file.
| Setting | What it is | If you leave it out |
|---|---|---|
OPENAI_API_KEY | Your OpenAI API key. | Required |
OWNER_USERNAME | Your Minecraft username. The only player whose chat the bot obeys. | Required |
BOT_USERNAME | The bot's name in the game. | MinecraftGPT |
SERVER_HOST | The server's address. | localhost |
SERVER_PORT | The server's port. Minecraft's usual port is 25565; a LAN world shows its own when you open it. | Set it |
AUTH | offline for servers with online-mode=false, microsoft to log in with a real Minecraft account. | offline |
LLM_MONTHLY_CAP_USD | The most the bot may spend on the AI model in a month, in US dollars. Past it, it makes no more model calls until next month. | 10 |
SERVER_AUTOMATION | forbidden on servers that don't allow bots to act on their own: no own life and no jobs, only your commands. | allowed |
SERVER_CHAT_SPACING_MS | Milliseconds between the bot's chat lines, for servers that kick fast talkers. | 1200 |
Which login mode
AUTH=offline: the bot joins underBOT_USERNAMEwith no account. The server must run withonline-mode=false. This is the simple choice for a private server or a LAN world.AUTH=microsoft: the bot logs in with a real Minecraft account, which it needs its own copy of the game for. The first start gives you a code to enter on Microsoft's sign-in page.
Read your server's rules before bringing a bot. Many public servers don't allow them.
Why OpenAI only
Every command is given to the model as a tool with a strict description of its arguments, so what the model sends back always fits. OpenAI's models enforce that. Other providers don't do so reliably yet, so the bot doesn't support them.