Deploy Gemma 3 27B IT
Example usage
Gemma 3 is an OpenAI-compatible model and can be called using the OpenAI SDK in any language.Copy
Ask AI
from openai import OpenAI
import os
model_url = "" # Copy in from API pane in Baseten model dashboard
client = OpenAI(
api_key=os.environ['BASETEN_API_KEY'],
base_url=model_url
)
# Chat completion
response_chat = client.chat.completions.create(
model="",
messages=[{
"role": "user",
"content": [
{"type": "text", "text": "What's in this image?"},
{
"type": "image_url",
"image_url": {
"url": "https://picsum.photos/id/237/200/300",
},
},
],
}],
temperature=0.3,
max_tokens=512,
)
print(response_chat)
Copy
Ask AI
{
"id": "143",
"choices": [
{
"finish_reason": "stop",
"index": 0,
"logprobs": null,
"message": {
"content": "[Model output here]",
"role": "assistant",
"audio": null,
"function_call": null,
"tool_calls": null
}
}
],
"created": 1741224586,
"model": "",
"object": "chat.completion",
"service_tier": null,
"system_fingerprint": null,
"usage": {
"completion_tokens": 145,
"prompt_tokens": 38,
"total_tokens": 183,
"completion_tokens_details": null,
"prompt_tokens_details": null
}
}