bladekit.app
An AI Fabric application: a named namespace of remotely-callable functions and classes. Calling bladekit.app() registers nothing on its own — the @app.function and @app.cls decorators populate it, and blade run / blade deploy load the module, read app.functions / app.classes, and ship them.
bladekit.app(name: str, *, image: Any = None)namestrApplication name — the deployment identity used by the CLI and the control plane.
imagestr | bladekit.ImageDefault:NoneDefault image for every function that does not set its own
image=. A catalogue alias / registry ref (string) or abladekit.ImageDSL object.
import bladekit
app = bladekit.app("demo", image="fabric/base")@app.function
Decorator that registers a plain function for remote execution, returning a Function handle exposing .remote(), .spawn() and .map(). Usable bare (@app.function) or with arguments (@app.function(gpu="RTX-A4500")).
@app.function(
*,
gpu: str | None = None,
cpu: float | None = None,
memory: int | None = None,
timeout: int | None = None,
image: Any = None,
idle_timeout: int | None = None,
volumes: dict[str, bladekit.Volume] | None = None,
secrets: list[bladekit.Secret] | None = None,
retries: int | dict | None = None,
priority: int | None = None,
namespace: str | None = None,
schedule: bladekit.Cron | None = None,
gpu_class: str = "spot",
best_effort: bool = False,
max_interruptions: int | None = None,
)gpustrDefault:NoneGPU type, e.g.
"RTX-A4500". Append":N"(N between 1 and 8) for multiple GPUs in one container, e.g."RTX-A4500:4". Omit for CPU-only.cpufloatDefault:NoneFractional CPU cores. Minimum 0.1 (100 millicores); server default 1.0 when unset.
memoryintDefault:NoneMemory in MB. Server default 16384 (16 GB) when unset.
timeoutintDefault:NoneMax seconds for one execution — it bounds the work, never the worker. A one-shot
blade run/ cron / map run is killed past it; on a deployed endpoint it caps each request, and the service itself never expires (replica lifetime belongs to the autoscaler:min_replicas, idle scale-down, redeploy). Server default 3600 (1 h) when unset.imagestr | bladekit.ImageDefault:NoneContainer image (catalogue alias, registry ref, or
bladekit.ImageDSL). Falls back to the App default when unset.idle_timeoutintDefault:NoneSeconds a warm container lingers with no work before scale-down. Server default 60 when unset.
volumesdict[str, bladekit.Volume]Default:NoneMaps a container mount path to a
bladekit.Volume.secretslist[bladekit.Secret]Default:NoneSecrets injected as environment variables inside the container.
retriesint | dictDefault:NoneRetry policy. An int shorthand (
retries=3, max 10) or a dict, e.g.{"max_retries": 3, "backoff": {"initial_seconds": 1, "max_seconds": 60, "factor": 2.0}}. Applied per-input formap().priorityintDefault:NoneScheduling priority 0–9 (9 = urgent, 0 = best-effort). Treated as 5 (FIFO) when unset.
namespacestrDefault:NoneTeam namespace used for GPU quota accounting.
schedulebladekit.CronDefault:NoneA
bladekit.Cron(...)object for cron-scheduled execution. Takes effect only in a deployed app, not inblade run.gpu_classstrDefault:"spot"Capacity class:
"spot"(interruptible, cheap) or"reserved"(non-interruptible, no preemption). Validated client-side.best_effortboolDefault:FalseOpt into best-effort interruptible scheduling.
max_interruptionsintDefault:NonePreemption budget: the maximum number of interruptions tolerated before the run gives up.
@app.function(gpu="RTX-A4500", timeout=600, retries=2)
def render(prompt: str) -> bytes:
...
render.remote("a red bicycle")@app.cls
Decorator that registers a class whose @app.methods are callable remotely. This is the standard inference pattern: load a model once per container in an @bladekit.enter() hook, then reuse it across every method call. The runner instantiates the class with no arguments, runs the enter hooks, then calls the target method.
@app.cls(
*,
gpu: str | None = None,
cpu: float | None = None,
memory: int | None = None,
timeout: int | None = None,
image: Any = None,
idle_timeout: int | None = None,
volumes: dict[str, bladekit.Volume] | None = None,
secrets: list[bladekit.Secret] | None = None,
gpu_class: str = "spot",
best_effort: bool = False,
max_interruptions: int | None = None,
)gpustrDefault:NoneGPU type, with an optional
":N"multi-GPU suffix — same semantics as@app.function.cpufloatDefault:NoneFractional CPU cores (minimum 0.1).
memoryintDefault:NoneMemory in MB.
timeoutintDefault:NoneMax seconds for one execution — same semantics as
@app.function: bounds each call (or each request on a deployed endpoint), never the lifetime of a deployed service.imagestr | bladekit.ImageDefault:NoneContainer image; falls back to the App default when unset.
idle_timeoutintDefault:NoneIdle seconds before a warm container scales down.
volumesdict[str, bladekit.Volume]Default:NoneMount path →
bladekit.Volumemap, shared by every method.secretslist[bladekit.Secret]Default:NoneSecrets injected into the container for every method.
gpu_classstrDefault:"spot""spot"(interruptible) or"reserved"(non-interruptible) — forwarded to each per-method function.best_effortboolDefault:FalseOpt into best-effort interruptible scheduling.
max_interruptionsintDefault:NonePreemption budget forwarded to each method.
import bladekit
app = bladekit.app("embeddings")
@app.cls(gpu="RTX-A4500", image="fabric/torch")
class Embedder:
@bladekit.enter()
def load(self):
# runs once per container, before the first call
from sentence_transformers import SentenceTransformer
self.model = SentenceTransformer("all-MiniLM-L6-v2")
@app.method()
def embed(self, texts: list[str]):
return self.model.encode(texts).tolist()
# local: Embedder().embed(...) ; remote:
Embedder().embed.remote(["hello", "world"])blade deploy embedder.py@app.method
Decorator that marks a method of an @app.cls class as remotely callable. Access it on an instance to get a bound handle: Embedder().embed exposes .remote(), .spawn() and .local() (a direct in-process call). It takes no arguments — resources come from the enclosing @app.cls.
@app.method()
def embed(self, ...):
...@bladekit.enter()
Decorator that marks a method to run once per container, before the first call — the place to load a model or open a connection. The runner instantiates the class with no arguments, runs every @bladekit.enter()-marked method, then dispatches calls. The instance and its enter side-effects are reused for every subsequent call on that warm container.
@bladekit.enter()
def load(self):
...@app.local_entrypoint
Decorator that marks the function blade run invokes locally — a driver that runs on your machine and fans work out to the cluster via .remote() / .map(). Usable bare (@app.local_entrypoint) or called (@app.local_entrypoint()). Registered entrypoints are collected on app.local_entrypoints.
@app.local_entrypoint()
def main():
...@app.local_entrypoint()
def main():
for out in render.map(["a cat", "a dog", "a bird"]):
print(len(out))blade run app.pyReference from the Blade console · Updated .