Codia API

Add code image generation to your workflow.

Sign in, create a credential, and send one simple HTTP request to generate code images for docs, sharing, and automated workflows.

Quick start

Request headers

ParameterTypeDescription
AuthorizationBearer Required. Use the credential created after signing in.
Content-Typeapplication/jsonRequired when sending the JSON request body.

Request parameters

ParameterTypeRequiredDescription
codestringYesThe source code to render. 1-50,000 characters.
languagestringNoShiki language id, such as typescript or python. If omitted, Codia detects it automatically.
format"webp" | "png" | "jpg" | "jpeg"NoOutput image format. All account levels may use any supported format; jpg is normalized to jpeg.
themestringNoShiki theme name. All account levels may use any bundled theme.
styleenumNoImage layout style. Defaults to default; vercel uses a black thin-frame layout with theme highlighting only, hides line numbers, avatars, and the language icon, and keeps dark crosses only at the top-left and bottom-right. Its dynamic minimum width is strictly greater than 440px.
innerPaddingintegerNoDistance from vercel code to the surrounding frame lines in px. Defaults to 16; range 0-120. Ignored by default style.
filenamestringNoOptional filename/title shown between the mock window controls and language icon.
bgColorstringNoOuter image background. All account levels may use colors and linear/radial gradients.
backgroundColorstringNoLegacy alias for bgColor. Prefer bgColor for new integrations.
borderSizeintegerNoOuter padding in px. Defaults to 12; range 0-120.
borderRadiusintegerNoCode window radius in px. Defaults to 4; range 0-119.
containerWidthintegerNoRequested code container width in px. Defaults to 600; must be positive and is capped at 1920. Values below the dynamic minContainerWidth are raised to that minimum.
minLinesintegerNoMinimum rendered code line count. Defaults to 3; range 1-1000. Blank lines are appended when needed.
endSpaceLinesintegerNoNumber of blank lines appended after the code. Defaults to 2; range 0-1000. Appended blank lines are included in line numbers and lineCount.
showLineNumbersbooleanNoWhether to show line numbers. Defaults to true.
showLanguageIconbooleanNoWhether to show the language icon. Defaults to true.
showAvatarbooleanNoWhether to show an avatar in the bottom-right corner of the code window. Defaults to false.
avatarUrlstringNoAvatar URL. When showAvatar is true, the server proxies it into base64; omit it to use the current API user's avatar.
avatarSizeintegerNoAvatar width and height in px. Defaults to 26; range 24-128.
avatarRadiusintegerNoAvatar corner radius in px. Defaults to 64; range 0-64.
qualityintegerNoOutput pixel-density multiplier from 1 to 3. Defaults to 1.
source"api" | "try-it-*"NoRender source label. API calls should use api, which is the default.
responseType"json" | "image" | "cdnUrl"NoResponse type. json returns the normal JSON payload, image returns raw bytes, and cdnUrl is Pro/Admin only: it uploads to R2/S3-compatible storage then returns a CDN URL.
returnImagebooleanNoLegacy image response switch. Prefer responseType: "image" for new integrations.

Response

With responseType=json, a successful response includes dataUrl and imageBase64, plus the resolved format, language, theme, dimensions, and recordId. With responseType=image, the response body is the image bytes and Content-Type is image/webp, image/png, or image/jpeg. With responseType=cdnUrl, the response includes cdnUrl, imageMd5, storageKey, uploaded, and basic metadata.

Tune parameters in Playground first

Use Playground to tune the theme, background, window size, export format, and other details until the result feels right. Then copy the parameters in one click and give that JSON to an AI so it can build your own workflow, Codex skill, or MCP calling script around stable settings.

Tune in Playground ↗

Examples

curlReplace CODIA_TOKEN with a credential created from the avatar menu.
curl -X POST "$CODIA_ORIGIN/v1/code/render" \
  -H "Authorization: Bearer $CODIA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "code": "const message = \\\"Hello, Codia\\\";\\nconsole.log(message);",
    "language": "typescript",
    "format": "png",
    "theme": "github-dark",
    "filename": "app.ts",
    "quality": 2
  }'

Usage limits

Free signed-in users can generate up to 200 API images per month with unrestricted parameters. Paid users can generate up to 3,600 per day, also without parameter restrictions. Administrators have no limit. Playground usage is not limited by API credentials.
Open Playground ↗