Skip to main content

Functions overview

Crusoe AI Platform Functions provides lightweight, event-driven serverless computing. You write a single function handler, and Crusoe AI Platform automatically builds, deploys, and scales your code on demand.

This page introduces the core concepts behind Functions, supported language runtimes, execution models, and how Crusoe Functions compare to other cloud serverless platforms.


What a function is

A function is a lightweight code unit executed in response to incoming events or HTTP requests. You write a single handle(event) function and deploy it with a single command or via the Console UI. Crusoe AI Platform provisions a secure HTTPS endpoint and manages infrastructure scaling automatically.

Key capabilities

  • Automatic Scaling: Functions automatically scale up to handle incoming traffic spikes.
  • Scale-to-zero Compute: Idle functions scale down to zero instances, eliminating idle server costs.
  • Fast Cold Starts: When an idle function receives a new request, the platform provisions an instance automatically within seconds.

Supported runtimes

Crusoe AI Platform supports four primary programming language runtimes:

RuntimeHandler FileHandler Export
Python (default)handler.pydef handle(event)
Node.jshandler.jsexports.handle
Gohandler.gofunc Handle
Rubyhandler.rbdef handle

For detailed language specifications and complete code examples, see the Runtimes guide.


Architecture and execution model

Your handler code executes behind an automated language shim provided by the platform. The shim acts as an event translation layer between incoming HTTP/event traffic and your application logic.

Event processing flow

  1. HTTP GET Requests: Passed to your handler as an empty event payload ({}).
  2. HTTP POST Requests: The JSON payload is parsed and passed directly as the event parameter (payload limit: 8 MiB).
  3. Response Formatting: Return standard dictionaries or objects from your handler. Include "statusCode" to specify custom HTTP status codes (defaults to 200).
  4. CloudEvents Standard: Structured events sent via CloudEvents specifications return a standard 204 No Content acknowledgment upon successful handling. See HTTP and Events.

Deploying functions

Functions use the unified Crusoe AI Platform deployment workflow, giving you full access to platform logging, telemetry, and management tools.

Deploying via Console UI

  1. Open the Console and navigate to Compute → Functions.
  2. Click Deploy function.
  3. Set Language to your runtime (Python, Node.js, Go, Ruby). The picker also sets the entry filename and the dependency file, so choose it before you add source.
  4. Supply the source in one of the dialog's three modes — Write code, Upload files, or Upload .tar.gz. There is no zip mode: the archive must be a .tar.gz of the source directory with its files at the top level of the archive, the same thing platformctl deploy uploads.
  5. Click Deploy.

The console's upload limits are stricter than the CLI's, and it refuses text-only violations before anything is built — see upload rejected as too large for the numbers and what to do instead.

Deploying via CLI

Deploy your function directly from your terminal using platformctl:

platformctl functions deploy --runtime python ./my-fn

When to use Functions

  • Choose Functions when: You need lightweight webhooks, event processors, API endpoints, or glue code without managing Dockerfiles or infrastructure configurations.
  • Choose Agents when: You are building AI workloads requiring LLM orchestration, session history, tools, and long-term memory.
  • Choose Serverless Containers when: You have existing container images, complex multi-file microservices, or specific custom runtime dependencies.

Platform comparison

The following table compares Crusoe AI Platform Functions with serverless function offerings from major cloud providers:

FeatureCrusoe AI Platform FunctionsAWS LambdaGCP Cloud Run FunctionsAzure Functions
Deployment ModelUnified command or Console UIAWS Console, SAM, or CDKgcloud CLI or GCP ConsoleAzure Portal or Core Tools
RuntimesPython, Node.js, Go, RubyPython, Node.js, Go, Java, customPython, Node.js, Go, JavaPython, Node.js, C#, Java
HTTPS EndpointProvisioned automaticallyRequires API Gateway or Function URLProvisioned automaticallyProvisioned automatically
ScalingAutomatic scale-to-zero computeAuto-scaling per concurrency limitAuto-scaling instance countsAuto-scaled app service plans

Note: Multi-region replication and custom SLA guarantees are currently unavailable.


Next steps