# Qai > Qai is an OpenAI-compatible API for text, image and video generation, made by QuickCasa, a Canadian software company. Pay per use, with no monthly fee and no minimum. All prices are in Canadian dollars (CAD). - Website: https://q-ai.ca - API base URL: https://llm.quickcasa.ai/v1 - Documentation: https://q-ai.ca/docs - Pricing: https://q-ai.ca/pricing - Sign up: https://q-ai.ca/signup - Contact: hi@quickcasa.ai ## What Qai is Qai is a pay-as-you-go API for generative AI. One API key covers six text models, five image models and one video model, including uncensored text and image tiers for adult work. Every endpoint follows the OpenAI API conventions, so any client library, framework or no-code tool that supports OpenAI works with Qai by changing the base URL. ## Base URL https://llm.quickcasa.ai/v1 ## Authentication Send the key as a bearer token ("Authorization: Bearer YOUR_API_KEY") or in an x-api-key header. Keys are created in the Qai dashboard after signing up at https://q-ai.ca/signup. Qai keys are GUIDs; they do not start with "sk-". ## Models All prices are in Canadian dollars (CAD). ### Text models (chat completions) - qai-hello-world: free sandbox model, capped at 100 calls per API key per UTC day. Works before billing is set up. Use it for testing and prototyping. - qai-flash: cheap and fast text generation. Best for conversational AI, summarisation, classification, high-volume tasks. $0.20 per 1M input tokens, $0.50 per 1M output tokens. - qai-pro: balanced default. Solid at reasoning, code generation, structured outputs. The tier most teams ship on. $0.80 per 1M input tokens, $2.00 per 1M output tokens. - qai-max: top capability. Long context, deep reasoning, complex multi-step problems. $1.50 per 1M input tokens, $5.00 per 1M output tokens. - qai-think: reasoning model with chain-of-thought baked in. Math, planning, tricky logic. $1.80 per 1M input tokens, $8.00 per 1M output tokens. - qai-uncensored: adult fiction and frank answers without refusals or lectures. Sexual content involving minors is refused. see /pricing, see /pricing. ### Image models - qai-imagine-turbo: fast image generation. Real-time, batch, preview workflows. $0.04 per image. - qai-imagine-quality: studio-grade image generation. Photorealism, accurate text rendering. $0.08 per image. - qai-imagine-uncensored-turbo: fast uncensored images. Adult / NSFW prompts, text to image, base64 only, never stored. see /pricing. - qai-imagine-uncensored: default uncensored image tier. see /pricing. - qai-imagine-uncensored-pro: highest-fidelity uncensored images. see /pricing. ### Video models - qai-motion: text-to-video generation. $0.18 per video-second. ### Coming soon - qai-embed: text embeddings for semantic search, RAG pipelines, classification. ## Endpoints ### Chat completions POST /v1/chat/completions OpenAI-compatible. Supports streaming via stream=true. Function calling and tool calls are supported. Streamed responses always end with a chunk that carries token usage; stream_options is accepted and not needed. Qai serves chat completions only: the Responses API (/v1/responses) answers 404, so clients that default to it need switching to chat completions. Example: { "model": "qai-pro", "messages": [ {"role": "user", "content": "Explain quantum entanglement in two sentences."} ] } ### Image generation POST /v1/images/generations Body: { model, prompt, n? (1 to 10), response_format? ("url" or "b64_json"), hostMedia? } If hostMedia is true, the generated image is uploaded to the Qai CDN and returned as a permanent URL. Otherwise, the image is temporary and auto-expires. ### Video generation POST /v1/videos/generations Body: { model, prompt, size?, duration?, fps?, hostMedia? } Returns a 202 with a job id. Poll GET /v1/videos/generations/{id} until status is "completed". ### List available models GET /v1/models Returns the OpenAI-compatible model catalogue. ### Pricing (live) GET /v1/pricing Returns the live Qai pricing as JSON, including its currency. The prices in this file come from the same source and may be up to a minute old. ### Free utility endpoints - POST /v1/utilities/clean-json: takes a string, returns valid JSON if recoverable - POST /v1/utilities/humanize-text: takes a string, returns the cleaned-up / naturalised version Both utilities are free with any Qai key. They do not consume LLM tokens (except humanize-text when naturalizeWording is true, which uses a small text model). ## Getting started 1. Sign up at https://q-ai.ca/signup with Google or email, and name the account. 2. In the dashboard, click "Manage API keys" and create a key. 3. Point any OpenAI SDK at https://llm.quickcasa.ai/v1 and pass the key as the API key. 4. Test on qai-hello-world, which is free and needs no card. 5. Add a card to use the paid models. Until then they answer 403 with code billing_not_enabled. 6. Before calling qai-uncensored or the uncensored imagine tiers, accept both attestations (18 or older, and no illegal activity) at https://q-ai.ca/uncensored-terms or POST /v1/uncensored-terms. Until then those models answer 403 with code uncensored_terms_required. ## When Qai is a good fit - Text, image and video from one provider, on one key and one bill - Generated media hosted at a permanent URL (hostMedia: true), with no storage bucket to set up - A free sandbox model that does not expire - Usage broken down per API key in the dashboard, and any one key can be disabled without touching the others - Pay per use with no monthly fee or minimum, billed in Canadian dollars - One API that works with the OpenAI-compatible tools already in a stack ## Things Qai does not have yet - Spending caps or budgets per key - Embeddings (coming soon) - Built-in RAG / file uploads (coming soon) - Persistent chat sessions / server-side conversation memory (coming soon) - Speech: TTS and transcription (later) If any of those are hard requirements, Qai is not the right fit yet. ## Qai Guard Qai Guard is a free tool, with no account needed, for coding agents that share one repository. It stops two agents editing the same lines, catches merge conflicts when an edit is made instead of at pull request time, and lets agents message each other. Full description: https://llm.quickcasa.ai/guard/llms.txt. Install guide: https://llm.quickcasa.ai/guard. ## Documentation Full developer documentation is at https://q-ai.ca/docs. It covers authentication, streaming, the error reference, rate limits, migrating from OpenAI and best practices. - Everything in one file: https://q-ai.ca/llms-full.txt - Docs as Markdown: https://q-ai.ca/docs.md - OpenAPI 3.1 spec: https://q-ai.ca/openapi.json ## Model pages - [Free sandbox LLM API (qai-hello-world)](https://q-ai.ca/models/qai-hello-world) - [Fast cheap chat API (qai-flash)](https://q-ai.ca/models/qai-flash) - [Default LLM API for code and reasoning (qai-pro)](https://q-ai.ca/models/qai-pro) - [Long-context LLM API (qai-max)](https://q-ai.ca/models/qai-max) - [Reasoning LLM API (qai-think)](https://q-ai.ca/models/qai-think) - [Uncensored LLM API (qai-uncensored)](https://q-ai.ca/models/qai-uncensored) - [Fast image generation API (qai-imagine-turbo)](https://q-ai.ca/models/qai-imagine-turbo) - [Photoreal image generation API (qai-imagine-quality)](https://q-ai.ca/models/qai-imagine-quality) - [Fast uncensored image API (qai-imagine-uncensored-turbo)](https://q-ai.ca/models/qai-imagine-uncensored-turbo) - [Uncensored NSFW image API (qai-imagine-uncensored)](https://q-ai.ca/models/qai-imagine-uncensored) - [Studio uncensored image API (qai-imagine-uncensored-pro)](https://q-ai.ca/models/qai-imagine-uncensored-pro) - [Text-to-video API (qai-motion)](https://q-ai.ca/models/qai-motion) ## Use cases - [Uncensored LLM and NSFW image API](https://q-ai.ca/use-cases/uncensored) - [Uncensored terms](https://q-ai.ca/uncensored-terms) ## Integration guides - [OpenAI SDKs](https://q-ai.ca/integrations/openai-sdk): Python and Node: change the base URL and the key, keep your code. - [LangChain](https://q-ai.ca/integrations/langchain): ChatOpenAI in Python and JavaScript with a custom base URL. - [Vercel AI SDK](https://q-ai.ca/integrations/vercel-ai-sdk): The OpenAI-compatible provider for text, streaming and images. - [Continue](https://q-ai.ca/integrations/continue): Chat, edit and agent mode in VS Code and JetBrains. - [Open WebUI](https://q-ai.ca/integrations/open-webui): Add Qai as an OpenAI connection and chat with every model. - [n8n](https://q-ai.ca/integrations/n8n): The OpenAI credential with a custom base URL, for AI agents and chains. - [Make](https://q-ai.ca/integrations/make): Call Qai from a scenario with the HTTP "Make a request" module. - [Zapier](https://q-ai.ca/integrations/zapier): Call Qai from a Zap with API by Zapier or Webhooks by Zapier. ## Contact - Email: hi@quickcasa.ai - Website: https://q-ai.ca - Sign up: https://q-ai.ca/signup ## Parent Qai is a product of QuickCasa (https://www.quickcasa.ai), a Canadian software company. # Models in detail ## Free sandbox LLM API (qai-hello-world) A free sandbox model for shaking out your integration, capped at 100 calls per API key per UTC day. Use it to validate your wiring before you start spending real money. Page: https://q-ai.ca/models/qai-hello-world - Model id: qai-hello-world - Kind: Text (chat completions) - Endpoint: POST /v1/chat/completions - Price (CAD): Free, capped at 100 calls per API key per UTC day - Context window: 131,072 tokens - Max output: 16,384 tokens - Streaming: Yes (server-sent events) - Tool calls: Yes - JSON mode: Yes - Best for: Integration testing Use it when: - You are testing that your integration calls land at all - You are wiring up streaming and want to verify the SSE parsing - You want to demo Qai in a sales / blog / tutorial without spending anything - You are debugging your prompt template structure Pick another tier when: - You need production-quality outputs - You will exceed 100 calls per key per day - You need long context windows - You are doing any task that requires nuanced reasoning ```bash curl https://llm.quickcasa.ai/v1/chat/completions \ -H "Authorization: Bearer $QAI_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "qai-hello-world", "messages": [{"role": "user", "content": "Say hi and tell me what model you are."}]}' ``` ```python import os from openai import OpenAI client = OpenAI(base_url="https://llm.quickcasa.ai/v1", api_key=os.environ["QAI_API_KEY"]) response = client.chat.completions.create( model="qai-hello-world", messages=[{"role": "user", "content": "Say hi and tell me what model you are."}], ) print(response.choices[0].message.content) ``` Alternatives: Hit the daily cap? Switch to qai-flash. Need real conversation quality? qai-pro. ## Fast cheap chat API (qai-flash) Cheap and quick. Optimised for chat, summarisation, classification, intent detection, and high-volume background tasks where you care more about unit economics than getting the most clever answer. Page: https://q-ai.ca/models/qai-flash - Model id: qai-flash - Kind: Text (chat completions) - Endpoint: POST /v1/chat/completions - Price (CAD): $0.20 per 1M input tokens; $0.50 per 1M output tokens - Context window: 1,000,000 tokens - Max output: 65,536 tokens - Streaming: Yes (server-sent events) - Tool calls: Yes - JSON mode: Yes - Best for: High-volume chat / classification Use it when: - You are powering a chatbot that answers in 1-3 sentences - You need to label, classify, or tag thousands of items a day - You are summarising customer support tickets, emails, or short docs - You are running an LLM call inside a per-row pipeline Pick another tier when: - You need long-form reasoning or multi-step argument chains - The task requires writing or critiquing code beyond simple snippets - You need very tight JSON-schema adherence on complex structures - The output needs to be impressive enough to send to a customer unedited ```bash curl https://llm.quickcasa.ai/v1/chat/completions \ -H "Authorization: Bearer $QAI_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "qai-flash", "messages": [{"role": "user", "content": "Classify this support ticket as: bug, billing, feature-request, other. Reply with just the label."}]}' ``` ```python import os from openai import OpenAI client = OpenAI(base_url="https://llm.quickcasa.ai/v1", api_key=os.environ["QAI_API_KEY"]) response = client.chat.completions.create( model="qai-flash", messages=[{"role": "user", "content": "Classify this support ticket as: bug, billing, feature-request, other. Reply with just the label."}], ) print(response.choices[0].message.content) ``` Alternatives: Need stronger reasoning? Up to qai-pro. Need cheaper testing? Down to qai-hello-world. ## Default LLM API for code and reasoning (qai-pro) The everyday workhorse. Solid at reasoning, code generation, structured output, instruction following, and the long tail of "I just need a good answer" tasks. If you are not sure which tier to pick, start here. Page: https://q-ai.ca/models/qai-pro - Model id: qai-pro - Kind: Text (chat completions) - Endpoint: POST /v1/chat/completions - Price (CAD): $0.80 per 1M input tokens; $2.00 per 1M output tokens - Context window: 1,048,576 tokens - Max output: 393,216 tokens - Streaming: Yes (server-sent events) - Tool calls: Yes - JSON mode: Yes - Best for: The thing most teams ship on Use it when: - You want a default that does most jobs well without over-paying - You are building customer-facing chat, generation, or assistant features - You need solid JSON / structured output following - You are writing code snippets, transforming data, or drafting prose Pick another tier when: - The task involves multi-hop reasoning across many constraints - You need cited / hallucination-free output - layer your own retrieval ```bash curl https://llm.quickcasa.ai/v1/chat/completions \ -H "Authorization: Bearer $QAI_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "qai-pro", "messages": [{"role": "user", "content": "Draft a 3-sentence onboarding email for a new SaaS sign-up. Friendly but professional, no exclamation marks."}]}' ``` ```python import os from openai import OpenAI client = OpenAI(base_url="https://llm.quickcasa.ai/v1", api_key=os.environ["QAI_API_KEY"]) response = client.chat.completions.create( model="qai-pro", messages=[{"role": "user", "content": "Draft a 3-sentence onboarding email for a new SaaS sign-up. Friendly but professional, no exclamation marks."}], ) print(response.choices[0].message.content) ``` Alternatives: Need heavier reasoning? Up to qai-max. Chain-of-thought required? qai-think. Cost-sensitive volume? Down to qai-flash. ## Long-context LLM API (qai-max) The heaviest lifter. Long context, deep reasoning, complex multi-step problems, hard code refactors, nuanced creative writing. Reach for it when you would rather wait a little longer than read a mediocre answer. Page: https://q-ai.ca/models/qai-max - Model id: qai-max - Kind: Text (chat completions) - Endpoint: POST /v1/chat/completions - Price (CAD): $1.50 per 1M input tokens; $5.00 per 1M output tokens - Context window: 1,048,576 tokens - Max output: 943,718 tokens - Streaming: Yes (server-sent events) - Tool calls: Yes - JSON mode: Yes - Best for: Quality matters more than speed Use it when: - The output is high-stakes enough to be worth the latency - You are doing complex code review, refactor planning, or architecture work - You are working with long documents or large code contexts - You need writing that holds together across many paragraphs - You are running an agent that needs strong instruction following over many turns Pick another tier when: - You are running an inner-loop pipeline where every second compounds - The task is simple - qai-pro will land at almost the same quality for less ```bash curl https://llm.quickcasa.ai/v1/chat/completions \ -H "Authorization: Bearer $QAI_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "qai-max", "messages": [{"role": "user", "content": "Refactor this 400-line React component to use hooks and split into smaller components. Keep the visual output identical."}]}' ``` ```python import os from openai import OpenAI client = OpenAI(base_url="https://llm.quickcasa.ai/v1", api_key=os.environ["QAI_API_KEY"]) response = client.chat.completions.create( model="qai-max", messages=[{"role": "user", "content": "Refactor this 400-line React component to use hooks and split into smaller components. Keep the visual output identical."}], ) print(response.choices[0].message.content) ``` Alternatives: Need chain-of-thought? qai-think. Simple task? Down to qai-pro. ## Reasoning LLM API (qai-think) A reasoning model. Spends extra compute thinking through a problem before answering. Best at math, formal logic, multi-constraint planning, and "let me check my work" style tasks where a wrong-but-confident first guess is the failure mode you most want to avoid. Page: https://q-ai.ca/models/qai-think - Model id: qai-think - Kind: Text (chat completions) - Endpoint: POST /v1/chat/completions - Price (CAD): $1.80 per 1M input tokens; $8.00 per 1M output tokens - Context window: 1,048,576 tokens - Max output: 512,000 tokens - Streaming: Yes (server-sent events) - Tool calls: Yes - JSON mode: Yes - Best for: Right answer over fast answer Use it when: - The problem has a single correct answer and you need to land on it - You are doing math, scheduling, optimisation, or symbolic reasoning - You need a model that will catch its own mistakes - You are running a workflow where one wrong step poisons the whole chain - You can wait a few seconds for the right answer Pick another tier when: - You need the first token on screen straight away in a chat UX - The task is creative / open-ended (the reasoning overhead is wasted) - You are doing high-volume classification or summarisation - You need answers in under a second ```bash curl https://llm.quickcasa.ai/v1/chat/completions \ -H "Authorization: Bearer $QAI_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "qai-think", "messages": [{"role": "user", "content": "I have meetings at 10-11am Eastern, 1-2pm Pacific, and 4-5pm London. Find one 30-minute slot that works for someone in Singapore (no later than 10pm local)."}]}' ``` ```python import os from openai import OpenAI client = OpenAI(base_url="https://llm.quickcasa.ai/v1", api_key=os.environ["QAI_API_KEY"]) response = client.chat.completions.create( model="qai-think", messages=[{"role": "user", "content": "I have meetings at 10-11am Eastern, 1-2pm Pacific, and 4-5pm London. Find one 30-minute slot that works for someone in Singapore (no later than 10pm local)."}], ) print(response.choices[0].message.content) ``` Alternatives: Need fast non-reasoning answers? qai-max or qai-pro. ## Uncensored LLM API (qai-uncensored) Writes adult fiction and answers frank questions without refusing or lecturing. Sexual content, dark themes and explicit language are in scope. The full reply is checked before any of it is sent; sexual content involving minors is refused. Page: https://q-ai.ca/models/qai-uncensored - Model id: qai-uncensored - Kind: Text (chat completions) - Endpoint: POST /v1/chat/completions - Price (CAD): See https://q-ai.ca/pricing; See https://q-ai.ca/pricing - Context window: 1,000,000 tokens - Max output: 131,072 tokens - Streaming: Yes (server-sent events) - Tool calls: Yes - JSON mode: Yes - Best for: Adult fiction and frank answers Use it when: - You are writing adult romance, erotica or dark fiction - Characters swear, want sex, or do ugly things, and you need the model to stay in scene - Other models fade to black, hedge, or scold the user - You want a direct answer to an adult question, not a lecture Pick another tier when: - You need the first token on screen immediately - the full answer is checked first, then streamed - You need the model to look at an image - You are building a product that must refuse adult content - use qai-pro - You want a general-purpose default for code, summaries or support chat ```bash curl https://llm.quickcasa.ai/v1/chat/completions \ -H "Authorization: Bearer $QAI_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "qai-uncensored", "messages": [{"role": "user", "content": "Write a chapter of adult romance between two consenting adults. Be specific about bodies and desire. Do not fade to black or moralise."}]}' ``` ```python import os from openai import OpenAI client = OpenAI(base_url="https://llm.quickcasa.ai/v1", api_key=os.environ["QAI_API_KEY"]) response = client.chat.completions.create( model="qai-uncensored", messages=[{"role": "user", "content": "Write a chapter of adult romance between two consenting adults. Be specific about bodies and desire. Do not fade to black or moralise."}], ) print(response.choices[0].message.content) ``` Alternatives: Need a general-purpose default? qai-pro. Need an uncensored image? qai-imagine-uncensored. The full cluster: uncensored LLM and NSFW image API. ## Fast image generation API (qai-imagine-turbo) A fast image model. Good for previews, batch generation, and any time you want to put several candidate images in front of a user instead of one. Page: https://q-ai.ca/models/qai-imagine-turbo - Model id: qai-imagine-turbo - Kind: Image generation - Endpoint: POST /v1/images/generations - Price (CAD): $0.04 per image - Delivery: URL or b64_json; hostMedia stores a permanent URL - Max size: 1024x1024 - Best for: Previews and batches Use it when: - You are showing many candidate images and letting the user pick - You are batch-generating thumbnails, avatars, or placeholders - Speed of feedback matters more than perfect detail - You are iterating on a prompt and need to see many variants quickly Pick another tier when: - You need photorealistic detail or accurate text rendering - The output is going on a billboard, a print piece, or a customer-facing hero image - You need consistent styling across many generations ```bash curl https://llm.quickcasa.ai/v1/images/generations \ -H "Authorization: Bearer $QAI_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "qai-imagine-turbo", "prompt": "a cozy reading nook with a window, golden hour lighting, soft watercolour style", "hostMedia": true}' ``` Alternatives: Need higher fidelity? Up to qai-imagine-quality. Need uncensored images? qai-imagine-uncensored-turbo. ## Photoreal image generation API (qai-imagine-quality) Studio-grade image generation. Best for hero images, marketing assets, product mockups, and anywhere the image is the centrepiece of what your user sees. Page: https://q-ai.ca/models/qai-imagine-quality - Model id: qai-imagine-quality - Kind: Image generation - Endpoint: POST /v1/images/generations - Price (CAD): $0.08 per image - Delivery: URL or b64_json; hostMedia stores a permanent URL - Max size: 2048x2048 - Best for: Hero images and marketing assets Use it when: - The image is the product, not a side decoration - You need photorealism, accurate text rendering, or fine detail - You are generating marketing visuals, hero images, or printed assets - Your user expects "professional photography" quality Pick another tier when: - You need to generate 100 variants and pick the best - use turbo - The output will be small (thumbnail, icon) - the quality is wasted - You need it in under 5 seconds ```bash curl https://llm.quickcasa.ai/v1/images/generations \ -H "Authorization: Bearer $QAI_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "qai-imagine-quality", "prompt": "professional product photo of a stainless-steel pour-over kettle on a clean white background, studio lighting, sharp focus", "hostMedia": true}' ``` Alternatives: Need many quick variants? Down to qai-imagine-turbo. Need uncensored images? qai-imagine-uncensored. ## Fast uncensored image API (qai-imagine-uncensored-turbo) Fast uncensored image generation. Adult and NSFW prompts are in scope. Text to image only: no one's photo can be edited. Images come back as base64 and are never stored on our side. Page: https://q-ai.ca/models/qai-imagine-uncensored-turbo - Model id: qai-imagine-uncensored-turbo - Kind: Image generation - Endpoint: POST /v1/images/generations - Price (CAD): See https://q-ai.ca/pricing - Delivery: Base64 only; the image is never stored - Max size: 2K, nearest aspect ratio to size - Best for: Fast adult image drafts Use it when: - You are iterating on an adult prompt and need many variants quickly - You are generating NSFW previews, thumbnails or moodboards - Speed matters more than studio detail Pick another tier when: - You need to edit an existing photograph - this endpoint takes no reference image - You need a hosted URL - this tier returns b64_json only - You want a SFW default - use qai-imagine-turbo ```bash curl https://llm.quickcasa.ai/v1/images/generations \ -H "Authorization: Bearer $QAI_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "qai-imagine-uncensored-turbo", "prompt": "a painted nude study of an adult woman stretching in late-afternoon studio light, classical oil technique", "response_format": "b64_json"}' ``` Alternatives: Need more fidelity? Up to qai-imagine-uncensored. Need SFW and a hosted URL? qai-imagine-turbo. The full cluster: uncensored LLM and NSFW image API. ## Uncensored NSFW image API (qai-imagine-uncensored) The default uncensored image tier. Adult and NSFW prompts, stronger detail than turbo. Text to image only, base64 only, never stored. Sexual content involving minors is refused. Page: https://q-ai.ca/models/qai-imagine-uncensored - Model id: qai-imagine-uncensored - Kind: Image generation - Endpoint: POST /v1/images/generations - Price (CAD): See https://q-ai.ca/pricing - Delivery: Base64 only; the image is never stored - Max size: 2K, nearest aspect ratio to size - Best for: Adult images you will actually use Use it when: - The image is adult work you actually want to ship, not a thumbnail - You need more fidelity than turbo without jumping to pro - You are generating character art, editorial nudes or erotic illustration Pick another tier when: - You need to edit someone's photo - You need a permanent hosted URL - You want a SFW marketing visual - use qai-imagine-quality ```bash curl https://llm.quickcasa.ai/v1/images/generations \ -H "Authorization: Bearer $QAI_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "qai-imagine-uncensored", "prompt": "photoreal adult couple kissing in a hotel doorway at night, cinematic lighting, film grain", "response_format": "b64_json"}' ``` Alternatives: Need it faster and cheaper? Down to qai-imagine-uncensored-turbo. Need the sharpest detail? Up to qai-imagine-uncensored-pro. The full cluster: uncensored LLM and NSFW image API. ## Studio uncensored image API (qai-imagine-uncensored-pro) The highest-fidelity uncensored image tier. Adult and NSFW prompts with studio-grade detail. Same rules as the other uncensored imagine tiers: text to image, base64 only, never stored. Page: https://q-ai.ca/models/qai-imagine-uncensored-pro - Model id: qai-imagine-uncensored-pro - Kind: Image generation - Endpoint: POST /v1/images/generations - Price (CAD): See https://q-ai.ca/pricing - Delivery: Base64 only; the image is never stored - Max size: 2K, nearest aspect ratio to size - Best for: Hero-grade adult images Use it when: - The image is the product: a cover, a print, a hero still - You need photoreal skin, fabric and lighting on an adult subject - Quality matters more than speed or unit cost Pick another tier when: - You are iterating on a prompt and will throw most of the outputs away - use turbo - You need a hosted URL or a photo edit - You want a SFW default ```bash curl https://llm.quickcasa.ai/v1/images/generations \ -H "Authorization: Bearer $QAI_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "qai-imagine-uncensored-pro", "prompt": "editorial photograph of an adult nude reclining on dark velvet, studio lighting, sharp focus, 85mm", "response_format": "b64_json"}' ``` Alternatives: Need it cheaper? Down to qai-imagine-uncensored. Need SFW photorealism with a hosted URL? qai-imagine-quality. The full cluster: uncensored LLM and NSFW image API. ## Text-to-video API (qai-motion) A text-to-video model that produces short clips with coherent motion and credible scene continuity, billed by the second of video returned. Page: https://q-ai.ca/models/qai-motion - Model id: qai-motion - Kind: Video generation - Endpoint: POST /v1/videos/generations - Price (CAD): $0.18 per video-second - Duration: Six seconds by default; set duration in seconds - Best for: Short clips and b-roll Use it when: - You are generating short marketing clips, product demos, or social-post hooks - You want generative b-roll for a longer piece you stitch together separately - The output is for ad creative or audience-facing motion - You want it hosted on a permanent URL out of the box Pick another tier when: - You need 30+ second clips - it is not built for long-form yet - You need consistent character / scene identity across many generations - The output needs to be photo-perfect (motion can still hallucinate) ```bash curl https://llm.quickcasa.ai/v1/videos/generations \ -H "Authorization: Bearer $QAI_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "qai-motion", "prompt": "a barista pulling an espresso shot, slow-motion crema pouring into a glass cup, warm cafe lighting", "hostMedia": true}' # The response is {"id": "...", "status": "processing"}. Poll until "completed": curl https://llm.quickcasa.ai/v1/videos/generations/JOB_ID \ -H "Authorization: Bearer $QAI_API_KEY" ``` # Integration guides ## Use Qai with OpenAI SDKs Qai follows the OpenAI chat completions API, so the official OpenAI SDKs work as they are. Change the base URL to `https://llm.quickcasa.ai/v1` and use a Qai API key. Guide: https://q-ai.ca/integrations/openai-sdk 1. **Install the SDK** Use the official package for your language. No Qai-specific SDK is needed. ```bash pip install openai # or npm install openai ``` 2. **Point it at Qai (Python)** Set `base_url` and pass your Qai key. Start on `qai-hello-world`, which is free, then change the model name for production. ```python import os from openai import OpenAI client = OpenAI(base_url="https://llm.quickcasa.ai/v1", api_key=os.environ["QAI_API_KEY"]) response = client.chat.completions.create( model="qai-hello-world", messages=[{"role": "user", "content": "Hello"}], ) print(response.choices[0].message.content) for chunk in client.chat.completions.create( model="qai-pro", messages=[{"role": "user", "content": "Write a haiku about Mondays"}], stream=True, ): if chunk.choices: print(chunk.choices[0].delta.content or "", end="") ``` 3. **Point it at Qai (Node)** Same idea in TypeScript or JavaScript: set `baseURL` and the key. ```javascript import OpenAI from 'openai'; const client = new OpenAI({ baseURL: 'https://llm.quickcasa.ai/v1', apiKey: process.env.QAI_API_KEY, }); const response = await client.chat.completions.create({ model: 'qai-pro', messages: [{ role: 'user', content: 'Hello' }], }); console.log(response.choices[0].message.content); ``` 4. **Or set it once in the environment** Both SDKs read `OPENAI_BASE_URL` and `OPENAI_API_KEY`, so existing code switches to Qai without edits. ```bash export OPENAI_BASE_URL=https://llm.quickcasa.ai/v1 export OPENAI_API_KEY=YOUR_QAI_API_KEY ``` Good to know: - Use `client.chat.completions`, not `client.responses`: Qai does not serve the Responses API and answers it with a 404. - Images work through `client.images.generate` with `qai-imagine-turbo` or `qai-imagine-quality`. Send `hostMedia: true` (in Python, `extra_body={"hostMedia": True}`) for a permanent URL. Uncensored imagine tiers (`qai-imagine-uncensored` and friends) return `b64_json` only and do not store the file. - Streamed responses end with a chunk that carries token usage. - Reasoning tiers (`qai-flash`, `qai-think`) think before they answer and those tokens count toward `max_tokens`, so leave a few hundred tokens of headroom. Tested against Qai on November 25, 2026 with openai 3.59 (Python) and openai 7.64 (Node): chat, streaming, tool calls, JSON mode and image generation. ## Use Qai with LangChain LangChain's `ChatOpenAI` accepts a custom base URL, so chains, agents and tool calling run on Qai with one setting. Guide: https://q-ai.ca/integrations/langchain 1. **Install the OpenAI integration** Python needs `langchain-openai`; JavaScript needs `@langchain/openai` and `@langchain/core`. ```bash pip install -U langchain-openai # or npm install @langchain/openai @langchain/core ``` 2. **Python** Pass `base_url` and `api_key` to `ChatOpenAI`. ```python import os from langchain_openai import ChatOpenAI model = ChatOpenAI( model="qai-pro", base_url="https://llm.quickcasa.ai/v1", api_key=os.environ["QAI_API_KEY"], ) print(model.invoke("Explain vector databases in two sentences.").content) ``` 3. **JavaScript** In JavaScript the base URL goes inside `configuration`. ```javascript import { ChatOpenAI } from '@langchain/openai'; const model = new ChatOpenAI({ model: 'qai-pro', apiKey: process.env.QAI_API_KEY, configuration: { baseURL: 'https://llm.quickcasa.ai/v1' }, }); const message = await model.invoke('Explain vector databases in two sentences.'); console.log(message.content); ``` 4. **Tools and agents** `bind_tools` (Python) and `bindTools` (JavaScript) work as usual. Pick `qai-flash` or a higher tier for tool calling. Good to know: - Leave `use_responses_api` (Python) and `useResponsesApi` (JavaScript) off. Qai serves chat completions. - Qai model ids do not match the OpenAI names LangChain routes to the Responses API, so the defaults already send chat completions. Tested against Qai on November 25, 2026 with langchain-openai 1.8.5 (Python) and @langchain/openai 1.8.5 (JavaScript): invoke, streaming and tool calling. ## Use Qai with Vercel AI SDK The AI SDK's OpenAI-compatible provider talks to Qai directly, for text, streaming and images. Guide: https://q-ai.ca/integrations/vercel-ai-sdk 1. **Install** You need the core `ai` package and the OpenAI-compatible provider. ```bash npm install ai @ai-sdk/openai-compatible ``` 2. **Create the provider** Give it a name, the Qai base URL and your key. ```typescript import { createOpenAICompatible } from '@ai-sdk/openai-compatible'; import { generateText, streamText, generateImage } from 'ai'; const qai = createOpenAICompatible({ name: 'qai', baseURL: 'https://llm.quickcasa.ai/v1', apiKey: process.env.QAI_API_KEY, }); const { text } = await generateText({ model: qai('qai-pro'), prompt: 'Name three Canadian lakes.' }); const result = streamText({ model: qai('qai-flash'), prompt: 'Write a haiku about Mondays.' }); for await (const part of result.textStream) process.stdout.write(part); const { images } = await generateImage({ model: qai.imageModel('qai-imagine-turbo'), prompt: 'a lighthouse at dusk' }); ``` Good to know: - If you use `@ai-sdk/openai` instead, call `openai.chat('qai-pro')`. The default `openai('qai-pro')` uses the Responses API, which Qai answers with a 404. Tested against Qai on November 25, 2026 with ai 7.0, @ai-sdk/openai-compatible 3.0 (generateText, streamText, generateImage) and @ai-sdk/openai 4.0 (.chat models). ## Use Qai with Continue Continue's OpenAI provider takes a custom `apiBase`, so Qai models show up in Continue's chat, edit and agent modes. Guide: https://q-ai.ca/integrations/continue 1. **Open your Continue config** Open `config.yaml` from Continue's settings (it lives in the `.continue` folder in your home directory). 2. **Add a Qai model** Use the `openai` provider with `apiBase` ending in `/v1`. Declaring `tool_use` lets agent mode call tools. ```yaml name: My Config version: 0.0.1 schema: v1 models: - name: Qai Pro provider: openai model: qai-pro apiBase: https://llm.quickcasa.ai/v1 apiKey: YOUR_QAI_API_KEY roles: - chat - edit - apply capabilities: - tool_use ``` 3. **Pick the model in Continue** Reload the config and choose "Qai Pro" in Continue's model menu. Good to know: - Leave the `autocomplete` role off: Qai has no completions or fill-in-the-middle endpoint, so tab autocomplete needs another model. - Do not set `useResponsesApi`; Qai serves chat completions. - `apiBase` must include `/v1`. Settings from Continue's documentation as of November 25, 2026. The requests Continue sends, streamed chat completions with tools, were tested against Qai the same day. ## Use Qai with Open WebUI Open WebUI connects to any OpenAI-compatible API. Add Qai as a connection and its models appear in the model picker. Guide: https://q-ai.ca/integrations/open-webui 1. **Add the connection** As an admin, open Settings, then Connections, then "Manage OpenAI API Connections", and add one with the URL `https://llm.quickcasa.ai/v1` and your Qai key. No trailing slash. 2. **Verify it** Verify the connection: Open WebUI lists Qai's models from `/v1/models`, and `qai-pro` and the other tiers appear in the model picker. 3. **Or configure it with environment variables** For a Docker install, set the base URL and key when you start the container. ```bash OPENAI_API_BASE_URL=https://llm.quickcasa.ai/v1 OPENAI_API_KEY=YOUR_QAI_API_KEY ``` Good to know: - If the connection has an API type setting, keep it on chat completions rather than Responses. - Requests go from your Open WebUI server to Qai, so the server needs outbound internet access. Settings from Open WebUI's documentation as of November 25, 2026. The requests it sends (listing `/v1/models`, streamed chat completions and native tool calls) were tested against Qai the same day. ## Use Qai with n8n n8n's OpenAI credential has a Base URL field, so the OpenAI Chat Model node can run AI agents and chains on Qai. Guide: https://q-ai.ca/integrations/n8n 1. **Create an OpenAI credential for Qai** Add a new OpenAI credential, paste your Qai key as the API Key, and set Base URL to `https://llm.quickcasa.ai/v1`. Saving it tests the connection by listing models. 2. **Add the OpenAI Chat Model node** In your AI Agent or chain, add the OpenAI Chat Model node, choose the Qai credential, and set the model by ID, for example `qai-pro`. 3. **Turn off "Use Responses API"** Newer versions of the node send the Responses API by default. Switch that option off so it sends chat completions, which Qai serves. Good to know: - In the OpenAI app node, use "Generate a Chat Completion", not "Generate a Model Response" (that one uses the Responses API). - Tool calling works for AI Agent tools; use `qai-flash` or a higher tier. Credential and node settings from n8n's documentation and source as of November 25, 2026. The node runs on LangChain's ChatOpenAI, which was tested against Qai the same day (invoke, streaming, tools). ## Use Qai with Make Make's OpenAI app is fixed to OpenAI, but the HTTP app can call Qai's chat completions endpoint directly. Guide: https://q-ai.ca/integrations/make 1. **Add an HTTP "Make a request" module** Set the URL to `https://llm.quickcasa.ai/v1/chat/completions` and the method to POST. 2. **Authenticate with your key** Choose the API key authentication type and create a keychain whose key is `Bearer YOUR_QAI_API_KEY`, sent in the header named `Authorization`. 3. **Send the request** Use a JSON body and turn on response parsing. Keep `stream` false. ```json { "model": "qai-flash", "messages": [{ "role": "user", "content": "Summarise this email: ..." }], "stream": false } ``` 4. **Map the answer** The reply text is at `choices[1].message.content` in the parsed output (Make counts array items from 1). Good to know: - Images work the same way: POST to `/v1/images/generations` with `model` and `prompt`. Module settings from Make's HTTP app documentation as of November 25, 2026. The request it sends was tested against Qai the same day. ## Use Qai with Zapier Zapier's ChatGPT app only talks to OpenAI, but its API tools can call Qai's chat completions endpoint. Guide: https://q-ai.ca/integrations/zapier 1. **Connect API by Zapier** Add an API by Zapier "API Request" action. For the connection, use static headers with one header, `Authorization: Bearer YOUR_QAI_API_KEY`, and set the domain filter to `llm.quickcasa.ai`. 2. **Configure the request** Method POST, URL `https://llm.quickcasa.ai/v1/chat/completions`, and a JSON body with `stream` set to false. ```json { "model": "qai-flash", "messages": [{ "role": "user", "content": "Draft a reply to: ..." }], "stream": false } ``` 3. **Use the reply** Map `choices[0].message.content` (or the matching field Zapier shows) into the next step. Good to know: - API by Zapier is in beta and needs a paid plan. Webhooks by Zapier ("Custom Request") also works, but it keeps the Authorization header in plain text in the step. Settings from Zapier's documentation as of November 25, 2026. The request it sends was tested against Qai the same day. # API reference Qai is an OpenAI-compatible API for text, image and video generation. Point any OpenAI SDK at `https://llm.quickcasa.ai/v1` with your Qai API key and the requests, streaming and errors work the way they do with OpenAI. These docs are also available as [Markdown](https://q-ai.ca/docs.md) and as an [OpenAPI 3.1 spec](https://q-ai.ca/openapi.json), and there are [step-by-step guides](https://q-ai.ca/integrations) for common SDKs and tools. ## Authentication All API requests require authentication via an API key. You can pass your key using either the `Authorization` header (OpenAI-style) or the `x-api-key` header. #### Option 1: Bearer Token (recommended) ``` Authorization: Bearer YOUR_QAI_API_KEY ``` #### Option 2: API Key Header ``` x-api-key: YOUR_QAI_API_KEY ``` ## Base URL All API requests should be made to: ``` https://llm.quickcasa.ai ``` Because the API is OpenAI-compatible, you can use the official OpenAI SDK by simply changing the `base_url` and `api_key`. ## Error Handling Errors follow the OpenAI error format: ```json { "error": { "message": "Invalid API key", "type": "invalid_request_error", "code": "unauthorized" } } ``` Common HTTP status codes: - **400** - Bad request (missing or invalid parameters) - **401** - Unauthorised (invalid or missing API key) - **429** - Rate limit exceeded - **502** - Generation service error - **503** - Service temporarily unavailable --- ## List Models GET /v1/models Returns a list of all available models. ```bash curl https://llm.quickcasa.ai/v1/models \ -H "Authorization: Bearer YOUR_QAI_API_KEY" ``` #### Response ```json { "object": "list", "data": [ { "id": "qai-hello-world", "object": "model", "owned_by": "qai", "type": "text" }, { "id": "qai-flash", "object": "model", "owned_by": "qai", "type": "text" }, { "id": "qai-pro", "object": "model", "owned_by": "qai", "type": "text" }, { "id": "qai-max", "object": "model", "owned_by": "qai", "type": "text" }, { "id": "qai-think", "object": "model", "owned_by": "qai", "type": "text" }, { "id": "qai-uncensored", "object": "model", "owned_by": "qai", "type": "text" }, { "id": "qai-imagine-turbo", "object": "model", "owned_by": "qai", "type": "image" }, { "id": "qai-imagine-quality", "object": "model", "owned_by": "qai", "type": "image" }, { "id": "qai-imagine-uncensored-turbo", "object": "model", "owned_by": "qai", "type": "image" }, { "id": "qai-imagine-uncensored", "object": "model", "owned_by": "qai", "type": "image" }, { "id": "qai-imagine-uncensored-pro", "object": "model", "owned_by": "qai", "type": "image" }, { "id": "qai-motion", "object": "model", "owned_by": "qai", "type": "video" } ] } ``` --- ## Chat Completions POST /v1/chat/completions Generate a text completion from a conversation. Fully compatible with the OpenAI chat completions API. #### Request Body | Parameter | Type | Description | | --- | --- | --- | | model required | string | One of `qai-hello-world` (free), `qai-flash`, `qai-pro`, `qai-max`, `qai-think`, or `qai-uncensored` (adult fiction and frank answers) | | messages required | array | Array of message objects with `role` and `content` | | stream optional | boolean | Enable Server-Sent Events streaming. Default: `false` | | temperature optional | number | Sampling temperature (0–2). Default: `1` | | max_tokens optional | integer | Maximum tokens to generate | | top_p optional | number | Nucleus sampling threshold | | stop optional | string \| array | Stop sequence(s) | | also accepted optional | various | `max_completion_tokens`, `frequency_penalty`, `presence_penalty`, `seed`, `response_format`, `tools`, `tool_choice`, `parallel_tool_calls`, `logprobs`, `top_logprobs` and `user`, with their OpenAI meanings | Message content can be a string or an array of `text` and `image_url` parts. Fields not listed here are ignored, and other content part types are refused with a 400. #### Example: Non-streaming ```bash curl https://llm.quickcasa.ai/v1/chat/completions \ -H "Authorization: Bearer YOUR_QAI_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "qai-flash", "messages": [ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What is QuickCasa?"} ], "temperature": 0.7 }' ``` #### Example: Streaming ```bash curl https://llm.quickcasa.ai/v1/chat/completions \ -H "Authorization: Bearer YOUR_QAI_API_KEY" \ -H "Content-Type: application/json" \ -N \ -d '{ "model": "qai-pro", "messages": [ {"role": "user", "content": "Write a haiku about apartments."} ], "stream": true }' ``` #### Response ```json { "id": "chatcmpl-abc123", "object": "chat.completion", "created": 1700000000, "model": "qai-flash", "choices": [{ "index": 0, "message": { "role": "assistant", "content": "QuickCasa is a property management platform..." }, "finish_reason": "stop" }], "usage": { "prompt_tokens": 25, "completion_tokens": 42, "total_tokens": 67 } } ``` --- ## Image Generation POST /v1/images/generations Generate images from a text prompt. Compatible with the OpenAI images API. #### Request Body | Parameter | Type | Description | | --- | --- | --- | | model required | string | `qai-imagine-turbo` (fast), `qai-imagine-quality` (detailed), or `qai-imagine-uncensored` / `-turbo` / `-pro` (adult / NSFW, base64 only) | | prompt required | string | A text description of the desired image | | n optional | integer | Number of images to generate, from 1 to 10. Default: `1` | | size optional | string | Accepted so OpenAI clients work unchanged. The output dimensions are set by the model. | | response_format optional | string | `url` or `b64_json`. Default: `url`. Uncensored imagine tiers accept `b64_json` only. | If some of the images in a request fail, the ones that succeeded are returned and only those are billed. #### Example ```bash curl https://llm.quickcasa.ai/v1/images/generations \ -H "Authorization: Bearer YOUR_QAI_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "qai-imagine-turbo", "prompt": "A modern apartment building at golden hour, photorealistic", "response_format": "b64_json" }' ``` #### Response ```json { "created": 1700000000, "data": [ { "b64_json": "iVBORw0KGgoAAAANSUhEUg..." } ] } ``` --- ## Video Generation POST /v1/videos/generations Generate short videos from a text prompt. This is a QuickCasa-specific endpoint (not part of the OpenAI spec). Videos are generated by the qai-motion model. Generation runs as a job: the request returns a job id straight away, and you poll for the result. #### Request Body | Parameter | Type | Description | | --- | --- | --- | | model required | string | `qai-motion` | | prompt required | string | A text description of the desired video | | size optional | string | Resolution hint as `WxH`. The model uses its own default when this is left out. | | duration optional | number | Requested length in seconds. You are billed on the length of the video you get back, rounded to the nearest second. | | fps optional | integer | Frame rate hint. The model uses its own default when this is left out. | #### Example ```bash curl https://llm.quickcasa.ai/v1/videos/generations \ -H "Authorization: Bearer YOUR_QAI_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "qai-motion", "prompt": "Aerial drone shot of a luxury condo complex, cinematic", "duration": 6 }' ``` #### Response (202) ```json { "id": "3f0c2a9e-6b1d-4c7a-9a52-1f4e8d2b7c10", "status": "processing" } ``` #### Poll for the result GET /v1/videos/generations/{id} Poll every 5 to 10 seconds with the same API key. While the video is being made you get `{"id", "status": "processing"}`. When it is ready: ```json { "id": "3f0c2a9e-6b1d-4c7a-9a52-1f4e8d2b7c10", "status": "completed", "result": { "created": 1700000000, "data": [ { "url": "https://llm.quickcasa.ai/media/temp/abc123", "content_type": "video/mp4", "duration_seconds": 6 } ] } } ``` **Note:** A clip usually takes a few minutes. A failed job returns HTTP 502 with `status: "failed"`, and a job that has not finished after 30 minutes is cancelled. Only the key's own company can poll a job. --- ## Uncensored terms `qai-uncensored` and the uncensored imagine tiers stay off until the account accepts two statements: that the caller is 18 or older, and that the models will not be used for illegal activity. One accept covers every key on the company. Tick both boxes at [/uncensored-terms](https://q-ai.ca/uncensored-terms), or call the endpoint below. GET /v1/uncensored-terms Returns whether this account has already accepted the current terms. POST /v1/uncensored-terms Stores both attestations. Both fields must be `true`. #### Request Body | Parameter | Type | Description | | --- | --- | --- | | iAmAnAdult required | boolean | Must be `true`. Confirms the caller is 18 years of age or older. | | noIllegalActivity required | boolean | Must be `true`. Confirms the models will not be used for illegal activity. | ```bash curl -X POST https://llm.quickcasa.ai/v1/uncensored-terms \ -H "Authorization: Bearer $QC_API_KEY" \ -H "Content-Type: application/json" \ -d '{"iAmAnAdult":true,"noIllegalActivity":true}' ``` --- ## Python SDK Use the official `openai` Python package. Just point it at our base URL. ```bash pip install openai ``` #### Chat Completion ```python from openai import OpenAI client = OpenAI( base_url="https://llm.quickcasa.ai/v1", api_key="YOUR_QAI_API_KEY", ) response = client.chat.completions.create( model="qai-flash", messages=[ {"role": "user", "content": "Hello!"} ], ) print(response.choices[0].message.content) ``` #### Streaming ```python stream = client.chat.completions.create( model="qai-pro", messages=[{"role": "user", "content": "Tell me a story."}], stream=True, ) for chunk in stream: if chunk.choices[0].delta.content: print(chunk.choices[0].delta.content, end="") ``` #### Image Generation ```python image = client.images.generate( model="qai-imagine-turbo", prompt="A cozy studio apartment with warm lighting", size="1024x1024", response_format="b64_json", ) print(image.data[0].b64_json[:50]) ``` --- ## Node.js SDK Use the official `openai` npm package. ```bash npm install openai ``` #### Chat Completion ```typescript import OpenAI from 'openai'; const client = new OpenAI({ baseURL: 'https://llm.quickcasa.ai/v1', apiKey: 'YOUR_QAI_API_KEY', }); const response = await client.chat.completions.create({ model: 'qai-flash', messages: [ { role: 'user', content: 'Hello!' }, ], }); console.log(response.choices[0].message.content); ``` #### Streaming ```typescript const stream = await client.chat.completions.create({ model: 'qai-pro', messages: [{ role: 'user', content: 'Tell me a story.' }], stream: true, }); for await (const chunk of stream) { const content = chunk.choices[0]?.delta?.content; if (content) { process.stdout.write(content); } } ``` #### Video Generation (fetch) ```typescript // Video generation uses a custom endpoint, so use fetch directly const response = await fetch('https://llm.quickcasa.ai/v1/videos/generations', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer YOUR_QAI_API_KEY', }, body: JSON.stringify({ model: 'qai-motion', prompt: 'Aerial tour of a modern apartment complex', duration: 6, }), }); const { id } = await response.json(); // Poll until the job finishes let job; do { await new Promise((resolve) => setTimeout(resolve, 5000)); const poll = await fetch(`https://llm.quickcasa.ai/v1/videos/generations/${id}`, { headers: { 'Authorization': 'Bearer YOUR_QAI_API_KEY' }, }); job = await poll.json(); } while (job.status === 'processing'); console.log(job.result.data[0].url); ``` --- ## cURL Quick Reference #### Text ```bash curl -X POST https://llm.quickcasa.ai/v1/chat/completions \ -H "Authorization: Bearer $QC_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model":"qai-flash","messages":[{"role":"user","content":"Hi!"}]}' ``` #### Image ```bash curl -X POST https://llm.quickcasa.ai/v1/images/generations \ -H "Authorization: Bearer $QC_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model":"qai-imagine-turbo","prompt":"sunset over a city skyline"}' ``` #### Video ```bash curl -X POST https://llm.quickcasa.ai/v1/videos/generations \ -H "Authorization: Bearer $QC_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model":"qai-motion","prompt":"walkthrough of a modern kitchen","duration":6}' ``` --- ## Streaming Every Qai text model supports Server-Sent Events streaming. Set `stream: true` on your chat completions request and Qai forwards tokens as they are generated. The response uses the standard OpenAI streaming envelope, so any client library that already handles OpenAI streaming works with Qai unmodified. Streamed responses include a final usage chunk with prompt and completion token counts, so streaming and non-streaming billing land at the same precision. If a particular model variant ever skips the usage chunk, Qai falls back to a token estimate so billing never silently records zero. ``` from openai import OpenAI client = OpenAI(base_url="https://llm.quickcasa.ai/v1", api_key="YOUR_QAI_API_KEY") stream = client.chat.completions.create( model="qai-pro", messages=[{"role": "user", "content": "Tell me a story."}], stream=True, ) for chunk in stream: delta = chunk.choices[0].delta.content if delta: print(delta, end="", flush=True) ``` ``` const stream = await client.chat.completions.create({ model: 'qai-pro', messages: [{ role: 'user', content: 'Tell me a story.' }], stream: true, }); for await (const chunk of stream) { process.stdout.write(chunk.choices[0]?.delta?.content ?? ''); } ``` --- ## Migrating from OpenAI If you have an existing app on the OpenAI API, the migration is exactly two changes: #### 1. Change the base URL Point your OpenAI client at `https://llm.quickcasa.ai/v1` instead of `https://api.openai.com/v1`. #### 2. Swap the model name Pick the Qai tier that matches your old model. Rough equivalents: - `gpt-4o-mini` > `qai-flash` - `gpt-4o` > `qai-pro` or `qai-max` - `gpt-4.1` > `qai-max` - `o1`, `o3` > `qai-think` - `dall-e-3` > `qai-imagine-quality` Everything else - streaming, function calling, JSON mode, system prompts, tool calls - works identically. ``` const client = new OpenAI({ - baseURL: 'https://api.openai.com/v1', + baseURL: 'https://llm.quickcasa.ai/v1', apiKey: process.env.QAI_API_KEY, }); await client.chat.completions.create({ - model: 'gpt-4o', + model: 'qai-pro', messages: [...], }); ``` --- ## Best practices #### Match the tier to the job Do not default to qai-max for everything just because it is the most capable. A summarisation pipeline runs fine on qai-flash for a tenth of the cost. Use the dashboard's per-model breakdown to spot where you are over-spending. #### Use one key per integration Especially in production. Usage is tracked per key in the dashboard, so a misbehaving cron job shows up under its own name, and disabling that one key stops it without touching anything else. #### Use the free sandbox during development qai-hello-world is free and capped at 100 calls per API key per UTC day. Wire your dev environment to it - your real spend should only start when you go to production. #### Stream when the user is waiting For chat-style interactions, set stream=true. A 4-second response feels instant when the first token arrives in 200ms; it feels broken when nothing happens for 4 seconds. #### Set `hostMedia: true` for production images and videos Without it, generated media is temporary and auto-expires. With it, you get a permanent URL on the Qai CDN that you can embed directly into emails, apps, or social posts without re-hosting. #### Pin to a model, not a default Always pass an explicit `model` field. Do not assume a default. Models can rev, behaviours can shift, and being explicit means your tests are reproducible. --- ## Errors reference Qai returns errors in OpenAI-compatible shape: `{ "error": { "message", "type", "code" } }`. Below is the full list of error codes you might see. #### HTTP 400 - invalid_request_error - `missing_field` - a required field (model, prompt) was not in your request body. - `invalid_request` - a chat request field is missing or has the wrong type, or the model rejected the request. The `message` says which. - `invalid_model` - the model id is not one Qai serves. Hit `GET /v1/models` for the live catalogue. - `invalid_value` - a field has a value outside its range (for example `n` above 10). - `context_length_exceeded` - the messages plus `max_tokens` are longer than the model can take. - `content_filtered` - the request was blocked by content moderation. #### HTTP 401 - invalid_request_error - `unauthorized` - the Authorization header was missing, malformed, or referred to a key that does not exist or is disabled. #### HTTP 403 - invalid_request_error - `billing_not_enabled` - the account has no Qai billing set up, so paid models are off for its keys. Finish signup, or use the free qai-hello-world. - `uncensored_terms_required` - this account has not accepted the uncensored terms yet. Tick both boxes at [/uncensored-terms](https://q-ai.ca/uncensored-terms), or POST both `iAmAnAdult` and `noIllegalActivity` to `/v1/uncensored-terms`. #### HTTP 429 - rate_limit_error - `rate_limit_exceeded` - too many requests from your address in the last minute. Retry with exponential backoff. - `sandbox_quota_exceeded` - the free qai-hello-world tier's per-key per-UTC-day quota was hit. Wait until midnight UTC or switch to qai-flash. - `upstream_busy` - the model is busy right now. Retry in a few seconds. #### HTTP 502, 503 and 504 - api_error - `upstream_error` - the model did not answer. Retry in a moment. - `generation_failed` - a video job could not be generated (returned when you poll it). - `model_unavailable` (503) - the model is temporarily unavailable. Retry shortly. - `billing_check_unavailable` (503) - Qai could not confirm billing for the account just now. Retry in a few seconds. - `uncensored_terms_unavailable` (503) - Qai could not confirm uncensored terms for the account just now. Retry in a few seconds. - `upstream_timeout` (504) - the model took too long to answer. #### HTTP 500 - api_error - `internal_error` - something on our side broke. If you see this repeatedly, email [hi@quickcasa.ai](mailto:hi@quickcasa.ai) with the timestamp and we will dig in. --- ## Rate limits Qai applies two layers of rate limiting: #### Per address Requests are limited to 100 per minute from each IP address, across every key and endpoint. If you exceed it, you get a 429 with `code: rate_limit_exceeded`. The response includes a `Retry-After` header. #### Per-key sandbox quota The free qai-hello-world tier is capped at 100 calls per API key per UTC day. When you hit the cap, that specific key returns 429 with `code: sandbox_quota_exceeded` until midnight UTC. Other models on the same key keep working. #### How to handle 429s 1. Respect the `Retry-After` header when present. 2. Use exponential backoff with jitter for retries (start at 500ms, double up to 30s). 3. If you regularly hit the limit, email us about lifting it - we can usually raise it within a business day. --- ## Frequently asked questions #### Is Qai really OpenAI-compatible? Yes. Same endpoints, same request bodies, same streaming envelope, same error format. Drop in OpenAI's SDK, change the baseURL, and you are running on Qai. We test against the official openai-python and openai-node libraries. #### Can I run Qai keys alongside OpenAI keys in the same app? Of course - just instantiate two clients with different baseURLs. Some teams route cheap chat to Qai and reserve OpenAI for one specific feature they have already tuned. There is no exclusivity. #### What is the actual latency? It depends on the model and the prompt. qai-flash and qai-pro answer fastest; qai-max and qai-think trade speed for depth. qai-uncensored checks the full answer before the first token is sent. Image generation takes seconds and video generation takes minutes, so poll the video job rather than blocking a request on it. #### What if a model is temporarily unavailable? You will get a 502 or 503 with a clear error message. Outages are rare but they happen - it is on the roadmap to automatically retry a failed generation against the next-best tier (e.g. qai-max failing over to qai-pro) so your app does not feel them. #### Does Qai store my prompts? For text, we store the metadata needed for billing (model, token count, timestamp, API key id) but not the prompt or the completion. For SFW images and video, the prompt is kept with the generated file's record. Uncensored imagine tiers return base64 and never store the image. #### How do I cancel? Sign in, head to your dashboard, click "Manage account" then "Cancel subscription". You stop being billed at the end of the current cycle. If you want all your data deleted too, email us and we will wipe everything. #### I lost my API key. How do I recover it? Sign in, disable the lost key, and create a new one. Disabling takes effect on the next request. #### Can I get higher rate limits? Yes. Email [hi@quickcasa.ai](mailto:hi@quickcasa.ai) with your account email and what you are building. Most lifts happen within a business day.