Performance & cost
This session
- Delivery time · median
- —
- Live model compute
- —
- Live input tokens
- 0
- Est. cost · USD
- $0.00
Free examples. Switch on to measure live inference with your key and quota.
Measurement details · 0 successful requests
- Successful requests
- 0
Run an example for free to see its measurements.
Model compute is the average per measured request. Delivery time is the median browser time for successful requests, including queue, network, and retries. Cached delivery speed is not inference speed. Model compute can exceed browser time when one request processes many inputs.
Tokens come from response headers. Inference costs use $0.04 per million input tokens, before plan credits. The estimate includes live and recorded tokens at the same rate; cached examples are not charged again. Missing usage is unavailable or a partial total (≥). Demo resets keep these totals; reload to start a new session.
Pick a photo and classify it.
Build with the SDKTypeScript · Python · dm1
One request from this demo. Copy it into your app.
Uses your MS_API_KEY and quota. Keep the key on your server.
npm install @cloudraker/milliseconds
export MS_API_KEY="your-api-key"import { readFile } from "node:fs/promises";
import { DecisionMachine } from "@cloudraker/milliseconds";
// Run on your server; reads MS_API_KEY from the environment.
// The image carries the input; the leading text is optional context.
const dm = new DecisionMachine();
const { result, usage } = await dm.classify(
await readFile("image.jpg"),
{
"glass": "A glass bottle, jar, drinking glass or other glass object.",
"paper": "Ordinary paper, newspaper, office paper or a paper flyer.",
"cardboard": "A cardboard box, corrugated board or thick cardboard packaging.",
"plastic": "A plastic bottle, rigid plastic container or plastic packaging.",
"metal": "A metal food can, drink can, lid or other metal object.",
"trash": "Other waste or mixed-material packaging, such as a coated disposable coffee cup or flexible food pouch."
},
{ detail: "low" }
).withUsage();
console.log(result);
console.log({ inputTokens: usage.inputTokens, modelMs: usage.inferenceMs });pip install cloudraker-milliseconds
export MS_API_KEY="your-api-key"from pathlib import Path
from milliseconds import DecisionMachine
# Reads MS_API_KEY from the environment.
# The image carries the input; the leading text is optional context.
dm = DecisionMachine()
result = dm.classify(
Path("image.jpg").read_bytes(),
{
"glass": "A glass bottle, jar, drinking glass or other glass object.",
"paper": "Ordinary paper, newspaper, office paper or a paper flyer.",
"cardboard": "A cardboard box, corrugated board or thick cardboard packaging.",
"plastic": "A plastic bottle, rigid plastic container or plastic packaging.",
"metal": "A metal food can, drink can, lid or other metal object.",
"trash": "Other waste or mixed-material packaging, such as a coated disposable coffee cup or flexible food pouch."
},
detail="low"
)
print(result)npm install -g @cloudraker/milliseconds
export MS_API_KEY="your-api-key"# Reads MS_API_KEY. The image and the other fields are read from disk.
cat > classify-labels.json <<'DM1_LABELS'
{
"glass": "A glass bottle, jar, drinking glass or other glass object.",
"paper": "Ordinary paper, newspaper, office paper or a paper flyer.",
"cardboard": "A cardboard box, corrugated board or thick cardboard packaging.",
"plastic": "A plastic bottle, rigid plastic container or plastic packaging.",
"metal": "A metal food can, drink can, lid or other metal object.",
"trash": "Other waste or mixed-material packaging, such as a coated disposable coffee cup or flexible food pouch."
}
DM1_LABELS
dm1 classify --image image.jpg --detail low --labels @classify-labels.json --json --usageUnder the hood How it works & limitations
API calls/classify
Sort by what the camera sees
Use material classification to triage collection photos or flag uncertain items for a sorting operator. One image goes to /classify with six described labels.
A material label is not a recycling instruction
TrashNet photographed single objects against a light background. A cluttered conveyor belt, dirty container or mixed-material package is a different task. Local collection rules still decide what belongs in each bin.
Real photos, original labels
These twelve unmodified photos come from TrashNet by Gary Thung and Mindy Yang, shared under the MIT license. Each photo links to its source archive and identifies its original filename. The dataset labels are comparison points, not predictions.
Image dataset license
MIT License Copyright (c) 2017 Gary Thung Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.