🌐
GitHub
github.com › googleapis › python-genai
GitHub - googleapis/python-genai: Google Gen AI Python SDK provides an interface for developers to integrate Google's generative models into their Python applications. · GitHub
1 month ago - If your image is stored in your local file system, you can read it in as bytes data and use the from_bytes class method to create a Part object. from google.genai import types YOUR_IMAGE_PATH = 'your_image_path' YOUR_IMAGE_MIME_TYPE = 'your_image_mime_type' with open(YOUR_IMAGE_PATH, 'rb') as f: image_bytes = f.read() for chunk in client.models.generate_content_stream( model='gemini-3.5-flash', contents=[ 'What is this image about?', types.Part.from_bytes(data=image_bytes, mime_type=YOUR_IMAGE_MIME_TYPE), ], ): print(chunk.text, end='')
Starred by 3.8K users
Forked by 929 users
Languages   Python
🌐
GitHub
googleapis.github.io › python-genai
Google Gen AI SDK documentation
If your image is stored in your local file system, you can read it in as bytes data and use the from_bytes class method to create a Part object. from google.genai import types YOUR_IMAGE_PATH = 'your_image_path' YOUR_IMAGE_MIME_TYPE = 'your_image_mime_type' with open(YOUR_IMAGE_PATH, 'rb') as f: image_bytes = f.read() for chunk in client.models.generate_content_stream( model='gemini-2.5-flash', contents=[ 'What is this image about?', types.Part.from_bytes(data=image_bytes, mime_type=YOUR_IMAGE_MIME_TYPE), ], ): print(chunk.text, end='')
🌐
GitHub
github.com › googleapis › java-genai
GitHub - googleapis/java-genai: Google Gen AI Java SDK provides an interface for developers to integrate Google's generative models into their Java applications. · GitHub
May 5, 2026 - package <your package name>; import com.google.common.collect.ImmutableList; import com.google.genai.Client; import com.google.genai.types.Content; import com.google.genai.types.GenerateContentResponse; import com.google.genai.types.Part; public class GenerateContentWithImageInput { public static void main(String[] args) { // Instantiate the client using Gemini Enterprise Agent Platform API.
Starred by 377 users
Forked by 115 users
Languages   Java
🌐
GitHub
github.com › googleapis › python-genai › blob › main › google › genai › types.py
python-genai/google/genai/types.py at main · googleapis/python-genai
Google Gen AI Python SDK provides an interface for developers to integrate Google's generative models into their Python applications. - python-genai/google/genai/types.py at main · googleapis/python-genai
Author   googleapis
🌐
GitHub
github.com › google-gemini › genai-processors
GitHub - google-gemini/genai-processors: GenAI Processors is a lightweight Python library that enables efficient, parallel content processing. · GitHub
from typing import AsyncIterable from genai_processors import content_api from genai_processors import processor class EchoProcessor(processor.Processor): # The PRODUCER interface (for the processor author): # Takes a robust ProcessorStream as input, and yields part types.
Starred by 2.1K users
Forked by 215 users
Languages   Python 77.7% | Jupyter Notebook 14.0% | HTML 8.3%
🌐
GitHub
github.com › googleapis › go-genai
GitHub - googleapis/go-genai: Google Gen AI Go SDK provides an interface for developers to integrate Google's generative models into their Go applications. · GitHub
May 22, 2026 - The Google Gen AI Go SDK enables developers to use Google's state-of-the-art generative AI models (like Gemini) to build AI-powered features and applications. This SDK supports use cases like: ... For example, with just a few lines of code, ...
Starred by 1.1K users
Forked by 152 users
Languages   Go
🌐
GitHub
googleapis.github.io › python-genai › genai.html
Submodules - Google Gen AI SDK documentation
import google.genai from google.genai import types import os if os.environ.get('GOOGLE_GENAI_USE_ENTERPRISE'): MODEL_NAME = 'gemini-2.0-flash-live-preview-04-09' else: MODEL_NAME = 'gemini-live-2.5-flash-preview'; client = genai.Client() async with client.aio.live.connect( model=MODEL_NAME, config={"response_modalities": ["TEXT"]} ) as session: await session.send_client_content( turns=types.Content( role='user', parts=[types.Part(text="Hello world!")])) async for msg in session.receive(): if msg.text: print(msg.text)
🌐
GitHub
github.com › googleapis › js-genai › blob › main › codegen_instructions.md
js-genai/codegen_instructions.md at main · googleapis/js-genai
You can use this approach to pass a variety of data types (images, audio, video, pdf). For PDF, use application/pdf as mimeType. import { GoogleGenAI, Part } from '@google/genai'; import * as fs from 'fs'; const ai = new GoogleGenAI({}); // ...
Author   googleapis
🌐
GitHub
github.com › googleapis › python-genai › blob › main › codegen_instructions.md
python-genai/codegen_instructions.md at main · googleapis/python-genai
While the simpler API call is often sufficient, you may run into scenarios where you need to work directly with the underlying Content and Part objects for more explicit control. These are the fundamental building blocks of the generate_content API. For instance, the following simple API call: from google import genai client = genai.Client() response = client.models.generate_content( model='gemini-3-flash-preview', contents='How does AI work?' ) print(response.text) is effectively a shorthand for this more explicit structure: from google import genai from google.genai import types client = genai.Client() response = client.models.generate_content( model='gemini-3-flash-preview', contents=[ types.Content(role='user', parts=[types.Part.from_text(text='How does AI work?')]), ] ) print(response.text) The list of APIs and capabilities above are not comprehensive.
Author   googleapis
🌐
GitHub
github.com › google-gemini › generative-ai-python › blob › main › google › generativeai › types › generation_types.py
deprecated-generative-ai-python/google/generativeai/types/generation_types.py at main · google-gemini/deprecated-generative-ai-python
This SDK is now deprecated, use the new unified Google GenAI SDK. - deprecated-generative-ai-python/google/generativeai/types/generation_types.py at main · google-gemini/deprecated-generative-ai-python
Author   google-gemini
Find elsewhere
🌐
Go Packages
pkg.go.dev › github.com › google › generative-ai-go › genai
genai package - github.com/google/generative-ai-go/genai - Go Packages
May 2, 2025 - FunctionCalls return all the FunctionCall parts in the candidate. type ChatSession struct { History []*Content // contains filtered or unexported fields } A ChatSession provides interactive chat. ... This example shows how to set the History field on ChatSession explicitly. package main import ( "context" "fmt" "log" "os" "github.com/google/generative-ai-go/genai" "google.golang.org/api/option" ) func main() { ctx := context.Background() client, err := genai.NewClient(ctx, option.WithAPIKey(os.Getenv("GEMINI_API_KEY"))) if err != nil { log.Fatal(err) } defer client.Close() model := client.GenerativeModel("gemini-1.5-flash") cs := model.StartChat() cs.History = []*genai.Content{ { Parts: []genai.Part{ genai.Text("Hello, I have 2 dogs in my house."), }, Role: "user", }, { Parts: []genai.Part{ genai.Text("Great to meet you.
🌐
GitHub
github.com › google › generative-ai-go › blob › main › genai › example_test.go
generative-ai-go/genai/example_test.go at main · google/generative-ai-go
Items: &genai.Schema{Type: genai.TypeString}, } resp, err := model.GenerateContent(ctx, genai.Text("List a few popular cookie recipes using this JSON schema.")) if err != nil { log.Fatal(err) } for _, part := range resp.Candidates[0].Content.Parts { if txt, ok := part.(genai.Text); ok { var recipes []string ·
Author   google
🌐
GitHub
github.com › googleapis › js-genai
GitHub - googleapis/js-genai: TypeScript/JavaScript SDK for Gemini and Vertex AI. · GitHub
April 25, 2026 - NOTE: This doesn't apply to FunctionCall and FunctionResponse parts, if you are specifying those, you need to explicitly provide the full Content[] structure making it explicit which Parts are 'spoken' by the model, or the user. The SDK will throw an exception if you try this. To handle errors raised by the API, the SDK provides this ApiError class. import {GoogleGenAI} from '@google/genai'; const GEMINI_API_KEY = process.env.GEMINI_API_KEY; const ai = new GoogleGenAI({apiKey: GEMINI_API_KEY}); async function main() { await ai.models.generateContent({ model: 'non-existent-model', contents: 'Write a 100-word poem.', }).catch((e) => { console.error('error name: ', e.name); console.error('error message: ', e.message); console.error('error status: ', e.status); }); } main();
Starred by 1.6K users
Forked by 251 users
Languages   TypeScript 94.3% | JavaScript 5.1% | HTML 0.3% | Shell 0.2% | Starlark 0.1% | CSS 0.0%
🌐
GitHub
googleapis.github.io › dotnet-genai
| Google GenAI .NET SDK
export GOOGLE_GENAI_USE_ENTERPRISE=true export GOOGLE_CLOUD_PROJECT='your-project-id' export GOOGLE_CLOUD_LOCATION='us-central1' ... Parameter types are specified in the Google.GenAI.Types namespace.
🌐
GitHub
github.com › googleapis › dotnet-genai
GitHub - googleapis/dotnet-genai: Google Gen AI Dotnet SDK provides an interface for developers to integrate Google's generative models into their .NET applications. · GitHub
export GOOGLE_GENAI_USE_ENTERPRISE=true export GOOGLE_CLOUD_PROJECT='your-project-id' export GOOGLE_CLOUD_LOCATION='us-central1' ... Parameter types are specified in the Google.GenAI.Types namespace.
Starred by 144 users
Forked by 42 users
Languages   HTML 93.4% | C# 6.6%
🌐
GitHub
github.com › googleapis › python-genai › blob › cf3c476ea300acc09b514d23b5f1f08c05efce60 › google › genai › types.py
python-genai/google/genai/types.py at cf3c476ea300acc09b514d23b5f1f08c05efce60 · googleapis/python-genai
Google Gen AI Python SDK provides an interface for developers to integrate Google's generative models into their Python applications. - python-genai/google/genai/types.py at cf3c476ea300acc09b514d23b5f1f08c05efce60 · googleapis/python-genai
Author   googleapis
🌐
GitHub
github.com › google-gemini › deprecated-generative-ai-python › issues › 736
ImportError: 'Content'/'Part' from 'google.generativeai.types' with Python 3.12.3 and google-generativeai 0.8.5 · Issue #736 · google-gemini/deprecated-generative-ai-python
June 6, 2025 - Please set it.") return genai.configure(api_key=api_key) model = genai.GenerativeModel(model_name="gemini-1.5-flash-latest") chat_session = model.start_chat() prompt = "Hello, what is your purpose?" # Attempting with explicit types after prior TypeError issues: messages = [Content(role="user", parts=[Part(text=prompt)])] logging.info("Attempting to send message to Gemini...") response = chat_session.send_message(messages) logging.info(f"Received response from Gemini: {response.text}") except Exception as e: logging.error(f"An error occurred: {e}", exc_info=True) if __name__ == "__main__": run_test()
Author   google-gemini
🌐
GitHub
github.com › google-gemini › generative-ai-python › blob › main › docs › api › google › generativeai.md
deprecated-generative-ai-python/docs/api/google/generativeai.md at main · google-gemini/deprecated-generative-ai-python
... protos module: This module provides low level access to the ProtoBuffer "Message" classes used by the API. types module: A collection of type definitions used throughout the library.
Author   google-gemini
🌐
GitHub
github.com › googleapis › python-genai › blob › main › README.md
python-genai/README.md at main · googleapis/python-genai
If your image is stored in your local file system, you can read it in as bytes data and use the from_bytes class method to create a Part object. from google.genai import types YOUR_IMAGE_PATH = 'your_image_path' YOUR_IMAGE_MIME_TYPE = 'your_image_mime_type' with open(YOUR_IMAGE_PATH, 'rb') as f: image_bytes = f.read() for chunk in client.models.generate_content_stream( model='gemini-2.5-flash', contents=[ 'What is this image about?', types.Part.from_bytes(data=image_bytes, mime_type=YOUR_IMAGE_MIME_TYPE), ], ): print(chunk.text, end='')
Author   googleapis