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:
| Runtime | Handler File | Handler Export |
|---|---|---|
| Python (default) | handler.py | def handle(event) |
| Node.js | handler.js | exports.handle |
| Go | handler.go | func Handle |
| Ruby | handler.rb | def 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
- HTTP GET Requests: Passed to your handler as an empty event payload (
{}). - HTTP POST Requests: The JSON payload is parsed and passed directly as the
eventparameter (payload limit: 8 MiB). - Response Formatting: Return standard dictionaries or objects from your handler. Include
"statusCode"to specify custom HTTP status codes (defaults to200). - CloudEvents Standard: Structured events sent via CloudEvents specifications return a standard
204 No Contentacknowledgment 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
- Open the Console and navigate to Compute → Functions.
- Click Deploy function.
- 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.
- 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.gzof the source directory with its files at the top level of the archive, the same thingplatformctl deployuploads. - 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:
| Feature | Crusoe AI Platform Functions | AWS Lambda | GCP Cloud Run Functions | Azure Functions |
|---|---|---|---|---|
| Deployment Model | Unified command or Console UI | AWS Console, SAM, or CDK | gcloud CLI or GCP Console | Azure Portal or Core Tools |
| Runtimes | Python, Node.js, Go, Ruby | Python, Node.js, Go, Java, custom | Python, Node.js, Go, Java | Python, Node.js, C#, Java |
| HTTPS Endpoint | Provisioned automatically | Requires API Gateway or Function URL | Provisioned automatically | Provisioned automatically |
| Scaling | Automatic scale-to-zero compute | Auto-scaling per concurrency limit | Auto-scaling instance counts | Auto-scaled app service plans |
Note: Multi-region replication and custom SLA guarantees are currently unavailable.
Next steps
- Quickstart: Deploy your first function — Deploy, test, and manage a function in minutes.
- Language Guides — Detailed guides for Python, Node.js, Go, and Ruby.
- Triggers — Configure triggers for HTTP, Cron schedules, Pub/Sub, and ObjectStore.
- Runtimes reference — Complete specification of handler contracts and event signatures.
- HTTP and Events — Technical details on request bodies, event limits, and CloudEvents.
- Troubleshooting — Solutions for common deployment and runtime errors.