dm1 CLI
The package ships the library and the dm1 binary together. Node 20 or later.
dm1 reads the key from MS_API_KEY. Pass --key to override it for one call. Without a key the tool exits 2 and prints the shell answer. Get a key in the console.
Help
dm1 <capability> --help prints that capability’s own help, with its arguments, its result fields and its examples.
Worked examples
Each capability’s own help carries its examples. These are they.
Describe your labels. The label text is the instruction, and the model reads it literally. dm1 classify "$T" billing shipping works. dm1 classify "$T" billing="charges and refunds" shipping="delivery and tracking" scores measurably better. Use name=description everywhere. On a terminal, dm1 classify says so when every label arrives bare.
Any list also loads from a file. @labels.json holds an array or a name-to-description object. --tree @taxonomy.json and --schema @invoice.json take a file, an @file, inline JSON, or @- for stdin.
Where the text comes from
One source only, in this order:
A leading - reads stdin explicitly. A trailing newline is a file ending, so dm1 drops it. It would otherwise bill and print.
When a pipe carries the text and the first positional could have carried it too, dm1 writes one line to stderr and names the argument that lost. Pass - to silence it.
Piped JSON becomes the request body
Piped input that starts with { becomes the whole request body. Copy a curl body out of these docs, pipe it in, and add flags:
Flags still win over the body’s own keys, so dm1 replaces a single key rather than the request. A yes-no or answer body with no text and no texts answers 200 and {"results": []} at the API. dm1 refuses that body instead, because nothing downstream can tell it apart from a real answer.
Batches and chunking
--lines and repeated --file send the texts in chunks of 32, the API’s batch limit, in order. This is the one place a client chunks for you, and it says so.
A streaming mode flushes each chunk as it lands, so a later failure still leaves usable output. When a chunk fails, dm1 names the chunk and the text range on stderr, and exits 1. The chunks before it were billed, so --usage still prints their totals.
Output modes
--jsonl writes the input text key after the result’s own fields, so an extracted field named text never takes the join key. A capability that returns a list keeps its envelope on the line: {"text": ..., "results": [...]}.
stdout holds results only. -v, --usage prints the tokens, the model time and the rate limits to stderr:
The requests left value counts inference request units, not HTTP calls. A batch with 24 texts consumes 24 units; text and statement or question counts multiply.
See Limits and rate limits for the limits by key type and production tier.
Exit codes and gates
Three flags turn a decision into an exit code. The result still prints.
--checkworks withyes-noandverifyonly. It exits 3 when the answer is no. In a batch, any no fails the run. A gate that verified nothing has not passed, so an empty result also exits 3.--min <p>exits 3 whenprobabilityfalls belowp.rateandextractcarry no probability, so they refuse the flag.--min-confidence <c>exits 3 whenconfidencefalls belowc.classify,rateandclassify-treecarry one.
dm1 check
dm1 check proves the key, the endpoint and the limits in one small classify of about 20 tokens. It prints a table on a terminal and JSON in a pipe.
Do not run it in a health-check loop. It bills like any other call. See Pricing.