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

# Create AI summary

> Create a new AI-generated summary. The public create surface
currently accepts `type=meal`; the resulting `MealSummary` is
retrievable through the list and detail routes alongside
system-generated summary types.

For meal records that should also appear in the user's meals
timeline and emit `meals:*` webhooks, use
`POST /users/{user_id}/nutrition/meals` instead. That endpoint
creates the meal, runs the same analysis, and links the
resulting `MealSummary` via `summary_id`.




## OpenAPI

````yaml /api-reference/openapi.yaml post /users/{user_id}/ai/summaries
openapi: 3.1.0
info:
  title: ONVY Health API
  description: >-
    AI-powered holistic health services API with data merging and metrics
    calculation
  version: 1.0.0
  contact:
    name: ONVY Support
    email: support@onvy.health
    url: https://onvy.health
  license:
    name: Proprietary
    url: https://onvy.health/terms
servers:
  - url: https://api.onvy.health
    description: Public API
security:
  - bearerAuth: []
tags:
  - name: static
    description: Static configuration endpoints
  - name: users
    description: User management
  - name: baselines
    description: User baseline metrics
  - name: daily-records
    description: Daily health records
  - name: chat
    description: AI chat completions
  - name: facts
    description: User facts for individualization
  - name: activities
    description: User activities (workouts and mindfulness sessions)
  - name: ai-summaries
    description: |
      AI-generated summaries. This is how ONVY exposes domain-specific
      insights such as meal nutrition analysis, sleep insights, workouts,
      and daily, weekly, nutrition, trend, and impact analysis. Most
      summary types are system-generated; the public create surface
      currently accepts `type=meal`.
  - name: custom-records
    description: Custom records and types
  - name: meals
    description: Nutrition meal tracking
paths:
  /users/{user_id}/ai/summaries:
    post:
      tags:
        - ai-summaries
      summary: Create AI summary
      description: |
        Create a new AI-generated summary. The public create surface
        currently accepts `type=meal`; the resulting `MealSummary` is
        retrievable through the list and detail routes alongside
        system-generated summary types.

        For meal records that should also appear in the user's meals
        timeline and emit `meals:*` webhooks, use
        `POST /users/{user_id}/nutrition/meals` instead. That endpoint
        creates the meal, runs the same analysis, and links the
        resulting `MealSummary` via `summary_id`.
      operationId: createAISummary
      parameters:
        - $ref: '#/components/parameters/UserIdParam'
      requestBody:
        description: AI summary creation data
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateAISummaryRequest'
            examples:
              text_meal:
                summary: Text-based meal summary
                value:
                  type: meal
                  data:
                    description: Grilled chicken breast with quinoa and steamed broccoli
                    meal_time: '2024-10-28T12:00:00Z'
                    portion_multiplier: 1.5
                    comment: Homemade healthy lunch
              image_meal:
                summary: Image-based meal summary
                value:
                  type: meal
                  data:
                    image_base64: data:image/jpeg;base64,/9j/4AAQSkZJRg...
                    meal_time: '2024-10-28T12:00:00Z'
                    portion_multiplier: 1
                    comment: Delicious homemade pasta
      responses:
        '201':
          description: AI summary created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AISummary'
        '400':
          $ref: '#/components/responses/BadRequest'
        '500':
          $ref: '#/components/responses/InternalError'
components:
  parameters:
    UserIdParam:
      name: user_id
      in: path
      required: true
      description: User ID (e.g., google_104940819145861640201)
      schema:
        type: string
  schemas:
    CreateAISummaryRequest:
      title: CreateAISummaryRequest
      type: object
      required:
        - type
        - data
      properties:
        type:
          type: string
          enum:
            - meal
          description: Type of AI summary to create. Currently only 'meal' is supported.
        data:
          description: Input data for the AI summary, structure depends on the type
          oneOf:
            - title: MealInput
              description: Input schema for creating or updating a meal
              type: object
              required:
                - meal_time
              properties:
                meal_time:
                  type: string
                  format: date-time
                  description: ISO 8601 timestamp of when the meal was consumed
                  example: '2024-10-28T12:00:00Z'
                description:
                  type: string
                  description: >-
                    Text description of the meal/food consumed. Required if
                    image_base64 is not provided.
                  maxLength: 2000
                  example: Grilled chicken breast with quinoa and steamed broccoli
                image_base64:
                  type: string
                  description: >-
                    Base64-encoded image data with data URI prefix. Required if
                    description is not provided.
                  pattern: ^data:image/(jpeg|png|jpg);base64,[A-Za-z0-9+/=]+$
                  example: data:image/jpeg;base64,/9j/4AAQSkZJRg...
                portion_multiplier:
                  type: number
                  description: Multiplier for portion size (default 1.0)
                  default: 1
                  minimum: 0.1
                  maximum: 10
                  example: 1.5
                comment:
                  type: string
                  description: Additional comment about the meal
                  maxLength: 500
                  example: Homemade healthy lunch
              anyOf:
                - required:
                    - description
                - required:
                    - image_base64
    AISummary:
      title: AISummary
      type: object
      required:
        - id
        - name
        - user_id
        - project_id
        - created_at
        - updated_at
        - period
        - data
        - llm_output
      properties:
        id:
          type: string
          description: Unique summary identifier
        name:
          type: string
          enum:
            - WorkoutSummary
            - MindfulsessionSummary
            - MealSummary
            - SleepSummary
            - DailySummary
            - WeeklySummary
            - TrendSummary
            - ImpactSummary
            - WeeklyActivitySummary
            - DailyNutritionSummary
            - WeeklyNutritionSummary
        user_id:
          type: string
        project_id:
          type: string
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        providers:
          type: array
          items:
            type: string
            enum:
              - GARMIN
              - APPLE
              - OURA
              - FITBIT
              - WHOOP
        is_custom:
          type: boolean
          description: If provided by customer POST
        ref:
          type: string
          description: Optional reference to original data
        period:
          type: object
          required:
            - type
            - id
            - start
            - end
          properties:
            type:
              type: string
              enum:
                - activity
                - day
                - week
                - month
                - quarter
                - half-year
                - year
            id:
              type: string
              description: Period identifier (e.g., 2024-W43, 2024-10-21)
            start:
              type: string
              format: date-time
            end:
              type: string
              format: date-time
            duration_seconds:
              type: integer
              description: Duration in seconds (for activity periods)
        data:
          type: object
          description: Additional metrics specific to summary type
        llm_output:
          type: object
          required:
            - language
            - title
            - text
          properties:
            language:
              type: string
              description: Language code (e.g., en, de)
            title:
              type: string
              description: Generated title
            text:
              type: string
              description: Generated summary text
            followup_questions:
              type: array
              items:
                type: string
        knowledge_urls:
          type: array
          items:
            type: object
            required:
              - title
              - url
            properties:
              title:
                type: string
              url:
                type: string
                format: uri
        user_comment:
          type:
            - string
            - 'null'
        user_rating:
          type: integer
          enum:
            - -1
            - 0
            - 1
          description: '-1 = bad, 0 = no rating, 1 = good'
        llm_debug:
          type: object
          properties:
            model:
              type: string
              description: Model used for generation
            prompt_id:
              type: string
              description: Prompt template identifier
            org_prompt_id:
              type: string
              description: Organization-specific prompt override
    ValidationError:
      type: object
      title: ValidationError
      required:
        - error
      properties:
        error:
          type: string
          minLength: 1
      additionalProperties: false
  responses:
    BadRequest:
      description: Bad request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ValidationError'
    InternalError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ValidationError'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: OAuth bearer token for Health API authentication

````