AI for every developer
Build with state-of-the-art generative AI models and tools to make AI helpful for everyone
Build with the Gemini API
Easily integrate Google’s largest and most capable AI model to your apps
import google.generativeai as genai
import PIL.Image
import os
genai.configure(api_key=os.environ["GOOGLE_API_KEY"])
img = PIL.Image.open('path/to/image.png')
model = genai.GenerativeModel(model_name="gemini-1.5-flash")
response = model.generate_content(["What is in this photo?", img])
print(response.text)
const { GoogleGenerativeAI } = require("@google/generative-ai");
const fs = require("fs");
const genAI = new GoogleGenerativeAI(process.env.GOOGLE_API_KEY);
async function run() {
const model = genAI.getGenerativeModel({ model: "gemini-1.5-flash"});
const result = await model.generateContent([
"What is in this photo?",
{inlineData: {data: Buffer.from(fs.readFileSync('path/to/image.png')).toString("base64"),
mimeType: 'image/png'}}]
);
console.log(result.response.text());
}
run();
curl https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent?key=${GOOGLE_API_KEY} \
-H 'Content-Type: application/json' \
-d '{
"contents":[{
"parts":[
{"text": "What is this picture?"},
{"inline_data": {
"mime_type":"image/png",
"data": "'"$(base64 -i 'path/to/image/image.png')"'"
}}
]}
]
}'
import "github.com/google/generative-ai-go/genai"
import "google.golang.org/api/option"
ctx := context.Background()
client, err := genai.NewClient(ctx, option.WithAPIKey(os.Getenv("GOOGLE_API_KEY")))
model := client.GenerativeModel("gemini-1.5-flash")
resp, err := model.GenerateContent(
ctx,
genai.Text("What's in this photo?"),
genai.ImageData("jpeg", imgData))
val model = GenerativeModel("gemini-1.5-flash")
val response = model.generateContent(content {
text("What's in this photo?")
image(ingredientsBitmap)
})
let model = GenerativeModel(name: "gemini-1.5-flash")
let response = try await model.generateContent("What's in this photo?", image)
final model = GenerativeModel(model: "gemini-1.5-flash", apiKey: apiKey);
final response = await model.generateContent([
Content.text("What's in this photo?"),
Content.data("image/png", imageBytes),
]);
Develop with Gemini assistance
Innovate with Gemma open models
Accelerate responsible AI development with unprecedented flexibility and access to lightweight, customizable models
Join the community
Tap into the power of our community forum. Get answers, build together, and be part of the conversation.