In this letter, we present real-time collision-free inverse kinematics (RCIK) that accurately performs consecutively provided six-degrees-of-freedom commands in environments containing static and dynamic obstacles. Our method is based on an optimization-based IK approach to generate IK candidates with high feasibility for the command. While checking various constraints (e.g., collision and joint velocity limits), we select the best configuration among generated IK candidates through our objective function, considering the continuity of joints and collision avoidance with obstacles. To avoid dynamic obstacles efficiently, we propose a novel, collision-cost prediction network (CCPN) that estimates collision costs using an occupancy grid updated from sensor data in real-time. We evaluate our method in three dynamic problems using a real robot, the Fetch manipulator, and four static problems using three different configurations of robots. We show that the proposed method successfully performs the consecutively given commands in real-time, mainly thanks to the collision-cost prediction network, while avoiding dynamic and static obstacles. The results of tested problems are available in the accompanying video.