Designing a mandatory input field with options

Are there any guidelines on how to present a mandatory input field which can either take in user input or be generated for the user?

(Example - A mandatory promo code field which can both take in user input OR generate it for the user incase they fail to provide one. )

I'm not sure which of the following would be easier for the user to understand:

Option 1: enter image description here

Present it upfront and provide an option to generate it for them incase the user doesn't have it.

Option 2: enter image description here

Provide it as a radio button and incase they don't opt for it, auto generate the number for them once they submit the form.