{
  "openapi": "3.1.0",
  "info": {
    "title": "Sensei Wearables API",
    "version": "1.0.0",
    "description": "Frames, voice commands, local OCR, and device sessions."
  },
  "paths": {
    "/v1/wearables/status": {
      "get": {
        "operationId": "status",
        "summary": "Service status and configured tools",
        "responses": {
          "200": {
            "description": "Service online",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Status"
                }
              }
            }
          }
        }
      }
    },
    "/v1/wearables/sessions": {
      "post": {
        "operationId": "createSession",
        "summary": "Create a 30-minute session",
        "description": "Supply a bootstrap token when authentication_required is true. The response provides a separate session token.",
        "security": [
          {},
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "device": {
                    "type": "string",
                    "enum": [
                      "rayban_gen2",
                      "smartphone",
                      "browser",
                      "mock"
                    ]
                  },
                  "consent": {
                    "type": "boolean",
                    "const": true
                  }
                },
                "required": [
                  "device",
                  "consent"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Session opened",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Session"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/wearables/sessions/{id}": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "get": {
        "operationId": "sessionStatus",
        "summary": "Read session diagnostics",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Session state",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "session_id": {
                      "type": "string"
                    },
                    "device": {
                      "type": "string",
                      "enum": [
                        "rayban_gen2",
                        "smartphone",
                        "browser",
                        "mock"
                      ]
                    },
                    "expires_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "processing": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "endSession",
        "summary": "Close a session and cancel its work",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "204": {
            "description": "Session closed"
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/wearables/analyze": {
      "post": {
        "operationId": "analyze",
        "summary": "Analyze text, a frame, or both",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "X-Sensei-Session",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "image": {
                    "type": "string",
                    "format": "binary",
                    "description": "JPEG or PNG, up to 3 MiB"
                  },
                  "text": {
                    "type": "string",
                    "description": "UTF-8, up to 2048 bytes"
                  },
                  "language": {
                    "type": "string",
                    "enum": [
                      "ru",
                      "ky",
                      "en"
                    ],
                    "default": "ru"
                  },
                  "intent": {
                    "type": "string",
                    "enum": [
                      "scene",
                      "read",
                      "find",
                      "color",
                      "transport",
                      "currency",
                      "translate",
                      "assistant"
                    ]
                  },
                  "captured_at_ms": {
                    "type": "integer",
                    "format": "int64",
                    "description": "Unix time in milliseconds, required for frames from Ray-Ban Meta"
                  }
                }
              },
              "encoding": {
                "image": {
                  "contentType": "image/jpeg, image/png"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Assistant response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Answer"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/wearables/voice": {
      "post": {
        "operationId": "voice",
        "summary": "Transcribe audio and answer using an optional frame",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "X-Sensei-Session",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "image": {
                    "type": "string",
                    "format": "binary",
                    "description": "JPEG or PNG, up to 3 MiB"
                  },
                  "language": {
                    "type": "string",
                    "enum": [
                      "ru",
                      "ky",
                      "en"
                    ],
                    "default": "ru"
                  },
                  "intent": {
                    "type": "string",
                    "enum": [
                      "scene",
                      "read",
                      "find",
                      "color",
                      "transport",
                      "currency",
                      "translate",
                      "assistant"
                    ]
                  },
                  "captured_at_ms": {
                    "type": "integer",
                    "format": "int64",
                    "description": "Unix time in milliseconds, required for frames from Ray-Ban Meta"
                  },
                  "audio": {
                    "type": "string",
                    "format": "binary",
                    "description": "Recorded audio up to 2 MiB"
                  }
                },
                "required": [
                  "audio"
                ]
              },
              "encoding": {
                "image": {
                  "contentType": "image/jpeg, image/png"
                },
                "audio": {
                  "contentType": "audio/wav, audio/webm, audio/ogg, audio/mp4"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Assistant response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Answer"
                }
              }
            }
          },
          "default": {
            "description": "Request failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "Status": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "online"
            ]
          },
          "authentication_required": {
            "type": "boolean"
          },
          "capabilities": {
            "type": "object",
            "properties": {
              "ocr": {
                "type": "boolean"
              },
              "ocr_languages": {
                "type": [
                  "array",
                  "null"
                ],
                "items": {
                  "type": "string"
                }
              },
              "color": {
                "type": "boolean"
              },
              "vision": {
                "type": "boolean"
              },
              "assistant": {
                "type": "boolean"
              },
              "speech_to_text": {
                "type": "boolean"
              }
            }
          }
        }
      },
      "Session": {
        "type": "object",
        "properties": {
          "session_id": {
            "type": "string"
          },
          "access_token": {
            "type": "string"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "session_id",
          "access_token",
          "expires_at"
        ]
      },
      "Answer": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "assistant.response"
            ]
          },
          "session_id": {
            "type": "string"
          },
          "request_id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "completed"
            ]
          },
          "response": {
            "type": "object",
            "properties": {
              "text": {
                "type": "string"
              },
              "language": {
                "type": "string",
                "enum": [
                  "ru",
                  "ky",
                  "en"
                ]
              },
              "intent": {
                "type": "string"
              }
            }
          }
        },
        "required": [
          "type",
          "session_id",
          "request_id",
          "status",
          "response"
        ]
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        },
        "required": [
          "error",
          "message"
        ]
      }
    }
  }
}
