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

# Choose the provider for a new sandbox

> Orders the providers the team lists for one new sandbox with CostGraph AutoPilot. providers are ComputeSDK provider names in the team's order; a repeated name counts once. Send the sandbox size as size_class (xs, sm, md, lg, xl or 2xl), or as vcpus and memory_mib; size_class wins when both are sent. Only the first 20 providers are priced, and a name CostGraph does not recognise is kept without a price. The team's first provider is the baseline. Providers are compared on expected_cost, the USD cost of one sandbox of the size running for expected_seconds: the run time rounded up to the provider's billing increment and at least its minimum billed time, at its price per hour. expected_seconds is the median run time, at most 24 hours, of the team's stopped sandboxes of the same size that started in the last 30 days when there are at least 20, otherwise 600. startup_p50_ms and success_rate come from ComputeSDK's public burst benchmark (github.com/computesdk/benchmarks, MIT), which starts 100 sandboxes at once: the median milliseconds from a create request to the first command in that sandbox, and the share of the 100 starts that succeeded; both are null for a provider it does not benchmark. When AutoPilot for sandboxes is on, the order follows the team's policy. cheapest: providers with a price for the size, lowest expected_cost first, then the others; a provider whose startup_p50_ms is more than twice the baseline's goes after the other priced providers, and a missing start time never holds a provider back. fastest: providers whose expected_cost is no more than the baseline's, fastest start first, then lower expected_cost, with those without a start time after them by expected_cost, then dearer providers in the same way, then those without a price; the baseline stays first unless a provider starts strictly faster than it. balanced: a provider whose expected_cost is no more than the baseline's and whose start time is within the baseline's start time plus the larger of 100 ms and 10% (the limit) scores (baseline expected_cost - its expected_cost) x (limit - its startup_p50_ms); providers scoring above zero come first, highest score first, then faster start, then lower expected_cost; then the other priced providers by start time (none last), then expected_cost; then those without a price; the baseline stays first when no provider scores above zero. In every policy a provider other than the baseline whose success_rate is below 0.95 moves to the end, and remaining ties keep the team's order. reason is the policy (cheapest, fastest or balanced) when the first provider changed, otherwise no_better_candidate. The order stays the team's when AutoPilot is off (reason off), when no size is sent (reason no_size) and when the baseline has no price for the size (reason baseline_not_priced). candidates lists every provider in the returned order with its USD price per hour, expected_cost, billing_increment_seconds and minimum_billed_seconds for the size when known. Always answers 200 when the body has at least one provider: when CostGraph cannot choose (rate_limited, billing_required or error), the order is the team's, candidates is empty and decision_id is empty. When the reason is billing_required, billing_url links to the billing settings. Send decision_id back with the sandbox's started event.



## OpenAPI

````yaml /api-reference/costgraph/openapi.json post /api/v1/tenant/sandboxes/route
openapi: 3.0.0
info:
  description: Read and manage your CostGraph organization, spend, alerts, and settings.
  title: CostGraph API
  contact: {}
  version: '1.0'
servers:
  - url: https://api.costgraph.ai
security: []
tags:
  - name: ai
    x-group: AI
  - name: ai-serving
    x-group: AI serving
  - name: anomalies
    x-group: Anomalies
  - name: auth
    x-group: Auth
  - name: billing
    x-group: Billing
  - name: billing-export
    x-group: Billing export
  - name: budgets
    x-group: Budgets
  - name: ci
    x-group: CI
  - name: compute-recommendations
    x-group: Compute recommendations
  - name: config
    x-group: Config
  - name: context-graph
    x-group: Context graph
  - name: cost
    x-group: Cost
  - name: gpus
    x-group: GPUs
  - name: graphai
    x-group: Graph AI
  - name: integrations
    x-group: Integrations
  - name: invitations
    x-group: Invitations
  - name: kubernetes-clusters
    x-group: Kubernetes clusters
  - name: marketplace
    x-group: Marketplace
  - name: network
    x-group: Network
  - name: network-requests
    x-group: Network requests
  - name: notifications
    x-group: Notifications
  - name: oauth
    x-group: OAuth
  - name: oauth-clients
    x-group: OAuth clients
  - name: opencost
    x-group: OpenCost
  - name: organization
    x-group: Audit log
  - name: organizations
    x-group: Organizations
  - name: placement-alternatives
    x-group: Placement alternatives
  - name: reports
    x-group: Reports
  - name: sandboxes
    x-group: Sandboxes
  - name: settings
    x-group: Settings
  - name: sso
    x-group: Single sign-on
  - name: tenants
    x-group: Tenants
  - name: ticketing
    x-group: Ticketing
  - name: user
    x-group: Users
  - name: virtual-machines
    x-group: Virtual machines
  - name: virtual-tags
    x-group: Virtual tags
  - name: workflows
    x-group: Workflows
paths:
  /api/v1/tenant/sandboxes/route:
    post:
      tags:
        - sandboxes
      summary: Choose the provider for a new sandbox
      description: >-
        Orders the providers the team lists for one new sandbox with CostGraph
        AutoPilot. providers are ComputeSDK provider names in the team's order;
        a repeated name counts once. Send the sandbox size as size_class (xs,
        sm, md, lg, xl or 2xl), or as vcpus and memory_mib; size_class wins when
        both are sent. Only the first 20 providers are priced, and a name
        CostGraph does not recognise is kept without a price. The team's first
        provider is the baseline. Providers are compared on expected_cost, the
        USD cost of one sandbox of the size running for expected_seconds: the
        run time rounded up to the provider's billing increment and at least its
        minimum billed time, at its price per hour. expected_seconds is the
        median run time, at most 24 hours, of the team's stopped sandboxes of
        the same size that started in the last 30 days when there are at least
        20, otherwise 600. startup_p50_ms and success_rate come from
        ComputeSDK's public burst benchmark (github.com/computesdk/benchmarks,
        MIT), which starts 100 sandboxes at once: the median milliseconds from a
        create request to the first command in that sandbox, and the share of
        the 100 starts that succeeded; both are null for a provider it does not
        benchmark. When AutoPilot for sandboxes is on, the order follows the
        team's policy. cheapest: providers with a price for the size, lowest
        expected_cost first, then the others; a provider whose startup_p50_ms is
        more than twice the baseline's goes after the other priced providers,
        and a missing start time never holds a provider back. fastest: providers
        whose expected_cost is no more than the baseline's, fastest start first,
        then lower expected_cost, with those without a start time after them by
        expected_cost, then dearer providers in the same way, then those without
        a price; the baseline stays first unless a provider starts strictly
        faster than it. balanced: a provider whose expected_cost is no more than
        the baseline's and whose start time is within the baseline's start time
        plus the larger of 100 ms and 10% (the limit) scores (baseline
        expected_cost - its expected_cost) x (limit - its startup_p50_ms);
        providers scoring above zero come first, highest score first, then
        faster start, then lower expected_cost; then the other priced providers
        by start time (none last), then expected_cost; then those without a
        price; the baseline stays first when no provider scores above zero. In
        every policy a provider other than the baseline whose success_rate is
        below 0.95 moves to the end, and remaining ties keep the team's order.
        reason is the policy (cheapest, fastest or balanced) when the first
        provider changed, otherwise no_better_candidate. The order stays the
        team's when AutoPilot is off (reason off), when no size is sent (reason
        no_size) and when the baseline has no price for the size (reason
        baseline_not_priced). candidates lists every provider in the returned
        order with its USD price per hour, expected_cost,
        billing_increment_seconds and minimum_billed_seconds for the size when
        known. Always answers 200 when the body has at least one provider: when
        CostGraph cannot choose (rate_limited, billing_required or error), the
        order is the team's, candidates is empty and decision_id is empty. When
        the reason is billing_required, billing_url links to the billing
        settings. Send decision_id back with the sandbox's started event.
      parameters:
        - description: Tenant ID
          name: X-CostGraph-Tenant-ID
          in: header
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/sandbox.RouteRequest'
        description: The team's providers and the sandbox size
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/responses.SuccessResponse'
                  - type: object
                    properties:
                      data:
                        $ref: '#/components/schemas/sandbox.RouteResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/responses.ErrorResponse'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/responses.ErrorResponse'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    sandbox.RouteRequest:
      type: object
      required:
        - providers
      properties:
        memory_mib:
          type: integer
          example: 4096
        providers:
          type: array
          minItems: 1
          items:
            type: string
          example:
            - e2b
            - daytona
        size_class:
          type: string
          enum:
            - ''
            - xs
            - sm
            - md
            - lg
            - xl
            - 2xl
          example: md
        vcpus:
          type: integer
          example: 2
    responses.SuccessResponse:
      type: object
      required:
        - message
        - status
      properties:
        data: {}
        message:
          type: string
          example: some message
        status:
          type: string
          example: success
    sandbox.RouteResponse:
      type: object
      required:
        - candidates
        - decision_id
        - order
        - provider
        - reason
      properties:
        billing_url:
          type: string
        candidates:
          type: array
          items:
            $ref: '#/components/schemas/sandbox.RouteCandidate'
        decision_id:
          type: string
        expected_seconds:
          type: number
          nullable: true
        order:
          type: array
          items:
            type: string
        provider:
          type: string
        reason:
          type: string
          enum:
            - cheapest
            - balanced
            - fastest
            - no_better_candidate
            - 'off'
            - no_size
            - baseline_not_priced
            - rate_limited
            - billing_required
            - error
    responses.ErrorResponse:
      type: object
      required:
        - message
        - status
      properties:
        message:
          type: string
          example: some message
        status:
          type: string
          example: error
    sandbox.RouteCandidate:
      type: object
      required:
        - priced
        - provider
      properties:
        billing_increment_seconds:
          type: integer
          nullable: true
        expected_cost:
          type: number
          x-semantic: costAmount
          nullable: true
        minimum_billed_seconds:
          type: integer
          nullable: true
        price_per_hour:
          type: number
          x-semantic: costAmount
          nullable: true
        priced:
          type: boolean
        provider:
          type: string
        sku:
          type: string
        startup_p50_ms:
          type: number
          nullable: true
        success_rate:
          type: number
          nullable: true
  securitySchemes:
    ApiKeyAuth:
      description: API key for machine-to-machine authentication
      type: apiKey
      name: X-API-Key
      in: header

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.