POST/api/v1/ai/pages/{slug}/write

Write with a prompt

Writes new Markdown for a page you can edit, from prompt and the text around the cursor. Streams the result as server-sent events: delta events with text as it's written, then done (or limit when a limit stops it). Nothing changes on the page: the result is a suggestion.

API token requiredOr edit secret60 per minute per IP

Guide: AI in pages

Code samples and Try it

Path parameters

#
  • slugstringRequired

    The document's address: the part after markdrop.in/.

Headers

#
  • X-Edit-Secretstring

    The document's edit secret (sk_…), for a document published without an account. See Edit key.

Request body

#

application/json, required

  • promptstringRequired

    What to write. Up to 2,500 characters.

  • beforestring

    Text just before the cursor, for context. Up to 2,000 characters.

  • afterstring

    Text just after the cursor, for context. Up to 2,000 characters.

Responses

#
  • 200OK.
  • 401No token, or the token is revoked or mistyped.
  • 422The request didn't validate. detail lists each problem, with where it is (loc) and why (msg).
  • 429Too many requests from your IP address. Wait the seconds in Retry-After.
Did this page help?