{"openapi":"3.1.0","info":{"title":"HyperWrite Autocomplete API","version":"0.1.0"},"paths":{"/v1/browser-sessions":{"post":{"summary":"Browser Sessions","operationId":"browser_sessions_v1_browser_sessions_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BrowserSessionRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BrowserSessionResponse"}}}},"422":{"description":"Schema or prompt budget invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/APIError"}}}},"401":{"description":"Invalid or expired credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/APIError"}}}},"403":{"description":"Origin or permission rejected","content":{"application/json":{"schema":{"$ref":"#/components/schemas/APIError"}}}},"409":{"description":"Duplicate request identifier","content":{"application/json":{"schema":{"$ref":"#/components/schemas/APIError"}}}},"413":{"description":"Request exceeds byte limit","content":{"application/json":{"schema":{"$ref":"#/components/schemas/APIError"}}}},"415":{"description":"Unsupported request media type or encoding","content":{"application/json":{"schema":{"$ref":"#/components/schemas/APIError"}}}},"503":{"description":"Service unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/APIError"}}}},"504":{"description":"Inference timed out","content":{"application/json":{"schema":{"$ref":"#/components/schemas/APIError"}}}}},"security":[{"APIKey":[]}]}},"/v1/autocomplete":{"post":{"summary":"Autocomplete","operationId":"autocomplete_v1_autocomplete_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AutocompleteRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AutocompleteResponse"}}}},"422":{"description":"Schema or prompt budget invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/APIError"}}}},"401":{"description":"Invalid or expired credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/APIError"}}}},"403":{"description":"Origin or permission rejected","content":{"application/json":{"schema":{"$ref":"#/components/schemas/APIError"}}}},"409":{"description":"Duplicate request identifier","content":{"application/json":{"schema":{"$ref":"#/components/schemas/APIError"}}}},"413":{"description":"Request exceeds byte limit","content":{"application/json":{"schema":{"$ref":"#/components/schemas/APIError"}}}},"415":{"description":"Unsupported request media type or encoding","content":{"application/json":{"schema":{"$ref":"#/components/schemas/APIError"}}}},"429":{"description":"User autocomplete requests are too close together","content":{"application/json":{"schema":{"$ref":"#/components/schemas/APIError"}}}},"503":{"description":"Service unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/APIError"}}}},"504":{"description":"Inference timed out","content":{"application/json":{"schema":{"$ref":"#/components/schemas/APIError"}}}}},"security":[{"APIKey":[]},{"BrowserSession":[]}]}},"/v1/events":{"post":{"summary":"Events","operationId":"events_v1_events_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/EventsRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Schema or prompt budget invalid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/APIError"}}}},"401":{"description":"Invalid or expired credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/APIError"}}}},"403":{"description":"Origin or permission rejected","content":{"application/json":{"schema":{"$ref":"#/components/schemas/APIError"}}}},"409":{"description":"Duplicate request identifier","content":{"application/json":{"schema":{"$ref":"#/components/schemas/APIError"}}}},"413":{"description":"Request exceeds byte limit","content":{"application/json":{"schema":{"$ref":"#/components/schemas/APIError"}}}},"415":{"description":"Unsupported request media type or encoding","content":{"application/json":{"schema":{"$ref":"#/components/schemas/APIError"}}}},"503":{"description":"Service unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/APIError"}}}},"504":{"description":"Inference timed out","content":{"application/json":{"schema":{"$ref":"#/components/schemas/APIError"}}}}},"security":[{"APIKey":[]},{"BrowserSession":[]}]}}},"components":{"schemas":{"AutocompleteRequest":{"properties":{"request_id":{"type":"string","format":"uuid","title":"Request Id"},"context_id":{"type":"string","maxLength":128,"minLength":1,"pattern":"^[A-Za-z0-9_.:-]+$","title":"Context Id"},"context_version":{"type":"string","maxLength":128,"minLength":1,"pattern":"^[A-Za-z0-9_.:-]+$","title":"Context Version"},"draft_revision":{"type":"integer","maximum":9007199254740991.0,"minimum":0.0,"title":"Draft Revision"},"prefix":{"type":"string","maxLength":4000,"title":"Prefix"},"messages":{"items":{"$ref":"#/components/schemas/Message"},"type":"array","maxItems":12,"title":"Messages"},"system_prompt":{"type":"string","maxLength":2000,"title":"System Prompt","default":""},"additional_context":{"type":"string","maxLength":12000,"title":"Additional Context","default":""},"trigger":{"type":"string","enum":["word_start","word_progress","word_boundary","accepted_word"],"title":"Trigger"}},"additionalProperties":false,"type":"object","required":["request_id","context_id","context_version","draft_revision","prefix","trigger"],"title":"AutocompleteRequest"},"AutocompleteResponse":{"properties":{"request_id":{"type":"string","format":"uuid","title":"Request Id"},"context_id":{"type":"string","title":"Context Id"},"context_version":{"type":"string","title":"Context Version"},"draft_revision":{"type":"integer","title":"Draft Revision"},"candidates":{"items":{"$ref":"#/components/schemas/Candidate"},"type":"array","maxItems":30,"title":"Candidates"},"expires_at":{"type":"integer","title":"Expires At"},"expires_in":{"type":"number","maximum":60.0,"minimum":0.0,"title":"Expires In","description":"Remaining lifetime in seconds at response creation."}},"additionalProperties":false,"type":"object","required":["request_id","context_id","context_version","draft_revision","candidates","expires_at","expires_in"],"title":"AutocompleteResponse"},"BrowserSessionRequest":{"properties":{"user_id":{"type":"string","maxLength":128,"minLength":1,"pattern":"^[A-Za-z0-9_.:-]+$","title":"User Id"},"origin":{"type":"string","maxLength":256,"title":"Origin"}},"additionalProperties":false,"type":"object","required":["user_id","origin"],"title":"BrowserSessionRequest"},"BrowserSessionResponse":{"properties":{"token":{"type":"string","title":"Token"},"expires_at":{"type":"integer","title":"Expires At"},"expires_in":{"type":"number","maximum":900.0,"minimum":0.0,"title":"Expires In","description":"Remaining lifetime in seconds at response creation."}},"additionalProperties":false,"type":"object","required":["token","expires_at","expires_in"],"title":"BrowserSessionResponse"},"Candidate":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"text":{"type":"string","maxLength":512,"minLength":1,"title":"Text"}},"additionalProperties":false,"type":"object","required":["id","text"],"title":"Candidate"},"Event":{"properties":{"event_id":{"type":"string","format":"uuid","title":"Event Id"},"request_id":{"type":"string","format":"uuid","title":"Request Id"},"candidate_id":{"anyOf":[{"type":"string","format":"uuid"},{"type":"null"}],"title":"Candidate Id"},"kind":{"type":"string","enum":["shown","accepted","dismissed","submitted"],"title":"Kind"},"word_count":{"type":"integer","maximum":1000.0,"minimum":0.0,"title":"Word Count","default":0}},"additionalProperties":false,"type":"object","required":["event_id","request_id","kind"],"title":"Event"},"EventsRequest":{"properties":{"events":{"items":{"$ref":"#/components/schemas/Event"},"type":"array","maxItems":50,"minItems":1,"title":"Events"}},"additionalProperties":false,"type":"object","required":["events"],"title":"EventsRequest"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"Message":{"properties":{"role":{"type":"string","enum":["user","assistant"],"title":"Role"},"content":{"type":"string","maxLength":10000,"title":"Content"}},"additionalProperties":false,"type":"object","required":["role","content"],"title":"Message"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"},"APIError":{"type":"object","required":["error"],"additionalProperties":false,"properties":{"error":{"type":"object","required":["code","message"],"additionalProperties":false,"properties":{"code":{"type":"string"},"message":{"type":"string"}}}}}},"securitySchemes":{"APIKey":{"type":"http","scheme":"bearer","description":"API key. Keep it on your backend; never send it from a browser."},"BrowserSession":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"Short-lived browser token; send the configured exact Origin."}}}}