Codeformer Serverless API

CodeFormer is a robust face restoration algorithm for old photos or AI-generated faces.

~5.92s
~$0.012
 1import requests
 2import json
 3
 4url = "https://api.segmind.com/v1/codeformer"
 5headers = {
 6    "x-api-key": "YOUR_API_KEY",
 7    "Content-Type": "application/json"
 8}
 9
10data = {
11    "image": "https://segmind.com/codeformer_input.png",
12    "scale": "1",
13    "fidelity": 0.5,
14    "bg": true,
15    "face": true
16}
17
18response = requests.post(url, headers=headers, json=data)
19
20if response.status_code == 200:
21    result = response.json()
22    print(json.dumps(result, indent=2))
23else:
24    print(f"Error: {response.status_code}")
25    print(response.text)

API Endpoint

POSThttps://api.segmind.com/v1/codeformer

Parameters

imagerequired
string (uri)

Image to Enhance

bgoptional
boolean

refers to the enhancement of the background present in the image.

Default: true
faceoptional
boolean

refers to the enhancement of the face present in the image.

Default: true
fidelityoptional
number

level of fidelity or quality desired for the generated image.

Default: 0.5Range: 0 - 1
scaleoptional
integer

The final upsampling scale of the image

Default: 1
Allowed values :
124

Response Type

Returns: Image

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