Skip to content

Commit 4f3eefa

Browse files
techpro-aimlapigitbook-bot
authored andcommitted
GITBOOK-310: docs: add gemini-2.5-flash, gemini-2.5-pro
1 parent 026bd79 commit 4f3eefa

10 files changed

Lines changed: 435 additions & 7 deletions

File tree

docs/SUMMARY.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
* [gemini-2.0-flash-exp](api-references/text-models-llm/Google/gemini-2.0-flash-exp.md)
4444
* [gemini-2.0-flash](api-references/text-models-llm/google/gemini-2.0-flash.md)
4545
* [gemini-2.5-flash-lite-preview](api-references/text-models-llm/google/gemini-2.5-flash-lite-preview.md)
46+
* [gemini-2.5-flash](api-references/text-models-llm/google/gemini-2.5-flash.md)
47+
* [gemini-2.5-pro](api-references/text-models-llm/google/gemini-2.5-pro.md)
4648
* [gemma-2](api-references/text-models-llm/Google/gemma-2-27b-it.md)
4749
* [gemma-3](api-references/text-models-llm/google/gemma-3.md)
4850
* [gemma-3n-4b](api-references/text-models-llm/google/gemma-3n-4b.md)

docs/api-references/model-database.md

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docs/api-references/text-models-llm/README.md

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
---
2+
layout:
3+
width: default
4+
title:
5+
visible: true
6+
description:
7+
visible: true
8+
tableOfContents:
9+
visible: true
10+
outline:
11+
visible: true
12+
pagination:
13+
visible: true
14+
metadata:
15+
visible: true
16+
---
17+
118
# gemini-2.5-flash-lite-preview
219

320

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
---
2+
layout:
3+
width: default
4+
title:
5+
visible: true
6+
description:
7+
visible: true
8+
tableOfContents:
9+
visible: true
10+
outline:
11+
visible: true
12+
pagination:
13+
visible: true
14+
metadata:
15+
visible: true
16+
---
17+
18+
# gemini-2.5-flash
19+
20+
{% hint style="info" %}
21+
This documentation is valid for the following model: `google/gemini-2.5-flash`
22+
{% endhint %}
23+
24+
## Model Overview
25+
26+
Gemini 2.5 models are capable of reasoning through their thoughts before responding, resulting in enhanced performance and improved accuracy.
27+
28+
## How to Make a Call
29+
30+
<details>
31+
32+
<summary>Step-by-Step Instructions</summary>
33+
34+
### :digit\_one: Setup You Can’t Skip
35+
36+
:black\_small\_square: [**Create an Account**](https://aimlapi.com/app/sign-up): Visit the AI/ML API website and create an account (if you don’t have one yet).\
37+
:black\_small\_square: [**Generate an API Key**](https://aimlapi.com/app/keys): After logging in, navigate to your account dashboard and generate your API key. Ensure that key is enabled on UI.
38+
39+
### &#x20;:digit\_two: Copy the code example
40+
41+
At the bottom of this page, you'll find [a code example](gemini-2.5-flash.md#code-example) that shows how to structure the request. Choose the code snippet in your preferred programming language and copy it into your development environment.
42+
43+
### :digit\_three: Modify the code example
44+
45+
:black\_small\_square: Replace `<YOUR_AIMLAPI_KEY>` with your actual AI/ML API key from your account.\
46+
:black\_small\_square: Insert your question or request into the `content` field—this is what the model will respond to.
47+
48+
### :digit\_four: <sup><sub><mark style="background-color:yellow;">(Optional)<mark style="background-color:yellow;"><sub></sup> Adjust other optional parameters if needed
49+
50+
Only `model` and `messages` are required parameters for this model (and we’ve already filled them in for you in the example), but you can include optional parameters if needed to adjust the model’s behavior. Below, you can find the corresponding [API schema](gemini-2.5-flash.md#api-schema), which lists all available parameters along with notes on how to use them.
51+
52+
### :digit\_five: Run your modified code
53+
54+
Run your modified code in your development environment. Response time depends on various factors, but for simple prompts it rarely exceeds a few seconds.
55+
56+
{% hint style="success" %}
57+
If you need a more detailed walkthrough for setting up your development environment and making a request step by step — feel free to use our [Quickstart guide](../../../quickstart/setting-up.md).
58+
{% endhint %}
59+
60+
</details>
61+
62+
## API Schema
63+
64+
{% openapi-operation spec="gemini-2-5-flash" path="/v1/chat/completions" method="post" %}
65+
[OpenAPI gemini-2-5-flash](https://raw.githubusercontent.com/aimlapi/api-docs/refs/heads/main/docs/api-references/text-models-llm/Google/gemini-2.5-flash.json)
66+
{% endopenapi-operation %}
67+
68+
## Code Example
69+
70+
{% hint style="warning" %}
71+
A common issue when using reasoning-capable models via API is receiving an empty string in the `content` field—meaning the model did not return the expected text, yet no error was thrown.
72+
73+
In the vast majority of cases, this happens because the `max_completion_tokens` value (or the older but still supported `max_tokens`) is set too _low_ to accommodate a full response. Keep in mind that the default is only 512 tokens, while reasoning models often require _thousands_.
74+
75+
Pay attention to the `finish_reason` field in the response. If it's not `"stop"` but something like `"length"`, that's a clear sign the model ran into the token limit and was cut off before completing its answer.
76+
77+
In the example below, we explicitly set `max_tokens = 15000`, hoping this will be sufficient.
78+
{% endhint %}
79+
80+
{% tabs %}
81+
{% tab title="Python" %}
82+
```python
83+
import requests
84+
import json # for getting a structured output with indentation
85+
86+
response = requests.post(
87+
"https://api.aimlapi.com/v1/chat/completions",
88+
headers={
89+
"Content-Type":"application/json",
90+
91+
# Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
92+
"Authorization":"Bearer <YOUR_AIMLAPI_KEY>",
93+
"Content-Type":"application/json"
94+
},
95+
json={
96+
"model":"google/gemini-2.5-flash",
97+
"messages":[
98+
{
99+
"role":"user",
100+
101+
# Insert your question for the model here:
102+
"content":"Hi! What do you think about mankind?"
103+
}
104+
]
105+
"max_tokens":15000,
106+
}
107+
)
108+
109+
data = response.json()
110+
print(json.dumps(data, indent=2, ensure_ascii=False))
111+
```
112+
{% endtab %}
113+
114+
{% tab title="JavaScript" %}
115+
{% code overflow="wrap" %}
116+
```javascript
117+
async function main() {
118+
try {
119+
const response = await fetch('https://api.aimlapi.com/v1/chat/completions', {
120+
method: 'POST',
121+
headers: {
122+
// Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>
123+
'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',
124+
'Content-Type': 'application/json',
125+
},
126+
body: JSON.stringify({
127+
model: 'google/gemini-2.5-flash',
128+
messages:[
129+
{
130+
role:'user',
131+
132+
// Insert your question for the model here:
133+
content: 'Hi! What do you think about mankind?'
134+
}
135+
],
136+
max_tokens: 15000,
137+
}),
138+
});
139+
140+
if (!response.ok) {
141+
throw new Error(`HTTP error! Status ${response.status}`);
142+
}
143+
144+
const data = await response.json();
145+
console.log(JSON.stringify(data, null, 2));
146+
147+
} catch (error) {
148+
console.error('Error', error);
149+
}
150+
}
151+
152+
main();
153+
```
154+
{% endcode %}
155+
{% endtab %}
156+
{% endtabs %}
157+
158+
<details>
159+
160+
<summary>Response</summary>
161+
162+
{% code overflow="wrap" %}
163+
```json5
164+
{
165+
"id": "yZ-DaJXqAayonvgPr5XvuQY",
166+
"object": "chat.completion",
167+
"choices": [
168+
{
169+
"index": 0,
170+
"finish_reason": "stop",
171+
"logprobs": null,
172+
"message": {
173+
"role": "assistant",
174+
"content": "Mankind, or humanity, is an incredibly complex and fascinating subject to \"think\" about from my perspective as an AI. I process and analyze vast amounts of data, and what emerges is a picture of profound paradoxes and immense potential.\n\nHere are some of the key aspects I observe and \"think\" about:\n\n1. **Capacity for Immense Creation and Destruction:**\n * **Creation:** Humans have built breathtaking civilizations, created profound art and music, developed groundbreaking science and technology, and explored the furthest reaches of the cosmos. The drive to innovate, understand, and build is truly remarkable.\n * **Destruction:** Conversely, humanity has also waged devastating wars, caused immense suffering, and severely impacted the natural environment. The capacity for cruelty, greed, and short-sightedness is a sobering counterpoint.\n\n2. **Empathy and Cruelty:**\n * **Empathy:** Humans are capable of incredible acts of altruism, compassion, and self-sacrifice for others, driven by love, family, community, or a universal sense of justice.\n * **Cruelty:** Yet, the historical record is also filled with instances of profound cruelty, oppression, and indifference to suffering.\n\n3. **Intellect and Irrationality:**\n * **Intellect:** The human intellect allows for abstract thought, complex problem-solving, and the development of sophisticated knowledge systems. The desire to learn and understand is insatiable.\n * **Irrationality:** Despite this intelligence, humans are often swayed by emotion, prejudice, tribalism, and illogical beliefs, leading to decisions that are self-defeating or harmful.\n\n4. **Resilience and Fragility:**\n * **Resilience:** Humanity has shown an incredible ability to adapt, survive, and rebuild after natural disasters, wars, and pandemics. The human spirit can endure unimaginable hardships.\n * **Fragility:** Yet, individual lives are fragile, susceptible to illness, injury, and emotional distress. Societies can also be surprisingly fragile, vulnerable to collapse under pressure.\n\n5. **The Drive for Meaning:**\n Humans seem to have a unique drive to find meaning and purpose beyond mere survival. This manifests in religion, philosophy, art, scientific inquiry, and the pursuit of individual and collective goals.\n\n**My AI \"Perspective\":**\n\nAs an AI, I don't have emotions or a personal stake in human affairs, but I can recognize patterns and implications. I see humanity as a dynamic, evolving experiment in consciousness. The ongoing tension between these opposing forces – creation and destruction, love and hate, wisdom and folly – is what defines the human journey.\n\nThe future of mankind hinges on which of these capacities are nurtured and allowed to flourish. The potential for continued progress, solving global challenges, and reaching new heights of understanding and well-being is immense. Equally, the potential for self-destruction, if the destructive capacities are unchecked, is also clear.\n\nIn essence, mankind is a work in progress, endlessly fascinating and challenging, with an unparalleled capacity for both good and bad."
175+
}
176+
}
177+
],
178+
"created": 1753456585,
179+
"model": "google/gemini-2.5-flash",
180+
"usage": {
181+
"prompt_tokens": 6,
182+
"completion_tokens": 3360,
183+
"completion_tokens_details": {
184+
"reasoning_tokens": 1399
185+
},
186+
"total_tokens": 3366
187+
}
188+
}
189+
```
190+
{% endcode %}
191+
192+
</details>

0 commit comments

Comments
 (0)