SDKs overview

Brainshop.ai provides access to its conversational AI capabilities primarily through a RESTful API. Software Development Kits (SDKs) and client libraries serve as wrappers around this API, facilitating interaction with the service from various programming languages. These libraries handle aspects such as HTTP request construction, parameter serialization, and response parsing, allowing developers to focus on application logic rather than low-level API communication details.

The SDKs and libraries for Brainshop.ai are designed to streamline the process of sending user inputs to an AI brain and retrieving generated responses. This includes functionality for authenticating requests, managing conversation context, and processing different types of AI outputs. While Brainshop.ai offers official SDKs for several common programming environments, the underlying API design also supports direct HTTP requests for languages or platforms not covered by a specific SDK, as detailed in the Brainshop.ai API reference documentation.

Developers using Brainshop.ai SDKs typically interact with methods that correspond to API endpoints for sending messages, retrieving brain information, or managing user sessions. The SDKs aim to provide a more idiomatic interface for each target language, abstracting away the common boilerplate involved in web API integrations. This approach can reduce development time and potential errors compared to manually constructing API calls.

Official SDKs by language

Brainshop.ai maintains official SDKs for several programming languages, providing tested and supported methods for integrating their conversational AI service. These SDKs are developed to align with the latest API versions and offer a consistent developer experience across different environments. The official offerings prioritize stability and adherence to the Brainshop.ai API specification.

Each official SDK typically includes modules for authentication, sending text queries, and handling the JSON responses returned by the Brainshop.ai API. Developers can find detailed usage instructions and examples within the Brainshop.ai official documentation portal. The table below outlines the key official SDKs available:

Language Package/Module Installation Command Maturity
Python brainshop-python pip install brainshop-python Stable
JavaScript (Node.js/Browser) @brainshop/sdk npm install @brainshop/sdk Stable
PHP brainshop/sdk-php composer require brainshop/sdk-php Stable
Ruby brainshop-ruby gem install brainshop-ruby Stable
Go github.com/brainshop/go-sdk go get github.com/brainshop/go-sdk Stable
Java com.brainshop:java-sdk Add to pom.xml or build.gradle Stable
C# (.NET) Brainshop.Net.SDK dotnet add package Brainshop.Net.SDK Stable

These official SDKs are regularly updated to ensure compatibility with the latest features and improvements in the Brainshop.ai platform. Developers are encouraged to consult the specific SDK's repository or documentation for the most current installation instructions and API usage details.

Installation

The installation process for Brainshop.ai SDKs typically follows the standard package management practices for each respective language. Prior to installation, ensure that the appropriate language runtime and package manager are installed on your development environment. Each SDK will require an API key and a brain ID, which can be obtained from your Brainshop.ai account dashboard after signing up for a Brainshop.ai plan.

Python

To install the Python SDK, use pip, the Python package installer. It is recommended to use a Python virtual environment to manage dependencies.

pip install brainshop-python

JavaScript (Node.js)

For JavaScript projects, especially in Node.js environments, npm or yarn can be used to install the SDK:

npm install @brainshop/sdk
# or
yarn add @brainshop/sdk

PHP

PHP projects typically use Composer for dependency management:

composer require brainshop/sdk-php

Ruby

The Ruby SDK is available as a Gem:

gem install brainshop-ruby

Go

Go modules are used for dependency management in Go projects:

go get github.com/brainshop/go-sdk

Java (Maven/Gradle)

For Java projects, add the dependency to your pom.xml (Maven) or build.gradle (Gradle) file. For Maven:

<dependency>
    <groupId>com.brainshop</groupId>
    <artifactId>java-sdk</artifactId>
    <version>1.0.0</version> <!-- Replace with the latest version -->
</dependency>

For Gradle:

implementation 'com.brainshop:java-sdk:1.0.0' // Replace with the latest version

C# (.NET)

For .NET projects, use the .NET CLI or NuGet Package Manager:

dotnet add package Brainshop.Net.SDK

After successful installation, the SDK can be imported and initialized with your API credentials within your application code.

Quickstart example

The following quickstart examples demonstrate basic interaction with Brainshop.ai using its official SDKs. These examples cover sending a user message and receiving a response from a configured AI brain. Replace YOUR_API_KEY and YOUR_BRAIN_ID with your actual credentials obtained from the Brainshop.ai dashboard.

Python Quickstart

This Python example initializes the client and sends a simple query:

from brainshop import BrainshopClient

api_key = "YOUR_API_KEY"
brain_id = "YOUR_BRAIN_ID"
user_id = "user123" # Unique ID for the user

client = BrainshopClient(api_key)

try:
    response = client.send_message(brain_id=brain_id, input_text="Hello, how are you?", uid=user_id)
    print(f"AI Response: {response['cnt']}")
except Exception as e:
    print(f"An error occurred: {e}")

JavaScript (Node.js) Quickstart

This Node.js example uses async/await to interact with the SDK:

const { BrainshopClient } = require('@brainshop/sdk');

const apiKey = "YOUR_API_KEY";
const brainId = "YOUR_BRAIN_ID";
const userId = "user123"; // Unique ID for the user

const client = new BrainshopClient(apiKey);

async function sendMessage() {
    try {
        const response = await client.sendMessage(brainId, "Hello, how can I help you?", userId);
        console.log(`AI Response: ${response.cnt}`);
    } catch (error) {
        console.error(`An error occurred: ${error.message}`);
    }
}

sendMessage();

PHP Quickstart

A basic PHP example for sending a message:

<?php
require 'vendor/autoload.php';

use Brainshop\BrainshopClient;

$apiKey = "YOUR_API_KEY";
$brainId = "YOUR_BRAIN_ID";
$userId = "user123"; // Unique ID for the user

$client = new BrainshopClient($apiKey);

try {
    $response = $client->sendMessage($brainId, "Tell me a joke.", $userId);
    echo "AI Response: " . $response['cnt'] . "\n";
} catch (Exception $e) {
    echo "An error occurred: " . $e->getMessage() . "\n";
}
?>

Ruby Quickstart

This Ruby example demonstrates client initialization and message sending:

require 'brainshop-ruby'

api_key = "YOUR_API_KEY"
brain_id = "YOUR_BRAIN_ID"
user_id = "user123" # Unique ID for the user

client = Brainshop::Client.new(api_key)

begin
  response = client.send_message(brain_id, "What is the weather today?", user_id)
  puts "AI Response: #{response['cnt']}"
rescue StandardError => e
  puts "An error occurred: #{e.message}"
end

Community libraries

In addition to the official SDKs, the broader developer community may create and maintain client libraries or integrations for Brainshop.ai. These community-driven projects can offer support for additional programming languages, frameworks, or specialized use cases not covered by the official offerings. Community libraries are often found on platforms like GitHub or language-specific package repositories.

When considering a community library, it is important to evaluate its maintenance status, documentation quality, and active development. Developers should verify compatibility with the current Brainshop.ai API version and review the project's licensing terms. While Brainshop.ai's official API reference provides the foundational details for any custom integration, community contributions can sometimes offer unique features or alternative approaches.

For instance, some community libraries might focus on integrating Brainshop.ai with specific chatbot frameworks (e.g., platforms for building bots on messaging apps) or provide utilities for managing conversation history in a particular database. These libraries can extend the reach and utility of Brainshop.ai into diverse development ecosystems. Developers looking for such resources can often find them by searching public code repositories for terms like "Brainshop.ai client" or "Brainshop.ai integration" alongside their preferred language or framework.

It is important to note that community libraries are not officially supported by Brainshop.ai, and their functionality and security are the responsibility of their respective maintainers. Users are advised to exercise due diligence when incorporating third-party code. For critical applications, direct integration using the official SDKs or direct API calls, as described in the Google Custom Search API best practices for integrations, is generally recommended for stability and official support.