Quick Integration

Connect the Mantium Platform with your Application

Common Mantium Usage Workflow (High Level)

  1. Create your account on https://app.mantiumai.com
  2. Setup the Providers you want to use. Get Provider API Keys
  3. Create your Prompts:
    1. Either directly in the UI by hand or using the curl import wizard.
    2. Using your own scripts via the Mantium API
    3. or by importing them from your file system using our handy import tool.
  4. Optionally organize your prompts into one or more Intelets
  5. Configure Security Policies and apply them to your organization, intelets, and/or prompts.
  6. Configure Human In The Loop where needed.
  7. Execute the Intelets or Prompts via Mantium API.
  8. Monitor the activity via the Mantium dashboard and logs viewer.

This documentation page is focused on step 6 - how to execute the prompts and intelets using the Mantium API.

Create a User

If you've already created a user via the website, you do not need to create another user to use the API. You can use the same user for both. This is the preferred approach for the one-time user setup step.

If, for some reason, creating a user via the API will be covered in the Advanced section of our Integration documentation.

Obtain a Bearer Token

The Mantium API requires valid 'Authorization: Bearer' tokens passed in the HTTP request header. These tokens will expire after 10 hours and must be refreshed to continue to use the API.

Once you have a user, you can get a new authorization token (login) any time you need it by running this command against the api:

curl -X 'POST' \
    'https://api.mantiumai.com/auth/login/access/token' \
    -H 'accept: application/json' \
    -H 'Content-Type: application/json' \
    -d '{
    "username": "some_user",
    "password": "some_password"
    }'
import requests

headers = {
    'accept': 'application/json',
    'Content-Type': 'application/json',
}

data = '{ "username": "some_user", "password": "some_password" }'

response = requests.post('https://api.mantiumai.com/auth/login/access/token', headers=headers, data=data)

You will get the response like this:

{
  "data": {
    "id": "f79fbc7f-bbd3-4c4a-852a-c2cecbc5aac6",
    "attributes": {
      "bearer_id": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Imw3YTZFZHFRMUZienZvWTk1MFhLMiJ9.eyJnaXZlbl9uYW1lIjoiVGVzdCIsImZhbWlseV9uYW1lIjoiVXNlciIsIm5pY2tuYW1lIjoicmljayIsIm5hbWUiOiJUZXN0IFVzZXIiLCJwaWN0dXJlIjoiaHR0cHM6Ly9zLmdyYXZhdGFyLmNvbS9hdmF0YXIvMzEyMDE2Njc0MDkxNjVkMmViYjQ0NzJkN2UwMWNjZDI_cz00ODAmcj1wZyZkPWh0dHBzJTNBJTJGJTJGY2RuLmF1dGgwLmNvbSUyRmF2YXRhcnMlMkZ0dS5wbmciLCJ1cGRhdGVkX2F0IjoiMjAyMS0wMy0yNFQxODoxMTowMi45MzhaIiwiZW1haWwiOiJyaWNrQG1hbnRpdW1haS5jb20iLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiaXNzIjoiaHR0cHM6Ly9kZXYtbWFudGl1bS51cy5hdXRoMC5jb20vIiwic3ViIjoiYXV0aDB8NjA0MmExM2Q1Nzk3ZGMwMDY4OGEwZmM3IiwiYXVkIjoiQVRxMXhpcXB2cWdxMUlLV05pSmxnTFgxRkFienJkVlYiLCJpYXQiOjE2MTY2MDk0NjIsImV4cCI6MTYxNjY0NTQ2Mn0.hks-xJ99ykPcZndu1Rnc8ywAa264sxE0tcujwF7ot0JndkRKhE6NIZVhITLufxw_JaYAhlbjCzfZbgirZW_S2QsSYGAX_Id7JFWv7QAIjkkgQ5hiIiRCn6tVWtrs5m_o1ADV0itqjxcuuGWu6fwZMNcBGlYbznyV7ga_znRtnigjQXJmBsnIs7UaNF4u7_PWbvBR3e4eyk_7xzrsegkz0IW3XuDvyMOHgRXqIQRz91ackMOXP7rJ4ckt94iETrauE-V4QjEtAcTRRWfyuxXX-XhK5uyqTsdEP2lY9Q-JpUqS1ptUKj8tZfsa0Iea6PxlXZb8YTQxKuW8_zhp1veVIA",
      "expires_on": "2021-03-25T18:11:03+00:00",
      "token_type": "Bearer"
    },
    "relationships": {}
  },
  "included": null,
  "meta": null,
  "links": null
}

The bearer_id value in that JSON is the important bit.

Every subsequent API request, until you reach the "expires_in" time, will need to include a header:
'Authorization: Bearer that really long bearer_id string

Revoke a Bearer Token

If you need to explicitly revoke a token (log out), you can run this command:

curl -X 'POST' \
        'https://api.mantiumai.com/auth/user/revoke/token' \
        -H 'accept: application/json' \
        -H 'Authorization: Bearer ey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ers = {
    'accept': 'application/json',
    'Authorization': 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6xxxxxx',
    'Content-Type': 'application/json',
}

data = '{ "token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Imw3YTZFZxxxxx" }'

response = requests.post('https://api.mantiumai.com/auth/user/revoke/token', headers=headers, data=data)

You will get the response below:

{
    "error": false,
    "message": "Operation was successful"
    }

Using the Bearer Token

As long as you include a valid Authorization: Bearer <id> in the HTTP headers with every request, you should be able to use them as documented in this document. For example, to list all of your prompts:

curl "https://api.mantiumai.com/v0/prompt" \
     -H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Imw3YTZFZHFRMUZienZvWTk1MFhLMiJ9.eyJnaXZlbl9uYW1lIjoiVGVzdCIsImZhbWlseV9uYW1lIjoiVXNlciIsIm5pY2tuYW1lIjoicmljayIsIm5hbWUiOiJUZXN0IFVzZXIiLCJwaWN0dXJlIjoiaHR0cHM6Ly9zLmdyYXZhdGFyLmNvbS9hdmF0YXIvMzEyMDE2Njc0MDkxNjVkMmViYjQ0NzJkN2UwMWNjZDI_cz00ODAmcj1wZyZkPWh0dHBzJTNBJTJGJTJGY2RuLmF1dGgwLmNvbSUyRmF2YXRhcnMlMkZ0dS5wbmciLCJ1cGRhdGVkX2F0IjoiMjAyMS0wMy0yNFQxODoxMTowMi45MzhaIiwiZW1haWwiOiJyaWNrQG1hbnRpdW1haS5jb20iLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiaXNzIjoiaHR0cHM6Ly9kZXYtbWFudGl1bS51cy5hdXRoMC5jb20vIiwic3ViIjoiYXV0aDB8NjA0MmExM2Q1Nzk3ZGMwMDY4OGEwZmM3IiwiYXVkIjoiQVRxMXhpcXB2cWdxMUlLV05pSmxnTFgxRkFienJkVlYiLCJpYXQiOjE2MTY2MDk0NjIsImV4cCI6MTYxNjY0NTQ2Mn0.hks-xJ99ykPcZndu1Rnc8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