Responses

Strictly speaking, this endpoint’s responses fully conform to the HTTP standard, returning status codes related to the request to run a model. Practically speaking, for an HTTP 201 response, you also need to check the model response body for any errors generated by the model itself.

This also means that 4xx and 5xx responses are returned strictly from the API gateway’s perspective, not the models’.

A Successful Model Run

This is the response from the example input above:

{
"slug":"price.dex-blended",
"version":"1.13",
"chainId":1,
"blockNumber":15502869,
"output":{
"price":92.80334705561403,
"src":"uniswap-v2,sushiswap,uniswap-v3"
           },
           "dependencies":{
"dex.primary-tokens":{"0.1":60},
"contract.metadata":{"1.0":13},
"uniswap-v2.get-pools":{"1.7":5},
"uniswap-v2.get-pool-price-info":{"1.11":23},
"uniswap-v2.get-pool-info-token-price":{"1.12":5},
"uniswap-v2.get-weighted-price":{"1.4":7},
"sushiswap.get-v2-factory":{"1.0":5},
"sushiswap.get-pools":{"1.5":5},
"sushiswap.get-pool-info-token-price":{"1.10":5},
"sushiswap.get-weighted-price":{"1.5":4},
"uniswap-v3.get-pools":{"1.5":5},
"uniswap-v3.get-pool-info":{"1.10":28},
"uniswap-v3.get-pool-price-info":{"1.3":39},
"uniswap-v3.get-pool-info-token-price":{"1.15":5},
"uniswap-v3.get-weighted-price":{"1.4":17},
"price.dex-pool":{"0.4":1},
"price.dex-blended":{"1.13":1}
           },
"runtime":58141
}

Lots of interesting things in this output.

The output block is the meat of our response. The fact that we have an output block and not an error block means that the model ran successfully. This data is returned by the model itself. It may change as the model is updated.

In this case we have:

A Failed Model Run

Now, let’s run the same model but provide an invalid token address: "0xNoNoNo".

Our output is completely different:

{
"slug":"price.dex-blended",
"version":"1.13",
"chainId":1,
"blockNumber":15502985,
"error":{
"type":"ModelInputError",
"message":"Error validating model price.dex-blended input: Address validation error: invalid literal for int() with base 16: '0xNoNoNo'",
"stack":[{
"slug":"price.dex-blended",
"version":"1.13",
"chainId":1,
"blockNumber":15502985,
"trace":""}],
"code":"generic",
"detail":null,
"permanent":false
           },
           "dependencies":{
"price.dex-blended":{"1.13":1}
           },
"runtime":128
}

Instead of an output block we have an error block with details of the error. type and message are self-explanatory. The others are useful to model developers.

Note that if we run cURL with a --include switch we see that the response code is 201.

Last updated