Gemini (OpenAI-Compatible)#
Access Google's Gemini 1.5 Pro and Flash models via OpenAI-compatible chat completions endpoint. Drop-in replacement for OpenAI's Chat Completions API.
Features#
OpenAI Format: Compatible with /v1/chat/completions endpoint.
Extended Context: Up to 2 million tokens.
Streaming Support: Real-time token streaming with stream: true.
Multimodal Input: Text and image processing via URLs or base64.
API Specification#
API Specification#
Drop-in replacement for OpenAI Chat Completions API. Accepts OpenAI message format and returns OpenAI-compatible response structure.
Request Examples#
Gemini 1.5 Pro (Python)#
Streaming Response (JavaScript)#
Using OpenAI SDK#
OpenAI-compatible chat completion response.{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1677652288,
"model": "gemini-1.5-pro",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Machine learning is a subset of artificial intelligence that uses algorithms to learn patterns from data, while deep learning is a subset of machine learning that uses neural networks with multiple layers to process complex data structures."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 45,
"completion_tokens": 60,
"total_tokens": 105
}
}
Model Selection#
| Model | Capabilities | Context |
|---|
gemini-1.5-pro | Most capable, vision, reasoning | 2M tokens |
gemini-1.5-flash | Fast and efficient, vision | 2M tokens |
gemini-1.5-vision | Specialized for image analysis | 2M tokens |
Modified at 2026-02-08 08:37:10