AI gateway
AI gateway routes every model call by Policy, checks cost Limits before the call, and keeps the full request and response.
AI gateway carries every model call a Startup makes. It picks the model by Policy, checks cost Limits before the call, and keeps the full request and response.
Contract
- Four operations: generate, embed, classify and transcribe. Every Agent, Function and Evaluator calls models through them.
- Code names a task class, never a model:
classify,judge,draft,agent,embedortranscribe. - A Policy maps each class to a ranked list of models, cheapest capable first. Policies inherit from Studio to Startup to call, like a Setting.
- Changing a model is a Change to a Policy, never to code.
- A call over its cost Limit waits for an Approval.
- Every request and response is kept forever, with its tokens, latency, Cost and the Task it served.
- Results stream as they generate.
- A Policy can split by Flag, so a cheaper model runs as an Experiment, judged on cost per accepted outcome.
- AI models explains how a Startup chooses and grades its models.
Verbs
None.
Interfaces
Example
// replydesk.io answers support email for small online shops. Its agent names task classes, never models.
import { $ } from 'startup-builder'
await $.Agent.create({
instructions: 'Label each email refund, shipping or other, then draft the reply.',
model: 'draft',
tools: ['Conversation.answer'],
})