Skip to main content

Capabilities

Message Submission

To submit a message, use the POST method on the endpoint /api-key/{communityId}. The following options are available in the request body:

user_input (Required)

  • Type: String
  • Description: The user's input message.
  • Validation: Must not be empty.

Example:

{
  "user_input": "Hello, how can I help?"
}

variables (Required)

  • Type: Array of Variable objects
  • Description: Additional variables associated with the message.
  • Validation: Must not be empty, and each element must be a valid Variable object.

Example

{
  "user_input": "Query",
  "variables": [
    {
      "name": "variable1",
      "value": "value1"
    },
    {
      "name": "variable2",
      "value": "value2"
    }
  ]
}

sessionId (Optional)

  • Type: String
  • Description: A unique session identifier.
  • Validation: Must be a string if provided.
{
  "user_input": "Query",
  "sessionId": "12345"
}

modelName (Optional)

  • Type: String
  • Description: The name of the available model to use.
  • Validation: Must be a valid AvailableModelName.
{
  "user_input": "Query",
  "modelName": "example_model" //gpt-3.5-turbo, gpt-4, claude-2
}

Example Usage

Here's an example of how to use the API in a JavaScript application using Axios:

const handleMessageSubmit = async () => {
  try {
    const res = await axios.post(
      `http://api.invictai.io/api/chat/api-key/${communityId}`,
      {
        user_input: input,
        sessionId: "123",
        variables: [
          { name: "variable1", value: "value1" },
          { name: "variable2", value: "value2" }
        ],
        modelName: "gpt-3.5-turbo"
      },
      {
        headers: {
          "X-INVICTA-API": apiKey,
        },
      }
    );
    console.log(res.data);
  } catch (error) {
    // Handle errors here
    console.error("Error submitting message:", error);
  }
};