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 | |
|---|---|
ID | The Meted request id, also returned as x-meted-request-id |
TASK | Task type the engine identified |
ACTUAL | Output tokens the provider generated |
TARGET | The engine's estimate of the tokens the answer needs |
DIFF | The difference between actual and target, as a percentage of actual |
TOTAL | End-to-end request latency |
ALLOCATION | What 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
The gateway has no authentication of its own. Anyone who can reach it can
spend your provider credits. It binds 127.0.0.1 by default. If you bind it
to a routable address, put it behind something that authenticates.
Environment overrides
| Variable | |
|---|---|
METED_MODE | observe, conservative, balanced, aggressive |
METED_PORT, METED_HOST | Where to listen |
METED_PROVIDER_BASE_URL | Upstream provider |
METED_ENGINE_MODULE, METED_ENGINE_WASM | Which 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.