# Endpoints

> Deploy a function as an HTTPS endpoint that scales to zero when idle and is called with your key.

Canonical page: https://klio.tech/docs/endpoints

## Deploy an endpoint

```python
from klio_compute import endpoint, Image

@endpoint(gpu="L4", image=Image(python_version="python3.12"), keep_warm_seconds=60)
def predict(**inputs):
    return {"echo": inputs}
```

```bash
klio deploy app.py:predict
```

The deploy prints the endpoint's address. Requests need a key: send one from Keys in the console as `Authorization: Bearer`.

## Call it

```bash
curl -X POST https://<your-endpoint-address> \
  -H "Authorization: Bearer $KLIO_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"text": "hello"}'
```

`klio curl` sends the same request with the key you signed in with, and only ever to an endpoint's own address.

## Scale to zero

An endpoint's containers stop after `keep_warm_seconds` without requests, and nothing is billed while none run. The next request starts one again, which takes longer than a warm request. Raise `keep_warm_seconds` to keep it ready for longer.

## Manage deployments

```bash
klio deployment list
klio deployment stop <deployment-id>
klio app list
klio app logs <app>
```

Every deployment is also in the console, with its logs, usage and cost.
