Pular para o conteúdo principal
POST
/
agents
/
{id}
/
query
This let you query your AI Employee for a specific query.
curl --request POST \
  --url https://app.zappway.ai/api/agents/{id}/query \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "query": "<string>",
  "conversationId": "<string>",
  "visitorId": "<string>",
  "temperature": 123,
  "streaming": true,
  "modelName": "gpt_5_4",
  "maxTokens": 123,
  "presencePenalty": 123,
  "frequencyPenalty": 123,
  "topP": 123,
  "filters": {
    "custom_ids": [
      "<string>"
    ],
    "datasource_ids": [
      "<string>"
    ]
  },
  "systemPrompt": "<string>",
  "userPrompt": "<string>",
  "promptType": "raw",
  "promptTemplate": "<string>"
}
'
{
  "answer": "<string>",
  "conversationId": "<string>",
  "visitorId": "<string>",
  "sources": [
    {}
  ]
}

Streaming

When streaming is enabled, the endpoint will emit events “answer” (answer of the model) and “endpoint_response” (full response of the endpoint)
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;
            // ...
          }
       },
  });

Autorizações

Authorization
string
header
obrigatório

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Parâmetros de caminho

id
string
obrigatório

ID of the AI Employee

Corpo

application/json
query
string
obrigatório

This is the query you want to ask your AI Employee.

conversationId
string

ID of the conversation (If not provided a new conversation is created)

visitorId
string

ID of the participant that's sending the query (If not provided a new ID is created)

temperature
number

Temperature of the model (min 0.0, max 1.0)

streaming
boolean

Enable streaming

modelName
enum<string>

Override agent model

Opções disponíveis:
gpt_5_4,
gpt_5_4_chat,
gpt_5_4_mini,
gpt_5_4_nano,
gpt_5_3_chat_latest,
gpt_5_3_codex,
gpt_5_2,
gpt_5_2_chat,
gpt_5_2_chat_latest,
gpt_5_1,
gpt_5_1_chat,
gpt_5,
gpt_5_mini,
gpt_5_4_mini,
gpt_5_4_nano,
minimax_m2_7,
mimo_v2_omni,
mimo_v2_pro,
gpt_5_nano,
gpt_4o_2024_11_20,
gpt_4o_mini_2024_07_18,
gemini_3_flash_preview,
gemini_3_pro_image_preview,
gemini_3_pro_preview,
gemini_pro_2_5,
gemini_flash_2_5,
gemini_flash_2_0,
nova_premier_v1,
nova_2_lite_v1,
claude_opus_4_5,
claude_4_5_sonnet,
claude_4_5_haiku,
claude_4_sonnet,
claude_3_5_sonnet,
claude_3_5_haiku,
grok_4,
grok_4_1_fast_free,
llama_4_maverick,
llama_4_scout,
mistral_large_2512,
deepseek_r1_0528,
deepseek_v3_0324,
sonar_pro,
lfm2_8b_a1b,
lfm_2_24b_a2b,
mixtral_8x22b,
mixtral_8x7b,
dolphin_mixtral_8x7b,
gpt_5_4,
gpt_5_3_chat_latest,
gpt_5_2_chat_latest,
gpt_5_3_codex,
claude_opus_4_6,
claude_sonnet_4_6,
gemini_3_1_flash_lite_preview,
gemini_3_1_flash_image_preview,
gemini_3_1_pro_preview
maxTokens
number

The maximum number of tokens to generate in the chat completion.

presencePenalty
number

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
number

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
number

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
object
systemPrompt
string

AI Employee System Prompt

userPrompt
string

AI Employee User Prompt

promptType
enum<string>
obsoleto

(DEPRECATED in favor of systemPrompt and userPrompt) Set the prompt type for this query

Opções disponíveis:
raw,
customer_support
promptTemplate
string
obsoleto

(DEPRECATED in favor of systemPrompt and userPrompt) Set the prompt template for this query

Resposta

Success

answer
string

The answer of the AI Employee.

conversationId
string

ID of the conversation

visitorId
string

ID of the participant that's sending the query

sources
object[]