Local development

Run the gateway locally.

meted dev
Meted 0.1.0  →  http://127.0.0.1:8787/v1

  Mode        observe    Compute and report the allocation. No ceiling is set on the request.
  Engine      baseline-heuristic 0.1.0 (open source, baseline)
  Provider    openai     https://api.openai.com/v1
  Credential  OPENAI_API_KEY is set

  const client = new OpenAI({ baseURL: "http://127.0.0.1:8787/v1" });

ID    TASK          ACTUAL  TARGET    DIFF    TOTAL  ALLOCATION

The live log

Every request through the gateway prints a line:

a19f  definition       184      38    -79%    902ms  observe_mode
b91c  coding           722     680     -6%    3.1s   applied 960
7daa  fact              91      18    -80%    410ms  observe_mode
Column
IDThe Meted request id, also returned as x-meted-request-id
TASKTask type the engine identified
ACTUALOutput tokens the provider generated
TARGETThe engine's estimate of the tokens the answer needs
DIFFThe difference between actual and target, as a percentage of actual
TOTALEnd-to-end request latency
ALLOCATIONWhat was applied, or why nothing was

A response with finish_reason: "length" is flagged truncated. An engine failure is flagged engine:<kind>. Use --quiet to turn the log off.

The log goes to stdout. Redirect it to keep it:

meted dev | tee meted.log

To collect the same fields as structured data, embed the gateway and use onRecord.

Options

meted dev --port 3001              # a different port
meted dev --host 0.0.0.0           # bind all interfaces, see the warning below
meted dev --mode balanced          # try a mode without changing the config
meted dev --quiet                  # no per-request log

Environment overrides

Variable
METED_MODEobserve, conservative, balanced, aggressive
METED_PORT, METED_HOSTWhere to listen
METED_PROVIDER_BASE_URLUpstream provider
METED_ENGINE_MODULE, METED_ENGINE_WASMWhich Sufficiency Engine to load

These win over meted.config.json, so one committed config can behave differently per environment.

Health

curl http://localhost:8787/_meted/health
{
  "ok": true,
  "version": "0.1.0",
  "mode": "observe",
  "engine": {
    "name": "baseline-heuristic",
    "proprietary": false,
    "source": "baseline"
  },
  "provider": { "id": "openai", "credentialPresent": true }
}

Stopping it

Ctrl-C stops the listener and lets in-flight requests finish streaming, so their token counts come from the provider rather than an estimate.

Was this page helpful?