The query endpoint allows you to retrieve information from a collection (your resources) via the WetroCloud API.
This endpoint supports two response formats to suit different use cases:

  • Free Text Response: A natural language answer to your query.
  • Structured Output Response: A structured JSON output.

Each response type has unique request and response formats, which are explained in detail on their respective pages.

Free Text Response

ParameterTypeDescription
collection_id(required)StringThe unique ID of the collection to query.
request_query(required)StringThe search term or query text.
stream(optional)BooleanEnables streaming response if True, it’s False by default
model(optional)StringSpecific model you desire to query response Check out our list of supported models here

Response Example: Free Text

{
  "response": "The sales for Q1 increased by 20% compared to last year, with online channels contributing significantly.",
  "tokens": 120,
  "success": true
}
FieldDescription
responseConversational response to the query.
tokensNumber of tokens used for processing.
successIndicates whether the query was successful.

Structured Output Response

Structured output is a feature that allows large language models (LLMs) to generate responses in a specific format with your resources. Structured output is best for extracting structured data to fit your application’s needs. It returns data formatted with the json_schema and json_schema_rules you provide. To use the structured output feature you need to provide the following parameters:

Streaming is not supported when doing structured output response

ParameterTypeDescription
collection_id (required)StringThe unique ID of the collection to query obtained from the /collection/create/ endpoint.
request_query (required)StringThe search term or query text.
json_schema (required)StringThe desired structure for the JSON response.
json_schema_rules (required)StringCustom rules to guide the response’s adherence to the specified JSON schema.
model(optional)StringSpecific model you desire to query response Check out our list of supported models here

Response Example: Structured Output

{
    "response": [
        {
            "month": "January",
            "sales": 15000
        },
        {
            "month": "February",
            "sales": 18000
        },
        {
            "month": "March",
            "sales": 17000
        }
    ],
    "tokens": 4007,
    "success": true
}
FieldDescription
responseJSON object structured as per the provided schema.
tokensNumber of tokens used for processing.
successIndicates whether the query was successful.