Authentication

Headers

Two headers are required for authentication:

  1. apikey

    • Description: Your unique API key to access the endpoint. This key is specific to your organization or project and can be found in your Humiris dashboard Here.
  2. mixTuningId

    • Description: The unique identifier for your MixTuning configuration (Mix Model).

Endpoint: Chat Completions

URL

Base URL : https://moai-service-app.humiris.ai/api/v1

POST /chat/completions

Description

Use this endpoint to send a chat completion request. This is similar to OpenAI’s chat/completions endpoint, with added functionality for custom tuning.

Headers

HeaderTypeRequiredDescription
apikeystringYesYour API key.
mixTuningIdstringYesThe MixTuning ID for personalized AI responses.

Body

The request body follows OpenAI’s chat/completions format.

Request Body Example

{
  "messages": [
    {
      "role": "user",
      "content": "Say this is a test."
    }
  ],
  "model": "Humiris/humiris-moai"
}
FielsTypeRequiredDescription
messagesstringYesArray of message objects, each with role and content.
modelstringYesThe model to use. Example: Humiris/humiris-moai

Response

{
  "id": "chatcmpl-12345",
  "object": "chat.completion",
  "created": 1698000000,
  "model": "Humiris/humiris-moai",
  "choices": [
    {
      "message": {
        "role": "assistant",
        "content": "This is a test."
      },
      "finish_reason": "stop",
      "stop_reason": "\n"
    }
  ],
  "usage": {
    "prompt_tokens": 5,
    "completion_tokens": 7,
    "total_tokens": 12
  }
}

Error

Status CodeErrorDescription
400BadRequestThe mixTuningId header is missing.
404MixTuningNotFoundThe provided mixTuningId does not exist.
401UnauthorizedInvalid or missing apikey.

Integration Examples

JavaScript Here’s how to integrate the API using the fetch method in JavaScript:

const fetch = require("node-fetch");

const apikey = "your-api-key";
const mixTuningId = "your-mix-tuning-id";

async function sendChatCompletion() {
  const response = await fetch(
    "https://moai-service-app.humiris.ai/api/v1/chat/completions",
    {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        apikey: apikey,
        mixTuningId: mixTuningId,
      },
      body: JSON.stringify({
        messages: [
          {
            role: "user",
            content: "Say this is a test.",
          },
        ],
        model: "Humiris/humiris-moai",
      }),
    }
  );

  if (!response.ok) {
    const error = await response.json();
    console.error("Error:", error);
    return;
  }

  const data = await response.json();
  console.log("Response:", data);
}

sendChatCompletion();

Python Here’s how to integrate the API using the request method in Python:

import requests

url = "https://moai-service-app.humiris.ai/api/v1/chat/completions"
headers = {
    "Content-Type": "application/json",
    "apikey": "your-api-key",
    "mixTuningId": "your-mix-tuning-id"
}
payload = {
    "messages": [
        {
            "role": "user",
            "content": "Say this is a test."
        }
    ],
    "model": "Humiris/humiris-moai"
}

response = requests.post(url, json=payload, headers=headers)

if response.status_code == 200:
    print("Response:", response.json())
else:
    print("Error:", response.status_code, response.json())

Support For any questions or issues, please contact Hilario Houmey at h.hilario@humiris.ai.