Gemini Developer API

Gemini API キーを取得して、数分で最初の API リクエストを作成できます。

Python

from google import genai  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";  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()     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) {     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 の確認

ネイティブ画像生成

Gemini 2.0 Flash を使用して、コンテキストに沿った画像をネイティブに生成、編集できます。

長いコンテキストの詳細

Gemini モデルに数百万のトークンを入力し、非構造化画像、動画、ドキュメントから理解を導き出します。

構造化された出力を生成する

Gemini が自動処理に適した構造化データ形式である JSON で応答するように制約します。

Gemini API で構築を開始する

ご利用開始