Live App model#
A Live App is an App with HTTP Endpoints backed by Tasks. The persistent product model is **Live App → Version → Endpoint**. Yak owns the Version and Endpoint lifecycle and returns the complete URLs; use those URLs as given.
The canonical hello_live_app.py example declares GET /hello and POST /echo in one App. Use yak serve while developing a session-bound endpoint. Use yak deploy when the Live App should remain available after the command exits.
yak serve and yak deploy#
Both commands discover the App declarations in the Python source, but keep different lifetimes:
- **
yak serve** runs the entrypoint remotely in an isolated Invocation, registers its declared Endpoints for the session, prints the complete server-returned Endpoint URLs, streams logs and remains active until stopped. Stopping the command ends the Invocation and Yak attempts to unregister its session Endpoints. It does not create a persistent Version. - **
yak deploy** submits the App for a persistent Live App Version. The entrypoint is used to discover the App declarations; its long-runningapp.serve()body is not the persistent service process. When the Version is ready, the command prints server-owned state and complete Endpoint URLs. The Live App remains after the CLI exits.
Neither command starts a local HTTP server. serve does not watch files or hot-reload handlers. A Task or image error can prevent endpoints from becoming usable; stopping a serve session requests cleanup of its temporary endpoint registrations.
Declare an Endpoint#
Use @yak.web_endpoint(...) on an App Task:
@app.task()
@yak.web_endpoint(method="GET", path="/hello")
def hello(request: yak.Request) -> yak.Response:
name = request.query_params.get("name", "Yak")
return yak.Response(body={"message": f"hello from {name}"})
One declaration maps an HTTP method and path to one Task. An App can declare multiple endpoints, including different methods on the same path. Use standard method names such as GET and POST; Yak validates the route and dispatches requests to the matching Task. A method mismatch returns 405 with an Allow header.
yak.Request exposes the method, path, headers, query parameters and body. request.json decodes JSON when read; malformed JSON raises json.JSONDecodeError inside the handler. Catch it when the endpoint should return a deliberate client error.
Return yak.Response when the handler needs explicit status, headers or content type. Dictionaries are JSON-serialized, strings are UTF-8 encoded and bytes pass through unchanged. The default content type is application/json.
Use the URL Yak returns#
Yak chooses the scheme, hostname and published path. Do not construct an endpoint hostname from an App name, Environment, Workspace or label. The returned URL already includes its path; do not append the declared path again.
For a persistent Live App, copy the complete URL printed by yak deploy:
HELLO_URL="<exact URL returned for GET /hello>"
curl "$HELLO_URL?name=Ada"
Use the separate complete URL returned for the POST Endpoint:
ECHO_URL="<exact URL returned for POST /echo>"
curl -X POST -H 'Content-Type: application/json' \\
-d '{"message":"hello"}' "$ECHO_URL"
Versions and inspection#
Each successful yak deploy publishes a new Live App Version. Readiness means the server has prepared the App and its route projection; it does not promise a warm process, health probes, autoscaling or gradual traffic shifting. A failed candidate does not become the active ready Version.
Use the App commands to inspect server-returned state and Version history:
yak app list
yak app list --json
yak app versions <id>
The CLI reports the Live App’s state and Endpoint records. Use the identifier returned by yak app list for the versions command. Use JSON when a script needs structured state; do not derive IDs, status or URLs locally.
Configuration boundary#
Persistent Live Apps use the App-level Image and accept named Secrets declared at App level. Inline Secret values and Task-level Secret overrides are run-scoped and are rejected for persistent use. Schedules, non-default Task resource overrides, Object Storage Mounts and Ephemeral Disks are not part of the current persistent Live App contract. Consult the focused Images , Secrets and storage guides before combining configuration.
Use a Task for finite work whose caller starts an Invocation and consumes its result. Use a Live App when clients need a persistent HTTP Endpoint. The Endpoint is still backed by a Task, but callers reach it over HTTP rather than submitting each Invocation through the Task call surface.
Failures and Preview limits#
Invalid entrypoints, endpoint declarations, image preparation or route setup can prevent the Live App Version from becoming ready. The SDK exposes DeploymentError for server-reported candidate failures. An exception raised while handling an HTTP request is a handler failure; invalid JSON only fails when request.json is accessed.
Yak is an invite-only Preview. It does not promise production availability, an SLA, high availability, warm-container behavior or zero-downtime updates. See Preview limitations for access and current product boundaries.