This API generates SEO-optimized blog articles using a given topic or keyword, leveraging OpenAI's GPT-4 model. The output can be customized in different languages and formats (HTML or Markdown).
- SEO-Optimized Blog Article Generation: Generates articles based on a given keyword, language, and format.
- Multiple Languages Supported: English, German, Dutch, Spanish, and Italian.
- HTML or Markdown: Choose the format of the generated content.
- Real-time Streaming: The article is streamed to the client as it is being generated.
- API Key Validation: Validates if the OpenAI API key is working correctly.
-
Clone the repository:
git clone https://github.com/yourusername/seo-blog-article-generator-api.git cd seo-blog-article-generator-api -
Install dependencies:
Create and activate a virtual environment (optional but recommended):
python3 -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
Install required packages:
pip install -r requirements.txt
-
Set up environment variables:
Copy
.env.exampleto.envand replaceYOUR_OPENAI_API_KEYwith your actual OpenAI API key:cp .env.example .env
Then, open the
.envfile and configure the following variables:OPENAI_API_KEY=your-openai-api-key -
Run the application:
python main.py
The app will be running on
http://localhost:5000.
GET /
Returns a simple "Hello World" message to check if the API is up and running.
GET /validate
Checks if the OpenAI API key is valid.
Response:
{
"success": true
}GET /generate/{keyword}
Generates an SEO-optimized blog article based on the provided keyword, language, and format.
-
Path Parameter:
keyword(string, required): The keyword or topic for the blog article.
-
Query Parameters:
language(string, required): Language of the generated blog article. Options:en,de,nl,es,it.format(string, optional): The format of the generated content. Options:markdown(default),html.
Example Request:
curl "http://localhost:5000/generate/digital-marketing?language=en&format=html"Response:
Returns a stream of the blog article content in the requested format (Markdown or HTML).
To generate an article about "digital marketing" in English and HTML format:
curl "http://localhost:5000/generate/digital-marketing?language=en&format=html"The server will start streaming the blog article as it's being generated.
The following environment variables need to be set:
- OPENAI_API_KEY: Your OpenAI API key to interact with GPT models.
This project is licensed under the MIT License. See the LICENSE file for more details.