th functions

Deploy Python, Node.js (TypeScript) and Go functions from a folder, pull the code you edited in the Console, and call them.

About

A function is one handler: you write it, and we add a small runtime that serves it over HTTP, build it and run it like a Container that stops when idle. The same code shows in the Console’s editor, so you can edit it there or locally: th functions pull fetches what the Console saved and th functions deploy sends your folder back.

RuntimesMain fileHandler
python314, python313 (recommended), python312, python311main.py (+ requirements.txt)def main(request) returning a str, dict (JSON) or (body, status, headers)
nodejs24 (recommended), nodejs22index.ts or index.js (+ package.json)export async function handler(req: Request) returning a Response, string or object
go126 (recommended), go125*.go + go.modfunc Handle(w http.ResponseWriter, r *http.Request)

A function has at most 100 text files, 512 KiB each and 2 MiB in all. Files in .thignore (else .dockerignore, else .gitignore), .git, node_modules, .venv, __pycache__ and dist are left out, and a Dockerfile is ignored. Builds are billed like Container builds. To run it on a schedule or for every queue message, add a trigger with th triggers.

How-to guides

Deploy a function from a folder

Shell
mkdir hello && cd hello
printf 'def main(request):\n    return {"message": "Hello, " + request.args.get("name", "World")}\n' > main.py
th functions deploy hello --env GREETING=hi
th functions call hello --path "/?name=Thai"

The first deploy creates the function; its runtime comes from the files (or --runtime). th waits for the build and prints the URL. --async returns once the build is queued.

Go back to an earlier version

Shell
th functions versions list hello
th functions versions activate hello 12
th functions pull hello --version 12 --dir hello-v12

Every deploy is a version, and the latest 30 are kept. Activating one serves it again with today’s settings and variables; if its image was cleaned up, its code is built again as a new version. --runtime on a deploy moves the function to another version of its language, e.g. --runtime python314.

Run a function only from its triggers

Shell
th functions deploy nightly-report --ingress triggers
th triggers create nightly --service nightly-report --schedule "0 3 * * *"

With --ingress triggers the function has no endpoint at all: no public URL, no custom domain and no address inside the project’s VPC. Only its Cron and Queue triggers reach it, and th triggers run runs one now. --ingress all opens it again.

Edit in the Console, then work locally

Shell
th functions pull hello --dir hello
# edit the files
th functions deploy hello --source hello

pull keeps local files that differ unless you pass --force.

Commands

CommandDescription
th functions deployUploads the files of DIR (default .) as the function's code, builds them and serves the result.
th functions listLists the functions of the active Project.
th functions describeShows a function's runtime, deploy state, settings and files.
th functions pullWrites the function's saved code (what the Console editor shows), or the code of one version, into DIR (default ./NAME).
th functions callSends one request to the function and prints the answer.
th functions logsPrints the latest log lines of a function (what the handler printed).
th functions versions listLists a function's versions, newest first.
th functions versions activateServes an earlier version again; today's settings and variables stay.
th functions runtimesLists the runtimes a function can use and the handler each expects.
th functions deleteDeletes a function with its code, triggers and revisions.

th functions deploy

Uploads the files of DIR (default .) as the function's code, builds them and serves the result.

Syntax

Shell
th functions deploy NAME [--source DIR] [flags]

A new function is created first; its runtime comes from --runtime or from the files (go.mod: Go, package.json / index.ts: Node.js, main.py / requirements.txt: Python).

Files listed in .thignore (or .dockerignore / .gitignore), .git, node_modules, .venv, __pycache__ and dist are left out. A Dockerfile is ignored: functions always build with the platform's runtime.

--runtime takes a runtime (python313, nodejs24, go126) or a language (python, nodejs, go: its recommended version). An existing function may move to another version of its language.

Every deploy is kept as a version (th functions versions list); --message describes it. --ingress sets who reaches the function: all (the internet, the default), internal (other services in its project) or triggers (no endpoint at all; only its Cron and Queue triggers run it). --env, --set-env-vars and --secret-env replace every variable of the function; without them the current variables stay. Settings given for an existing function (--cpu, --memory, --min-instances, ...) are applied before its code is built.

Examples

Shell
th functions deploy hello
Shell
th functions deploy hello --runtime python314 --message "Python 3.14"
Shell
th functions deploy orders --source ./orders --memory 512Mi --max-instances 10
Shell
th functions deploy nightly-report --ingress triggers

Positional arguments

NameDescription
NAMERequiredThe function’s name: lowercase letters, digits and -, starting with a letter. It is also its URL slug.

Parameters

NameTypeDefaultDescription
--sourcestring.Directory with the function's files
--runtimestringRuntime (e.g. python313, nodejs24, go126) or language (python, nodejs, go)
--entry-pointstringthe runtime's, e.g. main, handler, HandleHandler name
--cpustringvCPU, e.g. 0.25, 0.5, 1 (a size of the Container menu)
--memorystringMemory, e.g. 256Mi, 512Mi, 1Gi
--compute-classstringCompute class of a new function
--envlistEnvironment variable KEY=VALUE (repeatable)
--set-env-varslistEnvironment variables KEY=VALUE,KEY2=VALUE2
--secret-envlistSecret environment variable KEY=VALUE (repeatable)
--min-instancesnumberMinimum instances (0 stops it when idle)
--max-instancesnumberMaximum instances
--timeoutstringRequest timeout, e.g. 60s or 5m
--concurrencynumberRequests at once per instance (1-1000)
--cpu-always-allocatedflagKeep CPU between requests
--allow-unauthenticatedflagfor a new function; --no-allow-unauthenticated needs an invoker tokenAllow public calls
--ingressstringWho reaches the function: all, internal or triggers (no endpoint, triggers only)
--messagestringDescribe this version
--asyncflagReturn once the build is queued

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th functions list

Lists the functions of the active Project.

Syntax

Shell
th functions list

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th functions describe

Shows a function's runtime, deploy state, settings and files.

Syntax

Shell
th functions describe NAME

Positional arguments

NameDescription
NAMERequiredThe function’s name: lowercase letters, digits and -, starting with a letter. It is also its URL slug.

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th functions pull

Writes the function's saved code (what the Console editor shows), or the code of one version, into DIR (default ./NAME).

Syntax

Shell
th functions pull NAME [--dir DIR] [--version N] [--force]

An existing file with other content is kept unless --force.

Positional arguments

NameDescription
NAMERequiredThe function’s name: lowercase letters, digits and -, starting with a letter. It is also its URL slug.

Parameters

NameTypeDefaultDescription
--dirstring./NAMEDirectory to write into
--versionstringthe saved codeA version from th functions versions list
--forceflagOverwrite files that differ

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th functions call

Sends one request to the function and prints the answer.

Syntax

Shell
th functions call NAME [--data BODY|@FILE] [--method POST] [--path /x] [--token TOKEN]

With --data the method defaults to POST, otherwise GET. --token is the invoker token of a function that does not allow unauthenticated calls.

Positional arguments

NameDescription
NAMERequiredThe function’s name: lowercase letters, digits and -, starting with a letter. It is also its URL slug.

Parameters

NameTypeDefaultDescription
--datastringRequest body, or @FILE to read it from a file
--methodstringHTTP method
--pathstring/Path to call
--tokenstringInvoker token

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th functions logs

Prints the latest log lines of a function (what the handler printed).

Syntax

Shell
th functions logs NAME [--lines N]

Positional arguments

NameDescription
NAMERequiredThe function’s name: lowercase letters, digits and -, starting with a letter. It is also its URL slug.

Parameters

NameTypeDefaultDescription
--linesnumber100Number of lines (default 100)

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th functions versions list

Lists a function's versions, newest first.

Syntax

Shell
th functions versions list NAME

Every deploy is a version; the serving one is marked. The latest 30 are kept.

Positional arguments

NameDescription
NAMERequiredThe function’s name: lowercase letters, digits and -, starting with a letter. It is also its URL slug.

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th functions versions activate

Serves an earlier version again; today's settings and variables stay.

Syntax

Shell
th functions versions activate NAME VERSION

When the registry no longer holds its image, its code is built again as a new version and served once the build succeeds.

Examples

Shell
th functions versions activate hello 12
Shell
th functions versions activate hello v12

Positional arguments

NameDescription
NAMERequiredThe function’s name: lowercase letters, digits and -, starting with a letter. It is also its URL slug.
VERSIONRequired

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th functions runtimes

Lists the runtimes a function can use and the handler each expects.

Syntax

Shell
th functions runtimes

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑

th functions delete

Deletes a function with its code, triggers and revisions.

Syntax

Shell
th functions delete NAME [--quiet]

--quiet skips the prompt.

Positional arguments

NameDescription
NAMERequiredThe function’s name: lowercase letters, digits and -, starting with a letter. It is also its URL slug.

Global parameters

This command also takes the global parameters: --project, --region, --endpoint, --format, --quiet.

Back to top ↑