# Models

## The ExecutionRequest object

```json
{"openapi":"3.0.3","info":{"title":"Waterflai Public API","version":"v1"},"components":{"schemas":{"ExecutionRequest":{"type":"object","properties":{"input_data":{"type":"object","description":"A JSON object containing the input variables for the Chatflow or Workflow. The keys should match the names of the input nodes.","additionalProperties":true}}}}}}
```

## The ChatCompletionRequest object

```json
{"openapi":"3.0.3","info":{"title":"Waterflai Public API","version":"v1"},"components":{"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."}}}}}}
```

## The StreamDelta object

```json
{"openapi":"3.0.3","info":{"title":"Waterflai Public API","version":"v1"},"components":{"schemas":{"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."}}}}}}
```

## The ChatCompletionResponseStreamChoice object

```json
{"openapi":"3.0.3","info":{"title":"Waterflai Public API","version":"v1"},"components":{"schemas":{"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."}}}}}}
```

## The ChatCompletionStreamResponse object

```json
{"openapi":"3.0.3","info":{"title":"Waterflai Public API","version":"v1"},"components":{"schemas":{"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."}}}}}}
```

## The ChatMessage object

```json
{"openapi":"3.0.3","info":{"title":"Waterflai Public API","version":"v1"},"components":{"schemas":{"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."}}}}}}
```

## The UsageInfo object

```json
{"openapi":"3.0.3","info":{"title":"Waterflai Public API","version":"v1"},"components":{"schemas":{"UsageInfo":{"type":"object","properties":{"prompt_tokens":{"type":"integer"},"completion_tokens":{"type":"integer"},"total_tokens":{"type":"integer"}}}}}}
```

## The ResponseChatMessage object

```json
{"openapi":"3.0.3","info":{"title":"Waterflai Public API","version":"v1"},"components":{"schemas":{"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."}}}}}}
```

## The NodeExecutionInfo object

```json
{"openapi":"3.0.3","info":{"title":"Waterflai Public API","version":"v1"},"components":{"schemas":{"NodeExecutionInfo":{"type":"object","properties":{"duration":{"type":"number","format":"float","description":"Duration of the node execution in seconds."}}}}}}
```

## The NodeExecutionDetail object

```json
{"openapi":"3.0.3","info":{"title":"Waterflai Public API","version":"v1"},"components":{"schemas":{"NodeExecutionDetail":{"type":"object","properties":{"parameters":{"type":"object","additionalProperties":true,"description":"Input parameters for the node."},"execution_info":{"$ref":"#/components/schemas/NodeExecutionInfo"},"outputs":{"type":"object","additionalProperties":true,"description":"Output data from the node."}}},"NodeExecutionInfo":{"type":"object","properties":{"duration":{"type":"number","format":"float","description":"Duration of the node execution in seconds."}}}}}}
```

## The NodeExecutionResult object

```json
{"openapi":"3.0.3","info":{"title":"Waterflai Public API","version":"v1"},"components":{"schemas":{"NodeExecutionResult":{"type":"object","properties":{"node_id":{"type":"string"},"node_type":{"type":"string"},"execution_detail":{"$ref":"#/components/schemas/NodeExecutionDetail"},"error_occurred":{"type":"boolean"},"error_message":{"type":"string","nullable":true}}},"NodeExecutionDetail":{"type":"object","properties":{"parameters":{"type":"object","additionalProperties":true,"description":"Input parameters for the node."},"execution_info":{"$ref":"#/components/schemas/NodeExecutionInfo"},"outputs":{"type":"object","additionalProperties":true,"description":"Output data from the node."}}},"NodeExecutionInfo":{"type":"object","properties":{"duration":{"type":"number","format":"float","description":"Duration of the node execution in seconds."}}}}}}
```

## The ExecutionResult object

```json
{"openapi":"3.0.3","info":{"title":"Waterflai Public API","version":"v1"},"components":{"schemas":{"ExecutionResult":{"type":"object","description":"The detailed result from a synchronous execution.","properties":{"final_output":{"type":"object","additionalProperties":true,"description":"A JSON object containing the outputs from the designated output nodes."},"node_executions":{"type":"array","items":{"$ref":"#/components/schemas/NodeExecutionResult"},"nullable":true,"description":"A list of detailed execution results for each node, if requested."},"error_occurred":{"type":"boolean"},"error_message":{"type":"string","nullable":true}}},"NodeExecutionResult":{"type":"object","properties":{"node_id":{"type":"string"},"node_type":{"type":"string"},"execution_detail":{"$ref":"#/components/schemas/NodeExecutionDetail"},"error_occurred":{"type":"boolean"},"error_message":{"type":"string","nullable":true}}},"NodeExecutionDetail":{"type":"object","properties":{"parameters":{"type":"object","additionalProperties":true,"description":"Input parameters for the node."},"execution_info":{"$ref":"#/components/schemas/NodeExecutionInfo"},"outputs":{"type":"object","additionalProperties":true,"description":"Output data from the node."}}},"NodeExecutionInfo":{"type":"object","properties":{"duration":{"type":"number","format":"float","description":"Duration of the node execution in seconds."}}}}}}
```

## The ChatCompletionResponseChoice object

```json
{"openapi":"3.0.3","info":{"title":"Waterflai Public API","version":"v1"},"components":{"schemas":{"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."}}}}}}
```

## The ChatCompletionResponse object

```json
{"openapi":"3.0.3","info":{"title":"Waterflai Public API","version":"v1"},"components":{"schemas":{"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"}}}}}}
```

## The AsyncExecutionStartResponse object

```json
{"openapi":"3.0.3","info":{"title":"Waterflai Public API","version":"v1"},"components":{"schemas":{"AsyncExecutionStartResponse":{"type":"object","properties":{"execution_id":{"type":"string","description":"The unique identifier for this execution job."},"status_url":{"type":"string","format":"uri","description":"The URL to poll for the execution status."},"stream_url":{"type":"string","format":"uri","description":"The URL to stream real-time progress."},"cancel_url":{"type":"string","format":"uri","description":"The URL to cancel the execution."}}}}}}
```

## The ExecutionJobResponse object

```json
{"openapi":"3.0.3","info":{"title":"Waterflai Public API","version":"v1"},"components":{"schemas":{"ExecutionJobResponse":{"type":"object","properties":{"execution_id":{"type":"string"},"status":{"type":"string","enum":["PENDING","RUNNING","COMPLETED","FAILED","CANCELLED"]},"progress":{"type":"number","format":"float","description":"A value from 0.0 to 100.0 indicating the completion percentage."},"current_node":{"type":"string","nullable":true,"description":"The ID of the node currently being executed."},"completed_nodes":{"type":"integer"},"total_nodes":{"type":"integer"},"final_output":{"type":"object","nullable":true,"additionalProperties":true,"description":"The final result of the execution, available when status is `COMPLETED`."},"error_message":{"type":"string","nullable":true,"description":"Details about the error, available when status is `FAILED`."},"created_at":{"type":"string","format":"date-time"},"started_at":{"type":"string","format":"date-time","nullable":true},"completed_at":{"type":"string","format":"date-time","nullable":true},"retry_count":{"type":"integer"},"execution_source":{"type":"string","enum":["CHATBOT","STUDIO","API"]},"is_temporary":{"type":"boolean"},"cleanup_after":{"type":"string","format":"date-time","nullable":true}}}}}}
```

## The ExecutionCancelResponse object

```json
{"openapi":"3.0.3","info":{"title":"Waterflai Public API","version":"v1"},"components":{"schemas":{"ExecutionCancelResponse":{"type":"object","properties":{"execution_id":{"type":"string"},"cancelled":{"type":"boolean","description":"True if the cancellation was successful."},"message":{"type":"string","description":"A confirmation message."},"previous_status":{"type":"string","enum":["PENDING","RUNNING","COMPLETED","FAILED","CANCELLED"],"description":"The status of the job before cancellation was attempted."}}}}}}
```

## The ErrorResponse object

```json
{"openapi":"3.0.3","info":{"title":"Waterflai Public API","version":"v1"},"components":{"schemas":{"ErrorResponse":{"type":"object","required":["detail"],"properties":{"detail":{"type":"string","description":"A human-readable description of the error."}}}}}}
```

## The StreamEvent\_ExecutionStarted object

```json
{"openapi":"3.0.3","info":{"title":"Waterflai Public API","version":"v1"},"components":{"schemas":{"StreamEvent_ExecutionStarted":{"type":"object","properties":{"type":{"type":"string","enum":["execution_started"]},"timestamp":{"type":"string","format":"date-time"}}}}}}
```

## The StreamEvent\_NodeStarted object

```json
{"openapi":"3.0.3","info":{"title":"Waterflai Public API","version":"v1"},"components":{"schemas":{"StreamEvent_NodeStarted":{"type":"object","properties":{"type":{"type":"string","enum":["node_started"]},"node_id":{"type":"string"},"node_label":{"type":"string"},"node_type":{"type":"string"},"timestamp":{"type":"string","format":"date-time"}}}}}}
```

## The StreamEvent\_NodeCompleted object

```json
{"openapi":"3.0.3","info":{"title":"Waterflai Public API","version":"v1"},"components":{"schemas":{"StreamEvent_NodeCompleted":{"type":"object","properties":{"type":{"type":"string","enum":["node_completed"]},"node_id":{"type":"string"},"node_label":{"type":"string"},"node_type":{"type":"string"},"timestamp":{"type":"string","format":"date-time"}}}}}}
```

## The StreamEvent\_NodeSkipped object

```json
{"openapi":"3.0.3","info":{"title":"Waterflai Public API","version":"v1"},"components":{"schemas":{"StreamEvent_NodeSkipped":{"type":"object","properties":{"type":{"type":"string","enum":["node_skipped"]},"node_id":{"type":"string"},"node_label":{"type":"string"},"node_type":{"type":"string"},"reason":{"type":"string","description":"Reason why the node was skipped (e.g., Condition not met)."},"timestamp":{"type":"string","format":"date-time"}}}}}}
```

## The StreamEvent\_NodeError object

```json
{"openapi":"3.0.3","info":{"title":"Waterflai Public API","version":"v1"},"components":{"schemas":{"StreamEvent_NodeError":{"type":"object","properties":{"type":{"type":"string","enum":["node_error"]},"node_id":{"type":"string"},"node_label":{"type":"string"},"error":{"type":"string","description":"The error message from the node."},"timestamp":{"type":"string","format":"date-time"}}}}}}
```

## The StreamEvent\_ExecutionCompleted object

```json
{"openapi":"3.0.3","info":{"title":"Waterflai Public API","version":"v1"},"components":{"schemas":{"StreamEvent_ExecutionCompleted":{"type":"object","properties":{"type":{"type":"string","enum":["execution_completed"]},"final_output":{"type":"object","additionalProperties":true,"description":"The final computed output of the entire flow."},"workflow_execution":{"$ref":"#/components/schemas/ExecutionResult"},"timestamp":{"type":"string","format":"date-time"}}},"ExecutionResult":{"type":"object","description":"The detailed result from a synchronous execution.","properties":{"final_output":{"type":"object","additionalProperties":true,"description":"A JSON object containing the outputs from the designated output nodes."},"node_executions":{"type":"array","items":{"$ref":"#/components/schemas/NodeExecutionResult"},"nullable":true,"description":"A list of detailed execution results for each node, if requested."},"error_occurred":{"type":"boolean"},"error_message":{"type":"string","nullable":true}}},"NodeExecutionResult":{"type":"object","properties":{"node_id":{"type":"string"},"node_type":{"type":"string"},"execution_detail":{"$ref":"#/components/schemas/NodeExecutionDetail"},"error_occurred":{"type":"boolean"},"error_message":{"type":"string","nullable":true}}},"NodeExecutionDetail":{"type":"object","properties":{"parameters":{"type":"object","additionalProperties":true,"description":"Input parameters for the node."},"execution_info":{"$ref":"#/components/schemas/NodeExecutionInfo"},"outputs":{"type":"object","additionalProperties":true,"description":"Output data from the node."}}},"NodeExecutionInfo":{"type":"object","properties":{"duration":{"type":"number","format":"float","description":"Duration of the node execution in seconds."}}}}}}
```

## The StreamEvent\_ExecutionError object

```json
{"openapi":"3.0.3","info":{"title":"Waterflai Public API","version":"v1"},"components":{"schemas":{"StreamEvent_ExecutionError":{"type":"object","properties":{"type":{"type":"string","enum":["execution_error"]},"error":{"type":"string","description":"A fatal error that stopped the execution."},"timestamp":{"type":"string","format":"date-time"}}}}}}
```

## The StreamEvent object

```json
{"openapi":"3.0.3","info":{"title":"Waterflai Public API","version":"v1"},"components":{"schemas":{"StreamEvent":{"oneOf":[{"$ref":"#/components/schemas/StreamEvent_ExecutionStarted"},{"$ref":"#/components/schemas/StreamEvent_NodeStarted"},{"$ref":"#/components/schemas/StreamEvent_NodeCompleted"},{"$ref":"#/components/schemas/StreamEvent_NodeSkipped"},{"$ref":"#/components/schemas/StreamEvent_NodeError"},{"$ref":"#/components/schemas/StreamEvent_ExecutionCompleted"},{"$ref":"#/components/schemas/StreamEvent_ExecutionError"}],"discriminator":{"propertyName":"type"}},"StreamEvent_ExecutionStarted":{"type":"object","properties":{"type":{"type":"string","enum":["execution_started"]},"timestamp":{"type":"string","format":"date-time"}}},"StreamEvent_NodeStarted":{"type":"object","properties":{"type":{"type":"string","enum":["node_started"]},"node_id":{"type":"string"},"node_label":{"type":"string"},"node_type":{"type":"string"},"timestamp":{"type":"string","format":"date-time"}}},"StreamEvent_NodeCompleted":{"type":"object","properties":{"type":{"type":"string","enum":["node_completed"]},"node_id":{"type":"string"},"node_label":{"type":"string"},"node_type":{"type":"string"},"timestamp":{"type":"string","format":"date-time"}}},"StreamEvent_NodeSkipped":{"type":"object","properties":{"type":{"type":"string","enum":["node_skipped"]},"node_id":{"type":"string"},"node_label":{"type":"string"},"node_type":{"type":"string"},"reason":{"type":"string","description":"Reason why the node was skipped (e.g., Condition not met)."},"timestamp":{"type":"string","format":"date-time"}}},"StreamEvent_NodeError":{"type":"object","properties":{"type":{"type":"string","enum":["node_error"]},"node_id":{"type":"string"},"node_label":{"type":"string"},"error":{"type":"string","description":"The error message from the node."},"timestamp":{"type":"string","format":"date-time"}}},"StreamEvent_ExecutionCompleted":{"type":"object","properties":{"type":{"type":"string","enum":["execution_completed"]},"final_output":{"type":"object","additionalProperties":true,"description":"The final computed output of the entire flow."},"workflow_execution":{"$ref":"#/components/schemas/ExecutionResult"},"timestamp":{"type":"string","format":"date-time"}}},"ExecutionResult":{"type":"object","description":"The detailed result from a synchronous execution.","properties":{"final_output":{"type":"object","additionalProperties":true,"description":"A JSON object containing the outputs from the designated output nodes."},"node_executions":{"type":"array","items":{"$ref":"#/components/schemas/NodeExecutionResult"},"nullable":true,"description":"A list of detailed execution results for each node, if requested."},"error_occurred":{"type":"boolean"},"error_message":{"type":"string","nullable":true}}},"NodeExecutionResult":{"type":"object","properties":{"node_id":{"type":"string"},"node_type":{"type":"string"},"execution_detail":{"$ref":"#/components/schemas/NodeExecutionDetail"},"error_occurred":{"type":"boolean"},"error_message":{"type":"string","nullable":true}}},"NodeExecutionDetail":{"type":"object","properties":{"parameters":{"type":"object","additionalProperties":true,"description":"Input parameters for the node."},"execution_info":{"$ref":"#/components/schemas/NodeExecutionInfo"},"outputs":{"type":"object","additionalProperties":true,"description":"Output data from the node."}}},"NodeExecutionInfo":{"type":"object","properties":{"duration":{"type":"number","format":"float","description":"Duration of the node execution in seconds."}}},"StreamEvent_ExecutionError":{"type":"object","properties":{"type":{"type":"string","enum":["execution_error"]},"error":{"type":"string","description":"A fatal error that stopped the execution."},"timestamp":{"type":"string","format":"date-time"}}}}}}
```
