This article reviews recent studies on cosmic rays originating in the heliosphere with emphasis on the role played by solar flares. In the first part, the physical drivers for high-energy particle acceleration in the heliosphere including solar flares, coronal mass ejections (CMEs), corotating interaction regions (CIR) and solar wind termination shocks are briefly discussed. We then introduce solar particle acceleration mechanisms in which shocks, turbulence, Alfvén waves, and magnetic reconnection respectively play a role. It is demonstrated that the properties of accelerated particles in the Sun are known in considerable detail because magnetic reconnection geometry is visible through electromagnetic radiations, and imaging spectroscopy at hard X-ray and radio wavelengths is available. In the second part, we attempt to relate our knowledge of solar flare particles to several research topics on solar energetic particles (SEPs). The topics include: (1) possible influence of solar magnetic field structure upon the energy spectra and time profiles of the resulting SEPs, (2) temporal, spatial and spectral properties of SEP electrons measured in interplanetary space in comparison with those remotely observed in the Sun, and (3) the energydependent onset time of SEP protons and its implication on the proton acceleration beyond the Sun. It is argued that we should take advantage of solar imaging spectroscopy at X-ray and radio wavelengths to complement the cosmic ray studies largely based on in-situ observations in order to disentangle the roles played by solar flares and CMEs in accelerating SEPs and better understand the relationship between solar flares and SEPs.