{
  "openapi": "3.1.0",
  "info": {
    "title": "Chance API",
    "version": "1.0.0",
    "description": "Nodus Compute probability models. Uniform random draws, not prediction accuracy. No API key required."
  },
  "servers": [
    {
      "url": "https://chance.nodus-compute.ai"
    }
  ],
  "paths": {
    "/api/v1/models": {
      "get": {
        "operationId": "listModels",
        "summary": "List available probability models",
        "responses": {
          "200": {
            "description": "Model catalog",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "const": "list"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "outcomes": {
                            "type": "integer"
                          },
                          "sectors": {
                            "type": "object",
                            "properties": {
                              "min": {
                                "type": "integer"
                              },
                              "max": {
                                "type": "integer"
                              },
                              "default": {
                                "type": "integer"
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/infer": {
      "post": {
        "operationId": "runInference",
        "summary": "Sample one of four uniform distributions",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "model"
                ],
                "properties": {
                  "model": {
                    "type": "string",
                    "enum": [
                      "coin",
                      "dice",
                      "deck",
                      "wheel"
                    ]
                  },
                  "count": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 100,
                    "default": 1
                  },
                  "sectors": {
                    "type": "integer",
                    "minimum": 2,
                    "maximum": 24,
                    "default": 6,
                    "description": "Only accepted for wheel."
                  }
                }
              },
              "example": {
                "model": "coin",
                "count": 1
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Independent uniform draws with replacement.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "model",
                    "distribution",
                    "outcome_count",
                    "entropy_bits",
                    "count",
                    "results"
                  ],
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "model": {
                      "type": "string"
                    },
                    "distribution": {
                      "type": "string",
                      "enum": [
                        "uniform"
                      ]
                    },
                    "outcome_count": {
                      "type": "integer"
                    },
                    "entropy_bits": {
                      "type": "number"
                    },
                    "count": {
                      "type": "integer"
                    },
                    "results": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "value",
                          "probability"
                        ],
                        "properties": {
                          "value": {
                            "oneOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "integer"
                              }
                            ]
                          },
                          "probability": {
                            "type": "number",
                            "minimum": 0,
                            "maximum": 1
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON or parameters",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Unknown route",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "405": {
            "description": "Unsupported method",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "Body exceeds 4096 bytes",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "Expected application/json",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
