Piyush Kalsariya
Full-Stack Developer & AI Builder
Introduction to Gemma 4 and Local Setup
As a full-stack developer, I've been excited about the recent advancements in AI technology, particularly with the release of Gemma 4. Running Gemma 4 locally can be a bit challenging, but with the help of LM Studio's new headless CLI and Claude Code, the process has become much more streamlined. In this post, I'll share my experience of setting up Gemma 4 locally and provide a step-by-step guide on how to do it.
Prerequisites
Before we dive into the setup process, make sure you have the following prerequisites:
- Node.js: You'll need to have Node.js installed on your local machine. You can download the latest version from the official Node.js website.
- LM Studio's headless CLI: You'll need to install LM Studio's headless CLI using npm or yarn. You can find the installation instructions on the official LM Studio website.
- Claude Code: You'll need to have Claude Code installed on your local machine. You can find the installation instructions on the official Claude Code website.
Setting up Gemma 4 Locally
Now that we have the prerequisites out of the way, let's move on to setting up Gemma 4 locally. Here are the steps:
Step 1: Install the Required Dependencies
First, we need to install the required dependencies for Gemma 4. You can do this by running the following command in your terminal:
1npm install @gemma-ai/gemma-4
2```Step 2: Set up LM Studio's Headless CLI
Next, we need to set up LM Studio's headless CLI. You can do this by running the following command in your terminal:
1npx @lm-studio/headless-cli init
2```Step 3: Configure Claude Code
Now, we need to configure Claude Code to work with Gemma 4. You can do this by creating a new file called ``claude.json in the root of your project and adding the following code:
1{
2 "gemma-4": {
3 "apiKey": "YOUR_API_KEY",
4 "apiSecret": "YOUR_API_SECRET"
5 }
6}
7```Replace ``YOUR_API_KEY and YOUR_API_SECRET with your actual API key and secret.
Step 4: Run Gemma 4 Locally
Finally, we can run Gemma 4 locally using the following command:
1npx @gemma-ai/gemma-4 --headless --claude-code
2```This will start the Gemma 4 server in headless mode, and you can access it by visiting ``http://localhost:3000 in your web browser.
Conclusion
In this post, we've covered the process of running Gemma 4 locally using LM Studio's new headless CLI and Claude Code. With these tools, you can easily set up a fully functional Gemma 4 environment on your local machine, ready for experimentation and development. Some key benefits of running Gemma 4 locally include:
- Faster development: With a local setup, you can develop and test your Gemma 4 applications much faster.
- Improved security: By running Gemma 4 locally, you can keep your API keys and secrets secure.
- Enhanced flexibility: A local setup gives you the flexibility to customize and extend Gemma 4 to meet your specific needs.
