> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gp.scale.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Submit container image build

> Create a container image build record.

This multipart request accepts exactly one image source. Provide `context_archive`
to stream a tar.gz build context to the configured cloud build provider, or provide
`image_url` to register an existing tagged image as an immediately successful build
without invoking the provider. `build_args` and `platform` apply only to archive
builds.

Exactly one of `agent_name` or `agent_id` must identify the target agent.
`agent_name` creates a new build-only agent and must be unused. `agent_id` targets
an existing agent. Archive builds normally return in a queued or running state;
prebuilt images can immediately be passed to Cloud Deploy using the returned build
ID. Archives must be non-empty and no larger than 500 MB.



## OpenAPI

````yaml /openapi/v5.yaml post /v5/builds
openapi: 3.1.0
info:
  title: EGP API V5
  description: >-
    This is the parent API for all EGP APIs. If you are looking for the EGP API,
    please go to https://api.egp.scale.com/docs.
  contact:
    name: Scale Generative AI Platform
    url: https://scale.com/genai-platform
  version: 0.1.0
servers:
  - url: https://api.egp.scale.com
security: []
paths:
  /v5/builds:
    post:
      tags:
        - Agentex Cloud Build
      summary: Submit container image build
      description: >-
        Create a container image build record.


        This multipart request accepts exactly one image source. Provide
        `context_archive`

        to stream a tar.gz build context to the configured cloud build provider,
        or provide

        `image_url` to register an existing tagged image as an immediately
        successful build

        without invoking the provider. `build_args` and `platform` apply only to
        archive

        builds.


        Exactly one of `agent_name` or `agent_id` must identify the target
        agent.

        `agent_name` creates a new build-only agent and must be unused.
        `agent_id` targets

        an existing agent. Archive builds normally return in a queued or running
        state;

        prebuilt images can immediately be passed to Cloud Deploy using the
        returned build

        ID. Archives must be non-empty and no larger than 500 MB.
      operationId: POST-V5-/builds
      parameters:
        - name: x-selected-account-id
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Account ID Header
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/AgentexCloudBuildSubmitRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentexCloudBuild'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
components:
  schemas:
    AgentexCloudBuildSubmitRequest:
      properties:
        context_archive:
          anyOf:
            - type: string
              format: binary
            - type: 'null'
          title: Context Archive
          description: >-
            tar.gz archive containing the build context (Dockerfile and any
            files needed for the build)
        image_name:
          type: string
          title: Image Name
          description: Name for the built image
        image_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Image Url
          description: Existing tagged image to register instead of running a build
        agent_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Agent Name
          description: Name of the brand-new agent to create from this build
        agent_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Agent Id
          description: ID of the existing agent this build targets
        image_tag:
          type: string
          title: Image Tag
          description: Tag for the built image
          default: latest
        build_args:
          anyOf:
            - type: string
            - type: 'null'
          title: Build Args
          description: JSON string of build arguments
        platform:
          anyOf:
            - type: string
              enum:
                - linux/amd64
                - linux/arm64
                - linux/arm/v7
            - type: 'null'
          title: Platform
          description: >-
            Target platform for the Docker build. Defaults to the build host's
            native architecture when not specified.
        source_repo:
          anyOf:
            - type: string
              maxLength: 2048
            - type: 'null'
          title: Source Repo
          description: Normalized git remote the build context came from.
        source_commit:
          anyOf:
            - type: string
              maxLength: 64
              pattern: ^(?:[0-9a-fA-F]{40}|[0-9a-fA-F]{64})$
            - type: 'null'
          title: Source Commit
          description: Git commit the build context was at.
        source_ref:
          anyOf:
            - type: string
              maxLength: 4096
            - type: 'null'
          title: Source Ref
          description: Git branch or tag for source_commit.
        source_subpath:
          anyOf:
            - type: string
              maxLength: 4096
            - type: 'null'
          title: Source Subpath
          description: Build-context path relative to the repo root.
        working_tree_hash:
          anyOf:
            - type: string
              maxLength: 64
              pattern: ^[0-9a-fA-F]{64}$
            - type: 'null'
          title: Working Tree Hash
          description: Deterministic SHA-256 content hash of the build inputs.
        source_dirty:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Source Dirty
          description: Whether the work tree had uncommitted changes at build time.
      type: object
      required:
        - image_name
      title: AgentexCloudBuildSubmitRequest
    AgentexCloudBuild:
      properties:
        id:
          type: string
          title: Id
          description: The unique identifier of the entity.
        object:
          type: string
          const: agentex_cloud_build
          title: Object
          default: agentex_cloud_build
        cloud_provider_build_id:
          type: string
          title: Cloud Provider Build Id
          description: >-
            The unique identifier of the build from the cloud provider, or an
            internal UUID when an existing image is copied without a provider
            build.
        agent_name:
          type: string
          title: Agent Name
          description: The name of the agent that this build belongs to
        agent_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Agent Id
          description: The UUID of the agent that this build belongs to
        image_name:
          type: string
          title: Image Name
          description: The name of the container image to build.
        image_tag:
          type: string
          title: Image Tag
          description: The tag for the container image.
        image_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Image Url
          description: >-
            The URL of the container image. This is not guaranteed to be present
            until the build is complete.
        image_digest:
          anyOf:
            - type: string
            - type: 'null'
          title: Image Digest
          description: >-
            Registry manifest digest of the pushed image (e.g. sha256:...).
            Reported by the cloud provider when the build completes; null until
            then, and null on builds whose provider path does not report one.
            Unlike image_url, it names the exact image bytes and cannot be
            repointed.
        build_status:
          $ref: '#/components/schemas/AgentexCloudBuildStatus'
          description: The current build lifecycle status
        build_start_time:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Build Start Time
          description: When the cloud provider started the build
        build_end_time:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Build End Time
          description: When the cloud provider finished the build
        source_repo:
          anyOf:
            - type: string
            - type: 'null'
          title: Source Repo
          description: >-
            Normalized git remote the build context came from (host/path, no
            credentials).
        source_commit:
          anyOf:
            - type: string
            - type: 'null'
          title: Source Commit
          description: Git commit the build context was at, when a git work tree.
        source_ref:
          anyOf:
            - type: string
            - type: 'null'
          title: Source Ref
          description: Git branch or tag for source_commit, when resolvable.
        source_subpath:
          anyOf:
            - type: string
            - type: 'null'
          title: Source Subpath
          description: >-
            Build-context path relative to the repo root (which agent, in a
            monorepo).
        working_tree_hash:
          anyOf:
            - type: string
            - type: 'null'
          title: Working Tree Hash
          description: >-
            Deterministic SHA-256 content hash of the build inputs (not the
            tarball).
        source_dirty:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Source Dirty
          description: >-
            Whether the work tree had uncommitted changes at build time (null
            outside git).
        account_id:
          type: string
          title: Account Id
          description: The ID of the account that owns the given entity.
        created_at:
          type: string
          format: date-time
          title: Created At
          description: The date and time when the entity was created in ISO format.
        created_by:
          $ref: '#/components/schemas/Identity'
          description: The identity that created the entity.
      type: object
      required:
        - cloud_provider_build_id
        - agent_name
        - image_name
        - image_tag
        - build_status
        - source_repo
        - source_commit
        - source_ref
        - source_subpath
        - working_tree_hash
        - source_dirty
        - id
        - account_id
        - created_at
        - created_by
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    AgentexCloudBuildStatus:
      type: string
      enum:
        - queued
        - running
        - success
        - failed
        - cancelling
        - cancelled
        - deleting
        - delete_failed
        - timed_out
        - error
        - unknown
      title: AgentexCloudBuildStatus
    Identity:
      properties:
        id:
          type: string
          title: Id
        object:
          type: string
          const: identity
          title: Object
          default: identity
        type:
          $ref: '#/components/schemas/IdentityType'
      type: object
      required:
        - id
        - type
      title: Identity
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
          additionalProperties: true
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    IdentityType:
      type: string
      enum:
        - user
        - service_account
      title: IdentityType
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: x-api-key

````