39.2 Prompt "APIs": stable interfaces between app and model

Overview and links for this section of the guide.

Prompts as Contracts

Treat your prompt like an API endpoint. - **Inputs:** What variables does it take? `{{user_query}}`, `{{file_context}}`. - **Outputs:** What schema does it return? `z.object({ code: z.string() })`. - **Tests:** Golden inputs that MUST pass.

Versioning

Do not edit prompts in place. Use `v1`, `v2`, `v3`.

If you change the prompt to "Make it funnier," you might break the JSON output for the billing system. Versioning allows you to roll back instantly.

Where to go next