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

# Flow

> Flow (hybrid program execution) endpoint. Creates a job.

Args:
    user (User): User authenticated with api key.
    data (HybridSubmitModel): Hybrid job arguments.
    db: Database.

Returns:
    HybridJobModel: The new job object.



## OpenAPI

````yaml https://api.haiqu.ai/openapi.json post /flow
openapi: 3.1.0
info:
  title: Haiqu API
  summary: Haiqu RESTful API service.
  description: Cloud service providing the access to Haiqu cloud runtime
  contact:
    name: Haiqu Inc.
    url: https://haiqu.ai/
    email: info@haiqu.ai
  version: 1.4.0
servers: []
security: []
paths:
  /flow:
    post:
      summary: Flow
      description: |-
        Flow (hybrid program execution) endpoint. Creates a job.

        Args:
            user (User): User authenticated with api key.
            data (HybridSubmitModel): Hybrid job arguments.
            db: Database.

        Returns:
            HybridJobModel: The new job object.
      operationId: flow_flow_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/HybridSubmitModel'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HybridJobModel'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyQuery: []
        - APIKeyHeader: []
components:
  schemas:
    HybridSubmitModel:
      properties:
        experiment_id:
          type: string
          title: Experiment Id
        name:
          anyOf:
            - type: string
            - type: 'null'
          title: Name
          default: ''
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
          default: ''
        program:
          $ref: '#/components/schemas/HybridProgram'
        circuit_ids:
          items:
            type: string
          type: array
          minItems: 1
          title: Circuit Ids
        shots:
          type: integer
          minimum: 1
          title: Shots
          default: 1000
        parameters:
          anyOf:
            - items: {}
              type: array
            - type: 'null'
          title: Parameters
        observables:
          anyOf:
            - items:
                items:
                  prefixItems:
                    - items:
                        type: string
                      type: array
                    - items:
                        type: number
                      type: array
                  type: array
                  maxItems: 2
                  minItems: 2
                type: array
              type: array
            - type: 'null'
          title: Observables
        device_credentials:
          additionalProperties: true
          type: object
          title: Device Credentials
          default: {}
        dry_run:
          type: boolean
          title: Dry Run
          default: false
      type: object
      required:
        - experiment_id
        - program
        - circuit_ids
      title: HybridSubmitModel
      description: Hybrid submit payload data model.
    HybridJobModel:
      properties:
        id:
          type: string
          title: Id
        name:
          anyOf:
            - type: string
            - type: 'null'
          title: Name
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
        user_id:
          type: integer
          title: User Id
        experiment_id:
          type: string
          title: Experiment Id
        status:
          $ref: '#/components/schemas/JobStatus'
        job_type:
          $ref: '#/components/schemas/JobType'
        device_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Device Id
          default: Haiqu OS
        creation_date:
          type: string
          format: date-time
          title: Creation Date
        run_date:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Run Date
        finish_date:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Finish Date
        logs:
          anyOf:
            - type: string
            - type: 'null'
          title: Logs
        quality:
          anyOf:
            - type: number
            - type: 'null'
          title: Quality
        info:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Info
        time:
          anyOf:
            - type: number
            - type: 'null'
          title: Time
        parameters:
          anyOf:
            - items: {}
              type: array
            - type: 'null'
          title: Parameters
        program:
          $ref: '#/components/schemas/HybridProgram'
        input_circuit_ids:
          items:
            type: string
          type: array
          title: Input Circuit Ids
        shots:
          type: integer
          title: Shots
        observables:
          anyOf:
            - items:
                items:
                  prefixItems:
                    - items:
                        type: string
                      type: array
                    - items:
                        type: number
                      type: array
                  type: array
                  maxItems: 2
                  minItems: 2
                type: array
              type: array
            - type: 'null'
          title: Observables
        dry_run:
          type: boolean
          title: Dry Run
        quantum_results:
          anyOf:
            - items: {}
              type: array
            - type: 'null'
          title: Quantum Results
        estimated_qpu_cost:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Estimated Qpu Cost
      type: object
      required:
        - id
        - user_id
        - experiment_id
        - status
        - job_type
        - creation_date
        - program
        - input_circuit_ids
        - shots
        - dry_run
      title: HybridJobModel
      description: Hybrid Job (running on Haiqu backend).
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    HybridProgram:
      properties:
        schema_version:
          type: integer
          exclusiveMinimum: 0
          title: Schema Version
          default: 1
        layers:
          items:
            oneOf:
              - $ref: '#/components/schemas/InputLayer'
              - $ref: '#/components/schemas/DeviceLayer'
              - $ref: '#/components/schemas/PackingLayer'
              - $ref: '#/components/schemas/TranspilationLayer'
              - $ref: '#/components/schemas/EstimatorLayer'
              - $ref: '#/components/schemas/DistributionMitigationLayer'
              - $ref: '#/components/schemas/ObservableSplitLayer'
              - $ref: '#/components/schemas/NoiseTailoringLayer'
              - $ref: '#/components/schemas/DynamicalDecouplingLayer'
              - $ref: '#/components/schemas/AdvancedObsMitigationLayer'
              - $ref: '#/components/schemas/AdvancedDistMitigationLayer'
              - $ref: '#/components/schemas/AdvancedReadoutMitigationLayer'
              - $ref: '#/components/schemas/QWCComputeLayer'
            discriminator:
              propertyName: type
              mapping:
                advanced_dist_mitigation:
                  $ref: '#/components/schemas/AdvancedDistMitigationLayer'
                advanced_obs_mitigation:
                  $ref: '#/components/schemas/AdvancedObsMitigationLayer'
                advanced_readout_mitigation:
                  $ref: '#/components/schemas/AdvancedReadoutMitigationLayer'
                device:
                  $ref: '#/components/schemas/DeviceLayer'
                distribution_mitigation:
                  $ref: '#/components/schemas/DistributionMitigationLayer'
                dynamical_decoupling:
                  $ref: '#/components/schemas/DynamicalDecouplingLayer'
                estimator:
                  $ref: '#/components/schemas/EstimatorLayer'
                input:
                  $ref: '#/components/schemas/InputLayer'
                noise_tailoring:
                  $ref: '#/components/schemas/NoiseTailoringLayer'
                observable_split:
                  $ref: '#/components/schemas/ObservableSplitLayer'
                packing:
                  $ref: '#/components/schemas/PackingLayer'
                qwc_compute:
                  $ref: '#/components/schemas/QWCComputeLayer'
                transpilation:
                  $ref: '#/components/schemas/TranspilationLayer'
          type: array
          title: Layers
      type: object
      required:
        - layers
      title: HybridProgram
    JobStatus:
      type: string
      enum:
        - Submitted
        - Initializing
        - Queued
        - Validating
        - Running
        - Cancelled
        - Done
        - Error
      title: JobStatus
      description: Class for job status.
    JobType:
      type: string
      enum:
        - User local job
        - Analytics
        - Device specific analytics
        - Data Loading
        - Hybrid
        - Run
        - State Compression
        - Transpilation
        - Variational
        - Pretraining
        - SKQD
      title: JobType
      description: Class for job types.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    InputLayer:
      properties:
        type:
          type: string
          const: input
          title: Type
          default: input
      type: object
      title: InputLayer
      description: The program's entry point. Every program starts with one.
    DeviceLayer:
      properties:
        type:
          type: string
          const: device
          title: Type
          default: device
        device_id:
          type: string
          title: Device Id
        options:
          additionalProperties: true
          type: object
          title: Options
          default: {}
      type: object
      required:
        - device_id
      title: DeviceLayer
      description: |-
        Runs the circuits on a backend; every program ends with one.

        ``device_id`` selects the backend; ``options`` carries backend-specific
        settings (e.g. credentials).
    PackingLayer:
      properties:
        type:
          type: string
          const: packing
          title: Type
          default: packing
        pack_size:
          anyOf:
            - type: integer
              minimum: 2
            - type: 'null'
          title: Pack Size
      type: object
      title: PackingLayer
      description: >-
        Pack several copies of a circuit into one run to use spare device
        qubits.


        ``pack_size`` is the number of copies; leave it unset to pick a value

        automatically from the circuit and device sizes.
    TranspilationLayer:
      properties:
        type:
          type: string
          const: transpilation
          title: Type
          default: transpilation
        optimization_level:
          anyOf:
            - type: integer
              enum:
                - 0
                - 1
                - 2
                - 3
            - type: 'null'
          title: Optimization Level
      type: object
      title: TranspilationLayer
      description: >-
        Transpile the circuits for the target backend.


        ``optimization_level`` (0-3) sets the optimization effort; leave it
        unset for

        the default.
    EstimatorLayer:
      properties:
        type:
          type: string
          const: estimator
          title: Type
          default: estimator
        mitigation_enabled:
          type: boolean
          title: Mitigation Enabled
          default: false
        advanced_mitigation:
          type: boolean
          title: Advanced Mitigation
          default: true
        readout_mitigation:
          type: boolean
          title: Readout Mitigation
          default: true
        noise_tailoring:
          type: boolean
          title: Noise Tailoring
          default: false
        dynamical_decoupling:
          type: boolean
          title: Dynamical Decoupling
          default: true
        readout_mitigation_options:
          additionalProperties: true
          type: object
          title: Readout Mitigation Options
          default: {}
      type: object
      title: EstimatorLayer
      description: |-
        Measure observable expectation values with error mitigation.

        Use this when the job supplies observables. Error mitigation is opt-in.
    DistributionMitigationLayer:
      properties:
        type:
          type: string
          const: distribution_mitigation
          title: Type
          default: distribution_mitigation
        mitigation_enabled:
          type: boolean
          title: Mitigation Enabled
          default: true
        advanced_mitigation:
          type: boolean
          title: Advanced Mitigation
          default: true
        readout_mitigation:
          type: boolean
          title: Readout Mitigation
          default: true
        noise_tailoring:
          type: boolean
          title: Noise Tailoring
          default: false
        dynamical_decoupling:
          type: boolean
          title: Dynamical Decoupling
          default: true
        readout_mitigation_options:
          additionalProperties: true
          type: object
          title: Readout Mitigation Options
          default: {}
      type: object
      title: DistributionMitigationLayer
      description: |-
        Mitigate errors on the raw measured probability distribution.

        Use this when the job reads measurement outcomes (no observables).
    ObservableSplitLayer:
      properties:
        type:
          type: string
          const: observable_split
          title: Type
          default: observable_split
      type: object
      title: ObservableSplitLayer
      description: Split a task with several observables into one task per observable.
    NoiseTailoringLayer:
      properties:
        type:
          type: string
          const: noise_tailoring
          title: Type
          default: noise_tailoring
      type: object
      title: NoiseTailoringLayer
      description: Tailor device noise with Pauli twirling.
    DynamicalDecouplingLayer:
      properties:
        type:
          type: string
          const: dynamical_decoupling
          title: Type
          default: dynamical_decoupling
      type: object
      title: DynamicalDecouplingLayer
      description: Suppress idle-qubit errors with dynamical-decoupling sequences.
    AdvancedObsMitigationLayer:
      properties:
        type:
          type: string
          const: advanced_obs_mitigation
          title: Type
          default: advanced_obs_mitigation
      type: object
      title: AdvancedObsMitigationLayer
      description: >-
        Advanced observable-based error mitigation for hand-built pipelines.


        Use this in place of the ``advanced_mitigation`` flag on grouped
        mitigation

        layers when manually enabling observable-based advanced mitigation.
    AdvancedDistMitigationLayer:
      properties:
        type:
          type: string
          const: advanced_dist_mitigation
          title: Type
          default: advanced_dist_mitigation
      type: object
      title: AdvancedDistMitigationLayer
      description: >-
        Advanced distribution-based error mitigation for hand-built pipelines.


        Use this in place of the ``advanced_mitigation`` flag on grouped
        mitigation

        layers when manually enabling distribution-based advanced mitigation.
    AdvancedReadoutMitigationLayer:
      properties:
        type:
          type: string
          const: advanced_readout_mitigation
          title: Type
          default: advanced_readout_mitigation
      type: object
      title: AdvancedReadoutMitigationLayer
      description: Advanced measurement (readout) error mitigation.
    QWCComputeLayer:
      properties:
        type:
          type: string
          const: qwc_compute
          title: Type
          default: qwc_compute
      type: object
      title: QWCComputeLayer
      description: >-
        Compute observable expectation values from grouped commuting
        measurements.
  securitySchemes:
    APIKeyQuery:
      type: apiKey
      in: query
      name: HAIQU_API_KEY
    APIKeyHeader:
      type: apiKey
      in: header
      name: authorization

````