adebayo27/wetrocloud-sdk

A laravel sdk for wetrocloud

v1.0.0 2025-03-20 15:33 UTC

This package is auto-updated.

Last update: 2025-06-20 16:12:21 UTC


README

A Laravel SDK to interact with Wetrocloud's API for AI-powered features like text generation, data extraction, image-to-text conversion, and collection management.

Installation

Via Composer

You can install the SDK using Composer:

composer require adebayo27/wetrocloud-sdk

Environment Variables

Ensure you add your Wetrocloud API key to your .env file:

WETROCLOUD_API_KEY=your_api_key_here

Usage

Initialize the SDK

The SDK is automatically injected via Laravel's Service Provider. To use it in a controller or service, inject WetrocloudClient:

use Wetrocloud\Sdk\WetrocloudClient;

class ExampleController extends Controller
{
    protected WetrocloudClient $wetrocloud;

    public function __construct()
    {
        $this->wetrocloud = new WetrocloudClient(env('WETROCLOUD_API_KEY'), 'v1');
    }
}

Features

1. List Collections

Retrieves all available collections.

Usage

$collections = $wetrocloud->listCollections();

Response Example

{
    "count": 10,
    "next": null,
    "previous": null,
    "collections": [ ... ]
}

2. Create a Collection

Creates a new collection with a unique ID.

Usage

$collection = $wetrocloud->createCollection();

or

$collection = $wetrocloud->createCollection('my_unique_collection');

Response Example

{
    "collection_id": "my_unique_collection",
    "success": true
}

3. Query a Collection

Retrieves specific data from a collection.

Usage

$queryResult = $wetrocloud->queryCollection('my_collection', 'Find all users with role admin');

Response Example

{
    "results": [ ... ]
}

4. Data Categorization

Classifies text into predefined categories.

Usage

$categorization = $wetrocloud->categorizeText(
    "match review: John Cena vs. The Rock are fighting",
    ["football", "coding", "entertainment", "basketball", "wrestling", "information"]
);

Response Example

{
    "response": { "label": "wrestling" },
    "tokens": 1746,
    "success": true
}

5. Text Generation

Generates AI-powered text responses based on input messages.

Usage

$response = $wetrocloud->generateText([
    ['role' => 'user', 'content' => 'What is a large language model?']
]);

Response Example

{
    "response": "A large language model is a type of AI trained on vast datasets..."
}

6. Image-to-Text

Extracts text or answers questions about an image.

Usage

$response = $wetrocloud->imageToText(
    'https://example.com/sample-image.jpg',
    'What is in this image?'
);

Response Example

{
    "response": "A golden retriever dog playing in the park."
}

7. Data Extraction from a Website

Extracts structured data from a web page based on a JSON schema.

Usage

$response = $wetrocloud->extractDataFromWebsite(
    'https://example.com',
    ['title' => '', 'description' => '']
);

Response Example

{
    "data": { "title": "Example", "description": "This is an example website." }
}

Error Handling

All API requests return errors in a standard format.

Example Error Response

{
    "error": "Client error: 401 Unauthorized",
    "response": {
        "detail": "Invalid token."
    }
}

To handle errors, check if error is present in the response:

if (isset($response['error'])) {
    return response()->json($response, 400);
}

Support & Contributions

For issues or feature requests, open an issue on GitHub or contribute via pull requests.

GitHub Repository: https://github.com/adebayo27/wetrocloud-sdk

Documentation

For more details, check out the official API documentation: Wetrocloud Docs