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

# Ask AI a question

> Query information using natural language. This enhanced endpoint supports three types of queries: (1) questions about specific entities (people, companies), (2) questions about multiple entities at once, and (3) generic workspace-level questions that don't reference specific entities. The AI will analyze your workspace context to provide relevant answers.



## OpenAPI

````yaml post /v1/context/ask
openapi: 3.0.0
info:
  description: >-
    REST API for accessing and managing your Nex data. Generate API keys from
    the Nex web UI and use them to authenticate requests.
  title: Nex Developer API
  contact: {}
  version: '1.0'
servers:
  - url: https://app.nex.ai/api/developers
security: []
paths:
  /v1/context/ask:
    post:
      tags:
        - Context
      summary: Ask AI a question
      description: >-
        Query information using natural language. This enhanced endpoint
        supports three types of queries: (1) questions about specific entities
        (people, companies), (2) questions about multiple entities at once, and
        (3) generic workspace-level questions that don't reference specific
        entities. The AI will analyze your workspace context to provide relevant
        answers.
      operationId: queryContext
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/developer.QueryContextRequest'
        description: >-
          Natural language query - can be about specific entities, multiple
          entities, or general workspace questions
        required: true
      responses:
        '200':
          description: Query response with relevant information
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/developer.QueryContextResponse'
        '400':
          description: Bad request - Invalid query
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/httpx.APIError'
        '401':
          description: Unauthorized - Invalid or missing API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/httpx.APIError'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/httpx.APIError'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    developer.QueryContextRequest:
      type: object
      required:
        - query
      properties:
        query:
          type: string
          description: >-
            Natural language query - supports single entity questions (e.g.,
            'What's the status with techflow.io?'), multi-entity questions
            (e.g., 'Compare engagement levels of Acme Corp and TechFlow'), or
            general workspace questions (e.g., 'Which deals are most likely to
            close this quarter?')
      example:
        query: What's the status with techflow.io?
    developer.QueryContextResponse:
      type: object
      properties:
        answer:
          type: string
          description: >-
            AI-generated response to the query based on available workspace
            context
        entities_considered:
          type: array
          description: Entities that were analyzed to generate the answer
          items:
            type: object
            properties:
              id:
                type: integer
                description: Entity ID
              name:
                type: string
                description: Entity name
              type:
                type: string
                description: Entity type (PERSON, COMPANY)
              reason:
                type: string
                description: Why this entity was considered relevant
              insights_matched:
                type: integer
                description: Number of insights matched for this entity
              score:
                type: number
                description: Relevance score
        signals_used:
          type: array
          description: Specific signals/insights used to generate the answer
          items:
            type: object
            properties:
              insight_id:
                type: integer
                description: Insight ID
              entity_id:
                type: integer
                description: Entity ID this signal belongs to
              content:
                type: string
                description: Signal content excerpt
              score:
                type: number
                description: Relevance score
              type:
                type: string
                description: Signal type
        metadata:
          type: object
          description: Query processing metadata
          properties:
            query_type:
              type: string
              enum:
                - workspace_wide
                - entity_specific
              description: Whether the query was about specific entities or workspace-wide
            total_entities_searched:
              type: integer
              description: Total number of entities searched
            confidence:
              type: number
              description: Confidence score of the answer
      example:
        answer: >-
          Based on the available context, techflow.io appears to be a technology
          company. Marcus Rodriguez from techflow.io expressed interest in
          booking a demo on LinkedIn.
        entities_considered:
          - id: 25339323448557880
            name: TechFlow
            type: COMPANY
            reason: Direct match for techflow.io domain
            insights_matched: 3
            score: 0.95
          - id: 25339323448557884
            name: Marcus Rodriguez
            type: PERSON
            reason: Associated with TechFlow, recent LinkedIn activity
            insights_matched: 2
            score: 0.87
        signals_used:
          - insight_id: 38485049540083710
            entity_id: 25339323448557884
            content: 'Marcus Rodriguez commented on LinkedIn: Would love to book a demo'
            score: 0.92
            type: social_activity
          - insight_id: 38485049540083710
            entity_id: 25339323448557880
            content: TechFlow is a SaaS platform for workflow automation
            score: 0.88
            type: company_info
        metadata:
          query_type: entity_specific
          total_entities_searched: 156
          confidence: 0.89
    httpx.APIError:
      type: object
      properties:
        code:
          type: integer
        message:
          type: string
  securitySchemes:
    ApiKeyAuth:
      description: 'API key for authentication (format: "Bearer YOUR_API_KEY")'
      type: apiKey
      name: Authorization
      in: header

````