An AI-powered robotic arm controlled by natural language using Cerebras GLM 4.7
Watch the Demo Video: https://youtu.be/sG32tBE-YMw
Try it Live: https://main.safearm-ai.pages.dev/ (Best viewed on desktop)
SafeArm AI is a browser-based robotic arm simulation where you can talk to an AI to control the robot. Just say things like:
- "Pick up the red cube"
- "Move the sphere to the left"
- "Wave hello"
- "Grab the cylinder and lift it"
The AI (powered by Cerebras GLM 4.7) understands your commands, plans the movements, and executes them in real-time using inverse kinematics for precise object manipulation.
- 🦾 6-DOF Robotic Arm - Physics-based simulation with realistic joint limits
- 🧠 AI Brain (Cerebras GLM 4.7) - Natural language understanding with tool calling
- 🎯 Inverse Kinematics - Automatic angle calculation for precise positioning
- 🔧 Object Manipulation - Spawn, grab, move, and drop objects
- ⚡ Real-time Physics - Powered by Rapier physics engine
- 💬 Chat Interface - Conversational control with action transparency
| Layer | Technology |
|---|---|
| AI/LLM | Cerebras API (GLM 4.7) with tool calling |
| Frontend | React 19 + TypeScript |
| 3D Engine | Three.js via React Three Fiber |
| Physics | Rapier (via @react-three/rapier) |
| State | Zustand |
| Styling | Tailwind CSS 4 |
| Build | Vite 7 |
- Node.js 18+
- pnpm (or npm/yarn)
- Cerebras API key (get one here)
# Clone the repo
git clone https://github.com/mutaician/safearm-ai.git
cd safearm-ai
# Install dependencies
pnpm install
# Set up environment
cp .env.example .env
# Edit .env and add your VITE_CEREBRAS_API_KEY
# Start development server
pnpm devOpen http://localhost:5173 and start chatting with the robot!
The magic happens through function calling (tool use). The AI has access to these tools:
| Tool | Description |
|---|---|
move_joint |
Move individual joints (base, shoulder, elbow, wrist) |
approach_object |
Use inverse kinematics to reach an object |
gripper_action |
Open/close the gripper |
get_objects_on_table |
See what objects exist |
get_distance_to_target |
Check gripper proximity to object |
spawn_object |
Add cubes, spheres, cylinders, cones |
move_to_preset |
Go to home/ready positions |
When you say "pick up the red cube", the AI:
- Calls
get_objects_on_tableto find the cube - Uses
approach_objectwith inverse kinematics to position the gripper - Calls
gripper_action(close)to grab it
All at Cerebras speed - responses in milliseconds, not seconds!
src/
├── components/
│ ├── simulation/ # 3D components (RobotArm, Environment, etc.)
│ └── ui/ # Chat interface, controls
├── lib/
│ └── cerebras/ # AI integration (client, tools, agent)
└── store/ # Zustand state management
- Push your code to GitHub
- Go to Cloudflare Dashboard → Pages
- Click Create a project → Connect to Git
- Select your repository
- Configure build settings:
- Build command:
pnpm build - Build output directory:
dist - Root directory:
/(leave default)
- Build command:
- Add environment variable:
VITE_CEREBRAS_API_KEY= your API key
- Click Save and Deploy
# Install Wrangler
pnpm add -g wrangler
# Login to Cloudflare
wrangler login
# Build the project
pnpm build
# Deploy
wrangler pages deploy dist --project-name=safearm-aiThen add your VITE_CEREBRAS_API_KEY in Cloudflare Dashboard → Pages → Your Project → Settings → Environment variables.
The API key is bundled into the client-side code (prefixed with VITE_). For a production app, you'd want to:
- Create a Cloudflare Worker as a backend proxy
- Store the API key in Worker secrets
- Have the frontend call your Worker instead of Cerebras directly
For hackathon purposes, the current setup works fine!
- Cerebras is FAST - Tool calling responses feel instant, making the robot responsive
- Inverse Kinematics is hard - Spent time getting the math right for arm positioning
- GLM 4.7 + Tools = Perfect for Robotics - The model naturally plans multi-step actions
- Add action verification layer (confirm dangerous moves)
- Multiple arm coordination
- Voice commands via Web Speech API
- Save/replay movement sequences
- VR controller support
MIT
Built for the Cerebras x Cline Hackathon 🏆
