Machines quickstart
Machines are in beta. The routes and the objects can change before general availability.
This page saves a Machine that posts a supplier invoice to an ERP, then runs it. Your system is the ERP: you send the output of each tool call by hand. You need curl, jq and an API key with the scopes machines and machines:write. Read API keys.
Write the procedure and the tools
The procedure finds the vendor, then posts the invoice. The post is irreversible, so it has "limit": 1 and a check before it.
Lint the procedure
A lint costs nothing and saves nothing.
Remove "limit": 1 from the step post and lint again. The answer is still 200, with ok: false and the diagnostic irreversible-limit. Read the lint codes.
Send the output of the vendor lookup
Your system finds the vendor. Send the output with the id of the tool call:
The answer is the run at its next stop. It waits for the post:
To see the refusal path, send an error output instead: {"tool_call_id": "…", "is_error": true, "output": {"code": "vendor_not_found", "message": "No vendor."}}.
The same loop in TypeScript
This script runs the Machine and answers each tool call with a function of your system. It uses fetch only, so it runs in Node 20 or later, Bun, Deno and Cloudflare Workers.
A tool call can arrive again, for example after a timeout. Use idempotency_key as the idempotency key of your system. It is the same for each attempt of a step. Use the tool call id only when each attempt must run. Read Run a tool call.
Next steps
- Learn the run loop, holds and inputs: Machines.
- Write your own procedure: Machine language.
- Run the Machine from an OpenAI SDK: OpenAI compatible API.
- Get the
needs_inputevents in the background: Webhooks.