| 1 | --- |
| 2 | title: Apply Role |
| 3 | description: Apply model role |
| 4 | keywords: [apply, model, role] |
| 5 | sidebar_position: 4 |
| 6 | --- |
| 7 | |
| 8 | When editing code, Chat and Edit model output often doesn't clearly align with existing code. A model with the `apply` role is used to generate a more precise diff to apply changes to a file. |
| 9 | |
| 10 | ## Recommended Apply models |
| 11 | |
| 12 | <Info> |
| 13 | For the latest Apply model recommendations, see our [comprehensive model recommendations](/customization/models#recommended-models). |
| 14 | </Info> |
| 15 | |
| 16 | We recommend [Morph Fast Apply](https://morphllm.com) or [Relace's Instant Apply model](https://hub.continue.dev/relace/instant-apply) for the fastest Apply experience. You can sign up for Morph's free tier [here](https://morphllm.com/dashboard) or get a Relace API key [here](https://app.relace.ai/settings/api-keys). |
| 17 | |
| 18 | However, most Chat models can also be used for applying code changes. We recommend smaller/cheaper models for the task, such as Claude 3.5 Haiku. |
| 19 | |
| 20 | <Info> |
| 21 | Explore all apply models in [the |
| 22 | Hub](https://hub.continue.dev/explore/models?roles=apply) |
| 23 | </Info> |
| 24 | |
| 25 | ## Prompt templating |
| 26 | |
| 27 | You can customize the prompt template used for applying code changes by setting the `promptTemplates.apply` property in your model configuration. Continue uses [Handlebars syntax](https://handlebarsjs.com/guide/) for templating. |
| 28 | |
| 29 | Available variables for the apply template: |
| 30 | |
| 31 | - `{{{original_code}}}` - The original code before changes |
| 32 | - `{{{new_code}}}` - The new code after changes |
| 33 | |
| 34 | Example: |
| 35 | |
| 36 | ```yaml |
| 37 | models: |
| 38 | - name: My Custom Apply Template |
| 39 | provider: anthropic |
| 40 | model: claude-3-5-sonnet-latest |
| 41 | promptTemplates: |
| 42 | apply: | |
| 43 | Original: {{{original_code}}} |
| 44 | New: {{{new_code}}} |
| 45 | |
| 46 | Please generate the final code without any markers or explanations. |
| 47 | ``` |