Hanzo AI
OpenapiFunctions

Create functions

Publishes a serverless function under the caller's org and answers 201 with it.

POST /v1/functions

Addresshttps://api.hanzo.ai/v1/functions
MethodPOST
Operationpost_functions
AuthAuthorization: Bearer $HANZO_API_KEY

Publishes a serverless function under the caller's org and answers 201 with it.

The name is the key and is claimed once; the names that would shadow a collection route are reserved. runtime and environment are the same field — either spelling is accepted — and default to node.

Bounds are clamped rather than refused where a clamp is honest: a timeout above the 900-second ceiling becomes the ceiling instead of silently reverting to the 30-second default, and an omitted memory limit becomes 256Mi. target=fleet runs on the org's own GPU fleet and supports runtime=python only.

Requires a validated principal; the function is owned by that principal's org.

Request

11 fields, body application/json (required).

FieldInTypeRequiredDescription
codebodystring—Code is the source to run, capped so one function cannot amplify the store.
envNamesbodystring[]—EnvNames are the secret NAMES to mount.
environmentbodystring—Environment is a second spelling of runtime, accepted so a console that says "environment" needs no translation.
handlerbodystring—Handler is the entry point within the code.
imagebodystring—Image names a prebuilt image to run instead of source.
memoryLimitbodystring—MemoryLimit is the memory the function runs with, defaulting to 256Mi.
namebodystringyesName is the function's org-unique handle and the segment that addresses it, matching ^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$.
namespacebodystring—Namespace groups functions for display.
runtimebodystring—Runtime is the language the code runs under: node, python or deno.
targetbodystring—Target is where the function runs: sandbox (the default) or fleet, the org's own GPU fleet.
timeoutSecbodyinteger—TimeoutSec is the per-invocation deadline, defaulting to 30 and clamped at 900 — a larger value is capped rather than reset to the default.

Response

StatusBodyMeaning
201functionViewcreated

201 body — 16 fields.

FieldInTypeAlwaysDescription
avgDurationMsbodynumber—mean wall-clock of those runs
createdAtbodystring—when it was first published
endpointbodystring—the path that invokes it
envCountbodyinteger—how many secret NAMES it mounts; values are never carried
environmentbodystring—the language it runs under
errors7dbodyinteger—how many of those runs failed
imagebodystring—the prebuilt image it runs, when it runs one instead of source
invocations7dbodyinteger—runs in the last 7 days; ABSENT, never 0, when it has not run
lastDeployedAtbodystring—when its code last changed
memoryLimitbodystring—the memory it runs with, and the multiplier on its compute charge
namebodystring—the function's org-unique handle
namespacebodystring—the display group it belongs to; the org is the isolation key
statusbodystring—whether it is ready to serve
successRatebodynumber—share of those runs that succeeded, 0..1
targetbodystring—where it runs: empty for the sandbox, "fleet" for the org's GPU fleet
timeoutSecbodyinteger—its per-invocation deadline

Failure carries the platform error shape — see Errors.

Examples

hanzo functions create --name <name>

Functions API · All Hanzo APIs · Interactive reference

How is this guide?

On this page