Integration with Existing Services

You can easily integrate your Unit into your existing services using the SDK or the python client.

1. Direct API Integration

Python

const ReiCoreSdk = require("reicore-sdk");

// Initialize the SDK
const secretKey = "your_unit_secret_token";
const reiAgent = new ReiCoreSdk({ agentSecretKey: secretKey });

// Simple integration example
async function getAgentResponse(query) {
  try {
    const payload = {
      messages: [
        {
          role: "user",
          content: query,
        },
      ],
    };
    const response = await reiAgent.chatCompletion(payload);
    return response.choices[0].message.content;
  } catch (error) {
    console.error("Error:", error);
    return null;
  }
}

// Example usage in an Express service
const express = require("express");
const app = express();

app.use(express.json());

app.post("/query", async (req, res) => {
  try {
    const response = await getAgentResponse(req.body.text);
    if (!response) {
      return res.status(500).json({ error: "Failed to get response" });
    }
    res.json({ response });
  } catch (error) {
    res.status(500).json({ error: error.message });
  }
});

2. Webhook Integration

Setting up a Webhook Endpoint

3. Message Queue Integration

Using RabbitMQ

4. Database Integration

Using PostgreSQL

5. Microservice Integration

Using Docker and FastAPI

Last updated