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

# Grounded clinical answer with citations

> Return a concise answer grounded ONLY in the clinical knowledge base, with the recommendations cited. Synchronous (non-streamed).



## OpenAPI

````yaml /openapi.json post /v1/answer
openapi: 3.1.0
info:
  title: Locus API
  description: >-
    Locus knowledge layer — REST + MCP for clinical knowledge.


    Two categories of surface:

    - **query** (read) — `/v1/search`, `/v1/answer`, `/v1/context` (legacy Meili
    contract serving AlmaPro) and `/v2/retrieve` (knowledge-graph retrieval, MKF
    0.1.3).

    - **ops** — `/health`.


    The write plane (PDF → Neo4j graph: ingest, summarize, MKU extraction) is
    NOT exposed over HTTP — it is a batch pipeline driven by the `locus` CLI,
    which runs where the source PDFs are.
  version: 0.2.0
servers:
  - url: https://core.locusmedical.fr
    description: Production
security: []
paths:
  /v1/answer:
    post:
      tags:
        - query
      summary: Grounded clinical answer with citations
      description: >-
        Return a concise answer grounded ONLY in the clinical knowledge base,
        with the recommendations cited. Synchronous (non-streamed).
      operationId: answer_endpoint_v1_answer_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AnswerRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnswerResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - lsk: []
components:
  schemas:
    AnswerRequest:
      properties:
        query:
          type: string
          minLength: 1
          title: Query
          description: Free-text clinical question in French.
          examples:
            - Quelle antibioprophylaxie pour une chirurgie colorectale ?
        source_ids:
          anyOf:
            - items:
                type: integer
              type: array
            - type: 'null'
          title: Source Ids
          description: >-
            Optional allow-list of source ids to restrict retrieval. Omit (the
            default) to search all sources.
          examples:
            - []
      type: object
      required:
        - query
      title: AnswerRequest
    AnswerResponse:
      properties:
        query:
          type: string
          title: Query
          description: Echo of the submitted question.
        reformulated_question:
          anyOf:
            - type: string
            - type: 'null'
          title: Reformulated Question
          description: The question restated clearly by the model.
        answer:
          type: string
          title: Answer
          description: >-
            Concise answer grounded ONLY in the retrieved sources. If the
            knowledge base does not cover the question, a fixed 'not found'
            sentence.
        sources:
          items:
            $ref: '#/components/schemas/AnswerSource'
          type: array
          title: Sources
          description: Citations actually used — deduplicated by recommendation.
        steps:
          items:
            $ref: '#/components/schemas/Step'
          type: array
          title: Steps
          description: >-
            The agentic pipeline as input→output steps (search → rerank →
            answer). Display-only; for UIs that 'show the reasoning'. Safe to
            ignore.
        evidence:
          items:
            $ref: '#/components/schemas/EvidenceSource'
          type: array
          title: Evidence
          description: >-
            The sources that grounded the answer, as structured stacks (metadata
            + their excerpt units), grouped by recommendation. Richer than
            `sources` (the deduped citation line). Display-only.
        tokens_in:
          anyOf:
            - type: integer
            - type: 'null'
          title: Tokens In
          description: Prompt tokens billed.
        tokens_out:
          anyOf:
            - type: integer
            - type: 'null'
          title: Tokens Out
          description: Completion tokens billed.
      type: object
      required:
        - query
        - answer
        - sources
      title: AnswerResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    AnswerSource:
      properties:
        reco_id:
          type: integer
          title: Reco Id
          description: Id of the cited recommendation.
        reco_title:
          type: string
          title: Reco Title
          description: Title of the cited recommendation.
        source_name:
          type: string
          title: Source Name
          description: Issuing source, e.g. 'HAS', 'SFAR'.
        deep_link:
          anyOf:
            - type: string
            - type: 'null'
          title: Deep Link
          description: Direct link to the source document.
      type: object
      required:
        - reco_id
        - reco_title
        - source_name
      title: AnswerSource
      description: A cited recommendation actually used to ground the answer.
    Step:
      properties:
        tool:
          type: string
          title: Tool
          description: The step's tool, e.g. 'search', 'rerank'.
        in:
          additionalProperties: true
          type: object
          title: In
          description: What the step was given.
          examples:
            - query: antibioprophylaxie
        out:
          additionalProperties: true
          type: object
          title: Out
          description: What the step produced.
          examples:
            - n_units: 8
      type: object
      required:
        - tool
        - in
        - out
      title: Step
      description: |-
        One agentic step (input → output) in a pipeline.

        Surfaces the retrieve → rerank → synthesize loop so a UI can 'show the
        reasoning' (SPEC §4.2). Display-only; carries no business logic.
    EvidenceSource:
      properties:
        id:
          type: string
          title: Id
          description: Stable view id for this stack, e.g. 'src900'.
        org:
          type: string
          title: Org
          description: Issuing source, e.g. 'HAS', 'SFAR'.
        year:
          anyOf:
            - type: string
            - type: 'null'
          title: Year
          description: Publication year, if known.
        title:
          type: string
          title: Title
          description: Recommendation title.
        page:
          anyOf:
            - type: integer
            - type: 'null'
          title: Page
          description: Page in the source document, if known.
        url:
          anyOf:
            - type: string
            - type: 'null'
          title: Url
          description: Direct link to the original document.
        grade:
          anyOf:
            - type: string
            - type: 'null'
          title: Grade
          description: Evidence grade (A/B/C…) when the source carries one.
        units:
          items:
            $ref: '#/components/schemas/EvidenceUnit'
          type: array
          title: Units
          description: Structured excerpts from this source, most relevant first.
      type: object
      required:
        - id
        - org
        - title
        - units
      title: EvidenceSource
      description: >-
        A source as a CITABLE STACK: its metadata plus its structured units.


        The view-oriented projection of the chunks actually selected to ground
        the

        answer (post-retrieval + rerank), grouped by recommendation. It lets a
        UI

        render real, explorable source piles instead of a flat citation line.
    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
    EvidenceUnit:
      properties:
        text:
          type: string
          title: Text
          description: The excerpt text (a retrieved, reranked chunk).
        type:
          type: string
          title: Type
          description: Kind of unit, for display (extrait, recommendation…).
          default: extrait
      type: object
      required:
        - text
      title: EvidenceUnit
      description: One structured excerpt that grounded the answer — never a blob.
  securitySchemes:
    lsk:
      type: http
      description: Locus API key — paste the raw `lsk_…` value (no 'Bearer ' prefix).
      scheme: bearer

````