A unified, self-hosted AI gateway
for decisions your code can use.
Get classifications, yes/no answers and scores through a single API. Switch models without changing your application code.
Single-owner OpenAI-shaped Built with Bun
Your app
POST /v1/decisions
- model
support- input
- I got charged twice for my March invoice. Please refund the extra charge.
- questions
team,refund,urgency
Route support
- OpenAI
gpt-6-lunatimeout - TypeSafe
jev-1.14answered
Answer200
teambillingprobability 0.40refundyesprobability 0.89urgencyscorescore 0.87 on a scale from 0 to 2
Illustration: your app sends POST /v1/decisions with the route name support. The first step, OpenAI gpt-6-luna, times out, so dgateway tries the next step, TypeSafe jev-1.14, which answers. The response gives each answer, the provider and model that answered, the cost in US dollars and both attempts.
What is a decision model?
A decision model, such as Jev, gives your code an answer it can use directly: a category, a yes or no, or a score. OpenAI offers decision models through its Decisions API.
In the console, choose a native decision API or a compatible chat connection. Compatibility depends on the model and host:
- OpenAI
- OpenRouter
- TypeSafe
- Another hosted vendor
- A model on your own machine via Ollama or vLLM
Try it on your machine.
No API key needed.
A new install has a test route named default. It answers with a built-in mock instead of a real model, so you need no API key. Connect real providers when you are ready.
docker run -d --name dgateway \
-p 127.0.0.1:8790:8790 \
-v dgateway-data:/data \
--add-host host.docker.internal:host-gateway \
-e ADMIN_TOKEN=replace-with-a-long-random-token \
-e GATEWAY_SECRET=replace-with-a-separate-stable-secret \
ghcr.io/buddylabsai/dgateway:latestBefore you use it beyond a local trial, replace the ADMIN_TOKEN and GATEWAY_SECRET values with two different long random strings. Keep GATEWAY_SECRET the same over time: it encrypts the provider keys you store. Follow the setup guide
How routing works
Your app sends a route name in the model field. A route is a list of steps in order. Each step names a provider and a model. dgateway tries the first step. If that call fails, it tries the next one.
dgateway moves to the next step after a missing key, a timeout, a network error, a malformed answer, an upstream HTTP error or a request over the provider's limits. An upstream HTTP 400 or 422 stops the route instead.
POST /v1/decisions- Try first
- If needed
A request follows the route, trying providers in order.
Illustration: if the first provider fails, the request continues to the next provider, then returns an answer with usage, cost and attempts.
One endpoint.
Three kinds of answer.
Ask for a category, a yes or no, or a score. One response holds the answers, the token usage and the cost when known. confidence is not proof that an answer is right. Test your provider, model, instructions and thresholds on examples you have labelled yourself before you rely on them.
dgateway has no chat-completions endpoint, so chat apps and code editors cannot use it as a model server. It can still call chat models to answer decision questions. It does not choose the best model for a task. You choose the providers and their order, and you test them.