Skip to main content

CREATE AND RUN A MODEL

Prerequisites: Swamp installed, a repository initialized with swamp repo init.

Search for available model types

swamp model type search
{
  "query": "",
  "results": [
    {
      "raw": "command/shell",
      "normalized": "command/shell"
    }
  ]
}

Installed extensions add their types to this list. To install more, see extensions.

Inspect a type before using it

swamp model type describe command/shell
Type: command/shell
Version: 2026.02.09.1

Data Outputs:
  result [resource] - Shell command execution result (exit code, timing, command) (infinite)
  log [file] - Shell command output (stdout and stderr) (text/plain, infinite)

Methods:
  execute - Execute the shell command and capture stdout, stderr, and exit code
    Inputs:
      run (string) *required
      workingDir (string)
      timeout (integer)
      env (object)
      ignoreExitCode (boolean)

Create a model definition

swamp model create command/shell my-greeter
Created: my-greeter (command/shell)
Path: models/command/shell/<uuid>.yaml
Version: 2026.02.09.1
...

This writes a YAML definition under models/. The file contains the type, name, and empty globalArguments and methods blocks you can edit. For the full definition schema, see the model definitions reference.

Validate the definition

swamp model validate my-greeter
Validating: my-greeter (command/shell)
  ✓ Definition schema
  ✓ Global arguments
  ✓ Method arguments
  ✓ Expression paths
  ✓ Check selection
Summary: 5/5 validations passed
Result: PASSED

Run a method

swamp model method run my-greeter execute --input 'run=echo Hello from the swamp!'
...
Hello from the swamp!
...
Method "execute" completed on "my-greeter"

Each method run produces data artifacts according to the type's data output specs.

Inspect the output

To see what data a model has produced:

swamp data list my-greeter
Data for my-greeter (command/shell)

file (1 item):
  log  v2  text/plain  21B  2026-07-01

resource (1 item):
  result  v2  application/json  135B  2026-07-01

report (2 items):
  report-swamp-method-summary  v2  text/markdown  476B  2026-07-01
  report-swamp-method-summary-json  v2  application/json  2.6KB  2026-07-01

To retrieve a specific artifact:

swamp data get my-greeter result --json
{
  "id": "...",
  "name": "result",
  "modelId": "...",
  "modelName": "my-greeter",
  "modelType": "command/shell",
  "version": 1,
  "contentType": "application/json",
  "lifetime": "infinite",
  "garbageCollection": 10,
  "streaming": false,
  "tags": {
    "type": "resource",
    "specName": "result",
    "modelName": "my-greeter"
  },
  "ownerDefinition": {
    "ownerType": "model-method",
    "ownerRef": "..."
  },
  "createdAt": "...",
  "size": 121,
  "checksum": "...",
  "contentPath": "...",
  "content": {
    "exitCode": 0,
    "executedAt": "...",
    "command": "echo Hello from the swamp!",
    "durationMs": 4,
    "stdout": "Hello from the swamp!",
    "stderr": ""
  }
}

The execution result is in the content sub-object. The surrounding fields are data-layer metadata (identity, versioning, ownership, tags).

For file outputs like logs:

swamp data get my-greeter log
Data: log (v1)
Model: my-greeter (command/shell)
Content: text/plain, 21B
Lifetime: infinite | GC: 10
Tags: type=file, specName=log, modelName=my-greeter
Owner: model-method (...)
Created: ...
Path: ...

[stdout]
Hello from the swamp!

View method run history

swamp model method history my-greeter
{
  "modelName": "my-greeter",
  "type": "command/shell",
  "methodName": "execute",
  "status": "succeeded",
  "startedAt": "2026-07-01T21:37:01.540Z",
  "completedAt": "2026-07-01T21:37:01.554Z",
  "durationMs": 14,
  ...
}

Auto-create with direct type execution

If you want to skip the explicit model create step, pass the type directly:

swamp model method run @command/shell execute my-quick-model --input 'run=echo Quick start'

This auto-creates a definition under .swamp/auto-definitions/ and runs the method in a single command. Auto-definitions are not committed to version control.