First create a new chat: POST /api/v1/chats/new  Content-Type: application/json  { "chat": { "id": "", "title": "New Chat", "models":["your_model:latest"], "params": {}, "history": { "messages": {}, "currentId": null }, "messages": [], "tags": [],"timestamp":  } } Then add messages: POST /api/v1/chats/{chat_id}  Content-Type: application/json  { "chat": { "models": ["your_model:latest"], "messages": [ {"id": "", "parentId": null, "childrenIds": [], "role": "user", "content": "Your message here", "timestamp":, "models": ["your_model:latest"] } ], "history": { "messages": { "": { "id": "", "parentId": null, "childrenIds": [], "role": "user", "content": "Your message here", "timestamp":, "models": ["your_model:latest"] } }, "currentId": "" } } } Make a completion request: POST /api/chat/completions  Content-Type: application/json  { "stream": true, "model": "your_model:latest", "messages": [{ "role": "user", "content": "Your message here" } ], "params": { "num_ctx": 8192 }, "chat_id": "", "id": "" } And then update the chat: POST /api/v1/chats/{chat_id}  Content-Type: application/json  { "chat": { "models": ["your_model:latest"], "messages": [// Previous messages... { "id": "", "parentId": null, "childrenIds": [""],"role": "user", "content": "Your message", "timestamp": , "models": ["your_model:latest"] }, { "id": "", "parentId": "", "childrenIds": [], "role": "assistant", "content":"Assistant's response", "model": "your_model:latest", "timestamp":  } ], "history": { "messages": { // Include both messages here in the same format }, "currentId": "" } } }