{
  "openapi": "3.1.0",
  "info": {
    "title": "GeneralCompute API",
    "version": "1.0.0",
    "description": "OpenAI-compatible API surface for the GeneralCompute inference platform.",
    "contact": {
      "name": "GeneralCompute",
      "url": "https://www.generalcompute.com"
    }
  },
  "servers": [
    {
      "url": "https://api.generalcompute.com",
      "description": "Production"
    },
    {
      "url": "http://localhost:3000",
      "description": "Local"
    }
  ],
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "API key"
      }
    },
    "schemas": {
      "ChatCompletionRequest": {
        "type": "object",
        "properties": {
          "model": {
            "type": "string"
          },
          "messages": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "role": {
                  "type": "string",
                  "enum": [
                    "system",
                    "user",
                    "assistant",
                    "function",
                    "tool"
                  ]
                },
                "content": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "array",
                      "items": {}
                    },
                    {
                      "type": "null"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "name": {
                  "type": "string"
                },
                "function_call": {},
                "tool_calls": {}
              },
              "required": [
                "role"
              ]
            },
            "minItems": 1
          },
          "temperature": {
            "type": "number",
            "minimum": 0,
            "maximum": 2
          },
          "top_p": {
            "type": "number",
            "minimum": 0,
            "maximum": 1
          },
          "n": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "stream": {
            "type": "boolean",
            "default": false
          },
          "stop": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            ]
          },
          "max_tokens": {
            "type": "integer",
            "exclusiveMinimum": 0
          },
          "presence_penalty": {
            "type": "number",
            "minimum": -2,
            "maximum": 2
          },
          "frequency_penalty": {
            "type": "number",
            "minimum": -2,
            "maximum": 2
          },
          "logit_bias": {
            "type": "object",
            "additionalProperties": {
              "type": "number"
            }
          },
          "user": {
            "type": "string"
          },
          "top_k": {
            "type": "number"
          },
          "repetition_penalty": {
            "type": "number"
          }
        },
        "required": [
          "model",
          "messages"
        ]
      },
      "ChatCompletionResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "enum": [
              "chat.completion"
            ]
          },
          "created": {
            "type": "number"
          },
          "model": {
            "type": "string"
          },
          "choices": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "index": {
                  "type": "number"
                },
                "message": {
                  "type": "object",
                  "properties": {
                    "role": {
                      "type": "string"
                    },
                    "content": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "function_call": {},
                    "tool_calls": {}
                  },
                  "required": [
                    "role",
                    "content"
                  ]
                },
                "finish_reason": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "logprobs": {}
              },
              "required": [
                "index",
                "message",
                "finish_reason"
              ]
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "prompt_tokens": {
                "type": "number"
              },
              "completion_tokens": {
                "type": "number"
              },
              "total_tokens": {
                "type": "number"
              }
            },
            "required": [
              "prompt_tokens",
              "completion_tokens",
              "total_tokens"
            ]
          },
          "system_fingerprint": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "object",
          "created",
          "model",
          "choices"
        ]
      },
      "ChatCompletionChunk": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "enum": [
              "chat.completion.chunk"
            ]
          },
          "created": {
            "type": "number"
          },
          "model": {
            "type": "string"
          },
          "choices": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "index": {
                  "type": "number"
                },
                "delta": {
                  "type": "object",
                  "properties": {
                    "role": {
                      "type": "string"
                    },
                    "content": {
                      "type": "string"
                    }
                  }
                },
                "finish_reason": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              },
              "required": [
                "index",
                "delta",
                "finish_reason"
              ]
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "prompt_tokens": {
                "type": "number"
              },
              "completion_tokens": {
                "type": "number"
              },
              "total_tokens": {
                "type": "number"
              }
            },
            "required": [
              "prompt_tokens",
              "completion_tokens",
              "total_tokens"
            ]
          }
        },
        "required": [
          "id",
          "object",
          "created",
          "model",
          "choices"
        ]
      },
      "ModelsListResponse": {
        "type": "object",
        "properties": {
          "object": {
            "type": "string",
            "enum": [
              "list"
            ]
          },
          "data": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "object": {
                  "type": "string",
                  "enum": [
                    "model"
                  ]
                },
                "created": {
                  "type": "number"
                },
                "owned_by": {
                  "type": "string"
                }
              },
              "required": [
                "id",
                "object",
                "created",
                "owned_by"
              ]
            }
          }
        },
        "required": [
          "object",
          "data"
        ]
      },
      "PublicModelsResponse": {
        "type": "object",
        "properties": {
          "object": {
            "type": "string",
            "enum": [
              "list"
            ]
          },
          "data": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "modelId": {
                  "type": "string"
                },
                "displayName": {
                  "type": "string"
                },
                "supportsReasoning": {
                  "type": "boolean"
                },
                "supportsVision": {
                  "type": "boolean"
                },
                "maxTokens": {
                  "type": [
                    "number",
                    "null"
                  ]
                }
              },
              "required": [
                "modelId",
                "displayName",
                "supportsReasoning",
                "supportsVision",
                "maxTokens"
              ]
            }
          }
        },
        "required": [
          "object",
          "data"
        ]
      },
      "HealthStatusResponse": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "ok"
            ]
          }
        },
        "required": [
          "status"
        ]
      },
      "ReadinessStatusResponse": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "ready"
            ]
          },
          "database": {
            "type": "string",
            "enum": [
              "ok"
            ]
          },
          "redis": {
            "type": "string",
            "enum": [
              "ok"
            ]
          }
        },
        "required": [
          "status",
          "database",
          "redis"
        ]
      },
      "ReadinessFailureResponse": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "not ready"
            ]
          },
          "error": {
            "type": "string"
          }
        },
        "required": [
          "status",
          "error"
        ]
      },
      "OpenAIError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "message": {
                "type": "string"
              },
              "type": {
                "type": "string"
              },
              "param": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "code": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "message",
              "type"
            ]
          }
        },
        "required": [
          "error"
        ]
      }
    },
    "parameters": {}
  },
  "paths": {
    "/v1/chat/completions": {
      "post": {
        "summary": "Create chat completion",
        "description": "OpenAI-compatible chat completion endpoint with streaming support.",
        "tags": [
          "Chat"
        ],
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "description": "Chat completion request payload",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChatCompletionRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Chat completion response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatCompletionResponse"
                }
              },
              "text/event-stream": {
                "schema": {
                  "$ref": "#/components/schemas/ChatCompletionChunk"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAIError"
                }
              }
            }
          },
          "401": {
            "description": "API key missing or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAIError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/models/list": {
      "post": {
        "summary": "List models",
        "description": "Returns the list of active models associated with the organization.",
        "tags": [
          "Models"
        ],
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "List of available models",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ModelsListResponse"
                }
              }
            }
          },
          "401": {
            "description": "API key missing or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenAIError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/public/models": {
      "get": {
        "summary": "List public models",
        "description": "Public endpoint that returns the metadata for the models surfaced in docs and pricing pages.",
        "tags": [
          "Public"
        ],
        "responses": {
          "200": {
            "description": "List of model metadata objects",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicModelsResponse"
                }
              }
            }
          }
        }
      }
    },
    "/health": {
      "get": {
        "summary": "Liveness probe",
        "tags": [
          "System"
        ],
        "responses": {
          "200": {
            "description": "Server is running",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthStatusResponse"
                }
              }
            }
          }
        }
      }
    },
    "/health/ready": {
      "get": {
        "summary": "Readiness probe",
        "tags": [
          "System"
        ],
        "responses": {
          "200": {
            "description": "Server is ready to receive traffic",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReadinessStatusResponse"
                }
              }
            }
          },
          "503": {
            "description": "One or more dependencies are unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReadinessFailureResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "webhooks": {}
}
