A plugin for Azure OpenAI AI assisted note taking in Logseq. Uses Azure OpenAI's GPT-4.1 model by default.
This project is based on the excellent work by @briansunter and his project logseq-plugin-gpt3-openai. We have modified and optimized it specifically for Azure OpenAI services.
Special thanks to Brian Sunter for his outstanding contribution to the Logseq community!
- 🚀 Quick Start
- 💡 Features
- 📖 Usage Guide
- ⚙️ Configuration
- 📝 Examples
- ❓ FAQ & Troubleshooting
- 🛠️ Development
- 🤝 Contributing
Download the plugin in the Logseq marketplace by searching for azure openai.
You'll need:
- An Azure OpenAI resource with a deployed model
- API key from your Azure OpenAI resource
- Your Azure OpenAI resource name
- Your Azure OpenAI deployment name
- Go to Logseq Settings → Plugins → Azure OpenAI
- Fill in the required fields:
Azure OpenAI API Key: your-api-key-here Resource Name: myresource (from https://myresource.openai.azure.com/) Deployment Name: gpt-4 (your deployed model name) API Version: 2025-01-01-preview (default)
- Press
Cmd+G(Mac) orCtrl+G(Windows/Linux) to open the GPT popup - Or type
/gptin any block
- 🎯 Smart Context Awareness: Automatically uses selected blocks as context for AI prompts
- 📝 Multiple Output Options: Insert, replace, or selectively replace generated content
- 🎨 Rich Preview: Markdown rendering with preview and raw modes
- ⚡ Streaming Responses: Real-time AI response generation
- 🔧 Custom Templates: Create and use your own prompt templates
- 🌐 Multi-language Support: Configure AI to respond in different languages
- 🎛️ Flexible Commands: Block-level, page-level, and replacement operations
- 🔒 Enterprise Ready: Built for Azure OpenAI with enterprise security
To bring up the gpt popup, use the keyboard shortcut cmd+g (or ctrl+g on Windows/Linux), or select gpt from the block or slash menu.
If you are currently in a block, the plugin will use the text in the block as input to the prompt.
You can click and drag or shift+click to select multiple blocks to use as input to the prompt.
If you are not in a block, the plugin won't add any additional input text to your prompt, and will append the results of the prompt to the bottom of the page.
After selecting the prompt and generating a response, a preview of the response will be shown in the popup with markdown rendering support. The preview offers two view modes:
- Preview Mode: Renders markdown with proper formatting, headers, lists, code blocks, and tables
- Raw Mode: Shows the raw markdown text for editing or copying
You can click the Insert button or press the enter key to insert the response into the page.
You can also click the Replace button to replace the selected block with the response.
Additionally, you can use the Replace by Selected button to replace only the text you have selected in the preview area, giving you more precise control over what content to insert.
If you don't like the response, you can click the Regenerate button to generate a new response.
After you open the popup, you can write any text you want to use as the prompt.
For example you can write create flashcards based on the following text: and the plugin will generate flashcards for you to study.
There are a number of built in prompt templates that you can use to generate text. These are useful for generating outlines, summaries, and other tasks.
Extract the most important ideas from your text.
Generate common objections to arguments in your text.
Generate questions based on your text content.
You can also create your own custom prompt templates.
To do this, you create a block with the prompt-template:: property. The template will be added to the list of templates in the gpt popup.
The prompt-template:: property is the name of the prompt template.
In a block nested underneath the template block, create a code block in triple backticks with the language set to prompt. The text in the code block will be used as the prompt. Make sure the code block is in its own block indented underneath the template block.
For example, you can create a template like this:
- # Student Teacher Dialog prompt-template:: Student Teacher Dialog - ```prompt Rewrite text as a dialog between a teacher and a student: ```
To replace the selected block with the generated text, click the Replace button.
The Replace by Selected button allows you to replace only the text you have selected in the preview area. This feature provides fine-grained control over which parts of the AI response you want to insert into your document. Simply:
- Select the desired text in the preview area (works in both Preview and Raw modes)
- Click the
Replace by Selectedbutton - Only the selected portion will replace your original content
If you don't like the output of the prompt, you can click the Regenerate button to generate a new response. Sometimes the first response is not the best, but the second or third response can be better.
Type /gpt-block in a block or select gpt-block from the block menu.
gpt-block will send the block to Azure OpenAI's GPT API and append the response underneath the block with streaming output.
You can use this command to ask questions about the content in your block.
Type /gpt-replace-block in a block or select gpt-replace-block from the block menu, or use the configurable keyboard shortcut.
gpt-replace-block will send the block to Azure OpenAI's GPT API and replace the current block content with the AI response. This command has its own configurable prompt setting, allowing you to customize the AI behavior specifically for block replacement operations.
- Refining and improving existing text
- Correcting grammar and style
- Translating content
- Reformatting text according to specific requirements
Type /gpt-page in a block or select gpt-page from the block menu.
gpt-page will send the entire page to Azure OpenAI's GPT API and append the response to the bottom of the page with streaming output.
You can click and drag or shift+click to select multiple blocks to use as input to the prompt.
You can adjust the Chat Prompt setting to adjust how Azure OpenAI should respond to your input. By default, the setting is set to Do not refer to yourself in your answers. Do not say as an AI language model... to prevent the model from including unnecessary text in the response.
You can add guidance such as "respond in chinese" or "respond in spanish" to the prompt to get the model to respond in a different language.
Allows you to inject a prefix into the Azure OpenAI output before it is inserted into the block, such as a [[azure-ai]] tag or markdown formatting like > for a blockquote. This is useful for identifying blocks that were generated by Azure OpenAI.
Use the Output prefix options in the setting to set the prefix. You can add a space or \n newline to separate the prefix from the generated text.
logseq-plugin-azure-openai allows users to generate human-like text using Azure OpenAI within the LogSeq editor.
Write a prompt in a block, then run the /gpt command via the slash or block menu. The plugin will generate an Azure OpenAI response and insert it below. It removes leading and trailing whitespace from the prompt.
- Go to Azure Portal
- Create a new Azure OpenAI resource
- Deploy a model (recommended: GPT-4 or GPT-3.5-turbo)
- Note down your:
- API Key (found in Keys and Endpoint section)
- Endpoint URL (e.g.,
https://myresource.openai.azure.com/) - Deployment Name (the name you gave to your deployed model)
Navigate to: Logseq Settings → Plugins → Azure OpenAI
| Setting | Description | Example |
|---|---|---|
| API Key | Your Azure OpenAI API key | abc123... |
| Resource Name | Subdomain from your endpoint URL | myresource |
| Deployment Name | Your model deployment name | gpt-4 |
| API Version | Azure OpenAI API version | 2025-01-01-preview |
| Temperature | Response creativity (0.0-2.0) | 0.7 |
| Max Tokens | Maximum response length | 2000 |
- Open any Logseq page
- Press
Cmd+G(Mac) orCtrl+G(Windows/Linux) - Type a simple prompt like "Hello, can you help me?"
- If configured correctly, you should see an AI response
- GPT-4 (recommended)
- GPT-4 Turbo
- GPT-3.5-turbo
- Any Azure OpenAI deployed model
Azure OpenAI has limitations. It sometimes produces output that is subtly wrong or misleading. Don't rely on its output without verifying it yourself. Use it with caution.
- Summarize:
Summarize the following text in 3 bullet points: - Study Plans:
Create a 4-week study plan for learning Python programming - Flashcards:
Create flashcards for the following content: - Q&A Generation:
Generate 5 study questions based on this text:
- Meeting Notes:
Convert these meeting notes into action items: - Email Drafts:
Write a professional email about: - Project Planning:
Create a project timeline for: - Documentation:
Write technical documentation for this code:
- Grammar Check:
Improve the grammar and clarity of this text: - Translation:
Translate the following to Spanish: - Tone Adjustment:
Rewrite this in a more formal tone: - Content Ideas:
Generate 10 blog post ideas about:
- Data Tables:
Convert this unstructured data into a table: - Key Points:
Extract the most important ideas from: - Objections:
List potential objections to these arguments: - Comparisons:
Compare and contrast these concepts:
- Code Generation:
Write a Python function that: - Code Review:
Review this code and suggest improvements: - Documentation:
Write API documentation for: - Debugging:
Help me debug this error:
List 10 innovative startup ideas in renewable energy
Write a compelling tagline for a plant-based restaurant
Explain quantum computing to a 12-year-old
Create a workout plan for busy professionals
The plugin provides several configurable settings:
- Azure OpenAI API Key: Your Azure OpenAI API key
- Azure OpenAI Resource Name: Your Azure resource name
- Azure OpenAI Deployment Name: Your model deployment name (default: gpt-4.1)
- Azure OpenAI API Version: API version (default: 2025-01-01-preview)
- Chat Prompt: System prompt to guide the model's behavior
- Temperature: Controls randomness in output (0.0 to 2.0)
- Max Tokens: Maximum number of tokens to generate
- Output prefix: Text to prepend to generated content
- Replace Block Prompt: Custom prompt specifically for the
gpt-replace-blockcommand - Keyboard Shortcuts: Customizable shortcuts for different commands (including
gpt-replace-block)
Azure OpenAI Service provides REST API access to OpenAI's powerful language models including GPT-4, GPT-3.5-turbo, and the Codex series. It's Microsoft's cloud-based implementation of OpenAI models with enterprise-grade security and compliance.
- Enterprise Security: Better data protection and compliance
- Regional Availability: Deploy in specific Azure regions
- SLA Guarantees: Enterprise-grade service level agreements
- Integration: Seamless integration with other Azure services
All Azure OpenAI deployed models including:
- GPT-4 (recommended)
- GPT-4 Turbo
- GPT-3.5-turbo
- Future Azure OpenAI models
Symptoms: Plugin doesn't respond or shows authentication error Solutions:
- Verify your API key in Azure Portal → OpenAI → Keys and Endpoint
- Make sure you copied the entire key without extra spaces
- Try regenerating the key in Azure Portal
Symptoms: Error message about model not found Solutions:
- Check your deployment name in Azure Portal → OpenAI → Deployments
- Ensure the model is successfully deployed (status: Succeeded)
- Verify the deployment name matches exactly (case-sensitive)
Symptoms: Requests failing with rate limit messages Solutions:
- Wait 1-2 minutes before trying again
- Check your quota usage in Azure Portal
- Consider upgrading your Azure OpenAI tier
- Reduce request frequency
Symptoms: No responses generated, quota error messages Solutions:
- Check usage in Azure Portal → OpenAI → Quotas
- Wait for quota reset (usually monthly)
- Request quota increase in Azure Portal
- Consider multiple Azure regions
Symptoms: No popup appears or commands don't work Solutions:
- Restart Logseq
- Disable and re-enable the plugin
- Check if plugin is properly installed and enabled
- Verify keyboard shortcuts in settings
- Use shorter prompts when possible
- Reduce max tokens setting for quicker responses
- Consider using GPT-3.5-turbo for faster (but less capable) responses
- Set appropriate max tokens limits
- Use temperature settings wisely (lower = more deterministic, less creative)
- Monitor usage in Azure Portal regularly
-
Check Console Logs:
- Open Developer Tools:
Menu → View → Toggle Developer Tools - Look for error messages in the Console tab
- Open Developer Tools:
-
Verify Configuration:
- Settings → Plugins → Azure OpenAI
- Test with a simple prompt
-
Test Azure Connection:
- Use Azure Portal to test your endpoint directly
- Verify your resource is active and deployed
-
Common Configuration Mistakes:
❌ Wrong: https://myresource.openai.azure.com/ ✅ Correct: myresource ❌ Wrong: gpt-4-32k (if not deployed) ✅ Correct: gpt-4 (your actual deployment name)
- 📖 Check the Azure OpenAI Documentation
- 🐛 Open an Issue with:
- Your configuration (without API key)
- Error messages from console
- Steps to reproduce the problem
- 💬 Join the Logseq Discord community for general help
- Node.js 16+
- pnpm (recommended) or npm
- Logseq installed
-
Clone and Install
git clone https://github.com/haha1903/logseq-plugin-azure-openai.git cd logseq-plugin-azure-openai pnpm install -
Start Development Server
pnpm run dev
This enables hot reloading via the Logseq Vite plugin.
-
Load in Logseq
- Open Logseq
- Go to Settings → Turn on Developer Mode
- Navigate to Plugins → Load unpacked plugin
- Select the root folder of this plugin repo
- Configure your Azure OpenAI settings
pnpm run build├── src/
│ ├── components/ # UI components
│ ├── services/ # Azure OpenAI integration
│ ├── types/ # TypeScript types
│ └── utils/ # Helper functions
├── public/ # Static assets
└── dist/ # Built plugin files
- 🌐 Frontend: TypeScript, React, Vite
- 🎨 UI: Tailwind CSS, Radix UI components
- 🔧 Build: Vite, ESBuild
- 📱 Platform: Logseq Plugin API
- ☁️ API: Azure OpenAI REST API
Automatic deployment via GitHub Actions using semantic-release when commits follow conventional commit format.
We welcome contributions! Here's how you can help:
🐛 Open an issue with:
- Clear description of the problem
- Steps to reproduce
- Your environment (OS, Logseq version, plugin version)
- Console error messages (if any)
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes with clear commit messages
- Add tests if applicable
- Ensure code passes linting:
pnpm run lint - Submit a pull request
- Follow TypeScript best practices
- Use functional components and hooks
- Write clear, descriptive commit messages
- Add JSDoc comments for complex functions
- Test your changes thoroughly
- @haha1903 - Original Azure OpenAI adaptation
- @briansunter - Original GPT-3 plugin foundation
- Brian Sunter - For the excellent logseq-plugin-gpt3-openai foundation
- Azure OpenAI Service - For enterprise-grade AI services
- OpenAI - For the underlying language models
- Logseq - For the amazing note-taking platform
- The Logseq Community - For continuous feedback and support

