Jump to content
Wikitech

Machine Learning/LiftWing/API/External usage

From Wikitech

This page explains how external users can access Lift Wing API endpoints. External users are clients outside WMF production infrastructure, including Toolforge and Cloud VPS machines.

Internal users: see Internal_usage instead.

Access external endpoints

External Lift Wing endpoint URLs use the following format:

https://api.wikimedia.org/service/lw/inference/v1/models/{MODEL_NAME}:predict

Use Machine_Learning/LiftWing#Current_Inference_Services to see the list of available models and find the {MODEL_NAME}. Models in the "experimental" namespace are only available internally.

Quick start

This section shows sample curl API calls for two different models.

Each model has unique input requirements and output formats. Use the model card and API reference to understand how to make requests and interpret the response.

The following examples show one request to a model that uses page identifiers (page_title or page_id) as POST parameters, and one that uses revision (rev_id) instead.

Example of how to query the outlink-topic-model model via curl:

exportACCESSTOKEN="copy-paste-token"
# Get predicted topics for the page of Douglas Adams on English Wikipedia.
curlhttps://api.wikimedia.org/service/lw/inference/v1/models/outlink-topic-model:predict-XPOST-d'{"page_title": "Douglas_Adams", "lang": "en"}'-H"Authorization: Bearer $ACCESSTOKEN"-A"YOUR_APP_NAME (YOUR_EMAIL_OR_CONTACT_PAGE)"

Example of how to query the revertrisk-multilingual model via curl:

exportACCESSTOKEN="copy-paste-token"
# Get the revert risk probability for the edit on English Wikipedia identified by the revision id 123456.
curlhttps://api.wikimedia.org/service/lw/inference/v1/models/revertrisk-multilingual:predict-XPOST-d'{"rev_id": 123456, "lang": "en"}'-H"Authorization: Bearer $ACCESSTOKEN"-A"YOUR_APP_NAME (YOUR_EMAIL_OR_CONTACT_PAGE)"

Authentication

To use the Lift Wing API as an authenticated user, you must log in with OAuth. To do that, you must first obtain an access token for your client. Follow the instructions at mw:Wikimedia APIs/Authentication.

Rate limits for external usage

Lift Wing endpoints have the following rate limits for external clients:

Client type Req/h Req/s Based on
Anonymous 50,000 15 IP address or user agent
Browser requests 50,000 50 IP address or auth token
Authenticated 100,000 100 Auth token or session cookie
Known clients, including: 200,000 200 Auth token, user agent, or provenance

Reference documentation

AltStyle によって変換されたページ (->オリジナル) /