Gemini Developer API

Gemini API anahtarı edinin ve birkaç dakika içinde ilk API isteğinizi gönderin.

API anahtarınızı GEMINI_API_KEY ortam değişkeni olarak ayarlarsanız Gemini API kitaplıkları kullanılırken istemci tarafından otomatik olarak alınır. Aksi takdirde, istemciyi başlatırken API anahtarınızı bağımsız değişken olarak iletmeniz gerekir.

Python

from google import genai

# The client gets the API key from the environment variable `GEMINI_API_KEY`.
client = genai.Client()

response = client.models.generate_content(
    model="gemini-2.5-flash",
    contents="Explain how AI works in a few words",
)

print(response.text)

JavaScript

import { GoogleGenAI } from "@google/genai";

// The client gets the API key from the environment variable `GEMINI_API_KEY`.
const ai = new GoogleGenAI({});

async function main() {
  const response = await ai.models.generateContent({
    model: "gemini-2.5-flash",
    contents: "Explain how AI works in a few words",
  });
  console.log(response.text);
}

await main();

Go

package main

import (
    "context"
    "fmt"
    "log"
    "google.golang.org/genai"
)

func main() {
    ctx := context.Background()
    // The client gets the API key from the environment variable `GEMINI_API_KEY`.
    client, err := genai.NewClient(ctx, nil))
    if err != nil {
        log.Fatal(err)
    }

    result, err := client.Models.GenerateContent(
        ctx,
        "gemini-2.5-flash",
        genai.Text("Explain how AI works in a few words"),
        nil,
    )
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println(result.Text())
}

Java

package com.example;

import com.google.genai.Client;
import com.google.genai.types.GenerateContentResponse;

public class GenerateTextFromTextInput {
  public static void main(String[] args) {
    // The client gets the API key from the environment variable `GEMINI_API_KEY`.
    Client client = new Client();

    GenerateContentResponse response =
        client.models.generateContent(
            "gemini-2.5-flash",
            "Explain how AI works in a few words",
            null);

    System.out.println(response.text());
  }
}

REST

curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H 'Content-Type: application/json' \
  -X POST \
  -d '{
    "contents": [
      {
        "parts": [
          {
            "text": "Explain how AI works in a few words"
          }
        ]
      }
    ]
  }'

API'yi keşfetme

Doğal görüntü oluşturma

Gemini 2.0 Flash ile yerel olarak yüksek bağlama dayalı görseller oluşturun ve düzenleyin.

Uzun bağlamı keşfetme

Gemini modellerine milyonlarca jeton girin ve yapılandırılmamış resimlerden, videolardan ve dokümanlardan bilgi edinin.

Yapılandırılmış çıkışlar oluşturma

Gemini'yi, otomatik işlemeye uygun yapılandırılmış bir veri biçimi olan JSON ile yanıt vermeye zorlama.

Gemini API ile geliştirmeye başlama

Başlayın