Links

API reference

A reference for API endpoints on your Baseten account.
Page under construction! This reference is still incomplete but will be finished soon!
Baseten doesn't exactly have an API; you'll want to use the Python client to manage your account with code. However, applications and models deployed on your Baseten account automatically have API endpoints, so a comprehensive reference is still in order.
API requests require an API key in the Authorization header. Never store your API key in your code repository or make it accessible to end users by storing it client-side.

Model endpoint

cURL
Python
Node.js
$ curl -X POST https://app.baseten.co/model_versions/<model_version_id>/predict \
-H 'Authorization: Api-Key your-api-key-here' \
-d '{"inputs": [{"a": 1, "b": 2, "c": 3}]}'
import os
import requests
url = 'https://app.baseten.co/model_versions/<model_version_id>/predict'
auth_header = {'Authorization': f'Api-Key {os.environ["BASETEN_API_KEY"]}'}
model_input = {'inputs': [{'a': 1, 'b': 2, 'c': 3}]}
req = requests.post(
url,
headers = auth_header,
json = model_input,
)
print(req.text)
const data = JSON.stringify({
'inputs': [{'a': 1, 'b': 2, 'c': 3}]
})
const options = {
hostname: 'app.baseten.co',
port: 443,
path: '/model_versions/<model_version_id>/predict',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Api-Key ${process.env.BASETEN_API_KEY}`
}
}
const req = https.request(options, res => {
console.log(`statusCode: ${res.statusCode}`)
res.on('data', d => {
process.stdout.write(d)
})
})
req.on('error', error => {
console.error(error)
})
req.write(data)
req.end()

Worklet Endpoint

cURL
Python
Node.js
curl -X POST https://app.baseten.co/applications/<application_id>/worklets/<worklet_id>/invoke \
-H 'Authorization: Api-Key your-api-key-here' \
-d '{"worklet_input": {"a": 1, "b": 2, "c": 3}}'
import os
import requests
url = 'https://app.baseten.co/applications/<application_id>/worklets/<worklet_id>/invoke'
auth_header = {'Authorization': f'Api-Key {os.environ["BASETEN_API_KEY"]}'}
worklet_input = {"worklet_input": {'a': 1, 'b': 2, 'c': 3}}
req = requests.post(
url,
headers = auth_header,
json = worklet_input,
)
print(req.text)
const https = require('https')
const data = JSON.stringify({
'worklet_input': {'a': 1, 'b': 2, 'c': 3}
})
const options = {
hostname: 'app.baseten.co',
port: 443,
path: '/applications/<application_id>/worklets/<worklet_id>/invoke',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Api-Key ${process.env.BASETEN_API_KEY}`
}
}
const req = https.request(options, res => {
console.log(`statusCode: ${res.statusCode}`)
res.on('data', d => {
process.stdout.write(d)
})
})
req.on('error', error => {
console.error(error)
})
req.write(data)
req.end()