Visitar URL original
API Documentation | OGCOPS

API Documentation

Generate OG images, check URL meta tags, and list templates with our free REST API. No API key required. CORS-enabled for browser use.

GET /api/og

Generate an OG image as PNG. Returns image/png with Cache-Control headers.

Parameters

template string

Template ID (default: blog-minimal-dark)

title string

Main title text (optional; template default used when omitted)

description string

Subtitle or description

author string

Author name

bgColor string

Background color (3- or 6-digit hex, with or without #, e.g. #0a0a0a, 0a0a0a, #000, 000)

accentColor string

Accent color (3- or 6-digit hex, with or without #, e.g. #e07a5f, e07a5f, #0f0, 0f0)

textColor string

Text color (3- or 6-digit hex, with or without #, e.g. #ffffff, fff)

width number

Image width in pixels, 200–2400 (default: 1200). Templates always render at 1200×630 and scale to fit. If height is omitted, it is derived automatically to preserve the 1200:630 aspect ratio.

height number

Image height in pixels, 105–1260 (default: 630). If width is omitted, it is derived automatically to preserve the 1200:630 aspect ratio. If both dimensions are provided, their aspect ratio must match 1200:630 (returns 400 Bad Request otherwise).

Examples

curl
curl "https://og.codercops.com/api/og?\
title=Hello+World&\
template=blog-minimal-dark" \
  --output og-image.png
JavaScript
const params = new URLSearchParams({
  template: 'blog-minimal-dark',
  title: 'Hello World',
  author: 'OGCOPS',
});

const url = `https://og.codercops.com/api/og?${params}`;

// Use as meta tag:
// <meta property="og:image" content={url} />
Python
import requests

resp = requests.get(
    "https://og.codercops.com/api/og",
    params={
        "template": "blog-minimal-dark",
        "title": "Hello World",
        "author": "OGCOPS",
    },
)

with open("og-image.png", "wb") as f:
    f.write(resp.content)
GET /api/preview

Fetch and analyze meta tags from a URL. Returns JSON with meta tags, analysis score, and per-platform preview data for 8 platforms.

Parameters

url string required

URL to check (must be a valid URL)

Response

JSON Response
{
  "url": "https://example.com",
  "meta": {
    "title": "Example",
    "ogTitle": "Example - Site",
    "ogImage": "https://example.com/og.png",
    ...
  },
  "analysis": {
    "score": 85,
    "grade": "B",
    "issues": [...],
    "summary": "Good setup."
  },
  "platforms": [
    {
      "platform": "twitter",
      "name": "Twitter / X",
      "imageUrl": "...",
      "title": "...",
      "description": "...",
      ...
    },
    ...
  ]
}
GET /api/templates

List all available templates with their fields, defaults, and thumbnail URLs.

curl
curl "https://og.codercops.com/api/templates"
GET /api/templates/{id}/thumbnail.png

Get a 600×315 thumbnail preview of a template with its default values. Cached for 7 days.

Example
https://og.codercops.com/api/templates/\
blog-minimal-dark/thumbnail.png
POST /api/ai/generate

Proxy text generation through your own AI provider API key (BYOK). Supports OpenAI, Anthropic, Google, Groq, and OpenRouter. Your API key is passed through to the provider and never stored.

Request Body (JSON)

provider string required

AI provider: openai, anthropic, google, groq, or openrouter

apiKey string required

Your API key for the selected provider

model string required

Model ID (e.g. gpt-4o-mini, claude-sonnet-4-20250514, gemini-2.0-flash)

prompt string required

User prompt (max 10,000 characters)

systemPrompt string

Optional system prompt (max 5,000 characters)

maxTokens number

Max response tokens, 1–4096 (default: provider default)

temperature number

Sampling temperature, 0–2 (default: provider default)

Response

JSON Response
{ "content": "Generated text from the AI model" }

Example

JavaScript
const res = await fetch('https://og.codercops.com/api/ai/generate', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    provider: 'openai',
    apiKey: 'sk-your-key',
    model: 'gpt-4o-mini',
    prompt: 'Generate 3 catchy titles for a blog post about React',
    maxTokens: 200,
    temperature: 0.7,
  }),
});

const { content } = await res.json();

Error Codes

400

Invalid request body (missing fields or out-of-range values)

401

Invalid API key or unauthorized

429

Rate limited by the provider

502

Provider returned an error

POST /api/ai/validate

Validate an AI provider API key by making a minimal test request. Returns whether the key is valid.

Request Body (JSON)

provider string required

AI provider: openai, anthropic, google, groq, or openrouter

apiKey string required

API key to validate

Response

JSON Response
{ "valid": true }
// or
{ "valid": false, "error": "Invalid API key" }
POST /api/ai/autofill

Analyze a URL's content and auto-generate template field values using AI. Fetches the page, extracts content, then uses your AI key to suggest a template, fill fields, and pick colors.

Request Body (JSON)

url string required

URL to analyze

provider string required

AI provider

apiKey string required

Your API key

model string required

Model ID

Response

JSON Response
{
  "templateId": "blog-minimal-dark",
  "fields": {
    "title": "Generated Title",
    "description": "Generated description",
    "author": "Author Name"
  },
  "colors": {
    "bgColor": "#1a1a2e",
    "accentColor": "#e07a5f"
  }
}
Feedback