{"openapi":"3.1.0","info":{"title":"Qai API","version":"1.0.0","summary":"OpenAI-compatible API for text, image and video generation, by QuickCasa.","description":"Qai follows the OpenAI API conventions: point any OpenAI SDK at https://llm.quickcasa.ai/v1 and send a Qai API key. Prices are in CAD, billed per use. qai-hello-world is free and capped at 100 calls per API key per UTC day. Full documentation: https://q-ai.ca/docs.","contact":{"name":"Qai by QuickCasa","email":"hi@quickcasa.ai","url":"https://q-ai.ca"}},"externalDocs":{"description":"Qai documentation","url":"https://q-ai.ca/docs"},"servers":[{"url":"https://llm.quickcasa.ai","description":"Production"}],"security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"tags":[{"name":"Models"},{"name":"Text"},{"name":"Images"},{"name":"Video"},{"name":"Utilities"},{"name":"Pricing"},{"name":"Terms"}],"paths":{"/v1/models":{"get":{"tags":["Models"],"operationId":"listModels","summary":"List the models this key can call","responses":{"200":{"description":"The model list.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ModelList"}}}},"401":{"description":"The API key is missing, unknown or disabled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/chat/completions":{"post":{"tags":["Text"],"operationId":"createChatCompletion","summary":"Create a chat completion","description":"OpenAI-compatible chat completions with streaming, tool calls and JSON output. Reasoning models count hidden reasoning tokens toward max_tokens, so leave room for them.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatCompletionRequest"}}}},"responses":{"200":{"description":"The completion, or a server-sent event stream when stream is true.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatCompletion"}},"text/event-stream":{"schema":{"type":"string","description":"Lines of `data: {chat.completion.chunk}` ending with a usage chunk and `data: [DONE]`."}}}},"400":{"description":"The request is invalid. `code` says why (missing_field, invalid_model, invalid_value, invalid_request).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"The API key is missing, unknown or disabled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Paid models are off (`billing_not_enabled`) or uncensored models need accepted terms (`uncensored_terms_required`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited (`rate_limit_exceeded`) or the free sandbox quota is used up (`sandbox_quota_exceeded`). Honour `Retry-After`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"The model did not answer (`upstream_error`). Retry shortly.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"The model, the billing check or the uncensored-terms check is briefly unavailable. Retry shortly.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/images/generations":{"post":{"tags":["Images"],"operationId":"createImage","summary":"Generate images from a prompt","description":"Images are generated in parallel. Whatever succeeds is returned and billed; the call only fails when none did.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["model","prompt"],"properties":{"model":{"type":"string","enum":["qai-imagine-turbo","qai-imagine-quality","qai-imagine-uncensored-turbo","qai-imagine-uncensored","qai-imagine-uncensored-pro"]},"prompt":{"type":"string"},"n":{"type":"integer","minimum":1,"maximum":10,"default":1},"size":{"type":"string","description":"For example \"1024x1024\"."},"response_format":{"type":"string","enum":["url","b64_json"],"default":"url"},"hostMedia":{"type":"boolean","default":false,"description":"True returns a permanent CDN URL. Otherwise the URL is temporary and expires."}}}}}},"responses":{"200":{"description":"The generated images.","content":{"application/json":{"schema":{"type":"object","properties":{"created":{"type":"integer"},"data":{"type":"array","items":{"type":"object","properties":{"url":{"type":"string"},"b64_json":{"type":"string"}}}}}}}}},"400":{"description":"The request is invalid. `code` says why (missing_field, invalid_model, invalid_value, invalid_request).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"The API key is missing, unknown or disabled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Paid models are off (`billing_not_enabled`) or uncensored models need accepted terms (`uncensored_terms_required`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited (`rate_limit_exceeded`) or the free sandbox quota is used up (`sandbox_quota_exceeded`). Honour `Retry-After`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"The model did not answer (`upstream_error`). Retry shortly.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"The model, the billing check or the uncensored-terms check is briefly unavailable. Retry shortly.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/videos/generations":{"post":{"tags":["Video"],"operationId":"createVideo","summary":"Start a video generation job","description":"Returns at once with a job id. Poll GET /v1/videos/generations/{jobId} until status is \"completed\". Billed per second of video returned.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["model","prompt"],"properties":{"model":{"type":"string","enum":["qai-motion"]},"prompt":{"type":"string"},"duration":{"type":"number","exclusiveMinimum":0,"description":"Seconds. Six by default."},"fps":{"type":"number","exclusiveMinimum":0},"size":{"type":"string"},"hostMedia":{"type":"boolean","default":false}}}}}},"responses":{"202":{"description":"The job was accepted.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VideoJob"}}}},"400":{"description":"The request is invalid. `code` says why (missing_field, invalid_model, invalid_value, invalid_request).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"The API key is missing, unknown or disabled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Paid models are off (`billing_not_enabled`) or uncensored models need accepted terms (`uncensored_terms_required`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited (`rate_limit_exceeded`) or the free sandbox quota is used up (`sandbox_quota_exceeded`). Honour `Retry-After`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"The model did not answer (`upstream_error`). Retry shortly.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"The model, the billing check or the uncensored-terms check is briefly unavailable. Retry shortly.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/videos/generations/{jobId}":{"get":{"tags":["Video"],"operationId":"getVideoJob","summary":"Check a video job","parameters":[{"name":"jobId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"The job, processing or completed. A completed job carries `result` with the video URL.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VideoJob"}}}},"404":{"description":"No such job for this account, or it expired.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"The video could not be generated (`generation_failed`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VideoJob"}}}}}}},"/v1/pricing":{"get":{"tags":["Pricing"],"operationId":"getPricing","summary":"Live prices","description":"Public, no key needed. Prices are in CAD; the response carries the currency.","security":[],"responses":{"200":{"description":"Every metered price, keyed by metric.","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/v1/uncensored-terms":{"get":{"tags":["Terms"],"operationId":"getUncensoredTerms","summary":"Whether this account has accepted the uncensored terms","description":"qai-uncensored and the uncensored imagine tiers stay off until both attestations are stored on the company. Accept them here or at https://q-ai.ca/uncensored-terms.","responses":{"200":{"description":"The current acceptance status.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UncensoredTermsStatus"}}}},"401":{"description":"The API key is missing, unknown or disabled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Terms"],"operationId":"acceptUncensoredTerms","summary":"Accept the uncensored terms for this account","description":"Both `iAmAnAdult` and `noIllegalActivity` must be true. One accept covers every key on the company.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["iAmAnAdult","noIllegalActivity"],"properties":{"iAmAnAdult":{"type":"boolean","const":true,"description":"Confirms the caller is 18 years of age or older."},"noIllegalActivity":{"type":"boolean","const":true,"description":"Confirms the models will not be used for illegal activity."}}}}}},"responses":{"200":{"description":"The terms are on file.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UncensoredTermsStatus"}}}},"400":{"description":"The request is invalid. `code` says why (missing_field, invalid_model, invalid_value, invalid_request).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"The API key is missing, unknown or disabled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/utilities/clean-json":{"post":{"tags":["Utilities"],"operationId":"cleanJson","summary":"Recover valid JSON from messy model output","description":"Free with any Qai key. Strips markdown fences, fixes trailing commas and similar damage.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["input"],"properties":{"input":{"type":"string","minLength":1}}}}}},"responses":{"200":{"description":"The recovered JSON.","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"data":{},"raw":{"type":"string"},"corrections":{"type":"array","items":{"type":"string"}}}}}}},"400":{"description":"The request is invalid. `code` says why (missing_field, invalid_model, invalid_value, invalid_request).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"The API key is missing, unknown or disabled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Paid models are off (`billing_not_enabled`) or uncensored models need accepted terms (`uncensored_terms_required`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"The input could not be turned into JSON."},"429":{"description":"Rate limited (`rate_limit_exceeded`) or the free sandbox quota is used up (`sandbox_quota_exceeded`). Honour `Retry-After`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"The model did not answer (`upstream_error`). Retry shortly.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"The model, the billing check or the uncensored-terms check is briefly unavailable. Retry shortly.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/v1/utilities/humanize-text":{"post":{"tags":["Utilities"],"operationId":"humanizeText","summary":"Clean up AI-generated text","description":"Free typography cleanup by default. naturalizeWording also rewrites stiff wording with a small text model, is billed at qai-flash rates, and takes up to 8000 characters.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["input"],"properties":{"input":{"type":"string","minLength":1},"naturalizeWording":{"type":"boolean","default":false}}}}}},"responses":{"200":{"description":"The cleaned text.","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"text":{"type":"string"},"corrections":{"type":"array","items":{"type":"string"}},"naturalized":{"type":"boolean"}}}}}},"400":{"description":"The request is invalid. `code` says why (missing_field, invalid_model, invalid_value, invalid_request).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"The API key is missing, unknown or disabled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Paid models are off (`billing_not_enabled`) or uncensored models need accepted terms (`uncensored_terms_required`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited (`rate_limit_exceeded`) or the free sandbox quota is used up (`sandbox_quota_exceeded`). Honour `Retry-After`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"The model did not answer (`upstream_error`). Retry shortly.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"The model, the billing check or the uncensored-terms check is briefly unavailable. Retry shortly.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"Authorization: Bearer YOUR_QAI_API_KEY. Qai keys are GUIDs."},"apiKeyHeader":{"type":"apiKey","in":"header","name":"x-api-key"}},"schemas":{"Error":{"type":"object","properties":{"error":{"type":"object","properties":{"message":{"type":"string"},"type":{"type":"string"},"code":{"type":"string"}}}}},"Usage":{"type":"object","properties":{"prompt_tokens":{"type":"integer"},"completion_tokens":{"type":"integer"},"total_tokens":{"type":"integer"}}},"ToolCall":{"type":"object","required":["id","type","function"],"properties":{"id":{"type":"string"},"type":{"const":"function"},"function":{"type":"object","required":["name","arguments"],"properties":{"name":{"type":"string"},"arguments":{"type":"string","description":"JSON-encoded arguments."}}}}},"ChatMessage":{"type":"object","required":["role"],"properties":{"role":{"type":"string","enum":["system","user","assistant","tool"]},"content":{"description":"A string, null (assistant messages that only call tools), or an array of text and image_url parts.","oneOf":[{"type":"string"},{"type":"null"},{"type":"array","items":{"oneOf":[{"type":"object","required":["type","text"],"properties":{"type":{"const":"text"},"text":{"type":"string"}}},{"type":"object","required":["type","image_url"],"properties":{"type":{"const":"image_url"},"image_url":{"type":"object","required":["url"],"properties":{"url":{"type":"string","description":"An https URL or a data: URI."},"detail":{"type":"string","enum":["auto","low","high"]}}}}}]}}]},"name":{"type":"string"},"tool_call_id":{"type":"string","description":"Required on role \"tool\" messages: the id of the call being answered."},"tool_calls":{"type":"array","items":{"$ref":"#/components/schemas/ToolCall"}}}},"ChatCompletionRequest":{"type":"object","required":["model","messages"],"description":"OpenAI chat completions request. Fields not listed here are dropped before the request reaches the model.","properties":{"model":{"type":"string","enum":["qai-hello-world","qai-flash","qai-pro","qai-max","qai-think","qai-uncensored"]},"messages":{"type":"array","minItems":1,"items":{"$ref":"#/components/schemas/ChatMessage"}},"stream":{"type":"boolean","description":"Stream server-sent events. The stream ends with a chunk carrying `usage`, then `data: [DONE]`."},"max_tokens":{"type":"number"},"max_completion_tokens":{"type":"number"},"temperature":{"type":"number"},"top_p":{"type":"number"},"frequency_penalty":{"type":"number"},"presence_penalty":{"type":"number"},"seed":{"type":"number"},"stop":{"oneOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"logprobs":{"type":"boolean"},"top_logprobs":{"type":"number"},"user":{"type":"string"},"tools":{"type":"array","items":{"type":"object","required":["type","function"],"properties":{"type":{"const":"function"},"function":{"type":"object","required":["name"],"properties":{"name":{"type":"string"},"description":{"type":"string"},"parameters":{"type":"object"},"strict":{"type":"boolean"}}}}}},"tool_choice":{"oneOf":[{"type":"string","enum":["none","auto","required"]},{"type":"object","required":["type","function"],"properties":{"type":{"const":"function"},"function":{"type":"object","required":["name"],"properties":{"name":{"type":"string"}}}}}]},"parallel_tool_calls":{"type":"boolean"},"response_format":{"oneOf":[{"type":"object","required":["type"],"properties":{"type":{"type":"string","enum":["text","json_object"]}}},{"type":"object","required":["type","json_schema"],"properties":{"type":{"const":"json_schema"},"json_schema":{"type":"object"}}}]}}},"ChatCompletion":{"type":"object","properties":{"id":{"type":"string","description":"Starts with \"chatcmpl-\"."},"object":{"const":"chat.completion"},"created":{"type":"integer"},"model":{"type":"string"},"choices":{"type":"array","items":{"type":"object","properties":{"index":{"type":"integer"},"message":{"type":"object","properties":{"role":{"const":"assistant"},"content":{"type":["string","null"]},"tool_calls":{"type":"array","items":{"$ref":"#/components/schemas/ToolCall"}}}},"finish_reason":{"type":"string","enum":["stop","length","tool_calls","content_filter"]}}}},"usage":{"$ref":"#/components/schemas/Usage"}}},"ModelList":{"type":"object","properties":{"object":{"const":"list"},"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"object":{"const":"model"},"created":{"type":"integer"},"owned_by":{"const":"qai"},"type":{"type":"string","enum":["text","image","video"]}}}}}},"UncensoredTermsStatus":{"type":"object","properties":{"accepted":{"type":"boolean"},"termsVersion":{"type":"integer"},"acceptedAt":{"type":["integer","null"]},"attestations":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","enum":["iAmAnAdult","noIllegalActivity"]},"label":{"type":"string"},"detail":{"type":"string"},"accepted":{"type":"boolean"}}}}}},"VideoJob":{"type":"object","properties":{"id":{"type":"string"},"status":{"type":"string","enum":["processing","completed","failed"]},"result":{"type":"object","description":"Present when completed. Holds the video URL."},"error":{"$ref":"#/components/schemas/Error/properties/error"}}}}}}