Skip to content

OpenAI API

aigate edited this page Sep 15, 2026 · 2 revisions

OpenAI API πŸ”Œ

You've wired a model into your own script before, and it never ends. A vendor key in one file, an address in another, a model name hard-coded where you'll forget it. So you point the script at something that won't move: aigate answers on one local address, in the request shapes your code already speaks, and which provider replies is just a field you change per call. Nothing to install on the calling side.

One address, one port πŸšͺ

http://localhost:8080/v1

Same app and same port as the screen you've been clicking. Move it with AIGATE_PORT=9090 and both move together β€” there is only ever one port. (The host and port on an endpoint are a label for your own notes, not a second door.)

The paths that answer 🎯

  • GET /v1/models β€” what you can aim at right now, built live from your providers and combos
  • POST /v1/chat/completions β€” the familiar one
  • POST /v1/responses β€” OpenAI's newer responses shape
  • POST /v1/messages β€” the Anthropic Messages shape, too
  • POST /v1/messages/count_tokens β€” its token counter

So "OpenAI-compatible" here means plain enough that any client speaking that JSON works β€” and a client speaking Anthropic's shape is accepted on the same address. The Anthropic path answers in full for now, not streaming.

The model field is how you aim 🧭

Send a combo you set up β€” combo:my-combo β€” and if it holds several providers, the top one answers first, and a failure rolls on to the next (Providers & Combos). Or copy any id straight from GET /v1/models. Or just send a bare model name: aigate finds an enabled provider that offers it, and if more than one does, it picks the provider you marked as the one in use.

curl http://localhost:8080/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model":"combo:my-combo","messages":[{"role":"user","content":"hello"}]}'

The reply comes back in the same style your client expects β€” the short version:

{"choices":[{"message":{"content":"Hi there."}}],"usage":{"total_tokens":18}}

Send "stream":true to OpenAI-shape providers and it flows in pieces instead. Bodies follow the usual fields β€” model, messages, temperature, max_tokens. Prefer Python? The official OpenAI library works once you point its base URL here β€” a third-party library, not part of aigate.

The key you might need πŸ”‘

Turn an endpoint's access key on and send it as Authorization: Bearer <key> β€” or x-api-key, the header Anthropic clients use. Leave it off and the API is open to anyone who can reach that port: same network, same airport. That's the Quick Start cafΓ© warning again. Configuration and Keys sets it.

Nothing slips past the books 🧾

Every call from your own code is recorded like any other β€” tokens in, tokens out, an estimated cost. Pointing a script at aigate isn't going around it.


🧭 aigate wiki

Start here

Set it up

Every way to use it

Clone this wiki locally