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

# Estimate a prediction

> Validate and meter a prediction without running inference or charging credit.

The estimate is advisory. It does not reserve credit or lock the model or price
for a later prediction. USD amounts are exact decimal strings.



## OpenAPI

````yaml /openapi.json post /v1/predictions/estimate
openapi: 3.1.0
info:
  description: >-
    Synchronous structured predictions. Reuse Idempotency-Key for retries.
    Prices are USD decimal strings.
  title: D1 Prediction API
  version: 1.0.0
servers:
  - url: https://d1-staging-5gh8d.ondigitalocean.app
    description: Invited staging — simulated predictions and test credit
security:
  - APIKey: []
paths:
  /v1/predictions/estimate:
    post:
      tags:
        - Predictions
      summary: Estimate a prediction
      description: >-
        Validate and meter a prediction without running inference or charging
        credit.


        The estimate is advisory. It does not reserve credit or lock the model
        or price

        for a later prediction. USD amounts are exact decimal strings.
      operationId: estimate_v1_predictions_estimate_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PredictionInput'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EstimateResponse'
          description: Successful Response
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
          description: Malformed or ambiguous JSON.
          headers:
            Retry-After:
              description: When present, wait this many seconds before retrying.
              schema:
                minimum: 1
                type: integer
            X-Request-ID:
              description: Server request identifier for support and correlation.
              schema:
                type: string
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
          description: Missing, invalid, or revoked API key.
          headers:
            Retry-After:
              description: When present, wait this many seconds before retrying.
              schema:
                minimum: 1
                type: integer
            X-Request-ID:
              description: Server request identifier for support and correlation.
              schema:
                type: string
        '402':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
          description: Insufficient available credit.
          headers:
            Retry-After:
              description: When present, wait this many seconds before retrying.
              schema:
                minimum: 1
                type: integer
            X-Request-ID:
              description: Server request identifier for support and correlation.
              schema:
                type: string
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
          description: Account is waitlisted or suspended.
          headers:
            Retry-After:
              description: When present, wait this many seconds before retrying.
              schema:
                minimum: 1
                type: integer
            X-Request-ID:
              description: Server request identifier for support and correlation.
              schema:
                type: string
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
          description: Resource not found.
          headers:
            Retry-After:
              description: When present, wait this many seconds before retrying.
              schema:
                minimum: 1
                type: integer
            X-Request-ID:
              description: Server request identifier for support and correlation.
              schema:
                type: string
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
          description: >-
            Operation conflict, in-progress request, expired replay, or
            cancellation.
          headers:
            Retry-After:
              description: When present, wait this many seconds before retrying.
              schema:
                minimum: 1
                type: integer
            X-Request-ID:
              description: Server request identifier for support and correlation.
              schema:
                type: string
        '413':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
          description: Request exceeds a body, input, or model limit.
          headers:
            Retry-After:
              description: When present, wait this many seconds before retrying.
              schema:
                minimum: 1
                type: integer
            X-Request-ID:
              description: Server request identifier for support and correlation.
              schema:
                type: string
        '415':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
          description: Unsupported media type or content encoding.
          headers:
            Retry-After:
              description: When present, wait this many seconds before retrying.
              schema:
                minimum: 1
                type: integer
            X-Request-ID:
              description: Server request identifier for support and correlation.
              schema:
                type: string
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
          description: Request validation failed or model is unavailable.
          headers:
            Retry-After:
              description: When present, wait this many seconds before retrying.
              schema:
                minimum: 1
                type: integer
            X-Request-ID:
              description: Server request identifier for support and correlation.
              schema:
                type: string
        '429':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
          description: Account request, token, concurrency, or read limit exceeded.
          headers:
            Retry-After:
              description: When present, wait this many seconds before retrying.
              schema:
                minimum: 1
                type: integer
            X-Request-ID:
              description: Server request identifier for support and correlation.
              schema:
                type: string
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
          description: >-
            Unexpected service error; replay a prediction to resolve
            uncertainty.
          headers:
            Retry-After:
              description: When present, wait this many seconds before retrying.
              schema:
                minimum: 1
                type: integer
            X-Request-ID:
              description: Server request identifier for support and correlation.
              schema:
                type: string
        '502':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
          description: Invalid model output; no charge is settled.
          headers:
            Retry-After:
              description: When present, wait this many seconds before retrying.
              schema:
                minimum: 1
                type: integer
            X-Request-ID:
              description: Server request identifier for support and correlation.
              schema:
                type: string
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
          description: Service paused, capacity exhausted, or dependency unavailable.
          headers:
            Retry-After:
              description: When present, wait this many seconds before retrying.
              schema:
                minimum: 1
                type: integer
            X-Request-ID:
              description: Server request identifier for support and correlation.
              schema:
                type: string
        '504':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
          description: Prediction deadline exceeded; replay using the same operation key.
          headers:
            Retry-After:
              description: When present, wait this many seconds before retrying.
              schema:
                minimum: 1
                type: integer
            X-Request-ID:
              description: Server request identifier for support and correlation.
              schema:
                type: string
components:
  schemas:
    PredictionInput:
      additionalProperties: false
      properties:
        context:
          anyOf:
            - type: string
            - additionalProperties:
                $ref: '#/components/schemas/JsonValue'
              type: object
          title: Context
        model:
          default: default
          maxLength: 128
          minLength: 1
          pattern: ^[A-Za-z0-9_.-]+$
          title: Model
          type: string
        questions:
          items:
            discriminator:
              mapping:
                binary:
                  $ref: '#/components/schemas/BinaryQuestion'
                choice:
                  $ref: '#/components/schemas/ChoiceQuestion'
                score:
                  $ref: '#/components/schemas/ScoreQuestion'
              propertyName: type
            oneOf:
              - $ref: '#/components/schemas/BinaryQuestion'
              - $ref: '#/components/schemas/ChoiceQuestion'
              - $ref: '#/components/schemas/ScoreQuestion'
          maxItems: 16
          minItems: 1
          title: Questions
          type: array
      required:
        - context
        - questions
      title: PredictionInput
      type: object
    EstimateResponse:
      additionalProperties: false
      properties:
        estimated_cost_usd:
          pattern: ^\d+\.\d{9}$
          title: Estimated Cost Usd
          type: string
        input_tokens:
          minimum: 0
          title: Input Tokens
          type: integer
        metering_version:
          maxLength: 128
          minLength: 1
          pattern: ^[A-Za-z0-9_.-]+$
          title: Metering Version
          type: string
        model:
          maxLength: 128
          minLength: 1
          pattern: ^[A-Za-z0-9_.-]+$
          title: Model
          type: string
        pricing_version:
          maxLength: 128
          minLength: 1
          pattern: ^[A-Za-z0-9_.-]+$
          title: Pricing Version
          type: string
      required:
        - model
        - input_tokens
        - estimated_cost_usd
        - metering_version
        - pricing_version
      title: EstimateResponse
      type: object
    ErrorEnvelope:
      additionalProperties: false
      properties:
        error:
          $ref: '#/components/schemas/ErrorDetail'
      required:
        - error
      title: ErrorEnvelope
      type: object
    JsonValue: {}
    BinaryQuestion:
      additionalProperties: false
      properties:
        id:
          maxLength: 128
          minLength: 1
          pattern: ^[A-Za-z0-9_.-]+$
          title: Id
          type: string
        prompt:
          maxLength: 262144
          minLength: 1
          title: Prompt
          type: string
        type:
          const: binary
          title: Type
          type: string
      required:
        - id
        - prompt
        - type
      title: BinaryQuestion
      type: object
    ChoiceQuestion:
      additionalProperties: false
      properties:
        id:
          maxLength: 128
          minLength: 1
          pattern: ^[A-Za-z0-9_.-]+$
          title: Id
          type: string
        options:
          items:
            $ref: '#/components/schemas/Option'
          maxItems: 32
          minItems: 2
          title: Options
          type: array
        prompt:
          maxLength: 262144
          minLength: 1
          title: Prompt
          type: string
        type:
          const: choice
          title: Type
          type: string
      required:
        - id
        - prompt
        - type
        - options
      title: ChoiceQuestion
      type: object
    ScoreQuestion:
      additionalProperties: false
      properties:
        id:
          maxLength: 128
          minLength: 1
          pattern: ^[A-Za-z0-9_.-]+$
          title: Id
          type: string
        levels:
          items:
            maxLength: 262144
            minLength: 1
            type: string
          maxItems: 10
          minItems: 2
          title: Levels
          type: array
        prompt:
          maxLength: 262144
          minLength: 1
          title: Prompt
          type: string
        type:
          const: score
          title: Type
          type: string
      required:
        - id
        - prompt
        - type
        - levels
      title: ScoreQuestion
      type: object
    ErrorDetail:
      additionalProperties: false
      properties:
        code:
          title: Code
          type: string
        message:
          title: Message
          type: string
        request_id:
          title: Request Id
          type: string
      required:
        - code
        - message
        - request_id
      title: ErrorDetail
      type: object
    Option:
      additionalProperties: false
      properties:
        description:
          maxLength: 262144
          minLength: 1
          title: Description
          type: string
        id:
          maxLength: 128
          minLength: 1
          pattern: ^[A-Za-z0-9_.-]+$
          title: Id
          type: string
      required:
        - id
        - description
      title: Option
      type: object
  securitySchemes:
    APIKey:
      scheme: bearer
      type: http

````