Unprofane

Node (googleapis)

The googleapis client takes a rootUrl. Set it to the Unprofane host with your key as auth.

1. Change the client options

The discovered client accepts a rootUrl option. Every analyze call after it is unchanged.

import { google } from 'googleapis';

const client = await google.discoverAPI(
  'https://api.unprofane.com/$discovery/rest?version=v1alpha1',
);
const res = await client.comments.analyze({
  key: 'up_live_YOUR_KEY',
  resource: {
    comment: { text: 'you are a clown' },
    requestedAttributes: { TOXICITY: {} },
    languages: ['en'],
    doNotStore: true,
  },
});
console.log(res.data.attributeScores.TOXICITY.summaryScore.value);

2. Or use fetch

The raw HTTP guide shows the same request with fetch and no dependency.

Then

Map your thresholds with the replay tool, and read what is different. The other guides are on the migration hub.