> For the complete documentation index, see [llms.txt](https://docs.qolaba.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.qolaba.ai/api-platform/openai-compatible-chat/try-chatbot.md).

# Try Chatbot

## Create chat completion

> Generate a model response for a conversation. Supports streaming via SSE, tool calling, and RAG file search.

```json
{"openapi":"3.0.3","info":{"title":"Qolaba Chat Completions API","version":"1.1.0"},"tags":[{"name":"Chat","description":"OpenAI-compatible chat completions"}],"servers":[{"url":"https://api.platform.qolaba.ai/api/v1","description":"Production"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"API key passed as a Bearer token.\nGenerate your key at [platform.qolaba.ai](https://platform.qolaba.ai).\nExample: `Authorization: Bearer sk-xxxxxxxxxxxx`\n"}},"schemas":{"ChatCompletionRequest":{"type":"object","required":["model","messages"],"properties":{"model":{"type":"string","description":"Model ID to use for completion","enum":["google/gemini-2.5-flash","google/gemini-2.5-pro","google/gemini-3-pro-preview","google/gemini-3-flash-preview","google/gemini-3.1-pro-preview"]},"messages":{"type":"array","description":"Conversation history as an array of messages","minItems":1,"items":{"$ref":"#/components/schemas/ChatMessage"}},"stream":{"type":"boolean","default":false,"description":"If `true`, response is streamed as Server-Sent Events"},"temperature":{"type":"number","minimum":0,"maximum":2,"default":1,"description":"Sampling temperature. Lower values produce more deterministic output"},"max_tokens":{"type":"integer","minimum":1,"description":"Maximum number of tokens to generate in the response"},"tools":{"type":"array","description":"List of tools the model may call (function calling)","items":{"$ref":"#/components/schemas/Tool"}},"tool_choice":{"description":"Controls tool selection. `auto` lets the model decide, `none` disables tools, or specify a function name","oneOf":[{"type":"string","enum":["auto","none"]},{"type":"object","properties":{"type":{"type":"string","enum":["function"]},"function":{"type":"object","properties":{"name":{"type":"string"}}}}}]},"stream_options":{"type":"object","description":"Options for streaming responses. Note - `include_usage` is always enabled for credit tracking","properties":{"include_usage":{"type":"boolean","default":true,"description":"Always enabled. Usage data is included in the final streamed event for credit tracking"}}},"file_search_store_names":{"type":"array","items":{"type":"string"},"description":"RAG vector store names to search for context (format `fileSearchStores/{storeId}`)"},"thread_id":{"type":"string","description":"Conversation thread ID for multi-turn context tracking"},"user_id":{"type":"string","description":"User identifier for analytics and tracking"},"webhookUrl":{"type":"string","format":"uri","description":"Webhook URL for async result delivery"},"metadata":{"type":"object","description":"Extra key/value metadata to attach to the request"}}},"ChatMessage":{"type":"object","required":["role","content"],"properties":{"role":{"type":"string","enum":["system","user","assistant","tool"],"description":"Role of the message author"},"content":{"oneOf":[{"type":"string"},{"type":"array","items":{"type":"object"}}],"description":"Message content. String for text, array for multimodal input"},"tool_calls":{"type":"array","description":"Tool calls made by the assistant (present when role is `assistant`)","items":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string","enum":["function"]},"function":{"type":"object","properties":{"name":{"type":"string"},"arguments":{"type":"string"}}}}}},"tool_call_id":{"type":"string","description":"ID of the tool call this message responds to (present when role is `tool`)"}}},"Tool":{"type":"object","required":["type","function"],"properties":{"type":{"type":"string","enum":["function"]},"function":{"type":"object","required":["name","parameters"],"properties":{"name":{"type":"string","description":"Function name"},"description":{"type":"string","description":"Description of what the function does"},"parameters":{"type":"object","description":"JSON Schema describing the function parameters"}}}}},"ChatCompletionResponse":{"type":"object","properties":{"id":{"type":"string","description":"Unique completion identifier"},"object":{"type":"string","enum":["chat.completion"]},"created":{"type":"integer","description":"Unix timestamp of when the completion was created"},"model":{"type":"string","description":"Model used for the completion"},"choices":{"type":"array","items":{"type":"object","properties":{"index":{"type":"integer"},"message":{"$ref":"#/components/schemas/ChatMessage"},"finish_reason":{"type":"string","enum":["stop","length","tool_calls","content_filter"],"description":"Reason the model stopped generating"}}}},"usage":{"type":"object","description":"Credit usage breakdown for this completion","properties":{"total_credit":{"type":"number","description":"Total credits consumed"},"total_cost":{"type":"number","description":"Total cost in USD (with margin)"},"raw_cost":{"type":"number","description":"Base provider cost in USD"},"breakdown":{"type":"object","description":"Per-component cost breakdown"}}}}},"APIError":{"type":"object","properties":{"error":{"type":"object","properties":{"message":{"type":"string"},"type":{"type":"string","enum":["invalid_request_error","rate_limit_error","provider_error","server_error"]},"param":{"type":"string","nullable":true},"code":{"type":"string"}}}}}},"responses":{"Unauthorized":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}}}}}},"InsufficientCredit":{"description":"Organization has insufficient credits","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}}}}}}}},"paths":{"/chat/completions":{"post":{"tags":["Chat"],"summary":"Create chat completion","operationId":"chatCompletions","description":"Generate a model response for a conversation. Supports streaming via SSE, tool calling, and RAG file search.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatCompletionRequest"}}}},"responses":{"200":{"description":"Chat completion response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatCompletionResponse"}},"text/event-stream":{"schema":{"type":"string","description":"Server-Sent Events stream. Each event is a JSON object prefixed with `data: ` and terminated by two newlines."}}}},"400":{"description":"Invalid request parameters","content":{"application/json":{"schema":{"$ref":"#/components/schemas/APIError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/InsufficientCredit"},"429":{"description":"Rate limit exceeded (20 requests per minute)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/APIError"}}}},"502":{"description":"Upstream provider error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/APIError"}}}}}}}}}
```

## List chat models

> Retrieve available chat models with their capabilities and supported modalities.

```json
{"openapi":"3.0.3","info":{"title":"Qolaba Chat Completions API","version":"1.1.0"},"tags":[{"name":"Models","description":"List available models"}],"servers":[{"url":"https://api.platform.qolaba.ai/api/v1","description":"Production"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"API key passed as a Bearer token.\nGenerate your key at [platform.qolaba.ai](https://platform.qolaba.ai).\nExample: `Authorization: Bearer sk-xxxxxxxxxxxx`\n"}},"schemas":{"ModelListResponse":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"object":{"type":"string"},"created":{"type":"integer"},"owned_by":{"type":"string"}}}}}}},"responses":{"Unauthorized":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}}}}}},"InsufficientCredit":{"description":"Organization has insufficient credits","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}}}}}}}},"paths":{"/chat/models":{"get":{"tags":["Models"],"summary":"List chat models","operationId":"listChatModels","description":"Retrieve available chat models with their capabilities and supported modalities.","parameters":[{"name":"modality","in":"query","required":false,"description":"Filter models by modality (e.g. `text`, `image`)","schema":{"type":"string"}}],"responses":{"200":{"description":"List of available models","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ModelListResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/InsufficientCredit"}}}}}}
```

## Upload file

> Upload a file for RAG file search. The file is indexed into a vector store that can be referenced in chat completions via \`file\_search\_store\_names\`.

```json
{"openapi":"3.0.3","info":{"title":"Qolaba Chat Completions API","version":"1.1.0"},"tags":[{"name":"Files","description":"Upload files for RAG file search"}],"servers":[{"url":"https://api.platform.qolaba.ai/api/v1","description":"Production"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"API key passed as a Bearer token.\nGenerate your key at [platform.qolaba.ai](https://platform.qolaba.ai).\nExample: `Authorization: Bearer sk-xxxxxxxxxxxx`\n"}},"schemas":{"FileUploadRequest":{"type":"object","required":["url"],"properties":{"url":{"type":"string","format":"uri","description":"URL of the file to upload. Supported formats are `.pdf`, `.txt`, `.doc`, `.docx`"},"store_name":{"type":"string","description":"Optional name for the vector store. If omitted, a store is created automatically"}}},"FileUploadResponse":{"type":"object","properties":{"success":{"type":"boolean","description":"Whether the upload succeeded"},"store_name":{"type":"string","description":"Vector store name in `fileSearchStores/{storeId}` format"},"file_name":{"type":"string","description":"Name of the uploaded file"},"message":{"type":"string","description":"Status message"},"token_count":{"type":"integer","description":"Number of tokens indexed from the file"},"estimated_cost_usd":{"type":"number","description":"Estimated cost in USD"},"creditUtilisation":{"type":"number","description":"Credits consumed for this upload"}}},"APIError":{"type":"object","properties":{"error":{"type":"object","properties":{"message":{"type":"string"},"type":{"type":"string","enum":["invalid_request_error","rate_limit_error","provider_error","server_error"]},"param":{"type":"string","nullable":true},"code":{"type":"string"}}}}}},"responses":{"Unauthorized":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}}}}}},"InsufficientCredit":{"description":"Organization has insufficient credits","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}}}}}}}},"paths":{"/files":{"post":{"tags":["Files"],"summary":"Upload file","operationId":"uploadFile","description":"Upload a file for RAG file search. The file is indexed into a vector store that can be referenced in chat completions via `file_search_store_names`.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FileUploadRequest"}}}},"responses":{"200":{"description":"File uploaded and indexed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FileUploadResponse"}}}},"400":{"description":"Invalid request (unsupported file type, missing URL)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/APIError"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/InsufficientCredit"}}}}}}
```
