openapi: 3.1.0 info: # Do not change the title, if the title changes, the import paths will be broken title: Api version: 0.1.0 description: API specification servers: - url: /api description: Base API path tags: - name: health description: Health operations - name: openai description: OpenAI AI chat and audio operations - name: research description: Agentic research sessions and reports paths: /healthz: get: operationId: healthCheck tags: [health] summary: Health check description: Returns server health status responses: "200": description: Healthy content: application/json: schema: $ref: "#/components/schemas/HealthStatus" /openai/conversations: get: operationId: listOpenaiConversations tags: [openai] summary: List all conversations responses: "200": description: List of conversations content: application/json: schema: type: array items: $ref: "#/components/schemas/OpenaiConversation" post: operationId: createOpenaiConversation tags: [openai] summary: Create a new conversation requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/OpenaiConversationInput" responses: "201": description: Created conversation content: application/json: schema: $ref: "#/components/schemas/OpenaiConversation" /openai/conversations/{id}: get: operationId: getOpenaiConversation tags: [openai] summary: Get conversation with messages parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Conversation with messages content: application/json: schema: $ref: "#/components/schemas/OpenaiConversationWithMessages" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/OpenaiError" delete: operationId: deleteOpenaiConversation tags: [openai] summary: Delete a conversation parameters: - name: id in: path required: true schema: type: integer responses: "204": description: Deleted "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/OpenaiError" /openai/conversations/{id}/messages: get: operationId: listOpenaiMessages tags: [openai] summary: List messages in a conversation parameters: - name: id in: path required: true schema: type: integer responses: "200": description: List of messages content: application/json: schema: type: array items: $ref: "#/components/schemas/OpenaiMessage" post: operationId: sendOpenaiMessage tags: [openai] summary: Send a text message and receive a streaming text response parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/OpenaiMessageInput" responses: "200": description: SSE stream of assistant text chunks content: text/event-stream: {} # Research sessions /research/sessions: get: operationId: listResearchSessions tags: [research] summary: List all research sessions responses: "200": description: List of sessions content: application/json: schema: type: array items: $ref: "#/components/schemas/ResearchSession" post: operationId: createResearchSession tags: [research] summary: Create and start a new research session requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/ResearchSessionInput" responses: "201": description: Created research session content: application/json: schema: $ref: "#/components/schemas/ResearchSession" /research/sessions/{id}: get: operationId: getResearchSession tags: [research] summary: Get a research session with its tasks and report parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Research session detail content: application/json: schema: $ref: "#/components/schemas/ResearchSessionDetail" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/ResearchError" delete: operationId: deleteResearchSession tags: [research] summary: Delete a research session parameters: - name: id in: path required: true schema: type: integer responses: "204": description: Deleted "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/ResearchError" /research/sessions/{id}/run: post: operationId: runResearchSession tags: [research] summary: Start/resume the agentic research loop for a session (SSE stream) parameters: - name: id in: path required: true schema: type: integer responses: "200": description: SSE stream of agent events content: text/event-stream: {} "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/ResearchError" /research/sessions/{id}/tasks: get: operationId: listResearchTasks tags: [research] summary: List sub-tasks for a research session parameters: - name: id in: path required: true schema: type: integer responses: "200": description: List of tasks content: application/json: schema: type: array items: $ref: "#/components/schemas/ResearchTask" /research/sessions/{id}/report: get: operationId: getResearchReport tags: [research] summary: Get the synthesized report for a session parameters: - name: id in: path required: true schema: type: integer responses: "200": description: The research report content: application/json: schema: $ref: "#/components/schemas/ResearchReport" "404": description: Not found content: application/json: schema: $ref: "#/components/schemas/ResearchError" /research/stats: get: operationId: getResearchStats tags: [research] summary: Get aggregate research stats (total sessions, completed, sources found) responses: "200": description: Aggregate stats content: application/json: schema: $ref: "#/components/schemas/ResearchStats" components: schemas: HealthStatus: type: object properties: status: type: string required: - status OpenaiConversation: type: object properties: id: type: integer title: type: string createdAt: type: string format: date-time required: - id - title - createdAt OpenaiMessage: type: object properties: id: type: integer conversationId: type: integer role: type: string content: type: string createdAt: type: string format: date-time required: - id - conversationId - role - content - createdAt OpenaiConversationInput: type: object properties: title: type: string required: - title OpenaiMessageInput: type: object properties: content: type: string required: - content OpenaiConversationWithMessages: type: object properties: id: type: integer title: type: string createdAt: type: string format: date-time messages: type: array items: $ref: "#/components/schemas/OpenaiMessage" required: - id - title - createdAt - messages OpenaiError: type: object properties: error: type: string required: - error # Research domain ResearchSession: type: object properties: id: type: integer query: type: string status: type: string enum: [pending, running, completed, failed] depth: type: string enum: [quick, standard, deep] sourcesFound: type: integer tasksTotal: type: integer tasksCompleted: type: integer createdAt: type: string format: date-time completedAt: type: ["string", "null"] format: date-time required: - id - query - status - depth - sourcesFound - tasksTotal - tasksCompleted - createdAt - completedAt ResearchSessionInput: type: object properties: query: type: string minLength: 3 depth: type: string enum: [quick, standard, deep] required: - query ResearchTask: type: object properties: id: type: integer sessionId: type: integer title: type: string description: type: string status: type: string enum: [pending, running, completed, failed] sourcesFound: type: integer findings: type: ["string", "null"] createdAt: type: string format: date-time required: - id - sessionId - title - description - status - sourcesFound - findings - createdAt ResearchReport: type: object properties: id: type: integer sessionId: type: integer title: type: string summary: type: string body: type: string citations: type: array items: $ref: "#/components/schemas/Citation" createdAt: type: string format: date-time required: - id - sessionId - title - summary - body - citations - createdAt Citation: type: object properties: index: type: integer title: type: string url: type: string snippet: type: string credibilityScore: type: number required: - index - title - url - snippet - credibilityScore ResearchSessionDetail: type: object properties: id: type: integer query: type: string status: type: string enum: [pending, running, completed, failed] depth: type: string enum: [quick, standard, deep] sourcesFound: type: integer tasksTotal: type: integer tasksCompleted: type: integer createdAt: type: string format: date-time completedAt: type: ["string", "null"] format: date-time tasks: type: array items: $ref: "#/components/schemas/ResearchTask" report: nullable: true $ref: "#/components/schemas/ResearchReport" required: - id - query - status - depth - sourcesFound - tasksTotal - tasksCompleted - createdAt - completedAt - tasks - report ResearchStats: type: object properties: totalSessions: type: integer completedSessions: type: integer totalSourcesFound: type: integer averageTasksPerSession: type: number required: - totalSessions - completedSessions - totalSourcesFound - averageTasksPerSession ResearchError: type: object properties: error: type: string required: - error