'POST required.']); exit; } $input = json_decode(file_get_contents('php://input'), true); if (!is_array($input)) { echo json_encode(['error' => 'Invalid JSON.']); exit; } $config = readConfig(); $config['defaultModel'] = isset($input['defaultModel']) ? (string) $input['defaultModel'] : ''; if (!writeConfig($config)) { echo json_encode(['error' => 'Unable to save config.']); exit; } echo json_encode(['success' => true, 'defaultModel' => $config['defaultModel']]); exit; default: echo json_encode(['error' => 'Unknown action.']); exit; }