Prompt-based editing allows you to modify an artifact by making a new API call that includes the existing artifact content as context, along with a new prompt describing the desired modifications. Instead of regenerating a document from scratch, you provide editing instructions in a follow-up prompt.Documentation Index
Fetch the complete documentation index at: https://docs.thesys.dev/llms.txt
Use this file to discover all available pages before exploring further.
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