# OpenAI-Compatible API

- **Canonical URL:** https://getaimath.com/dictionary/openai-compatible-api/
- **Topics:** [AI APIs, Protocols & Integration](https://getaimath.com/dictionary/category/ai-apis-protocols-and-integration/)
- **Last updated:** 2026-11-25

## What is OpenAI-Compatible API?

**In one sentence:** An OpenAI-compatible API is an API that copies the request and response format of OpenAI's API, so the same code works with different providers.

Many tools, like vLLM, Ollama and various hosting services, offer this format. You can often switch providers by changing just the web address and key.

![APIs, JSON & MCP: The Drive-Thru Window & Universal Plug — Simple cartoon showing an App handing a neat checklist order slip (JSON) through a drive-thru window (API) to the AI, while a universal USB-C plug (MCP) connects the AI to Google Drive, Slack, and Email.](https://getaimath.com/diagrams/ai-apis-protocols-and-integration.png)
*Napkin Diagram (AI APIs, Protocols & Integration): An API is the drive-thru window apps use to talk to AI; JSON keeps replies neat; MCP is the universal plug for tools.*

## What is an example of OpenAI-Compatible API?

Pointing an app's base URL at a local Ollama server instead of a cloud service, with no other code changes.

## Why does OpenAI-Compatible API matter?

It reduces lock-in and makes switching models easy.

## Related Concepts

- [Model Endpoint](https://getaimath.com/dictionary/model-endpoint/): A model endpoint is the specific API address or deployment where a particular model can be called.
- [Model Context Protocol (MCP)](https://getaimath.com/dictionary/model-context-protocol-mcp/): The Model Context Protocol is an open standard that lets AI apps connect to tools and data sources in one consistent way.
- [Provider](https://getaimath.com/dictionary/provider/): A provider is a company or service that offers AI models for use, usually through an API.
- [A2A (Agent2Agent)](https://getaimath.com/dictionary/a2a-agent2agent/): A2A, or Agent2Agent, is an open protocol that lets AI agents from different companies and frameworks talk to and work with each other.
- [Context Limits](https://getaimath.com/dictionary/context-limits/): Context limits are the maximum amount of text, in tokens, a model can take in for one request, including the conversation so far.
- [WebSocket](https://getaimath.com/dictionary/websocket/): A WebSocket is a connection that stays open so a client and server can send messages back and forth instantly in both directions.

---
Source: The AI Math Dictionary (https://getaimath.com/dictionary/openai-compatible-api/)
