HEX
Server: LiteSpeed
System: Linux houston.panomity.com 6.8.0-100-generic #100-Ubuntu SMP PREEMPT_DYNAMIC Tue Jan 13 16:40:06 UTC 2026 x86_64
User: nudepix (1011)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //opt/PraisonAI/docs/agents/markdown.mdx
---
title: "Markdown Agent"
sidebarTitle: "Markdown"
description: "Learn how to create AI agents for generating and formatting content in Markdown."
icon: "markdown"
---

```mermaid
flowchart LR
    In[Content Request] --> Generator[Content Generator]
    Generator --> Formatter[Markdown Formatter]
    Formatter --> Validator[Format Validator]
    Validator --> Out[Markdown Output]
    
    style In fill:#8B0000,color:#fff
    style Generator fill:#2E8B57,color:#fff
    style Formatter fill:#2E8B57,color:#fff
    style Validator fill:#2E8B57,color:#fff
    style Out fill:#8B0000,color:#fff
```

A workflow demonstrating how the Markdown Agent can generate and format content in Markdown syntax.

## Quick Start

<Steps>
    <Step title="Install Package">
        First, install the PraisonAI Agents package:
        ```bash
        pip install praisonaiagents
        ```
    </Step>

    <Step title="Set API Key">
        Set your OpenAI API key as an environment variable:
        ```bash
        export OPENAI_API_KEY=your_api_key_here
        ```
    </Step>

    <Step title="Create Script">
        Create a new file `markdown_generator.py`:
        ```python
        from praisonaiagents import Agent

        # Create Markdown Agent
        markdown_agent = Agent(
            name="MarkdownWriter",
            role="Markdown Content Specialist",
            goal="Generate well-formatted content in Markdown syntax",
            instructions="You are a Markdown Agent, output in markdown format",
            llm="gpt-4o-mini",
            self_reflect=False
        )

        # Generate content
        response = markdown_agent.start(
            "Write a blog post about artificial intelligence"
        )
        
        # Save to file
        with open('blog_post.md', 'w') as f:
            f.write(response)
        ```
    </Step>
</Steps>

## Understanding Markdown Generation

The Markdown Agent specializes in creating properly formatted Markdown content:

1. **Content Generation**: Creates original content based on prompts
2. **Markdown Formatting**: Applies proper Markdown syntax
3. **Structure Validation**: Ensures correct formatting
4. **Document Organization**: Creates well-structured documents

## Features

<CardGroup cols={2}>
  <Card title="Content Creation" icon="pen-to-square">
    Generates original, well-structured content.
  </Card>
  <Card title="Markdown Syntax" icon="code">
    Proper implementation of Markdown formatting.
  </Card>
  <Card title="Document Structure" icon="sitemap">
    Organized document hierarchy and sections.
  </Card>
  <Card title="Format Validation" icon="check">
    Ensures correct Markdown syntax usage.
  </Card>
</CardGroup>

## Example Usage

```python
# Example: Generate a technical documentation
agent = Agent(
    instructions="You are a Markdown Agent, output in markdown format"
)

# Generate API documentation
response = agent.start("""
    Create technical documentation for a REST API with:
    - Introduction
    - Authentication
    - Endpoints
    - Examples
""")

# Save documentation
with open('api_docs.md', 'w') as f:
    f.write(response)
```

## Next Steps

- Learn about [Prompt Chaining](/features/promptchaining) for complex document generation
- Explore [Evaluator Optimizer](/features/evaluator-optimiser) for improving content quality
- Check out the [Documentation Agent](/agents/documentation) for specialized documentation generation