Using Gemma 2 9B Instruct on Replicate API

Implementation guide · Gemma 2 · Google DeepMind

ServerlessOpen Weights

Replicate API exposes Gemma 2 9B Instruct through model ID google-deepmind/gemma2-9b-it. Use the setup steps, sourced pricing, capabilities, and official provider links below to validate this route before deployment.

Last refreshed 2026-04-19. Next refresh: weekly.

Quick Start

  1. 1
    Create an account at Replicate API and generate an API key.
  2. 2
    Use the Replicate API SDK or REST API to call google-deepmind/gemma2-9b-it — see the documentation for request format.
  3. 3
    You'll be billed $0.10/1M input, $0.10/1M output tokens. See full pricing.

Code Examples

Install
pip install replicate
API key
REPLICATE_API_TOKEN
Model ID
google-deepmind/gemma2-9b-it

Replicate uses "owner/model-name" format (e.g. "meta/meta-llama-3-8b-instruct") for the latest version, or "owner/model-name:version-sha" to pin to a specific version. The REST endpoint splits owner and model-name into the path: /v1/models/{owner}/{model-name}/predictions.

import replicate

# reads REPLICATE_API_TOKEN from env
# google-deepmind/gemma2-9b-it format: "owner/model-name" (latest version) or "owner/model-name:version-hash"
output = replicate.run(
    "google-deepmind/gemma2-9b-it",
    input={"prompt": "Hello"}
)
# Output is a list or generator depending on the model
print("".join(output))

Pricing on Replicate API

TypePrice (per 1M)
Input tokens$0.10
Output tokens$0.10

Capabilities

Structured Outputs

About Gemma 2 9B Instruct

Gemma 2 9B Instruct, developed by Google, is a state-of-the-art large language model based on the advanced Gemini framework. It is a decoder-only transformer model with 9 billion parameters, offering a balance between size and performance. The model is trained on an expansive dataset comprising 8 trillion tokens, including web documents, code, and mathematical text, a notable 30% increase from its predecessor, Gemma 1.1. This allows it to adeptly handle diverse tasks such as question answering, creative writing, coding, and mathematical problem-solving.

Model Specs

Released2024-06-27
Parameters9B
Context8k
ArchitectureDecoder Only

Provider

Replicate API

Replicate

San Francisco, California, United States