📘 Dokumentasi API Brainxiex AI

📌 Pendahuluan

Selamat datang di dokumentasi API Brainxiex AI! API ini dirancang untuk membantu Anda membangun aplikasi yang cerdas dengan mudah dan efisien.

Dokumentasi ini mencakup:

  • Base URL dan endpoint yang tersedia
  • Cara autentikasi dengan API Key
  • Contoh implementasi di berbagai bahasa pemrograman
  • Penggunaan plugin untuk menambah data tambahan

🌐 Base URL

Base URL untuk mengakses semua endpoint API Brainxiex AI:

https://brainxiex.com/api/ai

Contoh Penggunaan cURL:

curl -X POST 'https://brainxiex.com/api/ai/chat/completions' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-d '{
  "model": "brainxiex",
  "messages": [{
    "role": "user",
    "content": "Halo!"
  }]
}'

🔑 Autentikasi

Untuk menggunakan API Brainxiex AI, Anda memerlukan API Key. Ada dua cara untuk menyertakan API Key dalam request:

Method 1: Header Authorization

Tambahkan header Authorization: Bearer YOUR_API_KEY di setiap request.

Authorization: Bearer YOUR_API_KEY

Method 2: Parameter URL

Tambahkan parameter ?apikey=YOUR_API_KEY di URL.

https://brainxiex.com/api/ai/chat/completions?apikey=YOUR_API_KEY

Cara Mendapatkan API Key

API Key dapat diperoleh dengan mengunjungi Dashboard Brainxiex dan membuat API Key baru.

🧠 Models

Untuk melihat semua model yang tersedia, gunakan endpoint berikut:

GET /api/ai/models

Contoh Response:

{
  "data": [
    {
      "id": "brainxiex",
      "name": "Brainxiex",
      "owned_by": "brainxiex",
      "created": 1234567890,
      "description": "Model AI utama Brainxiex"
    }
  ]
}

📝 Chat Completions

API untuk chat completion dengan berbagai model AI. Berikut contoh implementasi di berbagai bahasa pemrograman:

curl -X POST 'https://brainxiex.com/api/ai/chat/completions' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-d '{
  "model": "brainxiex",
  "messages": [{
    "role": "user",
    "content": "Halo, apa kabar?"
  }]
}'
<?php
$data = array(
  "model" => "brainxiex",
  "messages" => array(
    array(
      "role" => "user",
      "content" => "Halo, apa kabar?"
    )
  )
);

$options = array(
  "http" => array(
    "header" => "Content-Type: application/json\r\nAuthorization: Bearer YOUR_API_KEY\r\n",
    "method" => "POST",
    "content" => json_encode($data),
  ),
);

$context = stream_context_create($options);
$response = file_get_contents('https://brainxiex.com/api/ai/chat/completions', false, $context);
echo $response;
?>
const data = {
  model: "brainxiex",
  messages: [
    {
      role: "user",
      content: "Halo, apa kabar?"
    }
  ]
};

fetch('https://brainxiex.com/api/ai/chat/completions', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_API_KEY'
  },
  body: JSON.stringify(data)
})
.then(response => response.json())
.then(result => console.log(result))
.catch(error => console.error('Error:', error));
const axios = require('axios');

const data = {
  model: "brainxiex",
  messages: [
    {
      role: "user",
      content: "Halo, apa kabar?"
    }
  ]
};

axios.post('https://brainxiex.com/api/ai/chat/completions', data, {
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_API_KEY'
  }
})
.then(response => {
  console.log(response.data);
})
.catch(error => {
  console.error('Error:', error);
});
import requests
import json

url = "https://brainxiex.com/api/ai/chat/completions"
headers = {
  "Content-Type": "application/json",
  "authorization": "Bearer YOUR_API_KEY"
}
data = {
  "model": "brainxiex",
  "messages": [
    {
      "role": "user",
      "content": "Halo, apa kabar?"
    }
  ]
}

response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.json())
package main

import (
  "bytes"
  "encoding/json"
  "fmt"
  "net/http"
)

type Message struct {
  Role    string `json:"role"`
  Content string `json:"content"`
}

type Request struct {
  Model    string    `json:"model"`
  Messages []Message `json:"messages"`
}

func main() {
  data := Request{
    Model: "brainxiex",
    Messages: []Message{
      {Role: "user", Content: "Halo, apa kabar?"},
    },
  }

  jsonData, _ := json.Marshal(data)
  req, _ := http.NewRequest("POST", "https://brainxiex.com/api/ai/chat/completions", bytes.NewBuffer(jsonData))
  req.Header.Set("Content-Type", "application/json")
  req.Header.Set("Authorization", "Bearer YOUR_API_KEY")

  client := &http.Client{}
  resp, _ := client.Do(req)
  defer resp.Body.Close()

  fmt.Println(resp.Status)
}
import java.net.http.*;
import java.net.URI;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;

public class ChatCompletion {
  public static void main(String[] args) {
    String json = "{\"model\":\"brainxiex\",\"messages\":[{\"role\":\"user\",\"content\":\"Halo, apa kabar?\"}]}";
    
    HttpRequest request = HttpRequest.newBuilder()
      .uri(URI.create("https://brainxiex.com/api/ai/chat/completions"))
      .header("Content-Type", "application/json")
      .header("Authorization", "Bearer YOUR_API_KEY")
      .POST(HttpRequest.BodyPublishers.ofString(json))
      .build();
    
    try {
      HttpResponse response = HttpClient.newHttpClient()
        .send(request, HttpResponse.BodyHandlers.ofString());
      System.out.println(response.body());
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}
require 'net/http'
require 'json'
require 'uri'

uri = URI('https://brainxiex.com/api/ai/chat/completions')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Post.new(uri.path)
request['Content-Type'] = 'application/json'
request['Authorization'] = 'Bearer YOUR_API_KEY'

data = {
  model: 'brainxiex',
  messages: [
    { role: 'user', content: 'Halo, apa kabar?' }
  ]
}

request.body = data.to_json

response = http.request(request)
puts response.body
interface Message {
  role: string;
  content: string;
}

interface Request {
  model: string;
  messages: Message[];
}

const data: Request = {
  model: "brainxiex",
  messages: [
    {
      role: "user",
      content: "Halo, apa kabar?"
    }
  ]
};

fetch('https://brainxiex.com/api/ai/chat/completions', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_API_KEY'
  },
  body: JSON.stringify(data)
})
.then(response => response.json())
.then(result => console.log(result))
.catch(error => console.error('Error:', error));
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;

class Program {
  static async Task Main() {
    var data = new {
      model = "brainxiex",
      messages = new[] {
        new { role = "user", content = "Halo, apa kabar?" }
      }
    };

    var json = JsonConvert.SerializeObject(data);
    var content = new StringContent(json, Encoding.UTF8, "application/json");

    using var client = new HttpClient();
    client.DefaultRequestHeaders.Add("Authorization", "Bearer YOUR_API_KEY");

    var response = await client.PostAsync(
      "https://brainxiex.com/api/ai/chat/completions",
      content
    );

    var result = await response.Content.ReadAsStringAsync();
    Console.WriteLine(result);
  }
}
local http = require("socket.http")
local ltn12 = require("ltn12")
local json = require("dkjson")

local data = {
  model = "brainxiex",
  messages = {
    { role = "user", content = "Halo, apa kabar?" }
  }
}

local body = json.encode(data)
local headers = {
  ["Content-Type"] = "application/json",
  ["Authorization"] = "Bearer YOUR_API_KEY"
}

local response_body = {}
local code, headers, status = http.request({
  method = "POST",
  url = "https://brainxiex.com/api/ai/chat/completions",
  headers = headers,
  source = ltn12.source.string(body),
  sink = ltn12.sink.table(response_body)
})

print(table.concat(response_body))
#include 
#include 
#include 
#include 

using json = nlohmann::json;

int main() {
  CURL* curl = curl_easy_init();
  if(curl) {
    json data = {
      {"model", "brainxiex"},
      {"messages", json::array({
        {{"role", "user"}, {"content", "Halo, apa kabar?"}}
      })}
    };

    std::string json_str = data.dump();
    
    struct curl_slist *headers = NULL;
    headers = curl_slist_append(headers, "Content-Type: application/json");
    headers = curl_slist_append(headers, "Authorization: Bearer YOUR_API_KEY");
    
    curl_easy_setopt(curl, CURLOPT_URL, "https://brainxiex.com/api/ai/chat/completions");
    curl_easy_setopt(curl, CURLOPT_POSTFIELDS, json_str.c_str());
    curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
    
    CURLcode res = curl_easy_perform(curl);
    if(res != CURLE_OK)
      fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
    
    curl_easy_cleanup(curl);
  }
  return 0;
}

🖼️ Images Generation

API untuk generate gambar menggunakan AI. Berikut contoh implementasi:

curl -X POST 'https://brainxiex.com/api/ai/images/generations' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-d '{
  "prompt": "Sebuah kucing lucu sedang bermain",
  "n": 1,
  "size": "1024x1024"
}'
<?php
$data = array(
  "prompt" => "Sebuah kucing lucu sedang bermain",
  "n" => 1,
  "size" => "1024x1024"
);

$options = array(
  "http" => array(
    "header" => "Content-Type: application/json\r\nAuthorization: Bearer YOUR_API_KEY\r\n",
    "method" => "POST",
    "content" => json_encode($data),
  ),
);

$context = stream_context_create($options);
$response = file_get_contents('https://brainxiex.com/api/ai/images/generations', false, $context);
echo $response;
?>
const data = {
  prompt: "Sebuah kucing lucu sedang bermain",
  n: 1,
  size: "1024x1024"
};

fetch('https://brainxiex.com/api/ai/images/generations', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_API_KEY'
  },
  body: JSON.stringify(data)
})
.then(response => response.json())
.then(result => console.log(result))
.catch(error => console.error('Error:', error));
const axios = require('axios');

const data = {
  prompt: "Sebuah kucing lucu sedang bermain",
  n: 1,
  size: "1024x1024"
};

axios.post('https://brainxiex.com/api/ai/images/generations', data, {
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_API_KEY'
  }
})
.then(response => {
  console.log(response.data);
})
.catch(error => {
  console.error('Error:', error);
});
import requests
import json

url = "https://brainxiex.com/api/ai/images/generations"
headers = {
  "Content-Type": "application/json",
  "authorization": "Bearer YOUR_API_KEY"
}
data = {
  "prompt": "Sebuah kucing lucu sedang bermain",
  "n" => 1,
  "size": "1024x1024"
}

response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.json())
package main

import (
  "bytes"
  "encoding/json"
  "fmt"
  "net/http"
)

type ImageRequest struct {
  Prompt string `json:"prompt"`
  N      int    `json:"n"`
  Size   string `json:"size"`
}

func main() {
  data := ImageRequest{
    Prompt: "Sebuah kucing lucu sedang bermain",
    N:      1,
    Size:   "1024x1024",
  }

  jsonData, _ := json.Marshal(data)
  req, _ := http.NewRequest("POST", "https://brainxiex.com/api/ai/images/generations", bytes.NewBuffer(jsonData))
  req.Header.Set("Content-Type", "application/json")
  req.Header.Set("Authorization", "Bearer YOUR_API_KEY")

  client := &http.Client{}
  resp, _ := client.Do(req)
  defer resp.Body.Close()

  fmt.Println(resp.Status)
}
import java.net.http.*;
import java.net.URI;
import java.nio.charset.StandardCharsets;

public class ImageGeneration {
  public static void main(String[] args) {
    String json = "{\"prompt\":\"Sebuah kucing lucu sedang bermain\",\"n\":1,\"size\":\"1024x1024\"}";
    
    HttpRequest request = HttpRequest.newBuilder()
      .uri(URI.create("https://brainxiex.com/api/ai/images/generations"))
      .header("Content-Type", "application/json")
      .header("Authorization", "Bearer YOUR_API_KEY")
      .POST(HttpRequest.BodyPublishers.ofString(json))
      .build();
    
    try {
      HttpResponse response = HttpClient.newHttpClient()
        .send(request, HttpResponse.BodyHandlers.ofString());
      System.out.println(response.body());
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}
require 'net/http'
require 'json'
require 'uri'

uri = URI('https://brainxiex.com/api/ai/images/generations')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Post.new(uri.path)
request['Content-Type'] = 'application/json'
request['Authorization'] = 'Bearer YOUR_API_KEY'

data = {
  prompt: 'Sebuah kucing lucu sedang bermain',
  n: 1,
  size: '1024x1024'
}

request.body = data.to_json

response = http.request(request)
puts response.body
interface ImageRequest {
  prompt: string;
  n: number;
  size: string;
}

const data: ImageRequest = {
  prompt: "Sebuah kucing lucu sedang bermain",
  n: 1,
  size: "1024x1024"
};

fetch('https://brainxiex.com/api/ai/images/generations', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_API_KEY'
  },
  body: JSON.stringify(data)
})
.then(response => response.json())
.then(result => console.log(result))
.catch(error => console.error('Error:', error));
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;

class Program {
  static async Task Main() {
    var data = new {
      prompt = "Sebuah kucing lucu sedang bermain",
      n = 1,
      size = "1024x1024"
    };

    var json = JsonConvert.SerializeObject(data);
    var content = new StringContent(json, Encoding.UTF8, "application/json");

    using var client = new HttpClient();
    client.DefaultRequestHeaders.Add("Authorization", "Bearer YOUR_API_KEY");

    var response = await client.PostAsync(
      "https://brainxiex.com/api/ai/images/generations",
      content
    );

    var result = await response.Content.ReadAsStringAsync();
    Console.WriteLine(result);
  }
}
local http = require("socket.http")
local ltn12 = require("ltn12")
local json = require("dkjson")

local data = {
  prompt = "Sebuah kucing lucu sedang bermain",
  n = 1,
  size = "1024x1024"
}

local body = json.encode(data)
local headers = {
  ["Content-Type"] = "application/json",
  ["Authorization"] = "Bearer YOUR_API_KEY"
}

local response_body = {}
local code, headers, status = http.request({
  method = "POST",
  url = "https://brainxiex.com/api/ai/images/generations",
  headers = headers,
  source = ltn12.source.string(body),
  sink = ltn12.sink.table(response_body)
})

print(table.concat(response_body))
#include 
#include 
#include 
#include 

using json = nlohmann::json;

int main() {
  CURL* curl = curl_easy_init();
  if(curl) {
    json data = {
      {"prompt", "Sebuah kucing lucu sedang bermain"},
      {"n", 1},
      {"size", "1024x1024"}
    };

    std::string json_str = data.dump();
    
    struct curl_slist *headers = NULL;
    headers = curl_slist_append(headers, "Content-Type: application/json");
    headers = curl_slist_append(headers, "Authorization: Bearer YOUR_API_KEY");
    
    curl_easy_setopt(curl, CURLOPT_URL, "https://brainxiex.com/api/ai/images/generations");
    curl_easy_setopt(curl, CURLOPT_POSTFIELDS, json_str.c_str());
    curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
    
    CURLcode res = curl_easy_perform(curl);
    if(res != CURLE_OK)
      fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
    
    curl_easy_cleanup(curl);
  }
  return 0;
}

🔌 Penggunaan Plugin

Plugin memungkinkan Anda menambahkan data tambahan ke dalam request AI, sehingga AI dapat memberikan jawaban yang lebih spesifik dan relevan.

Struktur Plugin:

{
  "model": "brainxiex",
  "messages": [{
    "role": "user",
    "content": "Siapa bos perusahaan ini?"
  }],
  "plugin": [
    {
      "name": "Data Perusahaan",
      "description": "Informasi perusahaan",
      "type": "json",
      "data": {
        "json": {
          "Boss": "Budi Santoso",
          "Alamat": "Jl. Teknologi No. 123, Jakarta"
        }
      }
    }
  ]
}

Tipe Data Plugin:

  • json - Data dalam format JSON
  • markdown - Data dalam format Markdown
  • text - Data plain text
  • url - Data diambil dari URL
  • base64 - Data dalam format base64

Contoh Implementasi:

curl -X POST 'https://brainxiex.com/api/ai/chat/completions' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-d '{
  "model": "brainxiex",
  "messages": [{
    "role": "user",
    "content": "Siapa bos perusahaan ini?"
  }],
  "plugin": [
    {
      "name": "Data Perusahaan",
      "description": "Informasi perusahaan",
      "type": "json",
      "data": {
        "json": {
          "Boss": "Budi Santoso",
          "Alamat": "Jl. Teknologi No. 123"
        }
      }
    }
  ]
}'
<?php
$data = array(
  "model" => "brainxiex",
  "messages" => array(
    array(
      "role" => "user",
      "content" => "Siapa bos perusahaan ini?"
    )
  ),
  "plugin" => array(
    array(
      "name" => "Data Perusahaan",
      "description" => "Informasi perusahaan",
      "type" => "json",
      "data" => array(
        "json" => array(
          "Boss" => "Budi Santoso",
          "Alamat" => "Jl. Teknologi No. 123"
        )
      )
    )
  )
);

$options = array(
  "http" => array(
    "header" => "Content-Type: application/json\r\nAuthorization: Bearer YOUR_API_KEY\r\n",
    "method" => "POST",
    "content" => json_encode($data),
  ),
);

$context = stream_context_create($options);
$response = file_get_contents('https://brainxiex.com/api/ai/chat/completions', false, $context);
echo $response;
?>
const data = {
  model: "brainxiex",
  messages: [
    {
      role: "user",
      content: "Siapa bos perusahaan ini?"
    }
  ],
  plugin: [
    {
      name: "Data Perusahaan",
      description: "Informasi perusahaan",
      type: "json",
      data: {
        json: {
          Boss: "Budi Santoso",
          Alamat: "Jl. Teknologi No. 123"
        }
      }
    }
  ]
};

fetch('https://brainxiex.com/api/ai/chat/completions', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_API_KEY'
  },
  body: JSON.stringify(data)
})
.then(response => response.json())
.then(result => console.log(result))
.catch(error => console.error('Error:', error));
const axios = require('axios');

const data = {
  model: "brainxiex",
  messages: [
    {
      role: "user",
      content: "Siapa bos perusahaan ini?"
    }
  ],
  plugin: [
    {
      name: "Data Perusahaan",
      description: "Informasi perusahaan",
      type: "json",
      data: {
        json: {
          Boss: "Budi Santoso",
          Alamat: "Jl. Teknologi No. 123"
        }
      }
    }
  ]
};

axios.post('https://brainxiex.com/api/ai/chat/completions', data, {
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_API_KEY'
  }
})
.then(response => {
  console.log(response.data);
})
.catch(error => {
  console.error('Error:', error);
});
import requests
import json

url = "https://brainxiex.com/api/ai/chat/completions"
headers = {
  "Content-Type": "application/json",
  "authorization": "Bearer YOUR_API_KEY"
}
data = {
  "model": "brainxiex",
  "messages": [
    {
      "role": "user",
      "content": "Siapa bos perusahaan ini?"
    }
  ],
  "plugin": [
    {
      "name": "Data Perusahaan",
      "description": "Informasi perusahaan",
      "type": "json",
      "data": {
        "json": {
          "Boss": "Budi Santoso",
          "Alamat": "Jl. Teknologi No. 123"
        }
      }
    }
  ]
}

response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.json())
package main

import (
  "bytes"
  "encoding/json"
  "fmt"
  "net/http"
)

type PluginData struct {
  JSON map[string]string `json:"json"`
}

type Plugin struct {
  Name        string     `json:"name"`
  Description string     `json:"description"`
  Type        string     `json:"type"`
  Data        PluginData `json:"data"`
}

type Request struct {
  Model    string   `json:"model"`
  Messages []Message `json:"messages"`
  Plugin   []Plugin `json:"plugin"`
}

func main() {
  data := Request{
    Model: "brainxiex",
    Messages: []Message{
      {Role: "user", Content: "Siapa bos perusahaan ini?"},
    },
    Plugin: []Plugin{
      {
        Name:        "Data Perusahaan",
        Description: "Informasi perusahaan",
        Type:        "json",
        Data: PluginData{
          JSON: map[string]string{
            "Boss":   "Budi Santoso",
            "Alamat": "Jl. Teknologi No. 123",
          },
        },
      },
    },
  }

  jsonData, _ := json.Marshal(data)
  req, _ := http.NewRequest("POST", "https://brainxiex.com/api/ai/chat/completions", bytes.NewBuffer(jsonData))
  req.Header.Set("Content-Type", "application/json")
  req.Header.Set("Authorization", "Bearer YOUR_API_KEY")

  client := &http.Client{}
  resp, _ := client.Do(req)
  defer resp.Body.Close()

  fmt.Println(resp.Status)
}
import java.net.http.*;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.util.*;

public class PluginExample {
  public static void main(String[] args) {
    Map data = new HashMap<>();
    data.put("model", "brainxiex");
    
    List> messages = new ArrayList<>();
    Map msg = new HashMap<>();
    msg.put("role", "user");
    msg.put("content", "Siapa bos perusahaan ini?");
    messages.add(msg);
    data.put("messages", messages);
    
    String json = new com.google.gson.Gson().toJson(data);
    
    HttpRequest request = HttpRequest.newBuilder()
      .uri(URI.create("https://brainxiex.com/api/ai/chat/completions"))
      .header("Content-Type", "application/json")
      .header("Authorization", "Bearer YOUR_API_KEY")
      .POST(HttpRequest.BodyPublishers.ofString(json))
      .build();
    
    try {
      HttpResponse response = HttpClient.newHttpClient()
        .send(request, HttpResponse.BodyHandlers.ofString());
      System.out.println(response.body());
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}
require 'net/http'
require 'json'
require 'uri'

uri = URI('https://brainxiex.com/api/ai/chat/completions')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Post.new(uri.path)
request['Content-Type'] = 'application/json'
request['Authorization'] = 'Bearer YOUR_API_KEY'

data = {
  model: 'brainxiex',
  messages: [
    { role: 'user', content: 'Siapa bos perusahaan ini?' }
  ],
  plugin: [
    {
      name: 'Data Perusahaan',
      description: 'Informasi perusahaan',
      type: 'json',
      data: {
        json: {
          Boss: 'Budi Santoso',
          Alamat: 'Jl. Teknologi No. 123'
        }
      }
    }
  ]
}

request.body = data.to_json

response = http.request(request)
puts response.body
interface Message {
  role: string;
  content: string;
}

interface PluginData {
  json: {
    Boss: string;
    Alamat: string;
  };
}

interface Plugin {
  name: string;
  description: string;
  type: string;
  data: PluginData;
}

interface Request {
  model: string;
  messages: Message[];
  plugin: Plugin[];
}

const data: Request = {
  model: "brainxiex",
  messages: [
    {
      role: "user",
      content: "Siapa bos perusahaan ini?"
    }
  ],
  plugin: [
    {
      name: "Data Perusahaan",
      description: "Informasi perusahaan",
      type: "json",
      data: {
        json: {
          Boss: "Budi Santoso",
          Alamat: "Jl. Teknologi No. 123"
        }
      }
    }
  ]
};

fetch('https://brainxiex.com/api/ai/chat/completions', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_API_KEY'
  },
  body: JSON.stringify(data)
})
.then(response => response.json())
.then(result => console.log(result))
.catch(error => console.error('Error:', error));
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using System.Collections.Generic;

class Program {
  static async Task Main() {
    var data = new {
      model = "brainxiex",
      messages = new[] {
        new { role = "user", content = "Siapa bos perusahaan ini?" }
      },
      plugin = new[] {
        new {
          name = "Data Perusahaan",
          description = "Informasi perusahaan",
          type = "json",
          data = new {
            json = new {
              Boss = "Budi Santoso",
              Alamat = "Jl. Teknologi No. 123"
            }
          }
        }
      }
    };

    var json = JsonConvert.SerializeObject(data);
    var content = new StringContent(json, Encoding.UTF8, "application/json");

    using var client = new HttpClient();
    client.DefaultRequestHeaders.Add("Authorization", "Bearer YOUR_API_KEY");

    var response = await client.PostAsync(
      "https://brainxiex.com/api/ai/chat/completions",
      content
    );

    var result = await response.Content.ReadAsStringAsync();
    Console.WriteLine(result);
  }
}
local http = require("socket.http")
local ltn12 = require("ltn12")
local json = require("dkjson")

local data = {
  model = "brainxiex",
  messages = {
    { role = "user", content = "Siapa bos perusahaan ini?" }
  },
  plugin = {
    {
      name = "Data Perusahaan",
      description = "Informasi perusahaan",
      type = "json",
      data = {
        json = {
          Boss = "Budi Santoso",
          Alamat = "Jl. Teknologi No. 123"
        }
      }
    }
  }
}

local body = json.encode(data)
local headers = {
  ["Content-Type"] = "application/json",
  ["Authorization"] = "Bearer YOUR_API_KEY"
}

local response_body = {}
local code, headers, status = http.request({
  method = "POST",
  url = "https://brainxiex.com/api/ai/chat/completions",
  headers = headers,
  source = ltn12.source.string(body),
  sink = ltn12.sink.table(response_body)
})

print(table.concat(response_body))
#include 
#include 
#include 
#include 

using json = nlohmann::json;

int main() {
  CURL* curl = curl_easy_init();
  if(curl) {
    json data = {
      {"model", "brainxiex"},
      {"messages", json::array({
        {{"role", "user"}, {"content", "Siapa bos perusahaan ini?"}}
      })},
      {"plugin", json::array({
        {
          {"name", "Data Perusahaan"},
          {"description", "Informasi perusahaan"},
          {"type", "json"},
          {"data", json::object({
            {"json", json::object({
              {"Boss", "Budi Santoso"},
              {"Alamat", "Jl. Teknologi No. 123"}
            })}
          })}
        }
      })}
    };

    std::string json_str = data.dump();
    
    struct curl_slist *headers = NULL;
    headers = curl_slist_append(headers, "Content-Type: application/json");
    headers = curl_slist_append(headers, "Authorization: Bearer YOUR_API_KEY");
    
    curl_easy_setopt(curl, CURLOPT_URL, "https://brainxiex.com/api/ai/chat/completions");
    curl_easy_setopt(curl, CURLOPT_POSTFIELDS, json_str.c_str());
    curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
    
    CURLcode res = curl_easy_perform(curl);
    if(res != CURLE_OK)
      fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
    
    curl_easy_cleanup(curl);
  }
  return 0;
}

© 2025 Brainxiex Development. All rights reserved.

Dokumentasi API Brainxiex AI - Diperbarui secara berkala