Skip to main content
This recipe builds a small but complete workspace: a connector feeds a model, a tool enriches a record, an agent reasons over the data, and a play runs a workflow as rows change. Then you deploy it all with one command and run it. Every snippet uses the same define* builders documented in Resources. It matches the tree scaffolded by cargo-ai cdk init <dir> --template full (see Project layout).

1. Connect

Define the source system and the LLM provider. Use secret() for API keys, or adopt: true for a connector authorized via OAuth in the app.
connectors/hubspot.ts
connectors/openai.ts

2. Model

Source a model from the connector’s dataset with an extractSlug. Discover the valid slugs and config with cargo-ai cdk types or cargo-ai connection integration get <slug>.
models/contacts.ts

3. Tool

A tool is a workflow you can run on demand. Build the workflow with defineWorkflow, then wrap it in defineTool.
tools/enrich.ts

4. Agent

An agent reasons over the models, tools, and connector actions you hand it. Pass handles — Cargo deploys dependencies first and injects their uuids.
agents/sdr.ts

5. Play

A play runs a per-row workflow as the model’s rows change.
plays/onboarding.ts

6. Deploy

deploy applies in dependency order (connector → model → tool → agent → play) and records each resource’s uuid in cargo.state.json. Commit that file. See Secrets & environments for secret() and the CARGO_* variables.

7. Run

Run the tool on a single record, then chat with the agent:
Plays enrol through batch create, never run create — see Plays.

Next steps

Deploying

plan, deploy, prune, refresh, import, and destroy.

State & drift

How state tracks live resources and detects out-of-band changes.