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

# Scenario

> Scenario search: find row modifications that reach a desired class.



## OpenAPI

````yaml https://api.outerproduct.com/openapi.json post /v1/models/{model_id}/scenario
openapi: 3.1.0
info:
  title: OuterProduct API
  description: >-
    Public-facing REST API for OuterProduct model distillation, prediction, and
    explanation.
  version: 0.1.8
servers: []
security: []
paths:
  /v1/models/{model_id}/scenario:
    post:
      tags:
        - inference
      summary: Scenario
      description: 'Scenario search: find row modifications that reach a desired class.'
      operationId: scenario_v1_models__model_id__scenario_post
      parameters:
        - name: model_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Model Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ScenarioRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JobResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - BearerAuth: []
components:
  schemas:
    ScenarioRequest:
      properties:
        dataframe:
          $ref: '#/components/schemas/WireDataFrame-Input'
          description: >-
            Inline dataset spec — each materialized row is one query for the
            scenario search. Caps on row count are enforced inside the worker
            after ``materialize()``.
        target_value:
          type: number
          title: Target Value
          description: >-
            Score the search drives each query's prediction to cross. In label
            units for regression; the positive-class probability in (0, 1) for
            binary classification (e.g. 0.5 flips to the other side of the
            decision boundary). Each query travels in whichever direction
            reaches it.
        n_trials:
          type: integer
          minimum: 1
          title: N Trials
          default: 500
        max_steps:
          type: integer
          minimum: 1
          title: Max Steps
          default: 30
        random_state:
          anyOf:
            - type: integer
            - type: 'null'
          title: Random State
          default: 42
        explain_every:
          type: integer
          minimum: 1
          title: Explain Every
          description: >-
            Speed/quality knob: higher values speed up the search at some cost
            to scenario yield. Default 1 (highest quality).
          default: 1
        check_every:
          type: integer
          minimum: 1
          title: Check Every
          description: >-
            Speed/quality knob with higher leverage than explain_every: higher
            values speed up the search with a coarser stride. Default 1 (highest
            quality).
          default: 1
        top_k_drivers:
          anyOf:
            - type: integer
              minimum: 1
            - type: 'null'
          title: Top K Drivers
          description: >-
            Restrict each step to the K most influential features — yields
            sparser scenarios on wide feature spaces. None = no restriction.
            Avoid 1 (too restrictive).
        constraints:
          additionalProperties:
            $ref: '#/components/schemas/FeatureConstraintSchema'
          type: object
          title: Constraints
      type: object
      required:
        - dataframe
        - target_value
      title: ScenarioRequest
    JobResponse:
      properties:
        job_id:
          $ref: '#/components/schemas/ID'
          description: Server-assigned id of the submitted job
        status:
          $ref: '#/components/schemas/JobStatus'
        message:
          type: string
          title: Message
      type: object
      required:
        - job_id
        - status
        - message
      title: JobResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    WireDataFrame-Input:
      properties:
        version:
          type: integer
          const: 1
          title: Version
          default: 1
        plan:
          additionalProperties: true
          type: object
          title: Plan
        columns:
          items:
            $ref: '#/components/schemas/FieldDef-Input'
          type: array
          title: Columns
      additionalProperties: false
      type: object
      required:
        - plan
        - columns
      title: WireDataFrame
    FeatureConstraintSchema:
      properties:
        immutable:
          type: boolean
          title: Immutable
          default: false
        monotonic:
          anyOf:
            - type: string
              enum:
                - increase
                - decrease
            - type: 'null'
          title: Monotonic
        value_range:
          anyOf:
            - prefixItems:
                - anyOf:
                    - type: number
                    - type: 'null'
                - anyOf:
                    - type: number
                    - type: 'null'
              type: array
              maxItems: 2
              minItems: 2
            - type: 'null'
          title: Value Range
        allowed_values:
          anyOf:
            - items: {}
              type: array
            - type: 'null'
          title: Allowed Values
      type: object
      title: FeatureConstraintSchema
      description: >-
        Per-feature restriction applied during scenario walks.


        Continuous-only fields (value_range, monotonic) and categorical-only
        fields (allowed_values) are validated server-side against the model's
        feature groups.
    ID:
      anyOf:
        - type: string
          format: uuid
        - type: string
    JobStatus:
      type: string
      enum:
        - pending
        - running
        - completed
        - failed
      title: JobStatus
    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
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    FieldDef-Input:
      properties:
        name:
          type: string
          title: Name
        datatype:
          $ref: '#/components/schemas/DataType-Input'
      additionalProperties: false
      type: object
      required:
        - name
        - datatype
      title: FieldDef
    DataType-Input:
      oneOf:
        - $ref: '#/components/schemas/String'
        - $ref: '#/components/schemas/Boolean'
        - $ref: '#/components/schemas/CategoricalString'
        - $ref: '#/components/schemas/CategoricalInteger'
        - $ref: '#/components/schemas/Integer'
        - $ref: '#/components/schemas/Real'
        - $ref: '#/components/schemas/Datetime-Input'
      discriminator:
        propertyName: kind
        mapping:
          boolean:
            $ref: '#/components/schemas/Boolean'
          categorical_integer:
            $ref: '#/components/schemas/CategoricalInteger'
          categorical_string:
            $ref: '#/components/schemas/CategoricalString'
          datetime:
            $ref: '#/components/schemas/Datetime-Input'
          integer:
            $ref: '#/components/schemas/Integer'
          real:
            $ref: '#/components/schemas/Real'
          string:
            $ref: '#/components/schemas/String'
    String:
      properties:
        kind:
          type: string
          const: string
          title: Kind
          default: string
      additionalProperties: false
      type: object
      title: String
    Boolean:
      properties:
        kind:
          type: string
          const: boolean
          title: Kind
          default: boolean
      additionalProperties: false
      type: object
      title: Boolean
    CategoricalString:
      properties:
        kind:
          type: string
          const: categorical_string
          title: Kind
          default: categorical_string
        values:
          items:
            type: string
          type: array
          title: Values
      additionalProperties: false
      type: object
      required:
        - values
      title: CategoricalString
    CategoricalInteger:
      properties:
        kind:
          type: string
          const: categorical_integer
          title: Kind
          default: categorical_integer
        values:
          items:
            type: integer
          type: array
          title: Values
      additionalProperties: false
      type: object
      required:
        - values
      title: CategoricalInteger
    Integer:
      properties:
        kind:
          type: string
          const: integer
          title: Kind
          default: integer
        bits:
          type: integer
          enum:
            - 8
            - 16
            - 32
            - 64
          title: Bits
        signed:
          type: boolean
          title: Signed
          default: true
        range:
          anyOf:
            - $ref: '#/components/schemas/Range_int_'
            - type: 'null'
      additionalProperties: false
      type: object
      required:
        - bits
      title: Integer
    Real:
      properties:
        kind:
          type: string
          const: real
          title: Kind
          default: real
        bits:
          type: integer
          enum:
            - 16
            - 32
            - 64
          title: Bits
        range:
          anyOf:
            - $ref: '#/components/schemas/Range_float_'
            - type: 'null'
      additionalProperties: false
      type: object
      required:
        - bits
      title: Real
    Datetime-Input:
      properties:
        kind:
          type: string
          const: datetime
          title: Kind
          default: datetime
      additionalProperties: false
      type: object
      title: Datetime
    Range_int_:
      properties:
        min:
          anyOf:
            - type: integer
            - type: 'null'
          title: Min
        max:
          anyOf:
            - type: integer
            - type: 'null'
          title: Max
      additionalProperties: false
      type: object
      title: Range[int]
    Range_float_:
      properties:
        min:
          anyOf:
            - type: number
            - type: 'null'
          title: Min
        max:
          anyOf:
            - type: number
            - type: 'null'
          title: Max
      additionalProperties: false
      type: object
      title: Range[float]
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API key or OAuth2/OIDC access token
      description: >-
        An API key or OAuth2/OIDC access token sent as `Authorization: Bearer
        <token>`.

````