AI toolkit for OpenComputers - build AI-powered automation in Minecraft.
| Library | Description |
|---|---|
| ai | Vercel-like Core SDK for text generation, streaming, tool calling, and structured output |
| oc-code | Interactive AI coding agent with file editing, shell access, and TUI |
oc-code is an AI coding assistant that runs directly in OpenComputers. It can read, write, and edit files, run shell commands, and help you with coding tasks.
Here are some examples of what oc-code can do:
3D_Spinning_Cube.mp4
3D_HilbertCurve.mp4
And here is the demo YouTube video: https://youtu.be/u-gIQOXLimQ
oppm register DonChong2000/oc-ai
oppm install oc-code
Set your API key. For example, you can get one for free from Google AI Studio:
It supports Vercel, OpenAI, Google for now.
set GOOGLE_GENERATIVE_AI_API_KEY=<your-key>
oc-code
-
Interactive TUI - Color-coded interface with scrolling and command autocomplete
-
Monochorme mode - Works on robots' GPU/screen
-
Multi-provider support - Anthropic, OpenAI, Google (direct or via gateway)
-
Built-in tools - read_file, write_file, edit_file, list_directory, glob, grep, shell
-
Skills system - Extensible command handlers
| Command | Description |
|---|---|
/help |
Show available commands |
/model |
View or switch AI model |
/clear |
Clear conversation history |
/exit |
Exit oc-code |
!<cmd> |
Execute shell command directly |
The AI SDK provides programmatic access to AI models for your own scripts.
local ai = require("ai")
local google = require("ai.google")
local result = ai.generateText({
model = google("gemini-2.5-flash"),
prompt = "Hello, world!",
})
print(result.text)local weatherTool = ai.tool({
name = "get_weather",
description = "Get current weather",
parameters = {
type = "object",
properties = {
location = { type = "string" },
},
required = { "location" },
},
execute = function(args)
return { temp = 72, condition = "sunny" }
end,
})
local result = ai.generateText({
model = google("gemini-2.5-flash"),
prompt = "What's the weather in Tokyo?",
tools = { weatherTool },
maxSteps = 3,
})local result = ai.generateObject({
model = google("gemini-2.5-flash"),
schema = {
type = "object",
properties = {
name = { type = "string" },
age = { type = "number" },
},
},
prompt = "Generate a random person.",
})
print(result.object.name, result.object.age)oppm register DonChong2000/oc-ai
oppm install ai
Copy lib/ai/, lib/oc-code/, and lib/cmn-utils/ to your /lib/ directory.
Copy bin/oc-code.lua to your /bin/ directory.
| Variable | Provider | Required For |
|---|---|---|
GOOGLE_GENERATIVE_AI_API_KEY |
google("model") or /model google <model> |
|
OPENAI_API_KEY |
OpenAI | openai("model") or /model openai <model> |
AI_GATEWAY_API_KEY |
Vercel Gateway | "provider/model" string format |
- OpenComputers computer with internet card
- API key for your chosen provider
- For TUI: Tier 2+ screen (4-bit color) and GPU
- For terminal mode: Any computer or robot
MIT