Seamless integration with major language models such as OpenAI, Claude and Gemini provides extensive AI-based document processing capabilities for Python applications.
Detect and highlight grammar errors in documents using OpenAI, Google, and Claude AI models with Aspose.Words for Python via .NET. The CheckGrammar method analyzes DOC, DOCX, RTF, PDF, HTML, Markdown, ODT, TXT, and EPUB files and marks grammatical problems — helping you deliver polished, professional content without manual proofreading.
Authentication requires an API key from your chosen AI provider. For a full list of supported models, see the API Reference.
Start checking grammar in Python today — try the live demo above.
pip install aspose-words
Copy
doc = aw.Document("Document.docx")
api_key = os.getenv("API_KEY")
# Use OpenAI generative language models.
model = aw.ai.AiModel.create(aw.ai.AiModelType.GPT_4O_MINI).with_api_key(api_key).as_open_ai_model()
grammar_options = aw.ai.CheckGrammarOptions()
grammar_options.improve_stylistics = True
proofed_doc = model.check_grammar(doc, grammar_options)
proofed_doc.save("Output.docx")
doc = aw.Document("Document.docx")
# Pass an empty string if the self-hosted model does not require an API key.
model = CustomAiModel("my-model-24b", "https://your-server.com/v1").with_api_key("")
grammar_options = aw.ai.CheckGrammarOptions()
grammar_options.improve_stylistics = True
proofed_doc = model.check_grammar(doc, grammar_options)
proofed_doc.save("Output.docx")
class CustomAiModel(aw.ai.OpenAiModel):
def __init__(self, name, url):
super().__init__(name)
self._url = url
@property
def url(self):
return self._url
We host our Python packages in PyPi repositories. Please follow the step-by-step instructions on how to install "Aspose.Words for Python via .NET" to your developer environment.
This package is compatible with Python ≥3.5 and <3.12. If you develop software for Linux, please have a look at additional requirements for gcc and libpython in Product Documentation.