Your first API call
Get a free key and talk to a model from code.
Apps don't use a chat window. They send the model an API call: a request with your messages, and a response with the reply and how many tokens it used.
Your code sends
POST https://generativelanguage.googleapis.com/v1beta/models/gemini-3.5-flash-lite:generateContent
x-goog-api-key: YOUR_KEY
{
"systemInstruction": {
"parts": [
{
"text": "Answer in one sentence."
}
]
},
"contents": [
{
"role": "user",
"parts": [
{
"text": "Why is the sky blue?"
}
]
}
],
"generationConfig": {
"temperature": 0
}
}Google sends back
{
"candidates": [
{
"content": {
"parts": [
{
"text": "The sky is blue because Earth's atmosphere scatters shorter wavelengths of sunlight, like blue and violet, in all directions more than other colors."
}
],
"role": "model"
},
"finishReason": "STOP",
"index": 0
}
],
"usageMetadata": {
"promptTokenCount": 12,
"candidatesTokenCount": 29,
"totalTokenCount": 41,
"promptTokensDetails": [
{
"modality": "TEXT",
"tokenCount": 12
}
],
"serviceTier": "standard"
},
"modelVersion": "gemini-3.5-flash-lite",
"responseId": "onLYap3bOYuO4-EP-7nDoAQ"
}A real call, 2026-10-21. Every chatbot, copilot and agent is built on calls like this.
Your turn. Get a free Gemini key from Google AI Studio (sign in with Google, then Create API key), paste it below, and send your first message.
No key yet? Get one free in AI Studio (sign in with Google, click Create API key). It stays in this browser and goes only to Google.
Reply
Change the system prompt, send again, and watch the reply change.
The same call from Python, on your computer
pip install google-genaiPut your key in an environment variable (Mac or Linux first, then Windows):
export GEMINI_API_KEY="your-key"setx GEMINI_API_KEY "your-key"Save as first_call.py and run python first_call.py. (On Windows, open a new terminal after setx.)
1from google import genai23client = genai.Client() # reads your key from the GEMINI_API_KEY environment variable45reply = client.models.generate_content(6 model="gemini-flash-lite-latest",7 contents="Explain recursion in one sentence.",8)9print(reply.text)10print(reply.usage_metadata.prompt_token_count, "tokens in,", reply.usage_metadata.candidates_token_count, "tokens out")