Skip to content

REST API Reference

GET /

Get input/output JSON schemas of this model.

The response is a JSON object with the following fields:

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: Among pending, running, success and failed.
  • error_message: The error message if status is failed.

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: Among pending, running, success and failed.
  • error_message: The error message if status if failed.
  • logs: Logs while running the predict_demo method.

POST /demo/{demo_id}/cancel

Cancel a demo prediction.