slideshowAssistant procedure sends a user message to the Anthropic Claude API and returns a structured patch result that describes the changes the assistant wants to make to the current slideshow or slide.
The assistant does not mutate data directly — it returns a patchResult that your application applies to the local state.
Request
POST /rpc/slideshowAssistant
Input
All current slideshows. The assistant uses this to understand the full context of the presentation. See the Slideshow type reference.
Zero-based index of the active slideshow within the
slideshows array. The assistant focuses its changes on this slideshow.Zero-based index of the active slide within the current slideshow’s
slides array. Used to target slide-level edits.The natural language request from the user. For example:
"Add a KPI block showing revenue of $2.4M" or "Rewrite the explainer to be more concise".Optional conversation history for multi-turn interactions. Each message has a
role ("user", "assistant", or "system") and a content string.Pass the messages from previous turns to maintain context across multiple requests. The current userInput is automatically appended — do not include it here.Controls how much of the slideshow is sent to the AI model:
true— sends the full slideshow (all slides and concepts) as context. Use this for structural changes, adding new slides, or requests that reference multiple slides.false— sends only the current slide. Use this for targeted edits to a single slide. Results in lower token usage and faster responses.
Response
The raw text response from the AI model, including any reasoning or explanation the assistant provided alongside the patch.
true if the model’s response was cut off because it hit the max_tokens limit. If truncated, the patchResult may be incomplete or invalid.A snapshot of the slideshow state at the time the request was processed. Used to detect drift when applying the returned patch.
The outcome of the assistant’s attempt to generate a patch. This is a discriminated union with three possible statuses.
Errors
| Code | Description |
|---|---|
API_KEY_MISSING | No Anthropic API key is configured on the server. Set ANTHROPIC_API_KEY in the server environment. |
ANTHROPIC_API_ERROR | The Anthropic API returned an error. The error data includes status (HTTP status code) and details. |
ANTHROPIC_RATE_LIMITED | The Anthropic API rate limit was exceeded. The error data includes retryAfter (seconds until retry is allowed, if provided by Anthropic). |
INVALID_RESPONSE | The AI service returned a response with no text content. The error data includes reason. |
PATCH_GENERATION_FAILED | The assistant’s response could not be turned into a valid patch result. The error data includes reason. |
Examples
Best practices
ChoosinguseFullContext
Use useFullContext: false (current slide only) when:
- Editing content on a single slide (adding blocks, rewording text)
- Making targeted style or data changes
- You want faster responses and lower token consumption
useFullContext: true (full slideshow) when:
- Adding a new slide or reordering slides
- Asking the assistant to maintain consistency across slides (e.g., matching a concept)
- The request references other slides (e.g., “make this slide consistent with slide 3”)
previousMessages to give the assistant context from prior turns. Build the array by alternating user and assistant messages, where each assistant entry is the assistantText from the prior response. This keeps the conversation coherent for multi-step editing sessions.
Handling patchResult statuses
Always check patchResult.status before attempting to apply changes:
"ok"— apply thetransactionto your state"invalid"— show the user an error; logerrorsfor debugging"noop"— inform the user the assistant made no changes (and optionally why)