{
  "openapi": "3.0.3",
  "info": {
    "title": "StreamingTelligence HTTP API",
    "version": "v1-preview",
    "description": "StreamingTelligence HTTP API for model discovery and chat completions, with incremental responses over server-sent events. Model access is determined by your account permissions.",
    "contact": { "name": "StreamingTelligence", "email": "streamingtelligence@gmail.com" }
  },
  "servers": [{ "url": "/v1", "description": "Current website origin" }],
  "security": [{ "BearerAuth": [] }],
  "tags": [{ "name": "Inference", "description": "OpenAI-compatible HTTP requests. Upstream availability and model permissions are required." }],
  "paths": {
    "/models": {
      "get": {
        "tags": ["Inference"], "operationId": "listModels", "summary": "List available models",
        "description": "List the models exposed by the connected gateway. Model access is also restricted by the account's invitation.",
        "responses": {
          "200": { "description": "Model list returned by the connected upstream.", "content": { "application/json": { "schema": { "type": "object", "properties": {
            "object": { "type": "string", "enum": ["list"] },
            "data": { "type": "array", "items": { "type": "object", "required": ["id"], "properties": { "id": { "type": "string" }, "object": { "type": "string" }, "owned_by": { "type": "string" } }, "additionalProperties": true } }
          } } } } },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "503": { "$ref": "#/components/responses/Unavailable" }
        }
      }
    },
    "/chat/completions": {
      "post": {
        "tags": ["Inference"], "operationId": "createChatCompletion", "summary": "Create a chat completion",
        "description": "Send an OpenAI-compatible chat request. With stream=true, incremental JSON chunks arrive as SSE data events, ending with [DONE]. Multimodal content formats and optional parameters are model-specific and must be checked against the released model contract.",
        "requestBody": { "required": true, "content": { "application/json": { "schema": {
          "type": "object", "required": ["model", "messages"],
          "properties": {
            "model": { "type": "string", "description": "Model identifier allowed by your invitation." },
            "messages": { "type": "array", "minItems": 1, "items": { "type": "object", "required": ["role", "content"], "properties": {
              "role": { "type": "string", "enum": ["system", "user", "assistant"] },
              "content": { "type": "string", "description": "Text message. Model-specific multimodal content is not specified in this preview." }
            } } },
            "stream": { "type": "boolean", "default": false }
          },
          "additionalProperties": true
        }, "example": { "model": "MODEL_ALLOWED_BY_YOUR_INVITATION", "messages": [{ "role": "user", "content": "Describe this moment." }], "stream": true } } } },
        "responses": {
          "200": { "description": "Completion or an SSE stream, depending on the stream field. Optional fields depend on the model.", "content": {
            "application/json": { "schema": { "type": "object", "properties": {
              "id": { "type": "string" }, "model": { "type": "string" },
              "choices": { "type": "array", "items": { "type": "object", "properties": {
                "index": { "type": "integer" }, "message": { "type": "object", "properties": { "role": { "type": "string" }, "content": { "type": "string", "nullable": true } } },
                "finish_reason": { "type": "string", "nullable": true }
              }, "additionalProperties": true } },
              "usage": { "type": "object", "additionalProperties": true }
            }, "additionalProperties": true } },
            "text/event-stream": { "schema": { "type": "string", "description": "SSE events containing completion deltas, terminated by data: [DONE]." } }
          } },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "503": { "$ref": "#/components/responses/Unavailable" },
          "default": { "description": "Gateway or model-specific error. Status and schema are returned by the upstream.", "content": { "application/json": { "schema": { "type": "object", "additionalProperties": true } } } }
        }
      }
    }
  },
  "components": {
    "securitySchemes": { "BearerAuth": { "type": "http", "scheme": "bearer", "description": "An active API key, not your website password or invitation code." } },
    "schemas": { "IngressError": { "type": "object", "required": ["error"], "properties": { "error": { "type": "string" } } } },
    "responses": {
      "Unauthorized": { "description": "API key missing, inactive, expired or revoked.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/IngressError" }, "example": { "error": "A valid active API key is required." } } } },
      "Unavailable": { "description": "Upstream connection error. Check the error details and retry transient failures with bounded exponential backoff.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/IngressError" } } } }
    }
  }
}
