gemma-3n-4b
Model Overview
The first open model built on Google’s next-generation, mobile-first architecture—designed for fast, private, and multimodal AI directly on-device. With Gemma 3n, developers get early access to the same technology that will power on-device AI experiences across Android and Chrome later this year, enabling them to start building for the future today.
How to Make a Call
API Schema
Creates a chat completion using a language model, allowing interactive conversation by predicting the next response based on the given chat history. This is useful for AI-driven dialogue systems and virtual assistants.
An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and reasoning tokens.
512
The maximum number of tokens that can be generated in the chat completion. This value can be used to control costs for text generated via API.
512
If set to True, the model response data will be streamed to the client as it is generated using server-sent events.
false
What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or top_p but not both.
An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or temperature but not both.
This feature is in Beta. If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result.
A number between 0 and 1 that can be used as an alternative to top_p and top_k.
Only sample from the top K options for each subsequent token. Used to remove "long tail" low probability responses. Recommended for advanced use cases only. You usually only need to use temperature.
A number that controls the diversity of generated text by reducing the likelihood of repeated sequences. Higher values decrease repetition.
Alternate top sampling parameter.
Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence.
POST /v1/chat/completions HTTP/1.1
Host: api.aimlapi.com
Authorization: Bearer <YOUR_AIMLAPI_KEY>
Content-Type: application/json
Accept: */*
Content-Length: 339
{
"model": "google/gemma-3n-e4b-it",
"messages": [
{
"role": "user",
"content": "text",
"name": "text"
}
],
"max_completion_tokens": 512,
"max_tokens": 512,
"stream": false,
"stream_options": {
"include_usage": true
},
"temperature": 1,
"top_p": 1,
"seed": 1,
"min_p": 1,
"top_k": 1,
"repetition_penalty": 1,
"top_a": 1,
"stop": "text",
"logit_bias": {
"ANY_ADDITIONAL_PROPERTY": 1
}
}
No content
Code Example
import requests
import json
response = requests.post(
"https://api.aimlapi.com/v1/chat/completions",
headers={
"Content-Type":"application/json",
# Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
"Authorization":"Bearer <YOUR_AIMLAPI_KEY>",
"Content-Type":"application/json"
},
json={
"model":"google/gemma-3n-e4b-it",
"messages":[
{
"role":"user",
# Insert your question for the model here, instead of Hello:
"content":"Hello!"
}
]
}
)
data = response.json()
print(json.dumps(data, indent=2, ensure_ascii=False))
Last updated
Was this helpful?