See a full example that uses Scoopika here.
Server-side
npm install @scoopika/scoopika
import express from "express";
import endpoint from "./scoopika";
const app = express();
app.use(express.json());
app.post("/scoopika", (req, res) => {
endpoint.handleRequest({
request: req.body,
stream: (s) => res.write(s),
end: () => res.end()
});
})
Client-side
npm install @scoopika/client
import { Client, Agent } from "@scoopika/client";
const client = new Client("API_URL");
const agent = new Agent("AGENT_ID", client);
(async () => {
const response = await agent.run({
inputs: { message: "Hello!" },
hooks: {
onToken: (t) => console.log(t)
}
});
console.log(response);
})();