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
| Flag | Required | Description |
|---|---|---|
--name | Yes | Function name |
--runtime | Yes | Runtime: go, python, node, or rust |
--handler | Yes | Entry point (e.g., main.Handle, handler.main) |
--code | Yes | Path to code archive (zip) or directory |
--memory | No | Memory in MB (default: 128) |
--timeout | No | Execution timeout in seconds (default: 30) |
--min-instances | No | Minimum warm instances (default: 0) |
--max-instances | No | Maximum concurrent instances (default: 10) |
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
| Field | Type | Description |
|---|---|---|
runtime | string | go, python, node, or rust |
handler | string | Entry point function path |
code_uri | string | URI to the code archive |
memory_mb | int | Memory allocation in megabytes |
timeout_seconds | int | Maximum execution time |
min_instances | int | Minimum warm instances |
max_instances | int | Maximum concurrent instances |
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 -