Prompt Buddy logoPrompt Buddy

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.

Import to Prompt Buddy

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

FileContainsUse For
SKILL.mdEntry point: scope, routing table, and workflow.Start here.
docs/gemini-api-openai-compatibility-workflow-guide.mdA 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.textA 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.textA 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-.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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

  1. Open the most relevant file under docs/ for the exact documented workflow and wording.
  2. Open schemas/ files for exact structured contracts.
  3. Open examples/ files for concrete requests, commands, snippets, and manifests.
  4. 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