Is there anway to get API access without spending a fortune?

Hello,

I've been using cursor for months with my project but finding it having to many problems lately.

I've always been told you would get better value/understanding/working code from API but that the cost is very high for each message.

Is there anyway to get access to API that it's affordable?