Before you begin!
Visit the Wetrocloud console to get your API key. If you have trouble obtaining it, refer to this guide.

Introduction

This guide is for developers looking to get started with the WetroCloud API quickly. Using simple cURL commands, you’ll learn how to:

  • Create a collection
  • Insert resources into the collection
  • Query collection for answers
  • Chat with collection for conversations
  • Categorize resources
  • Remove resources
  • Delete Collection

Prerequisites:

By the end, you’ll have queried your first resource using Wetrocloud API.

Important!
Always prefix your API key with Token (including a space). Example: Token YOUR_API_KEY. Requests without this format will be rejected.

1

Getting Started

pip install wetro
2

Setting Up API Key

from wetro import Wetrocloud

# Initialize the main client and access modules
client = Wetrocloud(api_key="your_api_key")
3

Create a Collection

First, create a collection_id to group your resources.

from wetro import Wetrocloud

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

# Create a collection
collection = client.collection.create_collection(
  collection_id="my_unique_collection_id"
)

print(collection)
4

List all available collections

After creating a collection, you can get all your available collections on wetrocloud.

from wetro import Wetrocloud

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

# Get all collections
all_collections = client.collection.get_collection_list()

# print the response
print(all_collections)
5

Insert a Resource into the Collection

Add a resource to your collection using the collection_id you created earlier

from wetro import Wetrocloud
    
# Initialize the Wetrocloud client
client = Wetrocloud(api_key="your_api_key")

# Insert a Resource into a Collection
insert_response=client.collection.insert_resource(
  collection_id="my_unique_collection_id",
  resource="https://medium.com/@wetrocloud/why-legal-tech-needs-wetrocloud-ai-rag-and-the-future-of-legal-practice-66fb38c4df09",
  type="web"
)

# Print the response
print(insert_response)
6

Query Collection

Query your collection using the collection_id created earlier by providing a query in the request_query field.

from wetro import Wetrocloud

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

# Query the collection
query_response = client.collection.query_collection(
    collection_id="my_unique_collection_id",
    request_query="What are the key points of the article?"
)

# Print the response
print(query_response)

To keep things simple we made use of the /collection/query/ endpoint without structured output

7

Chat with Collection

Chat with your collection using the collection_id created earlier by providing a message in the message field and continue conversations by passing chat_history.

from wetro import Wetrocloud

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

# Create a chat history
chat_history = [
    {"role": "user", "content": "What is this collection about?"}, 
    {"role": "system", "content": "It stores research papers on AI technology."}
]

# Continue the conversation with context
chat_response = client.collection.chat(
    collection_id="my_unique_collection_id",
    message="Can you explain the latest paper's methodology?",
    chat_history=chat_history
)

# Print the chat response
print(chat_response)
8

Categorize a Resource

from wetro import Wetrocloud

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

# Categorize content
categorize_response = client.categorize(
    resource="match review: John Cena vs. The Rock.",
    type="text",
    json_schema={"label": "string"},
    categories=["wrestling", "entertainment", "sports", "news"],
    prompt="Categorize the text to see which category it best fits"
)

print(categorize_response)
print("\nThe text is categorized as:", categorize_response.response["label"])
9

Remove a Resource

Remove a resource from your collection using the collection_id and resource_id.

from wetro import Wetrocloud

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

# Delete the resource from the collection
delete_response = client.collection.delete_resource(
    collection_id="my_unique_collection_id",
    resource_id="resource_id_to_delete"
)

print(delete_response)
10

Delete a Collection

Delete a collection using its collection_id.

from wetro import Wetrocloud

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

# Delete the collection
delete_collection = client.collection.delete_collection(
    collection_id="my_unique_collection_id"
)

print(delete_collection)

Great, that was easy!

If you want to get a more in depth understanding of how wetrocloud SDK works, head on over to the API reference.