Skip to content
Anton GoncharovAI systems developer

Go service · limits · journal

Model gateway

Before a bot answers customers, the model call has to pass through a gateway. Otherwise one bot spends everyone’s budget overnight, and a second click of “send” charges tokens twice. Here three Zerno bots share one entrance. You can see what is left, which call used the backup model and which question hash was written to the journal.

Scenario: Zerno, a fictional roastery: support, leads and the shop bot.

Demo screenshot: Model gateway

Open the demo

The model reply is a local stand-in. Limits, the budget and the journal are written by a Go service to PostgreSQL.

The app runs in your browser: nothing is sent to a server.

What the demo shows

  • POST /v1/chat/completions — the same shape as OpenAI, with a key per bot

  • A per-minute cap and a daily token budget, with the remainder shown as a bar

  • An idempotency key: replaying the request returns the stored reply and does not charge the budget

  • A backup model when the primary one is unavailable: the journal shows which one answered

  • A journal: question hash, token counts, a cost estimate, latency and a trace id

How to try it

  1. Ask support

    “Ask support” calls the gateway with the support bot’s key. A row with the reply and the cost appears in the journal.

  2. Replay it

    “Replay the request” sends the same idempotency key. The budget does not decrease a second time.

  3. Use the backup model

    “Fallback model” marks the primary one unavailable. The journal row ends at zerno-small.

  4. Hit the limit

    “Five lead requests” — the leads bot allows 4 per minute, and the fifth is refused. “Spend the leads budget” uses up the daily budget, and the next call does not go through.

No paid neural networks

The reply text is a local stand-in, with no paid model call. Keys, limits, the budget, the journal and the OpenTelemetry trace are real and kept by the Go service.

The demo runs without OpenAI, YandexGPT or GigaChat API keys. Wherever a production system calls a model, there’s a local stub with the same interface — so the demo is free, always available and never makes things up.

What a production project adds

  • Real model providers behind the same entrance, with their own prices and a backup route
  • Keys for teams and projects, rather than three demo bots
  • The journal and traces in an OpenTelemetry collector
  • A separate budget per bot, per team and per day

Stack

  • Go
  • net/http
  • pgx
  • sqlc
  • goose
  • PostgreSQL
  • OpenTelemetry
  • slog
  • React 19

Want the same for your business?

Tell me about your task — I’ll tell you what from the demo fits, how long it will take and what I’ll need from you.

Other demos in this section

All demos
  • Web app · OCR · validating company details

    live

    Document recognition

    Upload an invoice or a certificate of completion — a photo, scan or PDF. The app recognizes the text, extracts company details and table rows and validates them: tax ID and account checksums, the total and VAT.

    • React
    • TypeScript
    • In-browser neural network
  • Web app · conversations · deals · analytics

    live

    Operator panel

    The workspace of an operator who receives difficult requests from a bot: a queue with a timer, a conversation summary, a reply draft, deals on a kanban board and analytics — on a live stream of customers.

    • React
    • TypeScript
  • Web app · Recharts · RBAC · audit

    live

    SaaS dashboard

    A SaaS revenue team’s workspace: MRR by plan, revenue movement, churn, customer health, CSV export for Excel and an activity log. All numbers are calculated from a single year of history — changing a plan in a customer card moves MRR on the charts immediately.

    • React
    • TypeScript
  • Web app · Laravel · PostgreSQL

    live

    Warehouse system on Laravel

    Warehouse accounting where stock is the sum of ledger entries, not a “qty--” field: orders with all-or-nothing reservation, picking by bin, receiving with CSV import, stocktaking and a ledger. A race between two real PHP processes in PostgreSQL shows why row locking is needed.

    • PHP
  • Web app · metrics · alerts

    live

    Bot monitoring

    How a bot is watched in production: how many requests, how fast it answers, how often it fails or doesn’t know the answer. A request log with a trace of every answer and rules that message the on-call engineer in Telegram when something goes wrong.

    • React
    • TypeScript
  • Go service · queue · approval

    live

    Purchasing agent

    A supplier request moves in steps through a queue: check stock, build a draft, wait for a person, and only then send. A cut-off send returns to the queue and does not create a second order.

    • Go
    • React
    • TypeScript
  • Go service · MCP · tools

    live

    Zerno MCP server

    An agent calls the roastery’s stock and orders through Model Context Protocol tools: stock, order status, a new lead. The JSON-RPC exchange is shown beside it.

    • Go
    • React
    • TypeScript
  • Python scraper · runs in the browser

    live

    Competitor price monitoring

    A Python scraper crawls the websites of three competitors of an electronics store every day: an HTML catalog with pagination, a sitemap with JSON-LD and an SPA with an API. It matches products with the catalog, sends notifications about changes, recommends a price by rules and exports a report to Excel. Python runs right in the browser.

    • Python
    • React
    • TypeScript
  • Web app · PWA · vanilla JS

    live

    Offline courier app

    A courier’s working day: orders, a call to the customer, handover with a photo and signature. The app opens and works without a network, and changes go to dispatch when the connection returns. If the dispatcher changed the same order in the meantime, the courier chooses which version is right.

    • Vanilla JS