Skip to content
This repository was archived by the owner on Jun 8, 2023. It is now read-only.

Provider Integrations

Kedar Vijay Kulkarni edited this page May 29, 2022 · 3 revisions

Provider Integrations

Managing the API keys of your selected organization.

List API Keys (GET)

Get a summary of the api keys your selected organization currently has configured.

Document link

const mantiumAi = require('@mantium/mantiumapi');

(async () => {
  await mantiumAi.Auth().accessTokenLogin({
    username: 'useremail@somedomain.com',
    password: 'p@ssWord!'
  })
    .then((response) => {
      // get bearer_id and set to default
      mantiumAi.api_key = response.data.attributes.bearer_id;
      return response;
    });

  /*
  * API Key is set on above
  * mantiumAi.api_key=`key`
  * so we can call these method directly now
  */
  await mantiumAi
    .ProviderIntegrations()
    .list({ page: 1, size: 2 })
    .then((response) => {
      console.log('*********** Provider Integrations list response *********');
      console.log(response.data);
      console.log(response.data[0].attributes);
    });
})();

Example of a successful API response

*********** Provider Integrations list response *********
{
  data: [
    {
      id: 'Cohere',
      type: 'api_key',
      {
        ai_provider: 'Cohere',
        verified: true,
        created: {
          timestamp: '2021-12-30T06:25:37.444072+00:00',
          user_id: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
          full_name: ' ',
          email: 'user@emai.com'
        },
        updated: null
      },
      relationships: {}
    },
    {
      id: 'OpenAI',
      type: 'api_key',
      {
        ai_provider: 'OpenAI',
        verified: true,
        created: {
          timestamp: '2022-05-29T12:18:11.014818+00:00',
          user_id: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
          full_name: ' ',
          email: 'user@emai.com'
        },
        updated: null
      },
      relationships: {}
    }
  ],
  included: [],
  meta: {},
  links: {}
}

Go to Table of Contents

Verify API Key (POST)

Confirm that the API Key is valid. POST the api key in the data packet: {"api_key": "somekey"} If no API Key is provided, we will try to use the saved one

https://api.mantiumai.com/v1/provider/verify_key/{ai_provider}

Requirements:

  • ai_provider* (string) provider name
  • api_key (string) proider api key, This is optional AI Provider API Key. If not present, then we use the saved key.

Document link

const mantiumAi = require('@mantium/mantiumapi');

(async () => {
  await mantiumAi.Auth().accessTokenLogin({
    username: 'useremail@somedomain.com',
    password: 'p@ssWord!'
  })
    .then((response) => {
      // get bearer_id and set to default
      mantiumAi.api_key = response.data.attributes.bearer_id;
      return response;
    });

  /*
  * API Key is set on above
  * mantiumAi.api_key=`key`
  * so we can call these method directly now
  */
  await mantiumAi
    .ProviderIntegrations('cohere')
    .verifyKey({ api_key: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' })
    .then((response) => {
      console.log('*********** Provider Integrations Verify Key response *********');
      console.log(response);
    });
})();

Example of a successful API response

*********** Provider Integrations Verify Key response *********
[ 'The cohere api key is good!' ]

Go to Table of Contents

Save Key (POST)

Save and verify a provider api key for your selected organization - if one exists already, overwrite it. If the "verified" value in the payload is included and set to true, we will assume it is verified.

https://api.mantiumai.com/v1/provider/save_key/{ai_provider}

Requirements:

  • ai_provider* (string) provider name
  • api_key* (string) AI Provider API Key.
  • verified (boolean) If TRUE, we will assume the key is good and not attempt to verify it.

Document link

const mantiumAi = require('@mantium/mantiumapi');

(async () => {
  await mantiumAi.Auth().accessTokenLogin({
    username: 'useremail@somedomain.com',
    password: 'p@ssWord!'
  })
    .then((response) => {
      // get bearer_id and set to default
      mantiumAi.api_key = response.data.attributes.bearer_id;
      return response;
    });

  /*
  * API Key is set on above
  * mantiumAi.api_key=`key`
  * so we can call these method directly now
  */
  await mantiumAi
    .ProviderIntegrations('openai')
    .saveKey({ api_key: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', verified: false })
    .then((response) => {
      console.log('*********** Provider Integrations Verify Key response *********');
      console.log(response);
    });
})();

Example of a successful API response

*********** Provider Integrations Verify Key response *********
{
  data: {
    id: 'OpenAI',
    type: 'api_key',
    attributes: {
      ai_provider: 'OpenAI',
      verified: true,
      created: {
        timestamp: '2022-05-29 14:27:33.147132+00:00',
        user_id: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
        full_name: ' ',
        email: 'user@emai.com'
      },
      updated: null
    },
    relationships: {}
  },
  included: [],
  meta: {},
  links: {}
}

Go to Table of Contents

Delete Key (DELETE)

Get a summary of the api keys your selected organization currently has configured.

https://api.mantiumai.com/v1/provider/delete_key/{ai_provider}

Requirements:

  • ai_provider* (string) provider name

Document link

const mantiumAi = require('@mantium/mantiumapi');

(async () => {
  await mantiumAi.Auth().accessTokenLogin({
    username: 'useremail@somedomain.com',
    password: 'p@ssWord!'
  })
    .then((response) => {
      // get bearer_id and set to default
      mantiumAi.api_key = response.data.attributes.bearer_id;
      return response;
    });

  /*
  * API Key is set on above
  * mantiumAi.api_key=`key`
  * so we can call these method directly now
  */
  await mantiumAi
    .ProviderIntegrations('openai')
    .removeKey()
    .then((response) => {
      console.log('*********** Provider Integrations Remove Key response *********');
      console.log(response);
    });
})();

Example of a successful API response

*********** Provider Integrations Remove Key response *********
Deleted 1 key

Go to Table of Contents

Clone this wiki locally