POST
/
agents
/
{id}
/
query
curl --request POST \
  --url https://api.chatvolt.ai/agents/{id}/query \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "query": "<string>",
  "conversationId": "<string>",
  "contact": {
    "firstName": "<string>",
    "email": "<string>",
    "phoneNumber": "<string>"
  },
  "visitorId": "<string>",
  "temperature": 123,
  "streaming": true,
  "modelName": "gpt_4_o",
  "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;
            // ...
          }
       },
  });

Authorizations

Authorization
string
headerrequired

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

Path Parameters

id
string
required

ID of the agent

Body

application/json
query
string
required

This is the query you want to ask your agent.

conversationId
string

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

contact
object
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

Available options:
gpt_4_o,
gpt_4o_medium,
gpt_4o_extended,
gpt_4o_mini,
gpt_4o_mini_medium,
gpt_4o_mini_extended,
gpt_o1,
gpt_o1_mini,
gpt_o1_mini_medium,
gemini_pro,
gemini_pro_vision,
gemini_pro_1_5,
gemini_flash_1_5,
gemma_2_9b,
gemma_2_27b,
llama_3_8b_instruct,
llama_3_70b_instruct,
llama_3_405b_instruct,
llama_3_11b_vision,
llama_3_90b_vision,
command_r,
openchat_8b,
claude_3_haiku,
claude_3_sonnet,
claude_3_opus,
firellava_13b,
mistral_7b_instruct,
mixtral_8x7b,
mixtral_8x22b,
mistral_large,
dolphin_mixtral_8x7b,
mythomax_l2_13b,
wizardlm_2,
phi_3_medium,
phi_3_mini,
nemotron_4_340b,
deepseek_coder,
sabia_3,
grok_2,
perplexity_llama_8b_online,
perplexity_llama_70b_online
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

Agent system prompt

userPrompt
string

Agent user prompt

promptType
enum<string>

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

Available options:
raw,
customer_support
promptTemplate
string

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

Response

200 - application/json
answer
string

The answer of the agent.

conversationId
string

ID of the conversation

visitorId
string

ID of the participant that's sending the query

sources
object[]