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.
/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 required Main title text
description string Subtitle or description
author string Author name
bgColor string Background color (hex, e.g. #0a0a0a)
accentColor string Accent color (hex)
width number Image width, 200–2400 (default: 1200)
height number Image height, 200–2400 (default: 630)
Examples
curl "https://og.codercops.com/api/og?\
title=Hello+World&\
template=blog-minimal-dark" \
--output og-image.png 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} /> 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) /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
{
"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": "...",
...
},
...
]
} /api/templates List all available templates with their fields, defaults, and thumbnail URLs.
curl "https://og.codercops.com/api/templates" /api/templates/{id}/thumbnail.png Get a 600×315 thumbnail preview of a template with its default values. Cached for 7 days.
https://og.codercops.com/api/templates/\
blog-minimal-dark/thumbnail.png /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
{ "content": "Generated text from the AI model" } Example
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
400Invalid request body (missing fields or out-of-range values)
401Invalid API key or unauthorized
429Rate limited by the provider
502Provider returned an error
/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
{ "valid": true }
// or
{ "valid": false, "error": "Invalid API key" } /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
{
"templateId": "blog-minimal-dark",
"fields": {
"title": "Generated Title",
"description": "Generated description",
"author": "Author Name"
},
"colors": {
"bgColor": "#1a1a2e",
"accentColor": "#e07a5f"
}
}