/v1beta/models/gemini-2.5-flash-preview-04-17:generateContent
Google AIThe Gemini Flash model is Google's fastest and most cost-effective multimodal model. It's optimized for high-volume, fast-response scenarios such as summarization, chat applications, image and video captioning, and data extraction from documents and tables. It supports text, image, and audio input, and generates text output.
Set to `application/json`.
Your Google AI API key.
An array of Content objects. Each Content object contains a list of Parts.
A list of unique SafetySetting instances for blocking unsafe content.
Configuration options for model generation and outputs.
A list of generated candidate responses from the model.
Feedback regarding the safety of the prompt.
curl 'https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-preview-04-17:generateContent?key=YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-X POST \
-d '{
"contents": [{
"parts":[{"text": "Explain quantum computing in simple terms."}]
}],
"generationConfig": {
"temperature": 0.7,
"maxOutputTokens": 150
}
}'
import { GoogleGenAI } from "@google/genai";
const ai = new GoogleGenAI({ apiKey: process.env.API_KEY });
async function run() {
const response = await ai.models.generateContent({
model: "gemini-2.5-flash-preview-04-17",
contents: "Explain quantum computing in simple terms.",
config: {
temperature: 0.7,
maxOutputTokens: 150
}
});
console.log(response.text);
}
run();
import google.generativeai as genai
genai.configure(api_key="YOUR_API_KEY")
model = genai.GenerativeModel('gemini-2.5-flash-preview-04-17')
response = model.generate_content(
"Explain quantum computing in simple terms.",
generation_config=genai.types.GenerationConfig(
temperature=0.7,
max_output_tokens=150
)
)
print(response.text)
{
"candidates": [
{
"content": {
"parts": [
{
"text": "Imagine a regular computer uses bits, which are like light switches that are either ON (1) or OFF (0). Quantum computers use 'qubits'. A qubit is like a dimmer switch that can be ON, OFF, or somewhere in between. It can even be both ON and OFF at the same time (superposition)!\\n\\nThis 'quantum weirdness' allows quantum computers to do many calculations at once, making them incredibly fast for certain problems that are too hard for regular computers, like discovering new medicines or breaking complex codes."
}
],
"role": "model"
},
"finishReason": "STOP",
"index": 0,
"safetyRatings": [
{
"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_HATE_SPEECH",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_HARASSMENT",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_DANGEROUS_CONTENT",
"probability": "NEGLIGIBLE"
}
]
}
],
"promptFeedback": {
"safetyRatings": [
{
"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_HATE_SPEECH",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_HARASSMENT",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_DANGEROUS_CONTENT",
"probability": "NEGLIGIBLE"
}
]
}
}