Skip to content

Functions#

A function is code run on your workspace's machines when it is called: one file of Python 3.12 or Node.js 22 and the packages it needs. You do not start or stop anything: a call goes to an instance of the function, which starts when a call comes and stops when it has been idle. In the API, functions are at /v1/functions.

Use a function when:

  • Something calls you: a webhook, a form, another program — its HTTP trigger is a URL that answers with your code.
  • A model needs a tool: an Eos deployment declares functions as tools, and the gateway runs them for the model (Give a model tools).
  • A small job runs on a timetable: a schedule can invoke a function instead of starting a run.
  • You glue things together: call a function from your programs with an input and get its answer, without building an image.

A function is not a run: a run is work you start and follow; a function is code that waits to be called, many times, by many callers.

Draft, versions and aliases#

  • The draft is what you write and save. It can be called as draft, to try it.
  • Publishing makes an immutable version of the draft: v1, v2… A version never changes; it keeps its code, its packages and its settings, and the schema a model calls it by.
  • Aliases name versions: prod → v2. Callers name the alias, and moving it is how a new version is rolled out — or an old one rolled back. latest is always the newest version.
flowchart LR
  D["draft"] -->|publish| V1["v1"]
  D -->|publish| V2["v2"]
  P(["prod"]) --> V1
  L(["latest"]) --> V2

Instances#

Each target that is called has its own instances: the draft, the version latest names, and each version an alias names. An instance serves up to scaling.concurrency calls at once (8 by default). Instances are added, up to scaling.max_instances, as calls keep them busy, and stop after scaling.idle_seconds without a call, down to scaling.min_instances (0 by default: scaled to zero). The draft is never kept warm.

When every instance is busy, a call waits in a queue (scaling.queue, 64 by default) for at most the function's timeout; when the queue is full, it is refused with 429 FUNCTION_BUSY. A call to a function with no instance running starts one and waits for it — a cold start: the image is pulled the first time on a machine, and the packages are installed each time an instance starts.

Instances are placed on the machines your workspace may use, like a run's workers, with the memory, CPU cores and GPUs the function asks for.

Isolation#

Instances run sandboxed by default: under gVisor, a kernel in user space between your code and the machine's, so a bug in the kernel your code reaches is gVisor's, not the machine's. Sandboxed instances need machines whose agent runs gVisor (installed with the agent on Linux; see Requirements).

A plain container is weaker — your code reaches the machine's kernel directly — and is used only when you choose it (isolation: container). A function with GPUs needs it: gVisor cannot reach GPUs here.

Credentials and data#

A function is given Credentials as environment variables or files, resolved on the machine: their values are never stored in the function. A call's input and answer pass through memory only — the cluster keeps neither, only a record of the call (when, how long, how it ended) and the function's own metrics. Its log lines stay on the machine that ran it and are read from there when you ask.

How a function is called#

From How
The console Astraeus → Functions → Test
The API POST /v1/functions/{name}/invoke?target=prod
The CLI astra astraeus functions invoke weather@prod -d '{"city": "Lisbon"}'
Python astraeus.Client.from_config().invoke("weather", {"city": "Lisbon"}, target="prod")
An AI assistant (MCP) the invoke_function tool (toolset Functions)
Its URL POST https://inference.astralyx.cloud/v1/functions/weather@prod/invoke, or on your edge machines, with an API key that lists the function
A timetable a schedule with a function_call
A model an Eos deployment's tools

What a model is told#

When a version is published, the schema of its input is generated from the handler: its parameters, their type hints and defaults, and its docstring (Python) or JSDoc (Node). That is what a model is told the function takes when a deployment uses it as a tool; you can review it, and a deployment may carry its own. See Write and publish a function.

Next#