Build & ship ML APIs.
Endpoints turn your Python functions into API endpoints to form a serverless backend for your applications. You can build and test endpoints from the web IDE.

The @route decorator

The @route decorator transforms any Python function into an endpoint. It's signature is as follows:
def func(request):
return request
The decorator accepts two more named arguments:
  • is_public (boolean): is this a public endpoint? (Public endpoints do not require an API key to request.)
    • Default: False
  • allowed_domains (list of strings): Sets a list of allowed domains to prevent CORS issues when invoking public endpoints.
    • Default: []
    • Example: ["", ""]
Routes must start with /. At the moment, the root route (just /) is not supported, but it will be in the future.

Invoking endpoints

You can invoke endpoints from the Blueprint web IDE or anywhere that can send an HTTP request: terminal, code, testing tools like Postman, and applications.
The url to invoke is formatted as follows:


Requests to private endpoints (by default, endpoints are private) must be accompanied with an API key for authentication. Pass the API key with an authorization header in the HTTP request. In cURL, that looks like:
- h "Authorization: API-KEY"
Generate API keys in your Baseten account. You can follow the API key docs for instructions.

Input Format

Your Python function should accept a single position argument, request, which passes in a dictionary of input. Input includes HTTP method, headers (all request headers are passed to the function), and body.
Blueprint endpoints support GET, POST, PUT, and DELETE methods. For GET requests, you can pass data with query parameters. For others, use the HTTP request body.

Output format

Your Python function can output anything JSON-serializable. Blueprint will serialize it and wrap it in a dictionary with the following format:
"success": true,
"output": YOUR_OUTPUT
You do not need to return success: true from your function, Blueprint does that for you. The endpoint will return success: false in the error case.
Note that for now, functions always return a 200 HTTP code, even in error cases. Proper HTTP codes will be added in the future.