CLI: Function Management

Manage serverless functions with the agentmetal function subcommand.

CLI: Function Management

Overview

The agentmetal function subcommand manages serverless functions. Functions run on-demand, scale to zero, and support multiple runtimes including Go, Python, Node.js, and Rust.

Operations

Create a Function

agentmetal function create \
  --name my-handler \
  --runtime go \
  --handler main.Handle \
  --code ./handler.zip \
  --memory 256 \
  --timeout 30
FlagRequiredDescription
--nameYesFunction name
--runtimeYesRuntime: go, python, node, or rust
--handlerYesEntry point (e.g., main.Handle, handler.main)
--codeYesPath to code archive (zip) or directory
--memoryNoMemory in MB (default: 128)
--timeoutNoExecution timeout in seconds (default: 30)
--min-instancesNoMinimum warm instances (default: 0)
--max-instancesNoMaximum concurrent instances (default: 10)
### List Functions
agentmetal function list
ID           NAME          RUNTIME   MEMORY   TIMEOUT   STATE
fn-a1b2c3    my-handler    go        256MB    30s       ready
fn-d4e5f6    processor     python    512MB    60s       ready

Get / Delete

agentmetal function get fn-a1b2c3
agentmetal function delete fn-a1b2c3

Invoke a Function

agentmetal function invoke fn-a1b2c3 --data '{"key": "value"}'

The invoke command triggers synchronous execution and returns the result:

agentmetal function invoke fn-a1b2c3 --data '{"name": "test"}' --output json
{
  "status_code": 200,
  "body": "{"message": "Hello, test"}",
  "duration_ms": 12,
  "billed_ms": 100
}

FunctionSpec Fields

FieldTypeDescription
runtimestringgo, python, node, or rust
handlerstringEntry point function path
code_uristringURI to the code archive
memory_mbintMemory allocation in megabytes
timeout_secondsintMaximum execution time
min_instancesintMinimum warm instances
max_instancesintMaximum concurrent instances
## Examples

Deploy a Python function:

agentmetal function create \
  --name data-processor \
  --runtime python \
  --handler handler.process \
  --code ./dist/processor.zip \
  --memory 512 \
  --timeout 60 \
  --min-instances 1

Invoke with piped data:

echo '{"records": [1,2,3]}' | agentmetal function invoke fn-abc123 --data -