> ## 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.

# Postprocess Counts

> Apply post-processing to quantum measurement counts.

This endpoint provides access to Haiqu's proprietary optimization algorithms
for post-processing QAOA/VQE measurement results.

All algorithm defaults are defined in haiqu-optimization. Users can override
any parameter by passing it in the params dictionary.

Args:
    request: PostprocessRequest containing:
        - lp_problem: QUBO problem serialized as LP file format
        - counts: Dictionary of bitstring -> count mappings
        - params: Optional parameters dict. Available options:
            * method (str): Post-processing method. Default: "bitflip_incremental"
            * reverse_string (bool): Whether to reverse bitstring ordering. Default: True
            * postprocess_iterations (int): Number of optimization passes. Default: 5
            * use_fast_eval (bool): Enable fast evaluation. Default: True
            * seed (int): Random seed for reproducibility. Default: None

Returns:
    PostprocessResponse with optimized costs and counts

Raises:
    HTTPException: 400 if invalid problem format
    HTTPException: 500 if processing fails

Example:
    {
        "lp_problem": "Minimize\n  x0 + x1\nBinary\n  x0\n  x1\nEnd",
        "counts": {"00": 100, "01": 50},
        "params": {
            "postprocess_iterations": 10,
            "seed": 42
        }
    }



## OpenAPI

````yaml https://api.haiqu.ai/openapi.json post /postprocess
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:
  /postprocess:
    post:
      summary: Postprocess Counts
      description: >-
        Apply post-processing to quantum measurement counts.


        This endpoint provides access to Haiqu's proprietary optimization
        algorithms

        for post-processing QAOA/VQE measurement results.


        All algorithm defaults are defined in haiqu-optimization. Users can
        override

        any parameter by passing it in the params dictionary.


        Args:
            request: PostprocessRequest containing:
                - lp_problem: QUBO problem serialized as LP file format
                - counts: Dictionary of bitstring -> count mappings
                - params: Optional parameters dict. Available options:
                    * method (str): Post-processing method. Default: "bitflip_incremental"
                    * reverse_string (bool): Whether to reverse bitstring ordering. Default: True
                    * postprocess_iterations (int): Number of optimization passes. Default: 5
                    * use_fast_eval (bool): Enable fast evaluation. Default: True
                    * seed (int): Random seed for reproducibility. Default: None

        Returns:
            PostprocessResponse with optimized costs and counts

        Raises:
            HTTPException: 400 if invalid problem format
            HTTPException: 500 if processing fails

        Example:
            {
                "lp_problem": "Minimize\n  x0 + x1\nBinary\n  x0\n  x1\nEnd",
                "counts": {"00": 100, "01": 50},
                "params": {
                    "postprocess_iterations": 10,
                    "seed": 42
                }
            }
      operationId: postprocess_counts_postprocess_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PostprocessRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostprocessResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyQuery: []
        - APIKeyHeader: []
components:
  schemas:
    PostprocessRequest:
      properties:
        lp_problem:
          type: string
          title: Lp Problem
        counts:
          additionalProperties:
            anyOf:
              - type: integer
              - type: number
          type: object
          title: Counts
        params:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Params
      type: object
      required:
        - lp_problem
        - counts
      title: PostprocessRequest
      description: Request model for postprocessing endpoint.
    PostprocessResponse:
      properties:
        optimized_costs:
          additionalProperties:
            type: number
          type: object
          title: Optimized Costs
        optimized_counts:
          additionalProperties:
            anyOf:
              - type: integer
              - type: number
          type: object
          title: Optimized Counts
      type: object
      required:
        - optimized_costs
        - optimized_counts
      title: PostprocessResponse
      description: Response model for postprocessing endpoint.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    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
  securitySchemes:
    APIKeyQuery:
      type: apiKey
      in: query
      name: HAIQU_API_KEY
    APIKeyHeader:
      type: apiKey
      in: header
      name: authorization

````