Using API keys with REST requests
You may limit access to your deployed models using API keys. API keys are created in the Settings area of Modelbit, and sent to deployments in the Authorization
header.
Using curl
With curl, use the -H
flag to set a header:
curl -s -XPOST "https://<your-workspace-url>/v1/example_deployment/latest" \
-H "Authorization: YOUR_API_KEY" \
-d '{"data":[[1,10,11],[2,20,21],[3,30,31]]}'
Using Python
In Python with the requests
package, add to the headers=
argument:
import json, requests
requests.post("https://<your-workspace-url>/v1/example_deployment/latest",
headers={
"Content-Type":"application/json",
"Authorization": "YOUR_API_KEY"
},
data=json.dumps({"data":[[1,10,11],[2,20,21],[3,30,31]]})).json()