A minimal CrewAI starter that shows how to wrap your agents with MachineID device registration and validation.
Use this template to prevent runaway fleets, enforce hard device limits, and ensure every CrewAI worker checks in before doing work.
The free org key supports 3 devices, with higher limits available on paid plans.
CrewAI installs most reliably on Python 3.11.
Python 3.12 / 3.13 / 3.14 may fail due to ecosystem-level constraints (PyO3, tokenizers, and transitive dependencies).
Recommended installation:
python3.11 -m venv venv311
source venv311/bin/activate
pip install -r requirements.txt-
crewai_agent.py:- Reads
MACHINEID_ORG_KEYfrom the environment - Uses a default
deviceIdofcrewai:agent-01(override withMACHINEID_DEVICE_ID) - Calls POST
/api/v1/devices/registerwithx-org-keyand adeviceId - Calls POST
/api/v1/devices/validatebefore starting the Crew - Enforces a hard gate:
- If
allowed == false, execution stops immediately
- If
- Prints stable decision metadata:
allowedcoderequest_id
- Reads
-
A minimal
requirements.txtusing only:crewairequests
This mirrors the same register + validate enforcement pattern used in the Python starter and other MachineID templates.
git clone https://github.com/machineid-io/crewai-machineid-template.git
cd crewai-machineid-templatepython3.11 -m venv venv311
source venv311/bin/activate
pip install -r requirements.txtVisit https://machineid.io
Click “Generate free org key”
Copy the key (it begins with org_)
export MACHINEID_ORG_KEY=org_your_org_key_here
export OPENAI_API_KEY=sk_your_openai_key_hereOptional override:
export MACHINEID_DEVICE_ID=crewai:agent-01One-liner:
MACHINEID_ORG_KEY=org_xxx OPENAI_API_KEY=sk_xxx python crewai_agent.pypython crewai_agent.pyYou will see:
- A register call
- A validate decision
- Either:
allowed=true→ CrewAI startsallowed=false→ process exits immediately
- Reads
MACHINEID_ORG_KEYfrom the environment - Uses a deterministic
deviceId(crewai:agent-01) - Calls
/api/v1/devices/register(idempotent):ok→ new device createdexists→ device already registered
- Calls
/api/v1/devices/validate(POST, canonical):allowed: true→ CrewAI may runallowed: false→ process must exit
There is no restore, grace period, or soft failure path.
Validation is a hard enforcement boundary.
To integrate MachineID:
- Register once when the worker starts
- Validate immediately before
crew.kickoff() - Exit immediately if
allowed == false
This pattern prevents:
- Accidental scaling
- Infinite worker spawning
- Uncontrolled cloud spend
- Runaway agent behavior
Drop the same register + validate block into any CrewAI worker or task runner.
crewai_agent.py— CrewAI worker with hard-gate enforcementrequirements.txt— Minimal dependenciesLICENSE— MIT licensed
Dashboard → https://machineid.io/dashboard
Generate free org key → https://machineid.io
Docs → https://machineid.io/docs
→ Python starter: https://github.com/machineid-io/machineid-python-starter
→ LangChain: https://github.com/machineid-io/langchain-machineid-template
→ OpenAI Swarm: https://github.com/machineid-io/swarm-machineid-template
- Plans are per org, each with its own
orgApiKey - Device limits apply to unique
deviceIdvalues registered through/devices/register - Plan changes take effect immediately — no agent code changes required
MIT licensed · Built by MachineID