Text Overlay Serverless API

Elevate your visuals withText Overlay Model. Easily add customized text to any image, perfect for social media, marketing, and blogs. Enjoy precise positioning, advanced styling, and seamless integration.

POST /v2/text-overlay · submit + poll
 1# pip install "segmind>=1.1.0"
 2# export SEGMIND_API_KEY="YOUR_API_KEY"
 3import segmind
 4
 5# Async (v2): submit to the queue and block until COMPLETED.
 6# run() returns the final result dict (600s deadline, 1.0s poll by default).
 7result = segmind.run(
 8    "text-overlay",
 9    align="right",
10    base64=False,
11    blend_mode="normal",
12    color="#FFF",
13    font="JosefinSans-Bold",
14    font_size=150,
15    graphspace=0,
16    image="https://segmind-sd-models.s3.amazonaws.com/display_images/txt_overlay_in.png.jpeg",
17    image_format="jpeg",
18    image_quality=90,
19    linespace=10,
20    margin_x=97,
21    margin_y=300,
22    outline_color="#11ff00",
23    outline_size=0,
24    text="TRAVEL\n TODAY",
25    text_underlay=True,
26    wrap=50,
27)
28print(result["status"])                      # COMPLETED
29print(result.get("output"))                  # model output (e.g. media URL)
30print(result["metrics"]["inference_time"])   # server compute seconds
31
32# --- Or submit + poll manually (track request_id, control the cadence) ---
33from segmind import SegmindClient, InferenceFailed, InferenceTimeout
34
35client = SegmindClient()                      # reads SEGMIND_API_KEY
36payload = {
37    "align": "right",
38    "base64": False,
39    "blend_mode": "normal",
40    "color": "#FFF",
41    "font": "JosefinSans-Bold",
42    "font_size": 150,
43    "graphspace": 0,
44    "image": "https://segmind-sd-models.s3.amazonaws.com/display_images/txt_overlay_in.png.jpeg",
45    "image_format": "jpeg",
46    "image_quality": 90,
47    "linespace": 10,
48    "margin_x": 97,
49    "margin_y": 300,
50    "outline_color": "#11ff00",
51    "outline_size": 0,
52    "text": "TRAVEL\n TODAY",
53    "text_underlay": True,
54    "wrap": 50,
55}
56job = client.submit_async("text-overlay", **payload)
57print(job.request_id)                         # available immediately
58try:
59    result = job.wait(timeout=600, interval=1.0)
60except InferenceTimeout as e:
61    print("still running:", e.request_id)
62except InferenceFailed as e:
63    print("failed:", e.detail)

API Endpoint

POSThttps://api.segmind.com/v1/text-overlay

Parameters

blend_moderequired
string

Blend mode for text overlay

Default: "normal"
Allowed values (29 total):
"normal""dissolve""darken""multiply""color burn""linear burn""darker color""lighten""screen""color dodge"+19 more
imagerequired
string (uri)

URL of the image

Default: "https://segmind-sd-models.s3.amazonaws.com/display_images/txt_overlay_in.png.jpeg"
textrequired
string

Text to be displayed on the image

Default: "TRAVEL\n TODAY"
alignoptional
string

Text alignment

Default: "right"
Allowed values :
"left""right""center"
base64optional
boolean

Output image as base64 format

Default: false
coloroptional
string

Text color

Default: "#FFF"
fontoptional
string

Font style for the text

Default: "JosefinSans-Bold"
Allowed values (37 total):
"AlexBrush-Regular""Allura-Regular""AmaticSC-Regular""Canterbury""JosefinSans-Bold""JosefinSans-BoldItalic""JosefinSans-Italic""JosefinSans-Light""JosefinSans-LightItalic""JosefinSans-Regular"+27 more
font_sizeoptional
integer

Font size for the text

Default: 150Range: 1 - 2500
graphspaceoptional
integer

Controls spacing between text and surrounding elements.

Default: 0Range: 0 - 2048
image_formatoptional
string

Output image format.

Default: "webp"
Allowed values :
"jpeg""png"
image_qualityoptional
integer

Quality when saving the output images, from 0 to 100. 100 is best quality, 0 is lowest quality

Default: 90Range: 0 - 100
linespaceoptional
integer

Space between lines

Default: 10Range: 0 - 2048
margin_xoptional
integer

Margin X for positioning text

Default: 97Range: 0 - 2048
margin_yoptional
integer

Margin Y for positioning text

Default: 300Range: 0 - 2048
outline_coloroptional
string

Outline color for text

Default: "#11ff00"
outline_sizeoptional
integer

Outline size for text

Default: 0Range: 0 - 2048
text_underlayoptional
boolean

Specifies whether the text should be rendered behind an object or remain in front of it

Default: true
wrapoptional
integer

Wrap width for text

Default: 50Range: 0 - 2048

Response Type

Returns: Image

Asynchronous requests (v2)

Use Async for video, long-running (>~60s), or high-concurrency workloads; Sync is simplest for fast image & LLM calls. Async submits a request and you poll it to completion.

  1. 1
    POST /v2/text-overlay

    Submitreturns request_id, status_url, response_url

  2. 2
    GET /v2/requests/{id}/status

    Polluntil COMPLETED or FAILED

  3. 3
    GET /v2/requests/{id}

    Resultfinal response body

Status states

QUEUEDAccepted, waiting for a worker
PROCESSINGRunning on a worker
COMPLETEDDone — result body is ready
FAILEDErrored (incl. content/RAI blocks)
  • A FAILED request is served as HTTP 422 — the body still carries the error detail.
  • An unknown or expired request_id returns HTTP 404.
  • Results are retained for 1 hour, then expire.
  • Content / RAI blocks surface as FAILED, not a separate state.
  • Track completion by polling the status endpoint.

Common Error Codes

The API returns standard HTTP status codes. Detailed error messages are provided in the response body.

400

Bad Request

Invalid parameters or request format

401

Unauthorized

Missing or invalid API key

403

Forbidden

Insufficient permissions

404

Not Found

Model or endpoint not found

406

Insufficient Credits

Not enough credits to process request

429

Rate Limited

Too many requests

500

Server Error

Internal server error

502

Bad Gateway

Service temporarily unavailable

504

Timeout

Request timed out