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

# OpenAI Compatible

## OpenAI Compatible Chat Completions (Simple Chatbots)

> Provides a drop-in replacement for the OpenAI Chat Completions API, designed specifically for \*\*Simple Chatbots\*\* built in Waterflai. This endpoint is not intended for executing Chatflows or Workflows.\
> You can use this for both streaming and non-streaming responses.

```json
{"openapi":"3.0.3","info":{"title":"Waterflai Public API","version":"v1"},"servers":[{"url":"https://api.waterflai.ai","description":"Production Server"}],"security":[{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"X-API-Key","description":"Your secret API key."}},"schemas":{"ChatCompletionRequest":{"type":"object","required":["model","messages"],"properties":{"model":{"type":"string","description":"The ID of the Simple Chatbot to use for this completion."},"messages":{"type":"array","items":{"$ref":"#/components/schemas/ChatMessage"}},"conversation_id":{"type":"string","description":"A unique identifier for the conversation session.","default":"UID"},"stream":{"type":"boolean","description":"If set, partial message deltas will be sent, like in ChatGPT.","default":false},"temperature":{"type":"number","format":"float","default":0.7},"top_p":{"type":"number","format":"float","default":1},"n":{"type":"integer","default":1},"max_tokens":{"type":"integer","default":4096},"stop":{"oneOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]},"presence_penalty":{"type":"number","format":"float","default":0},"frequency_penalty":{"type":"number","format":"float","default":0}}},"ChatMessage":{"type":"object","required":["role","content"],"properties":{"role":{"type":"string","enum":["system","user","assistant"],"description":"The role of the message author."},"content":{"type":"string","description":"The content of the message."}}},"ChatCompletionResponse":{"type":"object","properties":{"id":{"type":"string"},"object":{"type":"string"},"created":{"type":"integer","format":"unixtime"},"model":{"type":"string","description":"The model that generated the response (the Chatbot ID)."},"choices":{"type":"array","items":{"$ref":"#/components/schemas/ChatCompletionResponseChoice"}},"usage":{"$ref":"#/components/schemas/UsageInfo"}}},"ChatCompletionResponseChoice":{"type":"object","properties":{"index":{"type":"integer"},"message":{"$ref":"#/components/schemas/ResponseChatMessage"},"finish_reason":{"type":"string","enum":["stop","length","model_length","error","tool_calls",null]}}},"ResponseChatMessage":{"type":"object","properties":{"role":{"type":"string","description":"The role of the author of this message."},"content":{"type":"string","description":"The contents of the message."}}},"UsageInfo":{"type":"object","properties":{"prompt_tokens":{"type":"integer"},"completion_tokens":{"type":"integer"},"total_tokens":{"type":"integer"}}},"ChatCompletionStreamResponse":{"type":"object","description":"Represents a chunk of the streaming response.","properties":{"id":{"type":"string"},"object":{"type":"string"},"created":{"type":"integer","format":"unixtime"},"model":{"type":"string","description":"The model that generated the response (the Chatbot ID)."},"choices":{"type":"array","items":{"$ref":"#/components/schemas/ChatCompletionResponseStreamChoice"}}}},"ChatCompletionResponseStreamChoice":{"type":"object","properties":{"index":{"type":"integer"},"delta":{"$ref":"#/components/schemas/StreamDelta"},"finish_reason":{"type":"string","enum":["stop","length","model_length","error","tool_calls",null],"nullable":true}}},"StreamDelta":{"type":"object","properties":{"role":{"type":"string","enum":["assistant"],"description":"The role of the message author, typically 'assistant'."},"content":{"type":"string","nullable":true,"description":"The content delta of the message."}}},"ErrorResponse":{"type":"object","required":["detail"],"properties":{"detail":{"type":"string","description":"A human-readable description of the error."}}}},"responses":{"UnauthorizedError":{"description":"API key is missing or invalid.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"InternalServerError":{"description":"An unexpected error occurred on the server.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"paths":{"/v1/chat/completions":{"post":{"summary":"OpenAI Compatible Chat Completions (Simple Chatbots)","description":"Provides a drop-in replacement for the OpenAI Chat Completions API, designed specifically for **Simple Chatbots** built in Waterflai. This endpoint is not intended for executing Chatflows or Workflows.\nYou can use this for both streaming and non-streaming responses.","tags":["OpenAI Compatible"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatCompletionRequest"}}}},"responses":{"200":{"description":"Successful response. The format depends on the `stream` parameter in the request.","content":{"application/json":{"schema":{"description":"The full completion response object (when `stream` is `false`).","$ref":"#/components/schemas/ChatCompletionResponse"}},"text/event-stream":{"schema":{"$ref":"#/components/schemas/ChatCompletionStreamResponse","description":"A stream of Server-Sent Events (SSE). Each event is a JSON object corresponding to the `ChatCompletionStreamResponse` schema. The stream is terminated by a `data: [DONE]` message."}}}},"401":{"$ref":"#/components/responses/UnauthorizedError"},"499":{"description":"Client Closed Request. This custom status code indicates an internal inference error occurred. It is used to prevent client-side retries for errors that have already been handled or retried internally.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"$ref":"#/components/responses/InternalServerError"}}}}}}
```
