Skip to content

Commit 83474da

Browse files
kristinaorekhovagitbook-bot
authored andcommitted
GITBOOK-679: docs: add snippet for gemini-3-flash-preview
1 parent b7dee2d commit 83474da

1 file changed

Lines changed: 77 additions & 39 deletions

File tree

docs/api-references/text-models-llm/google/gemini-3-flash-preview.md

Lines changed: 77 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ This documentation is valid for the following list of our models:
1616

1717
## Model Overview
1818

19-
A fast multimodal LLM for low-latency chat and content generation, with strong reasoning and tool-use capabilities. Supports text input and optional image understanding for vision-based prompts.
19+
A fast multimodal LLM for low-latency chat with strong reasoning and tool-use capabilities. Supports text input and optional image understanding for vision-based prompts.
2020

2121
## How to Make a Call
2222

@@ -63,26 +63,30 @@ If you need a more detailed walkthrough for setting up your development environm
6363
{% code overflow="wrap" %}
6464
```python
6565
import requests
66+
import json # for getting a structured output with indentation
6667

6768
response = requests.post(
6869
"https://api.aimlapi.com/v1/chat/completions",
6970
headers={
70-
"Content-Type":"application/json",
71+
# Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
7172
"Authorization":"Bearer <YOUR_AIMLAPI_KEY>",
73+
"Content-Type":"application/json"
7274
},
7375
json={
7476
"model":"google/gemini-3-flash-preview",
7577
"messages":[
76-
{\
78+
{
7779
"role":"user",
78-
"content":"Hello"
80+
# Insert your question for the model here:
81+
"content":"Hi! What do you think about mankind?"
7982
}
80-
]
83+
],
84+
"max_tokens":15000,
8185
}
8286
)
8387

8488
data = response.json()
85-
print(data)
89+
print(json.dumps(data, indent=2, ensure_ascii=False))
8690
```
8791
{% endcode %}
8892
{% endtab %}
@@ -91,25 +95,38 @@ print(data)
9195
{% code overflow="wrap" %}
9296
```javascript
9397
async function main() {
94-
const response = await fetch('https://api.aimlapi.com/v1/chat/completions', {
95-
method: 'POST',
96-
headers: {
97-
'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
98-
'Content-Type': 'application/json',
99-
},
100-
body: JSON.stringify({
101-
model: 'google/gemini-3-flash-preview',
102-
messages:[
103-
{
104-
role:'user',
105-
content: 'Hello'
106-
}
107-
]
108-
}),
109-
});
110-
111-
const data = await response.json();
112-
console.log(JSON.stringify(data, null, 2));
98+
try {
99+
const response = await fetch('https://api.aimlapi.com/v1/chat/completions', {
100+
method: 'POST',
101+
headers: {
102+
// Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>
103+
'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
104+
'Content-Type': 'application/json',
105+
},
106+
body: JSON.stringify({
107+
model: 'google/gemini-3-flash-preview',
108+
messages:[
109+
{
110+
role:'user',
111+
112+
// Insert your question for the model here:
113+
content: 'Hi! What do you think about mankind?'
114+
}
115+
],
116+
max_tokens: 15000,
117+
}),
118+
});
119+
120+
if (!response.ok) {
121+
throw new Error(`HTTP error! Status ${response.status}`);
122+
}
123+
124+
const data = await response.json();
125+
console.log(JSON.stringify(data, null, 2));
126+
127+
} catch (error) {
128+
console.error('Error', error);
129+
}
113130
}
114131

115132
main();
@@ -125,21 +142,42 @@ main();
125142
{% code overflow="wrap" %}
126143
```json5
127144
{
128-
'id': 'gen-1733832000-example',
129-
'object': 'image',
130-
'created': 1733832000,
131-
'model': 'google/gemini-3-flash-preview',
132-
'data': [
133-
{
134-
'url': 'https://cdn.aimlapi.com/generated-images/google/gemini-3-flash-preview/example-output.png',
135-
'revised_prompt': 'Example output for documentation.'
145+
"id": "gen-1765999996-ACx5YQHD6LKvBVhtfuIA",
146+
"model": "google/gemini-3-flash-preview",
147+
"object": "chat.completion",
148+
"created": 1765999996,
149+
"choices": [
150+
{
151+
"logprobs": null,
152+
"finish_reason": "stop",
153+
"native_finish_reason": "STOP",
154+
"index": 0,
155+
"message": {
156+
"role": "assistant",
157+
"content": "Learning Python is one of the best decisions you can make if you are interested in coding. It is famous for being \"beginner-friendly\" because its syntax looks a lot like English.\n\nHere is a step-by-step roadmap to go from zero to a functional Python developer:\n\n---\n\n### Step 1: Set Up Your Environment\nDon't get bogged down in complex tools yet.\n* **Download Python:** Go to [python.org](https://www.python.org/) and download the latest version.\n* **Pick an Editor:** \n * **Thonny:** Great for absolute beginners because it shows you what the computer is thinking.\n * **VS Code:** The industry standard. Flexible and powerful.\n * **Replit:** If you don't want to install anything, you can code directly in your browser.\n\n### Step 2: Master the Fundamentals\nDon't rush this part. These concepts are the \"LEGO bricks\" of every program:\n1. **Variables and Data Types:** Learn about strings (text), integers (numbers), and booleans (True/False).\n2. **Basic Math:** `+`, `-`, `*`, `/`, `%` (remainder).\n3. **Conditionals:** `if`, `elif`, and `else`. This is how programs make decisions.\n4. **Loops:** `for` and `while` loops. This is how you repeat tasks.\n5. **Functions:** How to wrap a block of code so you can use it over and over.\n6. **Data Structures:** Lists, Dictionaries, and Sets. These are how you store and organize data.\n\n### Step 3: Best Resources (mostly free)\n* **For the \"Reading\" Learner:** [Automate the Boring Stuff with Python](https://automatetheboringstuff.com/) by Al Sweigart. It is free online and focuses on practical things you can actually use.\n* **For the \"Watching\" Learner:** \n * **Corey Schafer (YouTube):** The best deep-dive tutorials available.\n * **Programming with Mosh:** Good for a fast (1-6 hour) crash course.\n * **FreeCodeCamp:** Extensive 10-hour+ courses on YouTube.\n* **For the \"Interactive\" Learner:** \n * **University of Helsinki MOOC:** Arguably the best free Python course on the internet. It includes exercises that are graded automatically.\n\n### Step 4: Stop Watching, Start Doing\nThe \"Tutorial Hell\" trap is real—where you watch videos but can't write code on your own. To avoid this, build these tiny projects:\n* **Calculator:** Takes two numbers and adds/subtracts them.\n* **Number Guessing Game:** The computer picks a number and tells you if your guess is \"Higher\" or \"Lower.\"\n* **To-Do List:** Let the user add, delete, and view tasks in the terminal.\n* **Simple Web Scraper:** Pull the price of a product off a website.\n\n### Step 5: Choose a Specialization\nOnce you know the basics, Python branches out into different \"careers.\" Pick one:\n* **Data Science / AI:** Learn libraries like `Pandas`, `NumPy`, and `Scikit-learn`.\n* **Web Development:** Learn `Django` or `Flask` to build websites.\n* **Automation:** Use `Selenium` or `BeautifulSoup` to automate repetitive browser tasks.\n* **Game Dev:** Learn `Pygame`.\n\n### Key Tips for Success:\n1. **Code Every Day:** Even if it’s just for 15 minutes. Coding is a \"muscle memory\" skill.\n2. **Hand-write your code:** If you are struggling with a concept, write it out on a whiteboard or paper. \n3. **Don't memorize:** You don't need to memorize every command. Real developers Google things and use Documentation every single day.\n4. **Use AI wisely:** You can ask ChatGPT or Claude to \"Explain this line of code to me like I'm five.\" But **never** just copy-paste code you don't understand.\n\n**The Golden Rule:** The moment you finish a tutorial, try to change one thing in the code to see if you can make it do something different. That is when the real learning happens.",
158+
"refusal": null,
159+
}
160+
}
161+
],
162+
"usage": {
163+
"prompt_tokens": 5,
164+
"completion_tokens": 1330,
165+
"total_tokens": 1335,
166+
"prompt_tokens_details": {
167+
"cached_tokens": 0,
168+
"audio_tokens": 0,
169+
"video_tokens": 0
170+
},
171+
"completion_tokens_details": {
172+
"reasoning_tokens": 371,
173+
"image_tokens": 0
174+
}
175+
},
176+
"meta": {
177+
"usage": {
178+
"credits_used": 8846
179+
}
136180
}
137-
],
138-
'usage': {
139-
'prompt_tokens': 0,
140-
'completion_tokens': 0,
141-
'total_tokens': 0
142-
}
143181
}
144182
```
145183
{% endcode %}

0 commit comments

Comments
 (0)