Quickstart

Optimal API speaks the OpenAI chat API. Create a key, then call the API origin. Streaming and non-streaming requests use the same path.

List models

curl http://localhost:8000/v1/models \
  -H "Authorization: Bearer $API_KEY"

Chat completion

curl http://localhost:8000/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-4o-mini","messages":[{"role":"user","content":"Hello"}]}'

Auto routing

curl http://localhost:8000/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"auto","messages":[{"role":"user","content":"Hello"}]}'

auto, auto:cheap, auto:balanced, and auto:best pick a model for the task. The response names it in model and x-routed-model. A non-stream response also includes x-estimated-savings-micros. That savings figure compares the served price with an estimated premium baseline.

Workflows

curl http://localhost:8000/v1/workflows/from-template \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"template":"summarise_document"}'

Templates are customer support triage, document summarisation, and data extraction. Run a saved workflow with POST /v1/workflow-runs. Set stream to true for step events. Each model step uses the same router and billing as chat. The portal builder is on /workflows, and organisation controls are on /org. Token savings (response cache, trimming, compression, batch discount) stay off until the organisation turns them on. Volume discounts, committed spend, and dedicated rate limits are set by an operator. Measured amounts are on Savings and performance, with a monthly CSV and PDF report. The pricing page calculator is an estimate from platform averages.

Streaming

curl http://localhost:8000/v1/chat/completions \
  -N \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-4o-mini","stream":true,"messages":[{"role":"user","content":"Hello"}]}'

Set stream to true. The response is server-sent events, the same shape OpenAI clients expect. Balance is reserved before the call and settled from the usage that was delivered.