Deploy batch jobs on Blaxel as serverless, autoscalable workloads using the CLI, GitHub integration, or Dockerfile-based deployments.
This guide assumes you have developed a job locally.The Blaxel SDK allows you to connect to and orchestrate other resources (such as model APIs, tool servers, multi-agents) during development, and ensures telemetry, secure connections to third-party systems or private networks, smart global placement of workflows, and much more when jobs are deployed.
Learn more about authentication on Blaxel
The Blaxel SDK requires two environment variables to authenticate:
Variable
Description
BL_WORKSPACE
Your Blaxel workspace name
BL_API_KEY
Your Blaxel API key
You can create an API key from the Blaxel console. Your workspace name is visible in the URL when you log in to the console (e.g. app.blaxel.ai/{workspace}).Set them as environment variables or add them to a .env file at the root of your project:
When developing locally, you can also log in to your workspace with Blaxel CLI (as shown above). This allows you to run Blaxel SDK functions that will automatically connect to your workspace without additional setup. When you deploy on Blaxel, authentication is handled automatically — no environment variables needed.
You can deploy the job in order to make the entrypoint function (by default: index.ts / server.py) callable on a global endpoint. When deploying to Blaxel, you get a dedicated endpoint that enforces your deployment policies.Run the following command to build and deploy a local job on Blaxel:
bl deploy
You can alternatively use bl push to build and push the job container image to the Blaxel registry. bl push only publishes the image; it does not create a new sandbox deployment, update existing deployments, or restart running processes. This is useful for preparing images in advance.
Each deployed job has an HTTP endpoint to trigger a batch execution. You can find this endpoint in the Blaxel console, on the detail page for your deployed job.
HTTP endpoints are only available for deployed jobs.
You can invoke a job in multiple ways:
using the Blaxel SDK, API, or language-native HTTP client (only for deployed jobs);
For deployed jobs, you can start a batch job execution by running:
# Run a deployed job using Blaxel CLI with --data argumentbl run job <<JOB-NAME>> --data '{"tasks": [{"name": "John"}, {"name": "Jane"}]}'# Run a deployed job using Blaxel CLI with --file argumentbl run job <<JOB-NAME>> --file batches/sample-batch.json
When running a job locally, only JSON file input is currently supported, and you must include the --local argument:
# Run a job locally using Blaxel CLI with --local and --file argumentbl run job <<JOB-NAME>> --local --file batches/sample-batch.json
You can cancel a job execution from the Blaxel Console or via API.
The Blaxel Console > Dashboard displays detailed job metrics, including the number of active jobs, failures, and requests (both count and requests per second (RPS)) across all deployments.
To retrieve all jobs in your workspace, use the Management API list endpoint with pagination.
Pagination is recommended for list operations because retrieving all available resources in a single request is slow and resource-intensive, and therefore does not scale well.
For accounts with multiple workspaces, specify the workspace as an additional request parameter, such as ?workspace=WORKSPACE_NAME&..., or via an additional X-Blaxel-Workspace: WORKSPACE_NAME header in the request.
package.json # Mandatory. This file is the standard package.json file, it defines the entrypoint of the project and dependencies.blaxel.toml # This file lists configurations dedicated to Blaxel to customize the deployment.tsconfig.json # This file is the standard tsconfig.json file, only needed if you use TypeScript.src/└── index.ts # This file is the standard entrypoint of the project. It is where the core logic of the job is implemented.└── steps # This is an example of organization for your sub steps, feel free to change it.
Depending on what you do, all of the scripts are not required. With TypeScript, all 4 of them are used.
start : start the job locally through the TypeScript command, to avoid having to build the project when developing.
prod : start the job remotely from the dist folder, the project needs to have been built before.
build : build the project. It is done automatically when deploying.
The remaining fields in package.json follow standard JavaScript/TypeScript project conventions. Feel free to add any dependencies you need, but keep in mind that devDependencies are only used during the build process and are removed afterwards.
The deployment can be configured via the blaxel.toml file in your agent directory. This file is not mandatory; if the file is not found or a required option is not set, you will be prompted for the information during deployment.
name, workspace, and type fields are optional and serve as default values. Any bl command run in the folder will use these defaults rather than prompting you for input.
policies field is also optional. It allows you to specify a Blaxel policy to customize the deployment. For example, deploy it only in a specific region of the world.
[env] section defines environment variables that the job can access via the SDK. Note that these are NOT secrets.
[runtime] section lets you override job execution parameters: maximum number of concurrent tasks, maximum number of retries for each task, timeout (in s), or memory (in MB) to allocate.
[tasks] sections let you specify
[[triggers]] and [triggers.configuration] sections define ways to schedule job executions.
type = "cron" lets you create a cron schedule for the job to run periodically. The job will be executed without any argument by default. You can override this by passing:
tasks = [{my_arg="my_value"}] containing a list of task to execute at each occurrence of the cron (default value is one task, without arguments)
A private HTTP endpoint to launch job executions is always available by default, even if you don’t define a trigger in this file. You can launch a job execution by sending a POST request with the correct job and workspace arguments to https://api.blaxel.ai/v0/jobs/my-job/executions?workspace=my-workspace.
Ephemeral volumes are temporary disk-backed storage attached to a job at startup and automatically destroyed when the job completes. Ephemeral volumes have separate quotas from persistent volumes. Limits depend on your plan.
Ephemeral volumes are only available for jobs. Sandboxes and agents should use persistent volumes instead.