{"openapi":"3.1.0","info":{"title":"Ofia API","version":"1.0.0","description":"Ofia agent API: create LaTeX document projects, add files, ask the AI agent to write or edit the document, compile, and download the finished PDF."},"servers":[{"url":"/api/v1"}],"components":{"securitySchemes":{"apiKey":{"type":"http","scheme":"bearer","description":"An Ofia API key (ofia_sk_...), created on the Developers page."}},"schemas":{"Project":{"type":"object","properties":{"id":{"type":"integer"},"name":{"type":"string"},"description":{"type":"string","nullable":true},"workspaceMode":{"type":"string","enum":["research","visual"],"description":"research is displayed as Technical in Ofia."},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}}},"File":{"type":"object","properties":{"id":{"type":"integer"},"path":{"type":"string"},"content":{"type":"string"},"isBinary":{"type":"boolean"}}},"Message":{"type":"object","description":"A chat message. Assistant messages carry the run state: status is one of running, done, error, cancelled.","properties":{"id":{"type":"integer"},"role":{"type":"string","enum":["user","assistant"]},"content":{"type":"string"},"status":{"type":"string","nullable":true,"enum":["running","done","error","cancelled",null]},"changesApplied":{"type":"boolean","nullable":true}}}}},"security":[{"apiKey":[]}],"paths":{"/me":{"get":{"summary":"Account and remaining usage for the key's owner","responses":{"200":{"description":"Plan name and remaining usage percentages."}}}},"/projects":{"get":{"summary":"List projects","responses":{"200":{"description":"Array of projects."}}},"post":{"summary":"Create a project","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"workspaceMode":{"type":"string","enum":["research","visual"],"description":"Use visual for image-led projects; research opens the Technical workspace."}}}}}},"responses":{"200":{"description":"The created project."}}}},"/projects/{projectId}/files":{"get":{"summary":"List a project's files","responses":{"200":{"description":"Array of files."}}},"post":{"summary":"Create a text file (e.g. main.tex)","requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["path","content"],"properties":{"path":{"type":"string","example":"main.tex"},"content":{"type":"string"}}}}}},"responses":{"200":{"description":"The created file."}}}},"/projects/{projectId}/chat":{"post":{"summary":"Start an AI agent run (write or edit the document). Returns immediately with a running assistant message; poll /messages until its status is done. Requires a subscription or purchased credits.","requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["message"],"properties":{"message":{"type":"string"},"model":{"type":"string","description":"Optional model id. Defaults to the account's standard model."}}}}}},"responses":{"200":{"description":"The running assistant message ({message:{id,status}})."},"402":{"description":"No usage balance, or the account has no paid standing."},"409":{"description":"A run is already in progress for this project."}}}},"/projects/{projectId}/messages":{"get":{"summary":"Poll the conversation (run status lives on the latest assistant message)","parameters":[{"name":"limit","in":"query","schema":{"type":"integer"},"description":"Return only the most recent N messages."}],"responses":{"200":{"description":"Array of messages, oldest first."}}}},"/projects/{projectId}/compile":{"post":{"summary":"Compile the project's LaTeX to PDF (the agent usually compiles automatically after editing)","responses":{"200":{"description":"Compilation result with success flag and log."}}}},"/projects/{projectId}/pdf":{"get":{"summary":"Download the latest compiled PDF","responses":{"200":{"description":"application/pdf bytes."},"404":{"description":"No compiled PDF yet."}}}}}}