Editing Pattern
To edit an artifact, you call the same Artifact API endpoint used for generation. The key difference is the structure of themessages array, which must contain two messages in this specific order:
- An
assistantmessage: Thecontentof this message must be the full artifact content string of the document you want to edit. - A
usermessage: Thecontentof this message is your new prompt with the editing instructions, for example, “Add a slide about our key competitors” or “Change the title to ‘Q4 Financial Report’”.
metadata object (with the c1_artifact_type) should be included just as it was in the original generation call to ensure the context is maintained.
Full Example: Adding a Slide to a Presentation
This example shows the complete workflow for adding a new slide to an existing presentation.src/app/api/edit-slides/route.ts