You pay by the hour for the required skills (developer, architect, QA specialist, etc.), labor (hours needed), and materials used (paid software, cloud resources). If they finish sooner or use fewer materials, the cost decreases.
When does it make sense? You have a complex product or system, the scope of what should be done changes as you learn, and you want to start sooner.
What should you ask the vendor for? A rate card by role and seniority to model your budget and ensure the vendor cannot arbitrarily change the hourly price once work starts, examples of time and expense reports to verify that their reports are detailed enough to allow you to audit the charges, a proposal for governance and metrics like tasks completed per week to measure outcomes rather than just effort, and rules for replacing underperforming people at no extra cost to defend against paying for low productivity.
What should you put in the contract? Monthly and phase budgets, rules for extra hours and team changes, including the process for scaling the team up or down and rules about the vendor swapping personnel without the client's consent, time reporting standards (format, frequency, and granularity of the time logs, as well as data access within the vendor's tracking system), intellectual property (it dictates that all work created by the vendor (code, designs, documentation) becomes the exclusive property of the client upon payment), and security and confidentiality rules (NDA, data protection, and privacy).