/api/generate endpoint returns different response formats depending on the mode:
- Initial Generation: Streaming SSE response
- Follow-up Edits: JSON response
Follow-up Edit Response
WhenisFollowUp is true, the endpoint returns a JSON response.
TypeScript Interface
Response Fields
The complete generated or edited animation code.Always includes imports and exports. Ready to use in Remotion.
A brief 1-sentence summary of what changes were made.Examples:
"Changed background color to blue and increased font size""Created a countdown timer with spring animations"
Metadata about the generation process and detected skills.
Array of skill names that were detected and applied for this generation.Examples:
["chart", "3d"], ["text-animation"], []Indicates how the code was modified:
"tool_edit": Targeted edits were applied to existing code"full_replacement": Complete code was regenerated
Array of edit operations that were applied. Only present when
editType is "tool_edit".Each edit operation contains:description: Brief description of the edit (e.g., “Update background color”)old_string: The exact string that was replacednew_string: The replacement stringlineNumber: Line number where the edit was applied (optional)
The model name that was used for generation (e.g.,
"gpt-5.2").Initial Generation Response
For initial generation (whenisFollowUp is false), the endpoint returns a streaming response. See Streaming for details.
Example Responses
Successful Edit with Targeted Changes
Full Replacement Response
Error Responses
Missing API Key
400
Validation Error
400
Edit Failed
400
Ambiguous Edit
400
When an edit fails due to ambiguity, the client should retry with error correction context to help the AI provide more specific targeting.
Generic Server Error
500