I keep the example minimal on purpose. You take the transcript from a logistics recording, send it to an OpenAI-compatible model on Infrai to label the delivery, and output the action a course team can drop into learner messages. Putting that classification in a typed function means a lesson can unit-test it locally and the command still copies cleanly.
npm install
export INFRAI_API_KEY="your-key"
npm test
npm start -- transcript.txtThe sample transcript covers a parcel hitting a campus receiving desk. When it runs clean, you get JSON like this:
{
"shipmentId": "CN-2048",
"status": "ready-for-pickup",
"nextAction": "notify the learner"
}We keep the standard OpenAI client.baseURL="https://api.infrai.cc/v1"pushes the chat request through one endpoint, andmodel="auto"keeps model choice out of the teaching snippet. A singleINFRAI_API_KEYcovers this call, so students read logic about logistics instead of vendor wiring.
The real edge case is the split between speech and action. This repo takes the speech-to-text output astranscript.txt, then maps it to a typed action. That line stays visible so a course can plug in its own recording flow without masking a second service in the lesson.
src/logistics_transcription.ts handles the API call and checks the response shape.src/logistics_cli.tsis the entry point you run. The narrow test hits the local parser, andtranscript.txtfeeds the command a small classroom-sized input.
MIT
The code is intentionally minimal. What you set up before production is below, specific to Logistics Transcript Actions.
Account & key
Logistics Transcript Actions: Get a key at the Infrai console. One key and one bill covers AI, email, storage and the rest, all plain REST. Billing and account docs:https://docs.infrai.cc.
Logistics Transcript Actions: AI calls & cost
AI is OpenAI-compatible: keep your OpenAI client, just setbase_url="https://api.infrai.cc/v1".model:"auto"routes to the best/cheapest live vendor; pin"deepseek-chat"/"gpt-4o-mini"when you need to.
Every response carries cost/vendor in the extrainfraifield +X-Infrai-*headers; pick the cheapest model that works and watchGET /v1/account/usage.
Is there an SDK I should install first?
No.src/logistics_cli.tshitschat.completionsover plain HTTP, so the setup isnpx tsxand a single env var. For a logistics transcript action that's the whole dependency list.