Add OG Images to Your Flask App

Use Python's standard library to generate dynamic OG images in any Flask route.

Start Integrating

Zero Config

Just urlencode and you're good to go. No extra dependencies needed.

Jinja Ready

Pass the OG URL to your templates. Works seamlessly with Flask's render_template.

SQLAlchemy Friendly

Works with any ORM. Use your existing Post, User, or Article models.

Example Integration

from urllib.parse import urlencode
from flask import render_template
import os

@app.route("/blog/<slug>")
def blog_post(slug):
    post = Post.query.filter_by(slug=slug).first_or_404()
    og_params = urlencode({
        "title":    post.title,
        "template": "modern",
        "api_key":  os.environ["IMAGO_API_KEY"],
    })
    og_url = f"https://imagoapi.com/api/og/generate?{og_params}"
    return render_template("post.html", post=post, og_url=og_url)

# post.html: <meta property="og:image" content="{{ og_url }}">

Generate OG Images in Seconds

Start using Imago API today and add beautiful social cards to your Flask app.

Try Imago API Free