# Perspective integrations

Many tools call the Perspective API for you. Here is how to point each one at layahost. Where a tool has a setting for the endpoint, no code changes; where it has the Google URL built in, the change is one line.

Every tool needs a layahost API key from the [API keys](https://layahost.com/keys) page in place of the Google key. Scores come from a different model: re-check the thresholds you set in the tool. See [Accuracy](https://layahost.com/docs/perspective#accuracy).

## No code changes

### Coral by Vox Media

Coral's toxic comment filter has a custom endpoint setting. In the Coral admin, open **Configure → Moderation → Perspective toxic comment filter** and set:

| Setting | Value |
| --- | --- |
| Custom endpoint | `https://layahost.com/v1alpha1` |
| API key | Your layahost key (`lh_…`) |
| Model | `TOXICITY` (or any [supported attribute](https://layahost.com/docs/perspective)) |

Coral adds `/comments:analyze` to the endpoint and sends the key as `?key=`, which layahost accepts. The option to send moderation decisions back to Perspective keeps working through `comments:suggestscore`; layahost accepts those calls for free and stores nothing. Coral sends the site's language as a hint: layahost scores other languages too, but is most accurate in English.

### dingo

dingo's `LLMPerspective` evaluator takes the discovery URL as `api_url`. In its Perspective example that is the `PERSPECTIVE_API_URL` environment variable:

Environment

```bash
export PERSPECTIVE_API_KEY="lh_your_key"
export PERSPECTIVE_API_URL='https://layahost.com/$discovery/rest?version=v1alpha1'
```

### augustus

The `perspective.Perspective` detector has an `api_url` option. augustus only adds `?key=` to Google's own URL, so put the key in the URL yourself, and keep `api_key` set because it is required:

Detector options

```yaml
api_key: lh_your_key
api_url: https://layahost.com/v1alpha1/comments:analyze?key=lh_your_key
attrs: [TOXICITY]
```

### Your own code with googleapiclient

Change `discoveryServiceUrl` to `https://layahost.com/$discovery/rest?version=v1alpha1` and the key. Single requests and `new_batch_http_request()` batches both work. Full example in the [migration guide](https://layahost.com/docs/perspective).

## One-line changes

These tools have the Google address built in. Until they add a setting, change the line below in your copy.

| Tool | File | Change |
| --- | --- | --- |
| Stanford HELM | `src/helm/clients/perspective_api_client.py` | `discoveryServiceUrl` to `https://layahost.com/$discovery/rest?version=v1alpha1`. HELM's batches and its default `FLIRTATION` attribute work: `flirtation_score` stays empty. |
| lm-evaluation-harness | `lm_eval/tasks/realtoxicityprompts/metric.py` | The `commentanalyzer.googleapis.com` URL to `https://layahost.com/v1alpha1/comments:analyze`. `PERSPECTIVE_API_KEY` takes your layahost key. |
| DataFlow | `dataflow/serving/google_api_serving.py` | `discoveryServiceUrl` to `https://layahost.com/$discovery/rest?version=v1alpha1`; `GOOGLE_API_KEY` takes your layahost key. |
| 4CAT | `processors/machine_learning/perspective.py` | The `discoveryServiceUrl` in `discovery.build()` to `https://layahost.com/$discovery/rest?version=v1alpha1`; the `api.google.api_key` setting takes your layahost key. |
| Discourse Perspective plugin | `lib/discourse_perspective.rb` | `GOOGLE_API_DOMAIN` to `https://layahost.com`; the plugin's API key setting takes your layahost key. |

Using a tool that is not listed? Anything that lets you change the host works: replace `commentanalyzer.googleapis.com` with `layahost.com`. If it doesn't, write to [support@layahost.com](mailto:support@layahost.com) and we will look at it.
