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

Free text response provides natural, conversational-style answers to your queries. It is ideal for general Q&A and scenarios where a narrative or contextualized explanation is needed. Unlike structured output, free text does not require additional parameters like json_schema and json_schema_rules.

Request Example

from wetro import Wetrocloud

# Initialize the Wetrocloud client
client = Wetrocloud(api_key="your_api_key")

# Query the collection
response = client.collection.query_collection(
    collection_id="my_unique_collection_id",
    request_query="What are the sales trends for Q1?"
)

print(query_response)

Request Example with Stream

from wetro import Wetrocloud

# Initialize the Wetrocloud client
client = Wetrocloud(api_key="your_api_key")

# Query the collection with streaming
streaming_response = client.collection.query_collection(
    collection_id="my_unique_collection_id",
    request_query="What are the sales trends for Q1?",
    stream=True
)

# Process streaming response
for chunk in streaming_response:
    print(chunk.response, end="")

FieldDescription
collection_idCollection Id.
queryThis is the prompt.
model (optional)Pass in the model you want.

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.