Model API guide

Model Guide for you to implement FLock model


Manual creation via website

Technology Stack

  • TypeScript

  • JavaScript

API Call example

How it Works


Package installation

npm install --save axios dotenv
# or
yarn add axios dotenv
# or 
pnpm add axios dotenv


  • Create an .env file in the root directory or in your existing env file, add the followings:

// Some code
FLOCK_BOT_API_KEY= "<your_wallet_address_from_api_generation>"

Step by Step guide

  • Create a flockModel.ts

  • Create a async/await function flockModel wrapping the API call

    • use method for request

    • We will pass two parameters

      • question

      • knowledge_source_id

    • get the response of the call

    • We chose to use try/catch to handle any error during the call to debug the process.

import axios from "axios";
import * as dotenv from "dotenv";

// Load environment variables from .env file
dotenv.config({ path: "./.env" }); // Make sure the path is correct

async function main(prompt: string) {
  console.log("Prompt:", prompt);

  try {
    // Construct the request payload
    const payload = {
      question: prompt,
      chat_history: [],
      knowledge_source_id: "<model_id>", // replace with your model id

    // Set the headers
    const headers = {
      "x-api-key": process.env.FLOCK_BOT_API_KEY, // Ensure API key is set in .env

    // Send POST request using axios
    const response = await

    // Output the response data
  } catch (error) {
    console.error("Error:", error);

// Example call to the main function
main("Can you figure out how to make a chatbot?");

Last updated