REST API Reference
GET /
Get input/output JSON schemas of this model.
The response is a JSON object with the following fields:
input_schema
: Input JSON schema. Keys are same as the input class declared usingdefine_model
decorator.output_schema
: Output JSON schema. Keys are same as the output class declared usingdefine_model
decorator.demo_output_schema
: Demo output JSON schema. Keys are same as the demo output class declared usingdefine_model
decorator.
POST /predictions
Create a prediction.
The request body should be a list of input JSON objects.
The response is a JSON object with the prediction_id
field.
For example, let's assume that we defined the input as follows:
from tungstenkit import BaseIO, define_model
class Input(BaseIO):
prompt: str
seed: int
@define_model(input=Input, ...)
class TextToImageModel:
...
Then, you can send a request as follows:
$ curl -X 'POST' 'http://localhost:3000/predictions' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-d '[{"prompt": "a professional photograph of an astronaut riding a horse"}]'
{
"prediction_id": "39c9eb6b"
}
GET /predictions/{prediction_id}
Get the result of an asynchronous prediction.
The response is a JSON object with the following fields:
outputs
: List of output JSON objects.status
: Amongpending
,running
,success
andfailed
.error_message
: The error message ifstatus
isfailed
.
For example, let's assume that we defined the output as follows:
from tungstenkit import BaseIO, define_model, Image
class Output(BaseIO):
image: Image
@define_model(output=Output, ...)
class TextToImageModel:
...
Then, you can send a request as follows:
$ curl -X 'GET' 'http://localhost:3000/predictions/39c9eb6b' \
-H 'Accept: application/json'
{
"outputs": [{"image": "data:image/png;base64,..."}],
"status": "success"
}
POST /predictions/{prediction_id}/cancel
Cancel an asynchronous prediction.
POST /demo
Make a demo prediction.
The request body should be a list of input JSON objects.
The response is a JSON object with the demo_id
field.
GET /demo/{demo_id}
Get the result of a demo prediction.
The response is a JSON object with the following fields:
outputs
: List of output JSON objects.demo_outputs
: List of demo output JSON objects.status
: Amongpending
,running
,success
andfailed
.error_message
: The error message ifstatus
iffailed
.logs
: Logs while running thepredict_demo
method.
POST /demo/{demo_id}/cancel
Cancel a demo prediction.