OG Image Generator avatar

OG Image Generator

Try for free

No credit card required

Go to Store
OG Image Generator

OG Image Generator

daniil.poletaev/og-image-generator
Try for free

No credit card required

OG Image Generator is a tool that lets you dynamically create OG images from your HTML templates via an API. The tool is flexible, allowing you to use the default template or create fully custom templates.

You can access the OG Image Generator programmatically from your own Python applications by using the Apify API. You can also choose the language preference from below. To use the Apify API, you’ll need an Apify account and your API token, found in Integrations settings in Apify Console.

1from apify_client import ApifyClient
2
3# Initialize the ApifyClient with your Apify API token
4# Replace '<YOUR_API_TOKEN>' with your token.
5client = ApifyClient("<YOUR_API_TOKEN>")
6
7# Prepare the Actor input
8run_input = {
9    "html": """<!DOCTYPE html>
10<html lang=\"en\">
11<head>
12  <meta charset=\"UTF-8\">
13  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">
14  <script src=\"https://cdn.tailwindcss.com\"></script>
15</head>
16<body class=\"bg-gray-100 text-gray-900 flex items-center justify-center h-screen\">
17
18  <!-- OG Image Container -->
19  <div class=\"relative bg-white w-[1200px] h-[630px] rounded-lg shadow-xl border border-gray-200 overflow-hidden\">
20    
21    <!-- Background Accent -->
22    <div class=\"absolute inset-0 bg-gradient-to-r from-indigo-100 via-pink-100 to-yellow-100 opacity-50\"></div>
23
24    <!-- Logo -->
25    <div class=\"absolute bottom-6 left-6\">
26      <img src=\"{{logoUrl}}\" alt=\"Blog Logo\" class=\"h-10\">
27    </div>
28
29    <!-- Content Wrapper -->
30    <div class=\"relative flex flex-col h-full p-16\">
31      
32      <!-- Blog Category -->
33      <div class=\"text-base uppercase tracking-wider text-indigo-500 font-semibold mb-6\">{{category}}</div>
34      
35      <!-- Blog Title -->
36      <h1 class=\"text-6xl font-bold leading-tight text-gray-800 mb-8\">{{title}}</h1>
37      
38      <!-- Author and Date -->
39      <div class=\"flex items-center space-x-6 text-gray-600 text-xl\">
40        <div class=\"flex items-center space-x-3\">
41          <img class=\"w-12 h-12 rounded-full\" src=\"{{authorImage}}\" alt=\"{{author}}\">
42          <span>{{author}}</span>
43        </div>
44        <span>&bull;</span>
45        <span>{{date}}</span>
46      </div>
47    </div>
48  </div>
49
50</body>
51</html>
52""",
53    "templateData": {
54        "category": "Technology",
55        "title": "How to create dynamic OG title for your web",
56        "logoUrl": "https://w7.pngwing.com/pngs/243/698/png-transparent-apify-logo-tech-companies.png",
57        "date": "January 3, 2025",
58        "author": "Daniil Poletaev",
59        "authorImage": "https://images.apifyusercontent.com/rO00zibE4A243KKKW3pwsdT-IXjgOFWuA2s4RJV_7VM/rs:fill:70:70/aHR0cHM6Ly9saDMuZ29vZ2xldXNlcmNvbnRlbnQuY29tL2EvQUNnOG9jSWRPZ1QxMHAxblVSbGhKZUswSlZUdXpLZzJmVWN6MkEtNGZka1hwVWRSX1NtOVFSZw",
60    },
61}
62
63# Run the Actor and wait for it to finish
64run = client.actor("daniil.poletaev/og-image-generator").call(run_input=run_input)
65
66# Fetch and print Actor results from the run's dataset (if there are any)
67print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
68for item in client.dataset(run["defaultDatasetId"]).iterate_items():
69    print(item)
70
71# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

OG Image Generator API in Python

The Apify API client for Pythonis the official library that allows you to use OG Image Generator API in Python, providing convenience functions and automatic retries on errors.

Install the apify-client

pip install apify-client

Other API clients include:

Developer
Maintained by Community

Actor Metrics

  • 1 monthly user

  • 1 star

  • >99% runs succeeded

  • Created in Jan 2025

  • Modified 2 days ago