google-genai (the new one, replacing the older google-generativeai).
Set http_options.base_url to point requests at OpenPAI.
Python
JavaScript / TypeScript
Streaming
Multimodal
Function calling
Thinking mode
Embeddings
Notes
- When using the Gemini native protocol, the base URL is without
/v1(the SDK appends the/v1beta/models/...path automatically). - If your code originally uses the OpenAI-compatible path (
/v1/chat/completions), you can leave it unchanged and just switch the model ID togemini-*. - The OpenAI-compatible protocol automatically maps Gemini’s
parts/inline_datato thecontentarray, and vice versa.