OpenRouter: Google: Gemma 3n 4B

google-gemma-3n-4b
Released May 20, 2025 · 33K context · Free / Free
chat

Gemma 3n E4B-it is optimized for efficient execution on mobile and low-resource devices, such as phones, laptops, and tablets. It supports multimodal inputs—including text, visual data, and audio—enabling diverse tasks such as text generation, speech recognition, translation, and image analysis. Leveraging innovations like Per-Layer Embedding (PLE) caching and the MatFormer architecture, Gemma 3n dynamically manages memory usage and computational load by selectively activating model parameters, significantly reducing runtime resource requirements. This model supports a wide linguistic range (trained in over 140 languages) and features a flexible 32K token context window. Gemma 3n can selectively load parameters, optimizing memory and computational efficiency based on the task or device capabilities, making it well-suited for privacy-focused, offline-capable applications and on-device AI solutions. [Read more in the blog post](https://developers.googleblog.com/en/introducing-gemma-3n/)

Try Google: Gemma 3n 4B

Test this model directly in the playground.

Click to start testing in Playground...

One-Click Config

Optimized configs for your favorite AI tools.

Claude Code

# Claude Code works via OpenRouter's Anthropic-compatible API.
# Note: Only paid Anthropic Claude models are supported (e.g. claude-sonnet-4.6, claude-opus-4).
# Browse available Claude models at: https://openrouter.ai/models?q=anthropic

# Add to ~/.zshrc or ~/.bashrc
export OPENROUTER_API_KEY="<your-openrouter-api-key>"  # Get at https://openrouter.ai/settings/keys
export ANTHROPIC_BASE_URL="https://openrouter.ai/api"
export ANTHROPIC_AUTH_TOKEN="$OPENROUTER_API_KEY"
export ANTHROPIC_API_KEY=""  # Must be explicitly empty to avoid conflicts

# Optional: pin specific models for each role
# export ANTHROPIC_DEFAULT_SONNET_MODEL="anthropic/claude-sonnet-4.6"
# export ANTHROPIC_DEFAULT_HAIKU_MODEL="anthropic/claude-haiku-4.5"

# Then simply run: claude

Cursor

# Cursor → Settings (⚙️) → Models → Add Model
# Enter the model name exactly as shown, then fill in:
#   Override OpenAI Base URL: https://openrouter.ai/api/v1
#   OpenAI API Key: <your-api-key>   # Get at https://openrouter.ai
# Click "Verify" to confirm the connection, then enable the model.
#
# Model name to add: Google: Gemma 3n 4B

Codex

# Add to ~/.zshrc or ~/.bashrc
export OPENAI_BASE_URL="https://openrouter.ai/api/v1"
export OPENAI_API_KEY="<your-api-key>"  # Get at https://openrouter.ai

# Then run:
codex --model "Google: Gemma 3n 4B"

Gemini CLI

# ~/.gemini/settings.json
{
  "apiKey": "<your-api-key>",
  "model": "Google: Gemma 3n 4B"
}
# Get API key at https://openrouter.ai

OpenCode

// ~/.config/opencode/opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "free-llm": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Free LLM",
      "options": {
        "baseURL": "https://openrouter.ai/api/v1",
        "apiKey": "<your-api-key>"
      },
      "models": {
        "Google: Gemma 3n 4B": { "name": "Google: Gemma 3n 4B" }
      }
    }
  }
}
// Get API key at https://openrouter.ai

Hermes

# Step 1 — Edit config.yaml
# Windows: C:\Users\<you>\AppData\Local\hermes\config.yaml
# macOS/Linux: ~/.config/hermes/config.yaml

model:
  default: Google: Gemma 3n 4B
  provider: custom
  base_url: ${CUSTOM_BASE_URL}
  api_key: ${CUSTOM_API_KEY}
  model_aliases:
    Google: Gemma 3n 4B:
      model: "Google: Gemma 3n 4B"
      provider: "custom"

# Step 2 — Edit .env (same directory as config.yaml)
# Windows: C:\Users\<you>\AppData\Local\hermes\.env
# macOS/Linux: ~/.config/hermes/.env

# ========================
# Custom API (OpenAI-compatible)
# ========================
CUSTOM_API_KEY=<your-api-key>        # Get at https://openrouter.ai
CUSTOM_BASE_URL=https://openrouter.ai/api/v1

OpenClaw

// ~/.openclaw/openclaw.json  (JSON5 format)
{
  "agents": {
    "defaults": {
      "model": {
        "primary": "Google: Gemma 3n 4B",
      },
    },
  },
  "models": {
    "providers": {
      // Option A — Built-in provider (OpenAI, Anthropic, Google…)
      // Just add apiKey; OpenClaw handles the baseUrl automatically
      // "openai": { "apiKey": "<your-api-key>" },

      // Option B — Custom OpenAI-compatible base URL (e.g. OpenRouter, NVIDIA)
      "free-llm": {
        "baseUrl": "https://openrouter.ai/api/v1",
        "apiKey": "<your-api-key>",  // Get at https://openrouter.ai
        "api": "openai-completions", // openai-completions | anthropic-messages | …
        "models": [
          { "id": "Google: Gemma 3n 4B", "name": "Google: Gemma 3n 4B" },
        ],
      },
    },
  },
}
// Apply: openclaw gateway restart
// Verify: openclaw doctor --fix

FAQ

Is it really free?

Yes, Google: Gemma 3n 4B is provided as part of OpenRouter's free tier. A credit card may be needed for verification.

How to use it with Cursor?

Go to Cursor Settings > Models, add a custom model named "Google: Gemma 3n 4B", and set the Base URL to "https://openrouter.ai/api/v1".