All Products
Search
Document Center

Function Compute:Billing Overview

Last Updated:Jul 13, 2026

FC Agent Sandbox is billed based on the actual resources and duration consumed by each sandbox. When you create a sandbox by using the E2B SDK or E2B CLI, pay close attention to the sandbox lifecycle, resource specifications, template build frequency, and how external storage is used.

Billing Method

FC Agent Sandbox supports pay-as-you-go billing. Under the pay-as-you-go model, charges are based on the sandbox specifications, runtime state, and actual usage duration. This model is suitable for development and testing, elastic workloads, and on-demand agent execution environments.

For detailed rules, see Pay-as-you-go.

Main Billable Items

FC Agent Sandbox charges usually consist of the following resource categories:

  • Compute resources: The vCPU and memory used while a sandbox is actively running.

  • Disk resources: The local sandbox disk and the disk capacity used to preserve state during hibernation.

  • Template build resources: The compute resources consumed when you build a custom template by calling Template.build().

  • External cloud resources: When you use capabilities from other cloud services such as NAS, OSS, or Internet egress, you are billed by those cloud services separately.

Specifications and Quotas

When you create a sandbox, you can choose a template and configure parameters such as timeout, environment variables, and metadata through the SDK. The actual specifications and quotas available to you depend on your account, region, and product configuration.

Before you move to production, evaluate the following indicators:

  • Peak concurrent sandbox count.

  • CPU, memory, and disk specifications for each sandbox.

  • Average sandbox lifetime.

  • Input and output file sizes for each task.

  • Template build frequency and build duration.

If the default quotas do not meet your business requirements, you can request a quota increase in the Function Compute console or through Alibaba Cloud support channels.

Lifecycle and Costs

Resources are occupied after a sandbox is created. After the task is complete, call sandbox.kill() to release resources as soon as possible.

const sandbox = await Sandbox.create("code-interpreter-v1", {
  apiKey: process.env.E2B_API_KEY,
  apiUrl: process.env.E2B_API_URL,
  domain: process.env.E2B_DOMAIN,
});

try {
  await sandbox.commands.run("python3 -c \"print('hello')\"");
} finally {
  await sandbox.kill();
}

If you need to preserve the task context, you can use the hibernation and resume capabilities. For resume behavior and billing rules in different states, see Pay-as-you-go.

Cost Control Recommendations

  • Set a reasonable timeout for each sandbox to avoid leaving it idle for too long.

  • Explicitly terminate the sandbox after the task is complete instead of relying only on automatic timeout.

  • Prebuild commonly used dependencies into custom templates to reduce repeated installation during runtime.

  • Avoid repeatedly downloading large dependencies, large models, or large data files inside a sandbox.

  • Set explicit exit conditions for background commands, port services, and polling tasks.

  • Persist long-term data to external storage such as NAS or OSS instead of relying on the local sandbox filesystem.