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

# Log Artifact In Experiment

> Log or append an artifact value under an experiment metrics key.

Use this tool when the caller needs to persist run metadata, scalar values,
time-series points, JSON payloads, or base64 image artifacts under an
experiment. Repeated writes to the same ``data.name`` are stored as
timestamp-keyed entries and may later read back as normalized timeseries or
value shapes.

When to Use:
    - Call this after a run, optimization, or analysis step when metadata
      or derived outputs should be attached to an experiment.
    - Call this when the workflow needs to persist human-readable notes,
      numeric values, JSON payloads, or image-like previews.

Constraints:
    - ``kind`` must be exactly one of ``text``, ``value``, ``timeseries``,
      ``list``, ``dict``, or ``image``.
    - Repeated writes are stored under timestamp keys in the experiment
      metrics map, so read-side responses may normalize to ``value`` or
      ``timeseries`` instead of preserving the write-time ``kind`` verbatim.

Notes:
    - The route returns an empty ``200`` response on success.
    - After logging, callers can use ``list_artifacts_in_experiment`` or
      ``get_artifact_in_experiment`` to inspect the normalized MCP
      read-side artifact shape.

Args:
    experiment_id: Parent experiment identifier.
    user: Authenticated user resolved from the API key.
    data: Artifact payload. ``kind`` must be exactly one of ``text``,
        ``value``, ``timeseries``, ``list``, ``dict``, or ``image``.
    db: Active database session.

Returns:
    An empty ``200`` response when artifact data is persisted.

Raises:
    HTTPException: Raised with ``404`` if the experiment is missing, or
        ``400`` for invalid artifact shape such as missing timeseries
        points.



## OpenAPI

````yaml https://api.haiqu.ai/openapi.json post /ai/{experiment_id}/log_artifact
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:
  /ai/{experiment_id}/log_artifact:
    post:
      summary: Log Artifact In Experiment
      description: >-
        Log or append an artifact value under an experiment metrics key.


        Use this tool when the caller needs to persist run metadata, scalar
        values,

        time-series points, JSON payloads, or base64 image artifacts under an

        experiment. Repeated writes to the same ``data.name`` are stored as

        timestamp-keyed entries and may later read back as normalized timeseries
        or

        value shapes.


        When to Use:
            - Call this after a run, optimization, or analysis step when metadata
              or derived outputs should be attached to an experiment.
            - Call this when the workflow needs to persist human-readable notes,
              numeric values, JSON payloads, or image-like previews.

        Constraints:
            - ``kind`` must be exactly one of ``text``, ``value``, ``timeseries``,
              ``list``, ``dict``, or ``image``.
            - Repeated writes are stored under timestamp keys in the experiment
              metrics map, so read-side responses may normalize to ``value`` or
              ``timeseries`` instead of preserving the write-time ``kind`` verbatim.

        Notes:
            - The route returns an empty ``200`` response on success.
            - After logging, callers can use ``list_artifacts_in_experiment`` or
              ``get_artifact_in_experiment`` to inspect the normalized MCP
              read-side artifact shape.

        Args:
            experiment_id: Parent experiment identifier.
            user: Authenticated user resolved from the API key.
            data: Artifact payload. ``kind`` must be exactly one of ``text``,
                ``value``, ``timeseries``, ``list``, ``dict``, or ``image``.
            db: Active database session.

        Returns:
            An empty ``200`` response when artifact data is persisted.

        Raises:
            HTTPException: Raised with ``404`` if the experiment is missing, or
                ``400`` for invalid artifact shape such as missing timeseries
                points.
      operationId: log_artifact_in_experiment
      parameters:
        - name: experiment_id
          in: path
          required: true
          schema:
            type: string
            title: Experiment Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ContextArtifactSubmitModel'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyQuery: []
        - APIKeyHeader: []
components:
  schemas:
    ContextArtifactSubmitModel:
      properties:
        name:
          type: string
          title: Name
        kind:
          type: string
          enum:
            - text
            - value
            - timeseries
            - list
            - dict
            - image
            - file
          title: Kind
          description: >-
            Artifact type. Use `text` for strings, `value` for a single numeric
            value, `timeseries` for numeric points in `points`, `list` for JSON
            arrays, `dict` for JSON objects, and `image` for a base64 data URL
            such as `data:image/png;base64,...`.
        value:
          anyOf:
            - {}
            - type: 'null'
          title: Value
          description: >-
            Artifact payload for all kinds except `timeseries`. Send properly
            typed JSON values: string for `text`, number for `value`, array for
            `list`, object for `dict`, and a base64 data URL string for `image`.
            Leave this empty when `kind` is `timeseries`.
        points:
          anyOf:
            - items:
                $ref: '#/components/schemas/ContextTimeSeriesItem'
              type: array
            - type: 'null'
          title: Points
          description: >-
            Time series points to log when `kind` is `timeseries`. Each item
            must have numeric `x` and `y` fields. Leave this empty for all other
            kinds.
      type: object
      required:
        - name
      title: ContextArtifactSubmitModel
      description: >-
        Define payload for logging experiment artifacts from MCP tools.


        Logged artifact kinds are accepted on write, but MCP read endpoints
        expose a

        normalized artifact view and do not preserve every submitted ``kind`` as
        a

        distinct response shape.


        Attributes:
            name: Artifact key under which values are stored.
            kind: Artifact serialization mode accepted by the logging endpoint.
            value: Value payload for non-timeseries kinds.
            points: Time series points used when ``kind='timeseries'``.
      examples:
        - kind: value
          name: energy
          value: 42
        - kind: text
          name: note
          value: Optimization converged after 18 iterations
        - kind: timeseries
          name: training_loss
          points:
            - x: 1710000000
              'y': 0.91
            - x: 1710000060
              'y': 0.63
            - x: 1710000120
              'y': 0.41
        - kind: list
          name: probabilities
          value:
            - 0.12
            - 0.38
            - 0.5
        - kind: dict
          name: run_metadata
          value:
            device: simulator
            seed: 7
            shots: 1024
        - kind: image
          name: circuit_preview
          value: data:image/png;base64,aGVsbG8=
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ContextTimeSeriesItem:
      properties:
        x:
          type: number
          title: X
        'y':
          type: number
          title: 'Y'
      type: object
      title: ContextTimeSeriesItem
      description: |-
        Represent one point in a time series artifact payload.

        Attributes:
            x: Timestamp in Unix seconds.
            y: Numeric value for this timestamp.
    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

````