Using Gemma 4
Examples and tutorials for Gemma 4
Basic Chat
Simple conversational example
Function Calling
Use Gemma 4 to call functions and APIs
Multimodal Input
Process images with text understanding
API Usage
Python code examples for API integration
Python API Example
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained('google/gemma-4-31b')
tokenizer = AutoTokenizer.from_pretrained('google/gemma-4-31b')
input_text = "Explain how neural networks work"
inputs = tokenizer(input_text, return_tensors="pt")
outputs = model.generate(inputs["input_ids"], max_new_tokens=200)
print(tokenizer.decode(outputs[0]))