Building with AI

OpenAI-compatible APIs

Quick explainer2 min readIntermediate

An OpenAI-compatible API accepts the same request format as OpenAI's API, so apps written for OpenAI can talk to other models by changing a few settings.

In plain words

Many providers and tools accept the same request format as OpenAI's API. If a service is OpenAI-compatible, you keep using the OpenAI library and just point it at a different base URL with a different key and model name. Google's Gemini API and the local tool Ollama both offer this. Compatibility is often partial, so some features may be missing.

A quick example

Imagine a Python app that uses the official OpenAI library. To try a Gemini model, the developer changes three things: the API key, the base URL to Google's OpenAI-compatible endpoint, and the model name. The rest of the code stays the same.

Where you'll meet it

  • Switching providers without rewriting code.
  • Running local models behind a familiar interface.

Related

Sources

  1. DocsOpenAI compatibility, Google AI for Developers (Gemini API) · read 2 Nov 2026
  2. DocsOpenAI compatibility, Ollama documentation · read 29 Sept 2026

Checked by WhatIsAI against the sources above · 2 Nov 2026. Spotted an error? Report it.