google · Google AI Docs
Gemini API OpenAI compatibility
Instructions and configuration details for using the Gemini API via the OpenAI-compatible endpoint to allow existing OpenAI-based codebases to switch to Gemini models.
Derived skill
Files assembled from official documentation
Viewing SKILL.md
Gemini API OpenAI compatibility
Instructions and configuration details for using the Gemini API via the OpenAI-compatible endpoint to allow existing OpenAI-based codebases to switch to Gemini models.
When To Use
Use when migrating an existing application from OpenAI to Gemini without rewriting the core integration logic or when using libraries that require an OpenAI-compatible client interface.
Reference Files
| File | Contains | Use For |
|---|---|---|
SKILL.md | Entry point: scope, routing table, and workflow. | Start here. |
docs/gemini-api-openai-compatibility-workflow-guide.md | A guide explaining how to access Gemini models using OpenAI Python and JavaScript libraries and the REST API. | Questions about a guide explaining how to access Gemini models using OpenAI Python and JavaScript libraries and the REST API. |
examples/gemini-api-openai-compatibility-python-client-setup.text | A Python code example demonstrating how to initialize the OpenAI client using the Gemini API base URL and endpoint. | Exact payloads, commands, or snippets shown in A Python code example demonstrating how to initialize the OpenAI client using the Gemini API base URL and endpoint. |
examples/gemini-api-openai-compatibility-nodejs-chat-completions.text | A Node.js code example demonstrating how to use the OpenAI SDK to interact with the Gemini API via the OpenAI compatibility endpoint. | Exact payloads, commands, or snippets shown in A Node.js code example demonstrating how to use the OpenAI SDK to interact with the Gemini API via the OpenAI compati... |
examples/gemini-api-openai-compatibility-gemini-api-openai-chat-completions-curl-.text | A curl command demonstrating how to send a chat completion request to the Gemini API using the OpenAI compatibility endpoint. | Exact payloads, commands, or snippets shown in A curl command demonstrating how to send a chat completion request to the Gemini API using the OpenAI compatibility e... |
examples/gemini-api-openai-compatibility-python-client-setup-2.text | A Python code example demonstrating how to initialize the OpenAI client using the Gemini API base URL and endpoint. | Exact payloads, commands, or snippets shown in A Python code example demonstrating how to initialize the OpenAI client using the Gemini API base URL and endpoint. |
examples/gemini-api-openai-compatibility-nodejs-chat-completions-2.text | A Node.js code example demonstrating how to use the OpenAI SDK to interact with the Gemini API via the OpenAI compatibility endpoint. | Exact payloads, commands, or snippets shown in A Node.js code example demonstrating how to use the OpenAI SDK to interact with the Gemini API via the OpenAI compati... |
examples/gemini-api-openai-compatibility-gemini-api-openai-chat-completions-curl--2.text | A curl command demonstrating how to call the Gemini API using the OpenAI-compatible chat completions endpoint. | Exact payloads, commands, or snippets shown in A curl command demonstrating how to call the Gemini API using the OpenAI-compatible chat completions endpoint. |
examples/gemini-api-openai-compatibility-python-client-setup-3.text | A Python code example demonstrating how to initialize the OpenAI client using the Gemini API base URL and configuration. | Exact payloads, commands, or snippets shown in A Python code example demonstrating how to initialize the OpenAI client using the Gemini API base URL and configuration. |
examples/gemini-api-openai-compatibility-nodejs-chat-completions-3.text | A Node.js code example demonstrating how to use the OpenAI SDK to interact with the Gemini API via the OpenAI compatibility endpoint. | Exact payloads, commands, or snippets shown in A Node.js code example demonstrating how to use the OpenAI SDK to interact with the Gemini API via the OpenAI compati... |
examples/gemini-api-openai-compatibility-gemini-api-openai-chat-completions-curl--3.text | A curl command demonstrating how to send a chat completion request to the Gemini API using the OpenAI compatibility endpoint. | Exact payloads, commands, or snippets shown in A curl command demonstrating how to send a chat completion request to the Gemini API using the OpenAI compatibility e... |
examples/gemini-api-openai-compatibility-python-client-setup-4.text | A Python code example demonstrating how to initialize the OpenAI client using the Gemini API base URL and endpoint. | Exact payloads, commands, or snippets shown in A Python code example demonstrating how to initialize the OpenAI client using the Gemini API base URL and endpoint. |
examples/gemini-api-openai-compatibility-nodejs-chat-completions-4.text | A Node.js code example demonstrating how to use the OpenAI SDK to interact with the Gemini API via the OpenAI compatibility endpoint. | Exact payloads, commands, or snippets shown in A Node.js code example demonstrating how to use the OpenAI SDK to interact with the Gemini API via the OpenAI compati... |
examples/gemini-api-openai-compatibility-gemini-api-openai-chat-completions-curl--4.text | A curl command demonstrating how to send a chat completion request to the Gemini API using OpenAI-compatible syntax. | Exact payloads, commands, or snippets shown in A curl command demonstrating how to send a chat completion request to the Gemini API using OpenAI-compatible syntax. |
examples/gemini-api-openai-compatibility-python-client-initialization.text | A Python code snippet demonstrating how to initialize the OpenAI client using the Gemini API base URL and API key. | Exact payloads, commands, or snippets shown in A Python code snippet demonstrating how to initialize the OpenAI client using the Gemini API base URL and API key. |
examples/gemini-api-openai-compatibility-nodejs-client-initialization.text | A Node.js code example demonstrating how to initialize the OpenAI client using the Gemini API base URL and API key. | Exact payloads, commands, or snippets shown in A Node.js code example demonstrating how to initialize the OpenAI client using the Gemini API base URL and API key. |
examples/gemini-api-openai-compatibility-gemini-api-openai-chat-completions-curl--5.text | A curl command demonstrating how to send a chat completion request to the Gemini API using the OpenAI compatibility endpoint. | Exact payloads, commands, or snippets shown in A curl command demonstrating how to send a chat completion request to the Gemini API using the OpenAI compatibility e... |
examples/gemini-api-openai-compatibility-python-image-encoding.text | A Python script demonstrating how to use the OpenAI client to interact with the Gemini API, including a function to encode images in base64. | Exact payloads, commands, or snippets shown in A Python script demonstrating how to use the OpenAI client to interact with the Gemini API, including a function to e... |
examples/gemini-api-openai-compatibility-nodejs-client-initialization-2.text | A Node.js code example demonstrating how to initialize the OpenAI client using the Gemini API base URL and API key. | Exact payloads, commands, or snippets shown in A Node.js code example demonstrating how to initialize the OpenAI client using the Gemini API base URL and API key. |
examples/gemini-api-openai-compatibility-gemini-api-openai-chat-completions-curl--6.text | A curl command demonstrating how to send a multimodal request containing a base64 encoded image to the Gemini API using the OpenAI compatibility endpoint. | Exact payloads, commands, or snippets shown in A curl command demonstrating how to send a multimodal request containing a base64 encoded image to the Gemini API usi... |
examples/gemini-api-openai-compatibility-python-image-generation.text | A Python script using the OpenAI client library to generate images via the Gemini API compatibility endpoint. | Exact payloads, commands, or snippets shown in A Python script using the OpenAI client library to generate images via the Gemini API compatibility endpoint. |
examples/gemini-api-openai-compatibility-nodejs-image-generation.text | A Node.js code example demonstrating how to use the OpenAI SDK to generate images via the Gemini API compatibility endpoint. | Exact payloads, commands, or snippets shown in A Node.js code example demonstrating how to use the OpenAI SDK to generate images via the Gemini API compatibility en... |
examples/gemini-api-openai-compatibility-gemini-api-openai-images-generations-cur.text | A curl command demonstrating how to use the Gemini API's OpenAI-compatible endpoint to generate images. | Exact payloads, commands, or snippets shown in A curl command demonstrating how to use the Gemini API's OpenAI-compatible endpoint to generate images. |
examples/gemini-api-openai-compatibility-python-video-generation-request.text | A Python code example using the OpenAI client library to request video generation via the Gemini API's OpenAI-compatible endpoint. | Exact payloads, commands, or snippets shown in A Python code example using the OpenAI client library to request video generation via the Gemini API's OpenAI-compati... |
examples/gemini-api-openai-compatibility-nodejs-video-generation.text | A Node.js code example demonstrating how to use the OpenAI SDK to trigger video generation via the Gemini API compatibility layer. | Exact payloads, commands, or snippets shown in A Node.js code example demonstrating how to use the OpenAI SDK to trigger video generation via the Gemini API compati... |
examples/gemini-api-openai-compatibility-video-generation-curl.text | A curl command demonstrating how to use the Gemini API's OpenAI compatibility layer to generate video previews using the veo-3.1-generate-preview model. | Exact payloads, commands, or snippets shown in A curl command demonstrating how to use the Gemini API's OpenAI compatibility layer to generate video previews using... |
examples/gemini-api-openai-compatibility-python-video-retrieval.text | A Python script using the OpenAI client library to poll for the completion status of a video processed via the Gemini API OpenAI compatibility endpoint. | Exact payloads, commands, or snippets shown in A Python script using the OpenAI client library to poll for the completion status of a video processed via the Gemini... |
examples/gemini-api-openai-compatibility-nodejs-video-retrieval.text | A Node.js code example demonstrating how to use the OpenAI SDK to retrieve video status via the Gemini API OpenAI compatibility endpoint. | Exact payloads, commands, or snippets shown in A Node.js code example demonstrating how to use the OpenAI SDK to retrieve video status via the Gemini API OpenAI com... |
examples/gemini-api-openai-compatibility-curl-video-request.text | A curl command demonstrating how to request video data using the Gemini API's OpenAI compatibility endpoint. | Exact payloads, commands, or snippets shown in A curl command demonstrating how to request video data using the Gemini API's OpenAI compatibility endpoint. |
examples/gemini-api-openai-compatibility-python-audio-chat-completion.text | A Python code example demonstrating how to use the OpenAI client library to send audio files to the Gemini API via the OpenAI compatibility endpoint. | Exact payloads, commands, or snippets shown in A Python code example demonstrating how to use the OpenAI client library to send audio files to the Gemini API via th... |
examples/gemini-api-openai-compatibility-nodejs-chat-completions-audio.text | A Node.js code example demonstrating how to use the OpenAI client library to send audio files to the Gemini API via the OpenAI compatibility endpoint. | Exact payloads, commands, or snippets shown in A Node.js code example demonstrating how to use the OpenAI client library to send audio files to the Gemini API via t... |
examples/gemini-api-openai-compatibility-gemini-api-openai-chat-completions-curl--7.text | A curl command demonstrating how to send a base64 encoded audio file to the Gemini API using the OpenAI compatibility endpoint. | Exact payloads, commands, or snippets shown in A curl command demonstrating how to send a base64 encoded audio file to the Gemini API using the OpenAI compatibility... |
examples/gemini-api-openai-compatibility-python-structured-outputs.text | A Python code example demonstrating how to use the OpenAI SDK with the Gemini API to perform structured outputs parsing using Pydantic. | Exact payloads, commands, or snippets shown in A Python code example demonstrating how to use the OpenAI SDK with the Gemini API to perform structured outputs parsi... |
examples/gemini-api-openai-compatibility-nodejs-chat-completions-parse.text | A Node.js code example demonstrating how to use the OpenAI SDK to call the Gemini API with structured outputs using the chat completions parse method. | Exact payloads, commands, or snippets shown in A Node.js code example demonstrating how to use the OpenAI SDK to call the Gemini API with structured outputs using t... |
examples/gemini-api-openai-compatibility-python-embeddings.text | A Python code snippet demonstrating how to use the OpenAI client library to generate embeddings via the Gemini API compatibility endpoint. | Exact payloads, commands, or snippets shown in A Python code snippet demonstrating how to use the OpenAI client library to generate embeddings via the Gemini API co... |
examples/gemini-api-openai-compatibility-nodejs-embeddings.text | A Node.js code example demonstrating how to use the OpenAI SDK to generate embeddings via the Gemini API compatibility endpoint. | Exact payloads, commands, or snippets shown in A Node.js code example demonstrating how to use the OpenAI SDK to generate embeddings via the Gemini API compatibilit... |
examples/gemini-api-openai-compatibility-gemini-api-openai-embeddings-curl-reques.text | A curl command demonstrating how to make an OpenAI-compatible embeddings request to the Gemini API. | Exact payloads, commands, or snippets shown in A curl command demonstrating how to make an OpenAI-compatible embeddings request to the Gemini API. |
examples/gemini-api-openai-compatibility-chat-completions-request-payloads.text | A collection of JSON request payloads demonstrating OpenAI-compatible chat completion calls for the Gemini API. | Exact payloads, commands, or snippets shown in A collection of JSON request payloads demonstrating OpenAI-compatible chat completion calls for the Gemini API. |
examples/gemini-api-openai-compatibility-python-batch-upload.text | A Python code example demonstrating how to use the OpenAI client with the Gemini API base URL to upload JSONL files for batch processing. | Exact payloads, commands, or snippets shown in A Python code example demonstrating how to use the OpenAI client with the Gemini API base URL to upload JSONL files f... |
examples/gemini-api-openai-compatibility-embeddings-jsonl.text | A JSONL file containing requests to the Gemini API embeddings endpoint using OpenAI-compatible formatting. | Exact payloads, commands, or snippets shown in A JSONL file containing requests to the Gemini API embeddings endpoint using OpenAI-compatible formatting. |
examples/gemini-api-openai-compatibility-python-chat-completion.text | A Python code example demonstrating how to use the OpenAI client library to make chat completion requests to the Gemini API endpoint. | Exact payloads, commands, or snippets shown in A Python code example demonstrating how to use the OpenAI client library to make chat completion requests to the Gemi... |
examples/gemini-api-openai-compatibility-python-chat-completions-client.text | A Python code example demonstrating how to use the OpenAI client library to interact with the Gemini API via the OpenAI compatibility endpoint. | Exact payloads, commands, or snippets shown in A Python code example demonstrating how to use the OpenAI client library to interact with the Gemini API via the Open... |
examples/gemini-api-openai-compatibility-python-client-initialization-2.text | A Python code snippet demonstrating how to initialize the OpenAI client using the Gemini API base URL and API key. | Exact payloads, commands, or snippets shown in A Python code snippet demonstrating how to initialize the OpenAI client using the Gemini API base URL and API key. |
examples/gemini-api-openai-compatibility-nodejs-client-initialization-3.text | A Node.js code example demonstrating how to initialize the OpenAI client using the Gemini API base URL and API key. | Exact payloads, commands, or snippets shown in A Node.js code example demonstrating how to initialize the OpenAI client using the Gemini API base URL and API key. |
examples/gemini-api-openai-compatibility-curl-list-models.text | A curl command demonstrating how to list available models using the Gemini API OpenAI compatibility endpoint. | Exact payloads, commands, or snippets shown in A curl command demonstrating how to list available models using the Gemini API OpenAI compatibility endpoint. |
examples/gemini-api-openai-compatibility-python-client-initialization-3.text | A Python code snippet demonstrating how to initialize an OpenAI client using the Gemini API base URL and API key. | Exact payloads, commands, or snippets shown in A Python code snippet demonstrating how to initialize an OpenAI client using the Gemini API base URL and API key. |
examples/gemini-api-openai-compatibility-nodejs-client-initialization-4.text | A Node.js code example demonstrating how to initialize the OpenAI client using the Gemini API base URL and API key. | Exact payloads, commands, or snippets shown in A Node.js code example demonstrating how to initialize the OpenAI client using the Gemini API base URL and API key. |
examples/gemini-api-openai-compatibility-curl-request.text | A curl command demonstrating how to access Gemini models using the OpenAI-compatible endpoint. | Exact payloads, commands, or snippets shown in A curl command demonstrating how to access Gemini models using the OpenAI-compatible endpoint. |
What This Skill Covers
- Gemini models are accessible using the OpenAI libraries (Python and TypeScript / Javascript) along with the REST API, by updating three lines of code and usi...
- Main sections:
Python,JavaScript,REST,Thinking,Python.
Workflow
- Open the most relevant file under
docs/for the exact documented workflow and wording. - Open
schemas/files for exact structured contracts. - Open
examples/files for concrete requests, commands, snippets, and manifests. - Do not add behavior or configuration that is not present in the attached source files.
Canonical source: https://ai.google.dev/gemini-api/docs/openai
