{"openapi":"3.1.0","info":{"title":"layahost API","version":"1.0.0","summary":"Typed decisions (choice, yes/no, score) on the open Laya model. Jev-compatible.","description":"Ask a question about a text and get a typed answer with probabilities. One answered question is one billed decision. Docs: https://layahost.com/docs. Unofficial; not affiliated with Convai Innovations or TypeSafe AI.","contact":{"email":"support@layahost.com","url":"https://layahost.com"},"termsOfService":"https://layahost.com/terms"},"servers":[{"url":"https://layahost.com"}],"security":[{"bearer":[]}],"externalDocs":{"url":"https://layahost.com/docs","description":"Documentation"},"paths":{"/v1/decide":{"post":{"operationId":"decide","summary":"Decide","description":"One decision about one text: a template or your own question.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DecideRequest"}}}},"responses":{"200":{"description":"The decision.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Decision"}}}},"401":{"$ref":"#/components/responses/Error"},"402":{"$ref":"#/components/responses/Error"},"422":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"},"503":{"$ref":"#/components/responses/Error"}}}},"/v1/decide/batch":{"post":{"operationId":"decideBatch","summary":"Decide in batch","description":"The same decision for up to 64 texts. Each text is billed on its own.","requestBody":{"required":true,"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/DecisionSpec"}],"type":"object","required":["texts"],"properties":{"texts":{"type":"array","items":{"type":"string","maxLength":32000},"minItems":1,"maxItems":64}}}}}},"responses":{"200":{"description":"One result per text, in order; failed texts carry their status and are not billed.","content":{"application/json":{"schema":{"type":"object","properties":{"results":{"type":"array","items":{"allOf":[{"$ref":"#/components/schemas/Decision"}],"type":"object","properties":{"index":{"type":"integer"},"status":{"type":"integer"}}}},"usage":{"type":"object","properties":{"decisions":{"type":"integer"},"failed":{"type":"integer"},"cost_micros":{"type":"integer"},"cost_usd":{"type":"number"}}},"request_id":{"type":"string"}}}}}},"401":{"$ref":"#/components/responses/Error"},"402":{"$ref":"#/components/responses/Error"},"422":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"},"503":{"$ref":"#/components/responses/Error"}}}},"/v1/templates":{"get":{"operationId":"listTemplates","summary":"List templates","description":"Ready-made decisions for /v1/decide. Free.","responses":{"200":{"description":"Templates.","content":{"application/json":{"schema":{"type":"object","properties":{"templates":{"type":"array","items":{"type":"object","properties":{"template":{"type":"string"},"name":{"type":"string"},"description":{"type":"string"},"type":{"type":"string","enum":["choice","yes_no","score"]},"options":{"type":"array","items":{"type":"string"}},"example":{"type":"string"}}}}}}}}},"401":{"$ref":"#/components/responses/Error"}}}},"/v1/systemone":{"post":{"operationId":"systemOne","summary":"System one (Jev)","description":"Jev-compatible: several typed questions about one state. Billed per question.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SystemOneRequest"}}}},"responses":{"200":{"description":"Answers keyed by question id.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SystemOneResponse"}}}},"401":{"$ref":"#/components/responses/Error"},"402":{"$ref":"#/components/responses/Error"},"422":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"},"503":{"$ref":"#/components/responses/Error"}}}},"/v1/systemone/batch":{"post":{"operationId":"systemOneBatch","summary":"System one in batch","description":"Up to 64 Jev requests (256 questions in total), answered in order.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["requests"],"properties":{"requests":{"type":"array","items":{"$ref":"#/components/schemas/SystemOneRequest"},"minItems":1,"maxItems":64}}}}}},"responses":{"200":{"description":"One response per request.","content":{"application/json":{"schema":{"type":"object","properties":{"responses":{"type":"array","items":{"type":"object","properties":{"index":{"type":"integer"},"status":{"type":"integer"},"body":{"$ref":"#/components/schemas/SystemOneResponse"}}}},"request_id":{"type":"string"}}}}}},"401":{"$ref":"#/components/responses/Error"},"402":{"$ref":"#/components/responses/Error"},"422":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"},"503":{"$ref":"#/components/responses/Error"}}}},"/v1/models":{"get":{"operationId":"listModels","summary":"List models","description":"Models this key may use: built-in, public fine-tuned and the account's private models. Free.","responses":{"200":{"description":"Models.","content":{"application/json":{"schema":{"type":"object","properties":{"models":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"description":{"type":"string"},"release_date":{"type":"string"},"custom":{"type":"boolean"},"private":{"type":"boolean"}}}}}}}}},"401":{"$ref":"#/components/responses/Error"},"503":{"$ref":"#/components/responses/Error"}}}},"/v1/flows":{"get":{"operationId":"listFlows","summary":"List flows","description":"Decision flows drawn in the console. Free.","responses":{"200":{"description":"Flows.","content":{"application/json":{"schema":{"type":"object","properties":{"flows":{"type":"array","items":{"$ref":"#/components/schemas/FlowSummary"}}}}}}},"401":{"$ref":"#/components/responses/Error"}}}},"/v1/flows/{slug}":{"get":{"operationId":"getFlow","summary":"Get a flow","description":"One flow with its graph. Free.","parameters":[{"$ref":"#/components/parameters/FlowSlug"}],"responses":{"200":{"description":"The flow.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FlowSummary"}}}},"401":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"}}}},"/v1/flows/{slug}/run":{"post":{"operationId":"runFlow","summary":"Run a flow","description":"Run a flow on a text. Only the questions on the path are billed.","parameters":[{"$ref":"#/components/parameters/FlowSlug"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["text"],"properties":{"text":{"type":"string","maxLength":32000},"lang":{"type":"string","description":"Optional language hint (ISO 639-1), e.g. \"en\"."}}}}}},"responses":{"200":{"description":"The outcome and every step taken.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FlowRun"}}}},"401":{"$ref":"#/components/responses/Error"},"402":{"$ref":"#/components/responses/Error"},"422":{"$ref":"#/components/responses/Error"},"429":{"$ref":"#/components/responses/Error"},"503":{"$ref":"#/components/responses/Error"},"404":{"$ref":"#/components/responses/Error"}}}},"/v1/usage":{"get":{"operationId":"getUsage","summary":"Get usage","description":"Balance, plan and daily usage of the account. Free.","parameters":[{"name":"days","in":"query","schema":{"type":"integer","minimum":1,"maximum":90,"default":30}}],"responses":{"200":{"description":"Usage.","content":{"application/json":{"schema":{"type":"object"}}}},"401":{"$ref":"#/components/responses/Error"}}}},"/v1/moderations":{"post":{"operationId":"createModeration","summary":"Create moderation (OpenAI)","description":"OpenAI-compatible moderation: 13 category scores per text. Each input is billed as 8 decisions.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["input"],"properties":{"input":{"oneOf":[{"type":"string"},{"type":"array","items":{"type":"string"},"maxItems":32},{"type":"array","items":{"type":"object","properties":{"type":{"const":"text"},"text":{"type":"string"}}}}]},"model":{"type":"string","enum":["omni-moderation-latest","omni-moderation-2024-09-26","text-moderation-latest","text-moderation-stable","text-moderation-007"],"default":"omni-moderation-latest"}}}}}},"responses":{"200":{"description":"OpenAI moderation response.","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"model":{"type":"string"},"results":{"type":"array","items":{"type":"object","properties":{"flagged":{"type":"boolean"},"categories":{"type":"object","properties":{"harassment":{"type":"boolean"},"harassment/threatening":{"type":"boolean"},"hate":{"type":"boolean"},"hate/threatening":{"type":"boolean"},"illicit":{"type":"boolean"},"illicit/violent":{"type":"boolean"},"self-harm":{"type":"boolean"},"self-harm/intent":{"type":"boolean"},"self-harm/instructions":{"type":"boolean"},"sexual":{"type":"boolean"},"sexual/minors":{"type":"boolean"},"violence":{"type":"boolean"},"violence/graphic":{"type":"boolean"}}},"category_scores":{"type":"object","properties":{"harassment":{"type":"number"},"harassment/threatening":{"type":"number"},"hate":{"type":"number"},"hate/threatening":{"type":"number"},"illicit":{"type":"number"},"illicit/violent":{"type":"number"},"self-harm":{"type":"number"},"self-harm/intent":{"type":"number"},"self-harm/instructions":{"type":"number"},"sexual":{"type":"number"},"sexual/minors":{"type":"number"},"violence":{"type":"number"},"violence/graphic":{"type":"number"}}}}}}}}}}},"400":{"description":"OpenAI-style error."},"401":{"description":"OpenAI-style error."},"429":{"description":"Rate limit, or insufficient_quota when the balance is empty."}}}}},"components":{"securitySchemes":{"bearer":{"type":"http","scheme":"bearer","description":"An API key from the console (lh_...)."}},"parameters":{"FlowSlug":{"name":"slug","in":"path","required":true,"schema":{"type":"string"}}},"responses":{"Error":{"description":"Jev-style error: {\"detail\": {\"error_type\", \"message\"}}, or for 422 a list of {\"loc\", \"msg\", \"type\"}.","content":{"application/json":{"schema":{"type":"object","properties":{"detail":{"description":"An object, or a list for validation errors."}}}}}}},"schemas":{"DecisionSpec":{"type":"object","properties":{"template":{"type":"string","enum":["moderation","spam","support_intent","routing","sentiment","priority","prompt_injection","pii","language"],"description":"A ready-made decision; or give type + question (+ options)."},"type":{"type":"string","enum":["choice","yes_no","score"]},"question":{"type":"string","maxLength":2000},"options":{"description":"choice/score: a list of names, or names mapped to short descriptions. Score levels go lowest first.","oneOf":[{"type":"array","items":{"type":["string","number"]},"minItems":2},{"type":"object","additionalProperties":{"type":["string","null"]}}]},"model":{"type":"string","default":"laya-auto","description":"laya-auto, laya-english, laya-multilingual or a fine-tuned model from GET /v1/models."},"lang":{"type":"string"},"cache":{"type":"boolean","default":true}}},"DecideRequest":{"allOf":[{"$ref":"#/components/schemas/DecisionSpec"}],"type":"object","required":["text"],"properties":{"text":{"type":"string","maxLength":32000}}},"Decision":{"type":"object","properties":{"decision":{"description":"The chosen option (choice), level name (score) or true/false (yes_no).","type":["string","boolean"]},"probability":{"type":"number","description":"yes_no only: probability of yes."},"score":{"type":"number","description":"score only: expected level, 0-based."},"confidence":{"type":"number"},"probabilities":{"type":"object","additionalProperties":{"type":"number"}},"template":{"type":["string","null"]},"model":{"type":"string"},"usage":{"type":"object","properties":{"decisions":{"type":"integer"},"input_tokens":{"type":"integer"},"cost_micros":{"type":"integer"},"cost_usd":{"type":"number"}}},"latency_ms":{"type":"number"},"request_id":{"type":"string"}}},"SystemOneRequest":{"type":"object","required":["state","model","questions"],"properties":{"state":{"description":"Text, or any JSON (object or list)."},"model":{"type":"string","description":"laya-auto, laya-english, laya-multilingual, a fine-tuned model, or a Jev name (jev-latest maps to laya-auto)."},"questions":{"type":"object","additionalProperties":{"type":"object","required":["type"],"properties":{"type":{"type":"string","enum":["choice","noul","score"]},"instructions":{"description":"The question."},"criteria":{"description":"choice: {option: description|null}; score: [level, ...] lowest first; noul: {\"true\": ..., \"false\": ...} (optional)."}}}},"lang":{"type":"string"},"cache":{"type":"boolean","default":true}}},"SystemOneResponse":{"type":"object","properties":{"model":{"type":"string"},"answers":{"type":"object","additionalProperties":{"type":"object","properties":{"type":{"type":"string"},"choice":{"type":"string"},"noul":{"type":"number"},"score":{"type":"number"},"confidence":{"type":"number"},"probabilities":{"type":"object"},"legend":{"type":"object"}}}},"usage":{"type":"object","properties":{"input_tokens":{"type":"integer"},"output_tokens":{"type":"integer"}}},"meta":{"type":"object","properties":{"checkpoint":{"type":"string"},"cached":{"type":"boolean"},"latency_ms":{"type":"number"},"request_id":{"type":"string"},"decisions":{"type":"integer"},"cost_micros":{"type":"integer"},"cost_usd":{"type":"number"}}}}},"FlowSummary":{"type":"object","properties":{"flow":{"type":"string","description":"The slug, as in /v1/flows/{slug}/run."},"name":{"type":"string"},"description":{"type":["string","null"]},"version":{"type":"integer"},"questions":{"type":"integer"},"outcomes":{"type":"array","items":{"type":"string"}},"updated_at":{"type":"string","format":"date-time"},"definition":{"type":"object","description":"GET /v1/flows/{slug} only."}}},"FlowRun":{"type":"object","properties":{"flow":{"type":"string"},"version":{"type":"integer"},"outcome":{"type":"string"},"ended_at":{"type":"string"},"steps":{"type":"array","items":{"type":"object","properties":{"step":{"type":"string"},"label":{"type":"string"},"answer":{"type":"string"},"probability":{"type":"number"},"confidence":{"type":"number"},"followed":{"type":"string"},"probabilities":{"type":"object"}}}},"usage":{"type":"object","properties":{"decisions":{"type":"integer"},"cost_micros":{"type":"integer"},"cost_usd":{"type":"number"}}},"latency_ms":{"type":"integer"},"request_id":{"type":"string"}}}}}}