Skip to main content
An Agent is the reusable definition a sandbox launches from: the container image, data center, size, start command and environment variables. In the Console, this is the Template you register. Creating an Agent builds its image; sandboxes can launch once the build is ready.

Create an Agent

A sandbox Agent without idc or instance_type returns HTTP 422. Creating an Agent does not start a sandbox.
If the Agent’s environment includes GMI_MODELS, create returns a generated model API key in generated_api_key. It is returned only by create, so store it then. Reading or updating the Agent later does not return it.In Python, read agent.generated_api_key right after create. agent.refresh() and agent.update() clear it, and the image-build wait loop calls refresh().

Wait for the image build

Poll the Agent until template_build_status is ready. A failed build sets it to error, with the reason in template_build_error. See the Quickstart for a complete wait loop. A new image can take a few minutes to build. Building the same image again is faster.

Read build logs

Each build has paged logs. Read them while the build runs to see progress or the cause of a failure.
  • Build statuses: waiting, building, ready, error.
  • has_more false only means nothing more is available right now. Keep polling from next_offset while the build is waiting or building, then read one last page after it ends.
  • Build logs are not kept long. Once they expire, reading them returns HTTP 410, even for a successful build. Save them yourself during the build if you need them.
  • failure.message on a failed build is safe to show to end users.

Get, list, update and delete

  • Updating a locked field returns HTTP 422.
  • Deleting an Agent returns HTTP 409 while it still has sandboxes. Delete the sandboxes first, then retry.