# Gemma 4 31B Self Host: One GPU, One API Call

Published 2 November 2026, updated 8 November 2026. 5 min read. For: developers who want Gemma 4 31B behind their own API key instead of a shared hosted API.

## Key facts

- Gemma 4 31B needs about 75 GB in 16-bit, one 80 GB A100 or H100, and about 19 GB in 4-bit, one 24 GB RTX 4090.
- In 8-bit Gemma 4 31B needs about 38 GB, which fits one 48 GB L40S or RTX A6000.
- One call to POST /v1/deploy gives you your own OpenAI-compatible endpoint, its own API key and root SSH, billed by the hour.
- google/gemma-4-31B-it is listed under Apache 2.0 on Hugging Face and is not gated, so no Hugging Face token is needed.
- Office hours, 10 hours a day for 22 working days, is 220 GPU-hours: 220 x the live price a month in 16-bit, against 720 hours always on.

A Gemma 4 31B self host setup is one GPU and one API call. The model needs about 75 GB of GPU memory in 16-bit, so a single 80 GB A100 or H100 runs it at full precision, and about 19 GB in 4-bit, which fits a 24 GB RTX 4090. Rent that card by the hour and you get your own OpenAI-compatible endpoint, its own API key and root SSH.

## What self-hosting gets you

- **Your endpoint.** A URL that speaks the OpenAI API, behind a key made for it. The GPUs are yours for the rental: a machine never reaches another renter's.
- **Your settings.** Paste your own engine options: context length, prefix caching, anything vLLM or SGLang takes. Change them later over SSH without a new machine.
- **Your bill shape.** One hourly price, nothing per token. A busy hour costs the same as a quiet one, which is also the warning: an idle endpoint still bills.
- **A licence that lets you.** `google/gemma-4-31B-it` is listed under Apache 2.0 and is not gated, so no Hugging Face token is needed.

## Pick the GPU

| Precision | GPU memory | One GPU that holds it | Price per hour now |
|---|---|---|---|
| 16-bit | 75 GB | A100 80 GB or H100 (80 GB) | [the live price](/gpus/a100.html.md) (A100), [the live price](/gpus/h100.html.md) (H100) |
| 8-bit | 38 GB | L40S or RTX A6000 (48 GB) | [the live price](/gpus/l40s.html.md) (L40S), [the live price](/gpus/rtx-a6000.html.md) (RTX A6000) |
| 4-bit | 19 GB | RTX 4090 (24 GB) | [the live price](/gpus/rtx-4090.html.md) |

The figures come from the [Gemma 4 31B model page](/models/google/gemma-4-31b-it.html.md), on the rules in the [GPU memory guide](/guides/gpu-memory.html.md): about 2.4 bytes per parameter in 16-bit, 1.2 in 8-bit, 0.6 in 4-bit, with 20% included for the KV cache at moderate context.

Gemma 4 31B is a dense model with 31.3B parameters. It reads images as well as text, and its context window is 262,144 tokens. The weights alone take about 63 GB in 16-bit, 31 GB in 8-bit and 16 GB in 4-bit. Whatever the card has left is room for the KV cache:

- about 17 GB on an 80 GB [A100](/gpus/a100.html.md) in 16-bit,
- about 17 GB on a 48 GB [L40S](/gpus/l40s.html.md) in 8-bit,
- about 8 GB on a 24 GB RTX 4090 in 4-bit.

The 20% headroom covers moderate context, not the full window, so cap the context at what your app really sends. Need much more room for long prompts and many users? Put the 8-bit model on an 80 GB card: about 49 GB left over. The price column tells you what each choice costs per hour.

## Self-host it, step by step

**1. Make a token.** In the [console](/console/), open API & agents and create one, and save an SSH key while you are there.

**2. Plan it.** `POST /v1/deploy/plan` with the model is free and rents nothing. It lists every GPU the model fits on now, best value first, each with its hourly price.

**3. Deploy it** with a removal time and the engine options you want:

```sh
curl -X POST https://arrakis.goodailabs.com/v1/deploy \
  -H "Authorization: Bearer ark_..." \
  -H "Content-Type: application/json" \
  -d '{"model": "google/gemma-4-31B-it", "engine": "vllm",
       "termination_hours": 8,
       "extra_args": "--max-model-len 32768 --enable-prefix-caching"}'
```

Without a `node_id`, Arrakis rents the best-ranked machine that holds the model, on as few GPUs as it allows. Your options reach the engine word for word, without a shell.

**4. Wait for ready.** The engine downloads the model, then loads it. `GET /v1/instances/{id}/endpoint` returns the address and key, and `ready: true` once the model answers. If it does not, `GET /v1/instances/{id}/endpoint/log` shows the end of the engine's log.

**5. Call it** from any OpenAI client:

```python
from openai import OpenAI

client = OpenAI(base_url="http://<endpoint>/v1", api_key="sk-...")
reply = client.chat.completions.create(
    model="google/gemma-4-31B-it",
    messages=[{"role": "user", "content": "Draft a polite payment reminder."}],
)
print(reply.choices[0].message.content)
```

For the 4-bit setup on an RTX 4090, deploy a GGUF build on llama.cpp instead: `{"model": "unsloth/gemma-4-31B-it-GGUF:Q4_K_M", "engine": "llamacpp", "termination_hours": 8}`. Every option is on the [deploy page](/deploy.html.md), and once you have made the token, an agent can run steps 2 to 5 with `plan_deploy` and `deploy_model` ([Arrakis for agents](/agents.html.md)).

## Keep it private, and know the limit

The endpoint is the machine's address over plain HTTP, with a gate that checks the key before a request reaches the engine, which listens only inside the machine. For traffic you would rather keep off the open internet, open an SSH tunnel and call `http://localhost:8000/v1`:

```sh
ssh root@<host> -p <port> -N -L 8000:localhost:8000
```

The honest limit: machines run on independent hosts, and a host can read what runs on its machine. Self-hosting gives you your own endpoint, your own key and your own settings. It is not a home for regulated or confidential data. More in [private LLM deployment](/blog/private-llm-for-enterprise.html.md).

## The MoE sibling: Gemma 4 26B A4B

[gemma-4-26B-A4B-it](/models/google/gemma-4-26b-a4b-it.html.md) has 25.8B parameters with 4B active for each token. It needs about 62 GB in 16-bit (one A100 80 GB), 31 GB in 8-bit (one 32 GB RTX 5090) and 15 GB in 4-bit (one RTX 4090). Same Apache 2.0 licence, same deploy call with its own name. Every expert still sits in memory, so the memory follows the 25.8B; the work for each token follows the 4B. More models that fit one card: [open models on a single GPU](/blog/open-models-one-gpu-2026.html.md).

## Fine-tune it on the same class of card

Before activations: QLoRA about 22 GB (one RTX 4090), LoRA about 75 GB (one A100 80 GB), full fine-tuning about 500 GB (two B300s). Merge the adapter, push the model to a private Hugging Face repository, and deploy it with the same call plus a read-only `hf_token`.

## Stop paying for idle

Set `termination_hours` to the hours you need. The machine is removed on time and billing stops with it. The schedule is the biggest lever on the bill:

- **Office hours,** 10 hours a day for 22 working days: 220 GPU-hours, so 220 x [the live price](/gpus/a100.html.md) a month in 16-bit, or 220 x [the live price](/gpus/rtx-4090.html.md) in 4-bit.
- **Always on,** 720 hours a month: 720 x [the live price](/gpus/a100.html.md) in 16-bit.

Each fresh deploy downloads the model again on the machine's clock, so a daily schedule pays for a few minutes of loading every morning. That is still far less than the 14 idle hours a night an always-on endpoint bills for a team that sleeps.

## Self-host Gemma 4 31B today

One GPU, one call, your own endpoint. Start in the [console](/console/).

New here? Use code [FIRST25](/console/?code=FIRST25) for $25 off your first deposit of $50 or more, until 31 December 2026.

## Rent the GPUs in this post

- [A100](/gpus/a100.html.md): [the live price](/gpus/a100.html.md) per GPU-hour now; rent in the console (/console/#/gpus?gpu_type=A100) or with the MCP tool rent_gpu.
- [H100](/gpus/h100.html.md): [the live price](/gpus/h100.html.md) per GPU-hour now; rent in the console (/console/#/gpus?gpu_type=H100) or with the MCP tool rent_gpu.
- [L40S](/gpus/l40s.html.md): [the live price](/gpus/l40s.html.md) per GPU-hour now; rent in the console (/console/#/gpus?gpu_type=L40S) or with the MCP tool rent_gpu.
- [RTX A6000](/gpus/rtx-a6000.html.md): [the live price](/gpus/rtx-a6000.html.md) per GPU-hour now; rent in the console (/console/#/gpus?gpu_type=A6000) or with the MCP tool rent_gpu.

## Questions

**What GPU do I need to self host Gemma 4 31B?** One GPU: an 80 GB A100 or H100 in 16-bit (about 75 GB), a 48 GB L40S or RTX A6000 in 8-bit (about 38 GB), or a 24 GB RTX 4090 in 4-bit (about 19 GB).

**Is Gemma 4 31B licensed for commercial use?** google/gemma-4-31B-it is listed under Apache 2.0 on Hugging Face. Read the model card for the full terms.

**Do I need a Hugging Face token to deploy Gemma 4 31B?** Not for google/gemma-4-31B-it: it is not gated. Gated or private models need a read-only token, which goes to the machine only and is never stored by Arrakis.

**How is a self-hosted Gemma endpoint billed?** By the hour of the GPU, not per token. Each started hour is charged in full at the price locked when you rented, and billing stops when the machine is removed.

**Can I fine-tune Gemma 4 31B on one GPU?** With QLoRA, on one RTX 4090 (about 22 GB before activations); with LoRA, on one 80 GB A100 or H100 (about 75 GB). Full fine-tuning needs about 500 GB, two B300s.

## More from the blog

- [Deploy an LLM with an AI Agent: One Prompt, One Endpoint](/blog/deploy-model-from-chat.html.md): Deploy an LLM with an AI agent in one prompt: plan_deploy prices every GPU the model fits on, deploy_model returns an OpenAI-compatible endpoint and its key.
- [Qwen3.8 27B GPU Requirements: One GPU Is Enough](/blog/qwen-3-8-27b-gpu-requirements.html.md): Qwen3.8 27B GPU requirements: 67 GB in 16-bit, 33 GB in 8-bit, 17 GB in 4-bit. One A100, L40S or RTX 4090 runs it. Pick the card, deploy in one call.
- [FLUX.2 GPU Guide: Image Generation as Your Own Endpoint](/blog/flux-2-qwen-image-gpu.html.md): FLUX.2 GPU needs: FLUX.2-klein-9B takes about 42 GB, one L40S; Qwen-Image 70 GB, one A100. Deploy either on vLLM-Omni and pay by the hour, not per image.

Every post: [/blog](/blog.html.md). RSS: [/blog/feed.xml](/blog/feed.xml).
