People in some Libyan detention centres do not have access to clean water or medical facilities and they are often crammed into small spaces.
"Some detention centres are OK, but, for sure, in some others the conditions are not acceptable for people to be able to live with dignity," Aurélien Sigwalt of the field coordinator of Doctors Without Borders (MSF) in Misrata, in the north-west of the country, told RFI.
In some detention centres it can be difficult for MSF to have access to the whole centre.
"But as doctors, we see the conditions in which the patients - for us they're patients, not detainees - are," Sigwalt says. "And sometimes, they're really sick and need urgent care, sometimes they need to be brought to a hospital."
Doctors can tell just how harsh the conditions are just by seeing the patient.
"Physically, it's hard. But, of course, mentally as well. Some people come for consultations but they're not really sick. They just need to speak, talk to someone coming from the outside."
Some do not understand why they're in detained in these centres, Sigwalt adds.
Refugees locked up
In Libya undocumented immigration is a crime, regardless of why you have entered the country. So, even if you are fleeing conflict, if caught you are bound to be detained.
"Migrants shouldn't be seen as criminals. We are against people being locked up, who have not committed any crime. Refugees and asylum seekers are not illegal immigrants, they have asked for protection from the authorities," William Spindler, the UNHCR's Senior Communications Officer for North Africa, told RFI.
If returned to their own countries, they will face persecution, torture, human rights violations or even death, he says.
"Seeking asylum is not a crime. So people shouln't be put in detention, simply for the fact that they have fled their country seeking protection."
It is difficult to say what can be done to improve the situation because Libya lacks an effective government and it is hard for NGOs to operate under the conditions there.
Militias detain immigrants
"The Libyan government should be pushed to decriminalise illegal migration, so that there is no more peg, so to speak, for militias to arrest and detain migrants," says Mattia Toaldo, a Libya expert with the European Council on Foreign Relations.
He says that a proper registration process should be put in place.
"We often hear of numbers of migrants who are rescued by the coastguards. These numbers should be taken with a pinch of salt, because no one actually registers them."
First there's a need for the basics, then other frameworks can be envisaged, according to Toaldo.
Focus on south
But Claudia Gazzini, from the International Crisis Group, says that without a functioning parliament it will be difficult to draw up any sort of legal framework for migrants in Libya.
She says the problem should be tackled another way.
Most detention centres are in the north of the country. But people arrive from the south. Gazzini says that in order to stem that flow, more efforts need to be focused on the south.
"To stop the migrant flows to Libya, we first of all need to deal with the economic problems of the country, because people are in the business of smuggling humans, because the country is falling rapidly into a deep economic crisis," Gazzini says.
"And for many communities, especially in the south, human smuggling is the business that gives them hard cash. Quickly."
People-smuggling is a business in Libya. In the south there is profit to be made by bringing the migrants into the country and in the north there is profit to be made by helping them leave.
To stop this happening, Gazzini says, there is a need to think about major economic development projects, in the south and across the country.
The international community needs to find long-term solutions rather than the quick fixes we have been seeing so far, she argues.