The OpenAI API in open-source AI tools: how self-hosted apps connect to GPT models in 2026
Why the OpenAI format won
When ChatGPT launched, OpenAI's API was the only widely available way to call a strong language model from code. Developers wrote thousands of libraries, plugins and apps against its /v1/chat/completions endpoint, with a list of messages in and a message out. Later providers copied the format so those apps would work with them without changes. By 2026 the shape is a de facto standard: Ollama, LocalAI, vLLM, Groq, Mistral, Google's Gemini API, DeepSeek and gateways such as LiteLLM and OpenRouter all accept it.
OpenAI itself has moved on to the Responses API, which handles tools, files, web search and multi-turn state in one call, and recommends it for new projects. Chat Completions remains supported, and it is still what most open-source apps use, because that is the format every other provider copies.
Which directory projects use it
| Project | How it uses the OpenAI API |
|---|---|
| LibreChat | OpenAI as a default endpoint, plus any OpenAI-compatible endpoint in librechat.yaml |
| LobeChat | OpenAI provider, with a custom base URL option |
| Open WebUI | "OpenAI API" connections that work for any compatible server |
| Dify | Model provider plugin for chat, embeddings and speech |
| Langflow | OpenAI components for models and embeddings in visual flows |
| LiteLLM | Translates requests to and from OpenAI's format for 100+ providers |
Current pricing
OpenAI publishes per-token prices on its pricing page. As of October 2026:
| Model | Input per million | Cached input | Output per million |
|---|---|---|---|
| GPT-6.1 Sol | $2.00 | $0.10 | $10.00 |
That price applies to prompts under 272,000 tokens; longer prompts cost more. GPT-6.1 Sol launched on September 29, 2026, and OpenAI described it as close to its larger Astra model at about one fifth of the price. Smaller and older models remain available at lower rates. Two discounts matter for self-hosted apps:
- Prompt caching. When the start of a prompt repeats, such as a long system prompt or a document, OpenAI bills the repeated part at the cached rate, a 95% discount on GPT-6.1 Sol.
- Batch API. Jobs that can wait up to 24 hours, such as tagging thousands of support tickets, run at a discount through the Batch API.
On September 10, 2026, OpenAI added GPT-Live-1 to the API for full-duplex voice conversations, priced at $0.05 a minute for the front-end voice model, with harder reasoning handed off to other models.
What a month costs
Token counts vary widely, so treat these as rough examples at GPT-6.1 Sol rates.
| Use | Monthly tokens | Rough cost |
|---|---|---|
| One person chatting daily | 2M in, 0.5M out | About $9 |
| Team of 20 on LibreChat | 40M in, 10M out | About $180 |
| Document Q&A bot, 5,000 questions | 50M in (mostly cached), 2M out | About $25 to $120 depending on cache hits |
Input usually outweighs output in chat apps, because each turn resends the whole conversation. Long conversations get more expensive with every message, which is why many apps trim or summarize history.
Setting up a key safely
- Create a project on platform.openai.com for each app or environment, and generate a key inside it. Project keys can be limited to specific models and endpoints.
- Set a monthly budget and email alerts on the project.
- Store the key in an environment variable or secret manager, never in the app's front-end code or a public repository. Leaked keys are scraped from GitHub within minutes.
- In self-hosted apps, prefer server-side keys. LibreChat and Open WebUI keep the key on the server; letting users paste their own key is optional.
- Rotate the key if anyone who had access leaves.
Pointing the same app at another provider
Because the format is shared, the switch usually takes two settings: the base URL and the key.
| Provider | Base URL |
|---|---|
| OpenAI | https://api.openai.com/v1 |
| Ollama (local) | http://localhost:11434/v1 |
| Groq | https://api.groq.com/openai/v1 |
| Mistral | https://api.mistral.ai/v1 |
| LiteLLM proxy | http://your-proxy:4000 |
Differences remain in the details. Tool calling, structured outputs, image inputs and streaming behave slightly differently across providers, and some parameters are ignored. Test the features you depend on before switching a production app.
Data handling
OpenAI states that API data is not used for training by default and is kept for up to 30 days for abuse monitoring, with zero data retention available to approved customers. Business customers can sign a data processing agreement, and data residency options exist for some regions. For data that must never leave your network, the same apps can run against a local model through Ollama instead.
Rate limits
New accounts start at a low usage tier with modest tokens-per-minute limits, and limits rise automatically as you spend more over time. A team rolling out a chat app to many people at once can hit these limits on day one. Check your tier in the dashboard before launch, and use a gateway with retries and fallbacks so a 429 error from OpenAI routes the request to another model rather than failing.
Tools and structured outputs
Most agent features in open-source apps rely on two API features. Function calling lets the model return a request to run a named tool with JSON arguments, which the app executes and sends back. Structured outputs force the reply to match a JSON schema you supply, so a ticket classifier always returns valid fields instead of prose. Both work across OpenAI models and are copied by most compatible providers, though support for strict schema matching varies. Dify and Langflow use function calling under the hood for their agent nodes, and LibreChat's agents use it to call web search, code execution and MCP tools.
Moving to the Responses API
OpenAI's newer Responses API keeps conversation state on OpenAI's side, runs built-in tools such as web search and file search, and returns reasoning summaries. It suits apps built only for OpenAI. For self-hosted apps that switch between providers, Chat Completions stays the safer shared format, because few other providers implement Responses. If you write your own app, keep provider calls behind one small module so a later change to Responses, or to another vendor, touches one file.
When to use something else
If cost is the main concern, open-weight models through Groq or a local Ollama server cost far less per token. If you prefer Claude's writing and coding, the Anthropic API is a direct alternative. If you want the option to switch at any time, put LiteLLM in front and keep every app speaking one format.
Related: Anthropic API stack, LiteLLM stack, ChatGPT alternatives, LibreChat, Stack index.
Frequently asked questions
Why do so many open-source apps support the OpenAI API?
OpenAI's Chat Completions format arrived first and was widely copied. Ollama, LocalAI, Groq, Mistral, Google, DeepSeek, vLLM and most gateways now accept requests in the same shape, so supporting it once gives an app access to dozens of providers.
How much does the OpenAI API cost?
It is billed per token and varies by model. GPT-6.1 Sol costs $2 per million input tokens and $10 per million output tokens, with cached input at $0.10. Smaller models cost less. A million tokens is roughly 750,000 English words, so a typical chat exchange costs a fraction of a cent.
Is a ChatGPT subscription the same as API access?
No. ChatGPT Plus and Pro are consumer subscriptions for the ChatGPT app. The API is billed separately on platform.openai.com with prepaid credits, and you need an API key from there to use self-hosted apps such as LibreChat.
Does OpenAI train on API data?
OpenAI states that it does not train on data sent through the API by default. API inputs and outputs may be kept for up to 30 days for abuse monitoring, and eligible customers can request zero data retention.
How do I stop a self-hosted app from running up a large bill?
Set a monthly budget and usage alerts in the OpenAI dashboard, create a separate project with its own key for each app, and use a gateway such as LiteLLM to set per-user budgets and rate limits. Prepaid credit billing also caps spend at the amount you load.