Tiptap 简写

Alpha

Tiptap 简写是一种用于表示 Tiptap 文档的高效 Token 格式。与标准 JSON 相比,它可以将 AI Token 成本降低多达 80%,同时不损失准确性。

Alpha 版本

Tiptap 简写目前处于 alpha 开发阶段。在生产部署中,我们 建议使用 "json" 格式(Tiptap JSON)。我们建议你 先使用 JSON 格式构建应用,然后再考虑迁移到简写。


如果你对 Tiptap 简写带来的优势感兴趣,欢迎 联系我们

Set Up Tiptap Shorthand

By setting the format parameter in the JSON body, define the format that AI uses to read and edit documents. This parameter applies to all Server AI toolkit endpoints.

The default value of format is "json". To enable Tiptap shorthand, pass the format: "shorthand" parameter in all API requests.

For example, a request to fetch tool definitions:

curl -X POST https://api.tiptap.dev/v4/ai/toolkit/fetch-tools \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -d '{
    "format": "shorthand",
    "editorContext": {}
  }'

No other changes are required.

Format Consistency

Use the same format value in all API calls within the same conversation. Do not mix json and shorthand formats in a single AI interaction.

Tiptap 简写的工作原理

/v4/ai/toolkit/fetch-tools 端点会返回一个提示,告诉 AI 文档的结构以及它应该以何种格式生成。这包括对 AI 应如何生成文档内容的格式说明。该提示会向 AI 模型讲解语言规则和语法。

Tiptap 简写内容会被编码为一个文本字符串。与 Tiptap JSON 相比,无论是在字符数还是 token 数上,它都占用更少的空间。这在不更改 AI 模型的情况下,实现了速度提升和成本降低。

下一步

  • 查阅 API 参考,了解所有可用端点及其参数。