induwara.lk
induwara.lkDeveloper · AI APIs

OpenAI-Compatible API Base URL Cheatsheet

The exact base_url, auth header and a working OpenAI SDK snippet for 15 providers — OpenAI, Azure, Anthropic, Gemini, Groq, DeepSeek, xAI, OpenRouter and local runtimes. Switch providers by changing three lines. No signup, keys never leave your machine.

By Induwara AshinsanaUpdated Jul 8, 2026
OpenAI-Compatible Base URLs
15 providers · docs cited

Pick a provider to get its drop-in base_url, auth header and a working client-init snippet. No keys entered, fully client-side.

Snippet format
Base URL
https://api.openai.com/v1
Auth header
Authorization: Bearer <OPENAI_API_KEY>
Full compatibilityValid HTTPS endpoint.
OpenAI · Python SDK
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.openai.com/v1",
    api_key=os.environ["OPENAI_API_KEY"],
)

response = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)
  • The reference implementation — every other row targets this schema.
  • Chat endpoint resolves to https://api.openai.com/v1/chat/completions

All providers

ProviderBase URLCompatDocs
https://api.openai.com/v1
FullDocs
https://{resource}.openai.azure.com/openai/v1/
PartialDocs
https://api.anthropic.com/v1/
Chat onlyDocs
https://generativelanguage.googleapis.com/v1beta/openai/
PartialDocs
https://api.groq.com/openai/v1
FullDocs
https://api.together.xyz/v1
FullDocs
https://api.fireworks.ai/inference/v1
FullDocs
https://api.deepseek.com
FullDocs
https://api.mistral.ai/v1
Chat onlyDocs
https://api.x.ai/v1
FullDocs
https://openrouter.ai/api/v1
FullDocs
https://api.perplexity.ai
Chat onlyDocs
http://localhost:11434/v1
PartialDocs
http://localhost:1234/v1
FullDocs
http://localhost:8000/v1
FullDocs

9 of 15 (60%) are full OpenAI-schema compatible; the rest are chat-completions-only or need minor setup.

How it works

Most modern LLM providers expose an OpenAI-compatible endpoint: the same /chat/completions request and response shape that the official OpenAI SDKs speak. That means you can move an app from OpenAI to a cheaper, faster or self-hosted provider by changing only three things — the base_url, the API key, and the model name. Your request-building and response-parsing code stays identical.

This page is a lookup table, not a calculator. Each provider is a static record — { name, baseUrl, authHeader, envVar, exampleModel, quirks, docUrl, compat } — transcribed from that provider's own official documentation, which is the single citeable source for its base URL. Every row links back to that doc so any value can be re-verified in one click, and the file records a LAST_VERIFIED date (2026-07-08).

The snippet for each provider is generated purely by templating the selected record into a Python, Node or curl skeleton — no computation and no randomness, so the same provider always yields the same code. To keep the reference internally honest, two deterministic checks run on every row. First, the chat endpoint is derived from the base URL exactly as the SDKs do: strip a single trailing slash, then append /chat/completions. That is why Gemini's trailing-slash base URL does not produce a double slash, and DeepSeek's base URL without a /v1 segment still resolves correctly. Second, each base URL is parsed and classified as HTTPS, a local runtime, or a template that still contains a {placeholder} — which is how Azure's {resource} URL is flagged rather than shown as ready-to-run.

The compattag on each row — Full, Chat only or Partial — is taken from the provider's own compatibility statement. Chat completions work everywhere listed; other endpoints and parameters (embeddings, tool calling, logprobs, streaming usage) vary, so the tag tells you when to read the linked docs before depending on a feature. No API key is ever entered, transmitted or stored: snippets read the key from an environment variable, keeping the page fully client-side and safe to use anywhere.

Worked examples

Groq → Python

  1. Select Groq. base_url = https://api.groq.com/openai/v1
  2. Endpoint derived: strip trailing slash (none) + /chat/completions
  3. → https://api.groq.com/openai/v1/chat/completions
  4. Auth: Authorization: Bearer $GROQ_API_KEY
  5. client = OpenAI(base_url=..., api_key=os.environ["GROQ_API_KEY"])
  6. model="llama-3.3-70b-versatile" — matches Groq’s OpenAI doc ✓

Google Gemini → curl (trailing-slash edge case)

  1. base_url = https://generativelanguage.googleapis.com/v1beta/openai/
  2. The base URL ends in a slash — the SDK strips exactly one before appending
  3. → .../v1beta/openai/chat/completions (no double slash)
  4. Quirk: keep the /v1beta/openai/ suffix, not generateContent
  5. model="gemini-2.5-flash" — matches Google’s compat doc ✓

Azure OpenAI → template + extra query (edge case)

  1. base_url = https://{resource}.openai.azure.com/openai/v1/
  2. Verify: contains {resource} → flagged as a template, not ready-to-run
  3. Replace {resource}; pass deployment name as the model
  4. Add default query api-version=preview (included in the snippet)
  5. Endpoint → https://<resource>.openai.azure.com/openai/v1/chat/completions?api-version=preview ✓

Frequently asked questions

Sources & references

Each base URL is transcribed from the provider's own official documentation — the citeable source of truth for its OpenAI-compatible endpoint:

All 15 base URLs were last cross-checked against these docs on 2026-07-08. Providers occasionally change paths or add compatibility, so each row links to its live doc for one-click re-verification.

Related tools

Rate this tool
Be the first to rate

Comments & feedback

Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.

Spotted a base URL that changed, or a provider we should add?

Email me at [email protected] — most fixes ship within 24 hours.