- Replace /api/generate with /api/chat endpoint - Send messages as proper list with role/content structure - Preserve multi-turn semantics (system/user/assistant roles) - Compatible with OpenAI-compatible endpoints - Filter invalid message roles before sending