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

# AI Employee - Query

### Streaming

##### When streaming is enabled, the endpoint will emit events "answer" (answer of the model) and "endpoint\_response" (full response of the endpoint)

```js theme={null}
import {
  EventStreamContentType,
  fetchEventSource,
} from '@microsoft/fetch-event-source';

let buffer = '';
let bufferEndpointResponse = '';
const ctrl = new AbortController();

await fetchEventSource(queryAgentURL, {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json',
        },
        signal: ctrl.signal,
        body: JSON.stringify({
          streaming: true,
          query,
          conversationId,
          visitorId,
        }),

        async onopen(response) {
          if (response.status === 402) {
            throw new ApiError(ApiErrorType.USAGE_LIMIT);
          }
        },
        onmessage: (event) => {
          if (event.data === '[DONE]') {
            // End of stream
            ctrl.abort();

            try {
              const { sources, conversationId, visitorId } = JSON.parse(
                bufferEndpointResponse
              ) as ChatResponse;
            } catch {}
          } else if (event.data?.startsWith('[ERROR]')) {
            // ...
          } else if (event.event === "endpoint_response") {
            bufferEndpointResponse += event.data;
          } else if (event.event === "answer") {
            buffer += event.data;
            // ...
          }
       },
  });
```


## OpenAPI

````yaml POST /agents/{id}/query
openapi: 3.0.2
info:
  title: ZappWay - API OpenAPI specifications
  description: ''
  termsOfService: http://zappway.ai/terms
  contact:
    email: support@zappway.ai
  license:
    name: Apache 2.0
    url: http://www.apache.org/licenses/LICENSE-2.0.html
  version: 1.0.0
servers:
  - url: https://app.zappway.ai/api
security:
  - bearerAuth: []
tags:
  - name: agents
  - name: datastores
  - name: datasources
paths:
  /agents/{id}/query:
    post:
      tags:
        - agents
      summary: This let you query your AI Employee for a specific query.
      parameters:
        - in: path
          name: id
          schema:
            type: string
            description: ID of the AI Employee
          required: true
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                query:
                  type: string
                  description: This is the query you want to ask your AI Employee.
                conversationId:
                  type: string
                  description: >-
                    ID of the conversation (If not provided a new conversation
                    is created)
                visitorId:
                  type: string
                  description: >-
                    ID of the participant that's sending the query (If not
                    provided a new ID is created)
                temperature:
                  type: number
                  description: Temperature of the model (min 0.0, max 1.0)
                streaming:
                  type: boolean
                  description: Enable streaming
                modelName:
                  description: Override agent model
                  enum:
                    - claude_3_5_haiku
                    - claude_3_5_sonnet
                    - claude_4_5_haiku
                    - claude_4_5_sonnet
                    - claude_sonnet_4_6
                    - claude_4_sonnet
                    - claude_opus_4_5
                    - claude_opus_4_6
                    - claude_opus_4_7
                    - deepseek_r1_0528
                    - deepseek_v4_flash
                    - deepseek_v4_pro
                    - deepseek_v3_0324
                    - dolphin_mixtral_8x7b
                    - gemini_3_1_flash_image_preview
                    - gemini_3_1_flash_lite_preview
                    - gemini_3_1_pro_preview
                    - gemini_3_5_flash
                    - gemini_3_flash_preview
                    - gemini_3_pro_image_preview
                    - gemini_3_pro_preview
                    - gemini_flash_2_0
                    - gemini_flash_2_5
                    - gemini_pro_2_5
                    - gpt_4o_2024_11_20
                    - gpt_4o_mini_2024_07_18
                    - gpt_5
                    - gpt_5_1
                    - gpt_5_1_chat
                    - gpt_5_2
                    - gpt_5_2_chat
                    - gpt_5_2_chat_latest
                    - gpt_5_3_chat_latest
                    - gpt_5_3_codex
                    - gpt_5_4
                    - gpt_5_4_mini
                    - gpt_5_4_nano
                    - gpt_5_5_2026_04_23
                    - gpt_5_mini
                    - gpt_5_nano
                    - glm_5_1
                    - minimax_m2_7
                    - mimo_v2_omni
                    - mimo_v2_pro
                    - mimo_v2_5_pro
                    - grok_4
                    - grok_4_3
                    - grok_build_0_1
                    - grok_4_20
                    - grok_4_20_multi_agent
                    - lfm_2_24b_a2b
                    - llama_4_maverick
                    - llama_4_scout
                    - mistral_large_2512
                    - mixtral_8x22b
                    - mixtral_8x7b
                    - nova_2_lite_v1
                    - nova_premier_v1
                    - sonar_pro
                maxTokens:
                  type: number
                  description: >-
                    The maximum number of tokens to generate in the chat
                    completion.
                presencePenalty:
                  type: number
                  description: >-
                    Number between -2.0 and 2.0. Positive values penalize new
                    tokens based on whether they appear in the text so far,
                    increasing the model's likelihood to talk about new topics.
                frequencyPenalty:
                  type: number
                  description: >-
                    Number between -2.0 and 2.0. Positive values penalize new
                    tokens based on their existing frequency in the text so far,
                    decreasing the model's likelihood to repeat the same line
                    verbatim.
                topP:
                  type: number
                  description: >-
                    An alternative to sampling with temperature, called nucleus
                    sampling, where the model considers the results of the
                    tokens with top_p probability mass. So 0.1 means only the
                    tokens comprising the top 10% probability mass are
                    considered. We generally recommend altering this or
                    temperature but not both.
                filters:
                  type: object
                  properties:
                    custom_ids:
                      type: array
                      description: Filter by Custom IDs
                      items:
                        type: string
                    datasource_ids:
                      type: array
                      description: Filter by Datasource IDs
                      items:
                        type: string
                systemPrompt:
                  description: AI Employee System Prompt
                  type: string
                userPrompt:
                  description: AI Employee User Prompt
                  type: string
                promptType:
                  deprecated: true
                  description: >-
                    (DEPRECATED in favor of systemPrompt and userPrompt) Set the
                    prompt type for this query
                  enum:
                    - raw
                    - customer_support
                promptTemplate:
                  deprecated: true
                  type: string
                  description: >-
                    (DEPRECATED in favor of systemPrompt and userPrompt) Set the
                    prompt template for this query
              required:
                - query
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                properties:
                  answer:
                    type: string
                    description: The answer of the AI Employee.
                  conversationId:
                    type: string
                    description: ID of the conversation
                  visitorId:
                    type: string
                    description: ID of the participant that's sending the query
                  sources:
                    type: array
                    items:
                      type: object
                      description: Datasource chunks that were used to generate the answer
        '400':
          description: Invalid body
        '403':
          description: Unauthorized
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````