غزل
حساب کاربری

مستندات · نسخه‌ی Markdown

برای مدل‌های زبانی

غزل را به عامل هوش مصنوعی‌تان بدهید تا فارسی درست‌تری بنویسد: روال کار، آنچه نباید درست شود، متنی برای پرامپت سیستمی و تعریف ابزار.

عامل هوش مصنوعی نثر فارسی را که نوشته‌ای یا ویرایش کرده‌ای پیش از تحویل به fix غزل بده: {“text”: “<متن>”, “apply”: “house”}. برای Markdown، format: markdown بفرست؛ اگر فارسی گفتاری خواسته شده، kind: colloquial و اگر متن از پیش «خانهٔ» می‌نویسد، style: academy. متن برگشتی را به کار ببر. درباره‌ی توصیه‌ها و حدس‌های املایی در left تصمیم بگیر؛ حدس را فقط وقتی بپذیر که مطمئنی همان واژه را می‌خواستی. نقل‌قول، نام‌ها، شعر، کد و نشانی‌ها را تغییر نده. فقط نثر خودت را بفرست؛ اگر متن چنین بخش‌هایی دارد، check را صدا بزن و پیشنهادهای بیرون از آن‌ها را اعمال کن. فقط اگر متن را تغییر دادی، دوباره fix را اجرا کن.

هر متن فارسی را پیش از تحویل با ابزار غزل درست کن: POST https://ghazalai.ir/api/v1/fix با بدنه‌ی JSON {"text": "<متن>"} و سرآیند Authorization: Bearer gz_...؛ اگر متن Markdown است، "format": "markdown" را هم بفرست. "text" پاسخ را به‌جای متن خودت بگذار. در "left"، پیشنهادهای style و advice اختیاری‌اند و پیشنهادهای spell.* و guess را فقط وقتی بپذیر که مطمئنی. نقل‌قول، نام‌ها، شعر و کد را نفرست و تغییر نده. برای متن بلند، همان متن اولیه را با from: checked_to بفرست تا بررسی به پایان برسد. اگر پاسخ 429 یا 503 بود، به اندازه‌ی Retry-After ثانیه صبر کن.

سند بلند

با کلید طرح شخصی یا بسته، fix و check متن تا ۲۰۰٬۰۰۰ نویسه می‌پذیرند و بخش‌بخش پاسخ می‌دهند. تا وقتی checked_to به پایان متن نرسیده، همان متن اولیه را با from: checked_to بفرستید و text پاسخ‌ها را بی هیچ فاصله‌ای پشت هم بگذارید. fix.py در پوشه‌ی مهارت همین کار را می‌کند. سند بلند

متن نوشته‌شده با مدل زبانی

برای فارسی‌ای که مدل زبانی نوشته، "profile": "llm" را به check، fix، check_persian یا fix_persian بدهید. برای نثر صمیمی با صورت‌های نوشتاری، "kind": "formal" و برای متن گفتاری، "kind": "colloquial" بفرستید. این تنظیم تشخیص نوع متن را عوض نمی‌کند.

{"text": "این سوال می‌باشد.", "profile": "llm", "kind": "formal"}

پیش از انتخاب سطح هر قاعده، نمونه‌ای از پیشنهادهایش را خواندم. این تنظیم قاعده‌ها و سطحشان را تعیین می‌کند. تشخیص قاعده، جای پیشنهاد و صورت پیشنهادی همان می‌ماند. اگر profile را نفرستید، پاسخ مثل قبل است.

precision در نمونه‌ی خوانده‌شده سطح
دست‌کم ۹۵٪ error
دست‌کم ۸۵٪ و کمتر از ۹۵٪ advice
کمتر از ۸۵٪ یا بی‌نمونه حذف

یافته‌های سبکی، که هر دو صورت در آن‌ها درست است، style می‌مانند و apply: house مثل قبل اصلاحشان می‌کند. سطح‌ها را از همان متن‌هایی انتخاب کردم که پیشنهادها را در آن‌ها خواندم؛ روی متن‌های جداگانه نسنجیده‌ام. بعضی قاعده‌ها فقط یک یا دو نمونه داشتند.

ابتدا house ترجیح‌های نوشتاری را تعیین می‌کند و سپس profile پیشنهادها را محدود می‌کند. only از قاعده‌های این مجموعه انتخاب می‌کند، disable قاعده‌ها را حذف می‌کند و min_severity سطح تازه را می‌سنجد. هیچ‌کدام قاعده‌ای بیرون از این مجموعه اضافه نمی‌کند. max_findings مثل قبل شمار پیشنهادهای مانده را محدود می‌کند. برای نمونه، house.quotes: keep تغییر گیومه را کنار می‌گذارد. house.ezafe: hamza املای فرهنگستان را انتخاب می‌کند؛ قاعده‌ی اضافه‌ی آن در این مجموعه نیست.

fix برای apply همین سطح‌ها را به کار می‌برد. sure خطاهای دارای پیشنهاد را اصلاح می‌کند، به‌جز spell.*. house یافته‌های سبکی با یک پیشنهاد را هم اصلاح می‌کند. all توصیه‌ها و پیشنهادهای املایی را هم اعمال می‌کند. یافته‌هایی که پیشنهاد اصلاح ندارند، در left می‌مانند؛ پیش از تحویل درباره‌شان تصمیم بگیرید.

قاعده‌های سه‌نقطه، رقم لاتین و فاصله‌ی نشانه‌گذاری در این مجموعه نیستند. جای خالی فرم‌ها، ایموجی و نقل‌قول انگلیسی باعث شد پیشنهادهای نادرستشان زیاد باشد. انتخاب از قاعده‌های موجود، قاعده‌ای برای گرته‌برداری اضافه نمی‌کند.

شناسه و سطح قاعده‌ها در جدول صفحه‌ی انگلیسی آمده است.

تعریف ابزارها

یکی از دو بلوک tools را در درخواست خود بگذارید. هر کدام ghazal_fix و ghazal_check دارد؛ آرگومان‌هایشان را به /api/v1/fix و /api/v1/check بفرستید. توضیح‌ها و schema از OpenAPI می‌آیند. برای ساختن دوباره‌ی بلوک‌ها، از ریشه‌ی مخزن python scripts/build_agent_tools.py را اجرا کنید.

OpenAI

{
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "ghazal_fix",
        "description": "Returns the text corrected. `applied` lists what was changed (offsets into the text sent; the first suggestion\nwas used), `left` what is still worth a look (offsets into the returned text). With `apply: sure` only errors\nthat have a suggestion and are not spelling guesses (`spell.*`) are applied.\n`apply: house` also applies style findings with exactly one suggestion, never spelling guesses or advice.\nWith `profile: llm`, these choices use the profile's levels; style findings stay style, and `spell.*` still needs `apply: all`.\nFor short texts, fixing the returned text again changes nothing. With `format: markdown` code, URLs and markup come back unchanged.\nFor a document over 20,000 characters, `text` is the corrected range from `from` to `checked_to`.\n`applied` points into the original complete text; `left` points into this answer's corrected `text`, using `offsets`.\nAppend each returned `text` without separators; add the length already joined, in `offsets`, to each new `left` offset.\nA finding crossing a cut keeps its full `end`, which may exceed `checked_to` for `applied` or the returned text's length for `left`.\nSend the same original text and options with `from: checked_to` until the end. Only the checked range is charged.\nShort texts have no `checked_to`.\nWith `compact`, `applied` and `left` are lines as in `check`'s compact answer\n(`applied` without `@start`).",
        "parameters": {
          "properties": {
            "style": {"type": "string", "enum": ["ghazal", "academy"], "title": "Style", "description": "`ghazal`: Ghazal's house style. `academy`: the spelling rules of the Academy of Persian Language and Literature.", "default": "ghazal"},
            "house": {"anyOf": [{"properties": {"ezafe": {"anyOf": [{"type": "string", "enum": ["ye", "hamza"]}, {"type": "null"}], "title": "Ezafe", "description": "`ye`: خانه‌ی (`style: ghazal`); `hamza`: خانهٔ (`style: academy`). Omit to follow `style`. If both are sent, they must agree."}, "digits": {"type": "string", "enum": ["persian", "latin", "keep"], "title": "Digits", "description": "`persian`: ۱۲۳; `latin`: replace Persian and Arabic-Indic digits with 123 in Persian prose, outside code, URLs, Latin text and anything Markdown skips; `keep`: leave digits as written.", "default": "persian"}, "quotes": {"type": "string", "enum": ["guillemets", "keep"], "title": "Quotes", "description": "`guillemets`: «» for Persian quotations; `keep`: leave quotation marks as written.", "default": "guillemets"}}, "additionalProperties": false, "type": "object", "title": "House"}, {"type": "null"}], "description": "Optional writing preferences. Omit this object to keep the existing behaviour; omitted keys keep their defaults."},
            "words": {"items": {"type": "string", "maxLength": 60, "minLength": 1, "pattern": "^(?:[^\\W_]|[ً-ٰٟـ])+(?:‌(?:[^\\W_]|[ً-ٰٟـ])+)*$"}, "type": "array", "maxItems": 500, "title": "Words", "description": "Personal words, at most 500 entries of one word each, at most 60 characters, without spaces. Matching uses the spell checker's folding of Arabic letters, half-spaces and marks. Only spell.* and confuse.* findings are hidden. Omit or send [] to keep the existing answers.", "default": []},
            "text": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Text", "description": "The text to check: up to 200,000 characters with a personal plan, corporate plan or pack, otherwise 20,000. Send `text` or `texts`, not both."},
            "texts": {"anyOf": [{"items": {"type": "string"}, "type": "array"}, {"type": "null"}], "title": "Texts", "description": "Several texts, at most 20,000 characters in all with a newline between each, checked one by one; the answer has `results` in the same order."},
            "from": {"type": "integer", "minimum": 0.0, "title": "From", "description": "Resume at a previous `checked_to`, in Unicode code points. Send the same complete text and options; omit on the first call.", "default": 0},
            "kind": {"type": "string", "enum": ["auto", "formal", "mixed", "colloquial"], "title": "Kind", "description": "What kind of Persian the text is. `auto` decides from the words; spoken forms are flagged only in `formal` text.", "default": "auto"},
            "offsets": {"type": "string", "enum": ["utf16", "codepoint"], "title": "Offsets", "description": "How `start` and `end` count: UTF-16 code units (JavaScript strings) or Unicode code points (Python strings).", "default": "utf16"},
            "format": {"type": "string", "enum": ["text", "markdown"], "title": "Format", "description": "`markdown`: code, URLs, HTML, front matter and Markdown's own marks are left alone; only the prose is checked. Offsets still point into the text as sent.", "default": "text"},
            "profile": {"anyOf": [{"type": "string", "const": "llm"}, {"type": "null"}], "title": "Profile", "description": "`llm`: keep a fixed set of rules reviewed on Persian written by language models, at error or advice level; style findings, where both forms are right, stay style. Apply house preferences first, then the profile, then only, disable and min_severity. These options cannot add rules outside the profile. Rule detection and kind stay unchanged; use kind: formal for friendly written prose. Omit for the existing answers."},
            "only": {"anyOf": [{"items": {"type": "string"}, "type": "array"}, {"type": "null"}], "title": "Only", "description": "Report only these rules: ids like `ghazal.mi_prefix`, or prefixes ending in a dot like `spell.`."},
            "disable": {"items": {"type": "string"}, "type": "array", "title": "Disable", "description": "Never report these rules (ids or prefixes, as in `only`).", "default": []},
            "min_severity": {"type": "string", "enum": ["style", "guess", "advice", "error"], "title": "Min Severity", "description": "Report only findings of this severity or higher: style < guess < advice < error.", "default": "style"},
            "max_findings": {"anyOf": [{"type": "integer", "minimum": 0.0}, {"type": "null"}], "title": "Max Findings", "description": "Report at most this many findings per text, the first in the text. For a long document, this limit applies to each response."},
            "compact": {"type": "boolean", "title": "Compact", "description": "Answer in few tokens, for a language model: findings as one line each, no nulls, only what a model needs.", "default": false},
            "apply": {"type": "string", "enum": ["sure", "house", "all"], "title": "Apply", "description": "`sure`: only errors with a suggestion, not spelling guesses (the site's «fix all»). `house`: also applies style findings with exactly one suggestion, never spelling guesses or advice. `all`: every finding with a suggestion.", "default": "sure"}
          },
          "additionalProperties": false,
          "type": "object"
        }
      }
    },
    {
      "type": "function",
      "function": {
        "name": "ghazal_check",
        "description": "Finds what to correct. Each finding has `start` and `end` (where it is in the text), `text` (what is there),\n`suggestions` (what to write instead, best first; empty when there is no single fix), `rule` (explained in\nGET /api/v1/rules), `severity` (`error`: careful writers don't write it this way; `advice`: a source recommends\nit; `guess`: a model's guess, check it; `style`: both are right, the chosen style prefers this) and `confidence`\n(for guesses). With `profile: llm`, levels come from the review of Persian written by language models: at least 95% right for\n`error`, at least 85% for `advice`; other rules are omitted. Style findings stay `style`.\nConsistency findings also have a `reason` card with the two spellings and their counts.\n`register` is [spoken, written] evidence; `kind` is the kind of Persian the text was checked as;\nfor a long document both describe the whole text. `checked_to` and `from` count Unicode code points.\nSend the same whole text with `from: checked_to` to continue; only the checked range is charged.\nFinding offsets point into the whole text as sent. A cut that the server would not make gives 422.\nA finding that crosses a cut belongs to the piece containing its start; its end may exceed `checked_to`.\n`left_today` is what a key may still send today (null for own typing or with accounts off). With `compact`, each finding is one line:\n`@start «text» → «suggestion» | «another» rule severity`, and a guess's confidence last.",
        "parameters": {
          "properties": {
            "style": {"type": "string", "enum": ["ghazal", "academy"], "title": "Style", "description": "`ghazal`: Ghazal's house style. `academy`: the spelling rules of the Academy of Persian Language and Literature.", "default": "ghazal"},
            "house": {"anyOf": [{"properties": {"ezafe": {"anyOf": [{"type": "string", "enum": ["ye", "hamza"]}, {"type": "null"}], "title": "Ezafe", "description": "`ye`: خانه‌ی (`style: ghazal`); `hamza`: خانهٔ (`style: academy`). Omit to follow `style`. If both are sent, they must agree."}, "digits": {"type": "string", "enum": ["persian", "latin", "keep"], "title": "Digits", "description": "`persian`: ۱۲۳; `latin`: replace Persian and Arabic-Indic digits with 123 in Persian prose, outside code, URLs, Latin text and anything Markdown skips; `keep`: leave digits as written.", "default": "persian"}, "quotes": {"type": "string", "enum": ["guillemets", "keep"], "title": "Quotes", "description": "`guillemets`: «» for Persian quotations; `keep`: leave quotation marks as written.", "default": "guillemets"}}, "additionalProperties": false, "type": "object", "title": "House"}, {"type": "null"}], "description": "Optional writing preferences. Omit this object to keep the existing behaviour; omitted keys keep their defaults."},
            "words": {"items": {"type": "string", "maxLength": 60, "minLength": 1, "pattern": "^(?:[^\\W_]|[ً-ٰٟـ])+(?:‌(?:[^\\W_]|[ً-ٰٟـ])+)*$"}, "type": "array", "maxItems": 500, "title": "Words", "description": "Personal words, at most 500 entries of one word each, at most 60 characters, without spaces. Matching uses the spell checker's folding of Arabic letters, half-spaces and marks. Only spell.* and confuse.* findings are hidden. Omit or send [] to keep the existing answers.", "default": []},
            "text": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Text", "description": "The text to check: up to 200,000 characters with a personal plan, corporate plan or pack, otherwise 20,000. Send `text` or `texts`, not both."},
            "texts": {"anyOf": [{"items": {"type": "string"}, "type": "array"}, {"type": "null"}], "title": "Texts", "description": "Several texts, at most 20,000 characters in all with a newline between each, checked one by one; the answer has `results` in the same order."},
            "from": {"type": "integer", "minimum": 0.0, "title": "From", "description": "Resume at a previous `checked_to`, in Unicode code points. Send the same complete text and options; omit on the first call.", "default": 0},
            "kind": {"type": "string", "enum": ["auto", "formal", "mixed", "colloquial"], "title": "Kind", "description": "What kind of Persian the text is. `auto` decides from the words; spoken forms are flagged only in `formal` text.", "default": "auto"},
            "offsets": {"type": "string", "enum": ["utf16", "codepoint"], "title": "Offsets", "description": "How `start` and `end` count: UTF-16 code units (JavaScript strings) or Unicode code points (Python strings).", "default": "utf16"},
            "format": {"type": "string", "enum": ["text", "markdown"], "title": "Format", "description": "`markdown`: code, URLs, HTML, front matter and Markdown's own marks are left alone; only the prose is checked. Offsets still point into the text as sent.", "default": "text"},
            "profile": {"anyOf": [{"type": "string", "const": "llm"}, {"type": "null"}], "title": "Profile", "description": "`llm`: keep a fixed set of rules reviewed on Persian written by language models, at error or advice level; style findings, where both forms are right, stay style. Apply house preferences first, then the profile, then only, disable and min_severity. These options cannot add rules outside the profile. Rule detection and kind stay unchanged; use kind: formal for friendly written prose. Omit for the existing answers."},
            "only": {"anyOf": [{"items": {"type": "string"}, "type": "array"}, {"type": "null"}], "title": "Only", "description": "Report only these rules: ids like `ghazal.mi_prefix`, or prefixes ending in a dot like `spell.`."},
            "disable": {"items": {"type": "string"}, "type": "array", "title": "Disable", "description": "Never report these rules (ids or prefixes, as in `only`).", "default": []},
            "min_severity": {"type": "string", "enum": ["style", "guess", "advice", "error"], "title": "Min Severity", "description": "Report only findings of this severity or higher: style < guess < advice < error.", "default": "style"},
            "max_findings": {"anyOf": [{"type": "integer", "minimum": 0.0}, {"type": "null"}], "title": "Max Findings", "description": "Report at most this many findings per text, the first in the text. For a long document, this limit applies to each response."},
            "compact": {"type": "boolean", "title": "Compact", "description": "Answer in few tokens, for a language model: findings as one line each, no nulls, only what a model needs.", "default": false}
          },
          "additionalProperties": false,
          "type": "object"
        }
      }
    }
  ]
}

Anthropic

{
  "tools": [
    {
      "name": "ghazal_fix",
      "description": "Returns the text corrected. `applied` lists what was changed (offsets into the text sent; the first suggestion\nwas used), `left` what is still worth a look (offsets into the returned text). With `apply: sure` only errors\nthat have a suggestion and are not spelling guesses (`spell.*`) are applied.\n`apply: house` also applies style findings with exactly one suggestion, never spelling guesses or advice.\nWith `profile: llm`, these choices use the profile's levels; style findings stay style, and `spell.*` still needs `apply: all`.\nFor short texts, fixing the returned text again changes nothing. With `format: markdown` code, URLs and markup come back unchanged.\nFor a document over 20,000 characters, `text` is the corrected range from `from` to `checked_to`.\n`applied` points into the original complete text; `left` points into this answer's corrected `text`, using `offsets`.\nAppend each returned `text` without separators; add the length already joined, in `offsets`, to each new `left` offset.\nA finding crossing a cut keeps its full `end`, which may exceed `checked_to` for `applied` or the returned text's length for `left`.\nSend the same original text and options with `from: checked_to` until the end. Only the checked range is charged.\nShort texts have no `checked_to`.\nWith `compact`, `applied` and `left` are lines as in `check`'s compact answer\n(`applied` without `@start`).",
      "input_schema": {
        "properties": {
          "style": {"type": "string", "enum": ["ghazal", "academy"], "title": "Style", "description": "`ghazal`: Ghazal's house style. `academy`: the spelling rules of the Academy of Persian Language and Literature.", "default": "ghazal"},
          "house": {"anyOf": [{"properties": {"ezafe": {"anyOf": [{"type": "string", "enum": ["ye", "hamza"]}, {"type": "null"}], "title": "Ezafe", "description": "`ye`: خانه‌ی (`style: ghazal`); `hamza`: خانهٔ (`style: academy`). Omit to follow `style`. If both are sent, they must agree."}, "digits": {"type": "string", "enum": ["persian", "latin", "keep"], "title": "Digits", "description": "`persian`: ۱۲۳; `latin`: replace Persian and Arabic-Indic digits with 123 in Persian prose, outside code, URLs, Latin text and anything Markdown skips; `keep`: leave digits as written.", "default": "persian"}, "quotes": {"type": "string", "enum": ["guillemets", "keep"], "title": "Quotes", "description": "`guillemets`: «» for Persian quotations; `keep`: leave quotation marks as written.", "default": "guillemets"}}, "additionalProperties": false, "type": "object", "title": "House"}, {"type": "null"}], "description": "Optional writing preferences. Omit this object to keep the existing behaviour; omitted keys keep their defaults."},
          "words": {"items": {"type": "string", "maxLength": 60, "minLength": 1, "pattern": "^(?:[^\\W_]|[ً-ٰٟـ])+(?:‌(?:[^\\W_]|[ً-ٰٟـ])+)*$"}, "type": "array", "maxItems": 500, "title": "Words", "description": "Personal words, at most 500 entries of one word each, at most 60 characters, without spaces. Matching uses the spell checker's folding of Arabic letters, half-spaces and marks. Only spell.* and confuse.* findings are hidden. Omit or send [] to keep the existing answers.", "default": []},
          "text": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Text", "description": "The text to check: up to 200,000 characters with a personal plan, corporate plan or pack, otherwise 20,000. Send `text` or `texts`, not both."},
          "texts": {"anyOf": [{"items": {"type": "string"}, "type": "array"}, {"type": "null"}], "title": "Texts", "description": "Several texts, at most 20,000 characters in all with a newline between each, checked one by one; the answer has `results` in the same order."},
          "from": {"type": "integer", "minimum": 0.0, "title": "From", "description": "Resume at a previous `checked_to`, in Unicode code points. Send the same complete text and options; omit on the first call.", "default": 0},
          "kind": {"type": "string", "enum": ["auto", "formal", "mixed", "colloquial"], "title": "Kind", "description": "What kind of Persian the text is. `auto` decides from the words; spoken forms are flagged only in `formal` text.", "default": "auto"},
          "offsets": {"type": "string", "enum": ["utf16", "codepoint"], "title": "Offsets", "description": "How `start` and `end` count: UTF-16 code units (JavaScript strings) or Unicode code points (Python strings).", "default": "utf16"},
          "format": {"type": "string", "enum": ["text", "markdown"], "title": "Format", "description": "`markdown`: code, URLs, HTML, front matter and Markdown's own marks are left alone; only the prose is checked. Offsets still point into the text as sent.", "default": "text"},
          "profile": {"anyOf": [{"type": "string", "const": "llm"}, {"type": "null"}], "title": "Profile", "description": "`llm`: keep a fixed set of rules reviewed on Persian written by language models, at error or advice level; style findings, where both forms are right, stay style. Apply house preferences first, then the profile, then only, disable and min_severity. These options cannot add rules outside the profile. Rule detection and kind stay unchanged; use kind: formal for friendly written prose. Omit for the existing answers."},
          "only": {"anyOf": [{"items": {"type": "string"}, "type": "array"}, {"type": "null"}], "title": "Only", "description": "Report only these rules: ids like `ghazal.mi_prefix`, or prefixes ending in a dot like `spell.`."},
          "disable": {"items": {"type": "string"}, "type": "array", "title": "Disable", "description": "Never report these rules (ids or prefixes, as in `only`).", "default": []},
          "min_severity": {"type": "string", "enum": ["style", "guess", "advice", "error"], "title": "Min Severity", "description": "Report only findings of this severity or higher: style < guess < advice < error.", "default": "style"},
          "max_findings": {"anyOf": [{"type": "integer", "minimum": 0.0}, {"type": "null"}], "title": "Max Findings", "description": "Report at most this many findings per text, the first in the text. For a long document, this limit applies to each response."},
          "compact": {"type": "boolean", "title": "Compact", "description": "Answer in few tokens, for a language model: findings as one line each, no nulls, only what a model needs.", "default": false},
          "apply": {"type": "string", "enum": ["sure", "house", "all"], "title": "Apply", "description": "`sure`: only errors with a suggestion, not spelling guesses (the site's «fix all»). `house`: also applies style findings with exactly one suggestion, never spelling guesses or advice. `all`: every finding with a suggestion.", "default": "sure"}
        },
        "additionalProperties": false,
        "type": "object"
      }
    },
    {
      "name": "ghazal_check",
      "description": "Finds what to correct. Each finding has `start` and `end` (where it is in the text), `text` (what is there),\n`suggestions` (what to write instead, best first; empty when there is no single fix), `rule` (explained in\nGET /api/v1/rules), `severity` (`error`: careful writers don't write it this way; `advice`: a source recommends\nit; `guess`: a model's guess, check it; `style`: both are right, the chosen style prefers this) and `confidence`\n(for guesses). With `profile: llm`, levels come from the review of Persian written by language models: at least 95% right for\n`error`, at least 85% for `advice`; other rules are omitted. Style findings stay `style`.\nConsistency findings also have a `reason` card with the two spellings and their counts.\n`register` is [spoken, written] evidence; `kind` is the kind of Persian the text was checked as;\nfor a long document both describe the whole text. `checked_to` and `from` count Unicode code points.\nSend the same whole text with `from: checked_to` to continue; only the checked range is charged.\nFinding offsets point into the whole text as sent. A cut that the server would not make gives 422.\nA finding that crosses a cut belongs to the piece containing its start; its end may exceed `checked_to`.\n`left_today` is what a key may still send today (null for own typing or with accounts off). With `compact`, each finding is one line:\n`@start «text» → «suggestion» | «another» rule severity`, and a guess's confidence last.",
      "input_schema": {
        "properties": {
          "style": {"type": "string", "enum": ["ghazal", "academy"], "title": "Style", "description": "`ghazal`: Ghazal's house style. `academy`: the spelling rules of the Academy of Persian Language and Literature.", "default": "ghazal"},
          "house": {"anyOf": [{"properties": {"ezafe": {"anyOf": [{"type": "string", "enum": ["ye", "hamza"]}, {"type": "null"}], "title": "Ezafe", "description": "`ye`: خانه‌ی (`style: ghazal`); `hamza`: خانهٔ (`style: academy`). Omit to follow `style`. If both are sent, they must agree."}, "digits": {"type": "string", "enum": ["persian", "latin", "keep"], "title": "Digits", "description": "`persian`: ۱۲۳; `latin`: replace Persian and Arabic-Indic digits with 123 in Persian prose, outside code, URLs, Latin text and anything Markdown skips; `keep`: leave digits as written.", "default": "persian"}, "quotes": {"type": "string", "enum": ["guillemets", "keep"], "title": "Quotes", "description": "`guillemets`: «» for Persian quotations; `keep`: leave quotation marks as written.", "default": "guillemets"}}, "additionalProperties": false, "type": "object", "title": "House"}, {"type": "null"}], "description": "Optional writing preferences. Omit this object to keep the existing behaviour; omitted keys keep their defaults."},
          "words": {"items": {"type": "string", "maxLength": 60, "minLength": 1, "pattern": "^(?:[^\\W_]|[ً-ٰٟـ])+(?:‌(?:[^\\W_]|[ً-ٰٟـ])+)*$"}, "type": "array", "maxItems": 500, "title": "Words", "description": "Personal words, at most 500 entries of one word each, at most 60 characters, without spaces. Matching uses the spell checker's folding of Arabic letters, half-spaces and marks. Only spell.* and confuse.* findings are hidden. Omit or send [] to keep the existing answers.", "default": []},
          "text": {"anyOf": [{"type": "string"}, {"type": "null"}], "title": "Text", "description": "The text to check: up to 200,000 characters with a personal plan, corporate plan or pack, otherwise 20,000. Send `text` or `texts`, not both."},
          "texts": {"anyOf": [{"items": {"type": "string"}, "type": "array"}, {"type": "null"}], "title": "Texts", "description": "Several texts, at most 20,000 characters in all with a newline between each, checked one by one; the answer has `results` in the same order."},
          "from": {"type": "integer", "minimum": 0.0, "title": "From", "description": "Resume at a previous `checked_to`, in Unicode code points. Send the same complete text and options; omit on the first call.", "default": 0},
          "kind": {"type": "string", "enum": ["auto", "formal", "mixed", "colloquial"], "title": "Kind", "description": "What kind of Persian the text is. `auto` decides from the words; spoken forms are flagged only in `formal` text.", "default": "auto"},
          "offsets": {"type": "string", "enum": ["utf16", "codepoint"], "title": "Offsets", "description": "How `start` and `end` count: UTF-16 code units (JavaScript strings) or Unicode code points (Python strings).", "default": "utf16"},
          "format": {"type": "string", "enum": ["text", "markdown"], "title": "Format", "description": "`markdown`: code, URLs, HTML, front matter and Markdown's own marks are left alone; only the prose is checked. Offsets still point into the text as sent.", "default": "text"},
          "profile": {"anyOf": [{"type": "string", "const": "llm"}, {"type": "null"}], "title": "Profile", "description": "`llm`: keep a fixed set of rules reviewed on Persian written by language models, at error or advice level; style findings, where both forms are right, stay style. Apply house preferences first, then the profile, then only, disable and min_severity. These options cannot add rules outside the profile. Rule detection and kind stay unchanged; use kind: formal for friendly written prose. Omit for the existing answers."},
          "only": {"anyOf": [{"items": {"type": "string"}, "type": "array"}, {"type": "null"}], "title": "Only", "description": "Report only these rules: ids like `ghazal.mi_prefix`, or prefixes ending in a dot like `spell.`."},
          "disable": {"items": {"type": "string"}, "type": "array", "title": "Disable", "description": "Never report these rules (ids or prefixes, as in `only`).", "default": []},
          "min_severity": {"type": "string", "enum": ["style", "guess", "advice", "error"], "title": "Min Severity", "description": "Report only findings of this severity or higher: style < guess < advice < error.", "default": "style"},
          "max_findings": {"anyOf": [{"type": "integer", "minimum": 0.0}, {"type": "null"}], "title": "Max Findings", "description": "Report at most this many findings per text, the first in the text. For a long document, this limit applies to each response."},
          "compact": {"type": "boolean", "title": "Compact", "description": "Answer in few tokens, for a language model: findings as one line each, no nulls, only what a model needs.", "default": false}
        },
        "additionalProperties": false,
        "type": "object"
      }
    }
  ]
}

وقتی مدل ابزار را صدا زد، برنامه‌ی شما آرگومان‌ها را به نشانی همان ابزار می‌فرستد و پاسخ را به مدل برمی‌گرداند:

import json, os, urllib.request

def ghazal_fix(arguments):
    request = urllib.request.Request("https://ghazalai.ir/api/v1/fix", json.dumps(arguments).encode(), {"content-type": "application/json", "authorization": "Bearer " + os.environ["GHAZAL_KEY"]})
    with urllib.request.urlopen(request) as answer:
        return json.load(answer)

برای همه‌ی فیلدهای دیگر، مثل only و apply، صفحه‌ی fix را ببینید. سقف‌ها در کلید و سقف‌ها است.

توکن کمتر، و ابزارهای دیگر

با "compact": true پاسخ check و fix کوتاه می‌شود: هر پیشنهاد یک سطر، بی null و بی فیلدهایی که مدل لازم ندارد. پاسخ کوتاه

عاملی که فارسی می‌نویسد این‌ها را هم به کار می‌برد: vowels برای اعراب واژه‌هایی که چند خوانش دارند، verse برای وزن و قافیه‌ی شعری که می‌نویسد، و verb وقتی از صورت یک فعل مطمئن نیست.

نویسه‌ها با Unicode code point شمرده می‌شوند، مثل len در Python. خطای سقف روزانه، left_today و reset_at را دارد: نویسه‌های مانده و زمان شروع روز بعد به وقت UTC. همین مقدارها در X-RateLimit-Remaining و X-RateLimit-Reset می‌آیند؛ retry_after هم مثل Retry-After شمار ثانیه‌های انتظار است. متنی کوتاه‌تر ممکن است در سهمیه‌ی مانده جا شود. سقف‌ها

API را از سرور خودتان صدا بزنید و کلید را همان‌جا نگه دارید. API سرآیند CORS نمی‌فرستد؛ فراخوانی بی‌کلید برای سایت، برنامه و افزونه‌ی Word غزل است. توکن‌کاوی و جست‌وجوی پیکره فقط در سایت‌اند؛ نشانی v1 یا ابزار MCP ندارند.

متنی که می‌فرستید برای بهتر شدن غزل نگه داشته می‌شود؛ حریم خصوصی.