curl
set -eo pipefail
curl -fsS https://sharemy.ai/v1/images/edits \
-H "Authorization: Bearer $SHAREMYAI_API_KEY" \
-F 'image=@photo.jpg;type=image/jpeg' \
-F 'mask=@mask.png;type=image/png' \
-F model=lama -F grow=4 \
| jq -er '.data[0].b64_json' | base64 --decode > edited.pngimport base64, os
from pathlib import Path
from openai import OpenAI
client = OpenAI(api_key=os.environ["SHAREMYAI_API_KEY"], base_url="https://sharemy.ai/v1")
with open("photo.jpg", "rb") as image, open("mask.png", "rb") as mask:
result = client.images.edit(
model="lama",
image=image,
mask=mask,
prompt="", # The SDK takes a prompt. LaMa ignores it.
extra_body={"grow": 4},
)
Path("edited.png").write_bytes(base64.b64decode(result.data[0].b64_json))import fs from "node:fs";
import OpenAI from "openai";
const client = new OpenAI({ apiKey: process.env.SHAREMYAI_API_KEY, baseURL: "https://sharemy.ai/v1" });
const result = await client.images.edit({
model: "lama",
image: fs.createReadStream("photo.jpg"),
mask: fs.createReadStream("mask.png"),
prompt: "",
grow: 4,
});
fs.writeFileSync("edited.png", Buffer.from(result.data[0].b64_json, "base64"));{
"created": 123,
"data": [
{
"b64_json": "<string>"
}
]
}{
"id": "<string>",
"object": "job",
"created": 123,
"endpoint": "/v1/images/generations",
"status": "queued"
}{
"error": {
"message": "Choose a temperature from 0 to 2.",
"type": "invalid_request_error",
"param": "temperature",
"code": "invalid_value"
}
}{
"error": {
"message": "Send your API token as Authorization: Bearer smai_…. Create one at https://sharemy.ai, account panel, API tokens.",
"type": "invalid_request_error",
"param": null,
"code": "invalid_api_key"
}
}{
"error": {
"message": "This costs 8.192 credits and your balance is 3.000 credits. Add credits at https://sharemy.ai.",
"type": "insufficient_quota",
"param": null,
"code": "insufficient_quota",
"price_credits": 8.192,
"balance_credits": 3
}
}{
"error": {
"message": "This account is suspended. If you think that is a mistake, contact us.",
"type": "invalid_request_error",
"param": null,
"code": "account_suspended"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "model_not_found",
"price_credits": 123,
"balance_credits": 123
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "model_not_found",
"price_credits": 123,
"balance_credits": 123
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "model_not_found",
"price_credits": 123,
"balance_credits": 123
}
}{
"error": {
"message": "At most 4 API calls at once. Wait for one to finish.",
"type": "invalid_request_error",
"param": null,
"code": "rate_limit_exceeded"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "model_not_found",
"price_credits": 123,
"balance_credits": 123
}
}{
"error": {
"message": "The machine running this left the network. (request 69ba81e5-6a67-4cd5-a28b-2e023337b936)",
"type": "api_error",
"param": null,
"code": "network_error"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "model_not_found",
"price_credits": 123,
"balance_credits": 123
}
}API reference
Edit an image
Remove an object or watermark with LaMa. Upload a picture and a PNG mask to get a full-resolution PNG.
POST
/
v1
/
images
/
edits
curl
set -eo pipefail
curl -fsS https://sharemy.ai/v1/images/edits \
-H "Authorization: Bearer $SHAREMYAI_API_KEY" \
-F 'image=@photo.jpg;type=image/jpeg' \
-F 'mask=@mask.png;type=image/png' \
-F model=lama -F grow=4 \
| jq -er '.data[0].b64_json' | base64 --decode > edited.pngimport base64, os
from pathlib import Path
from openai import OpenAI
client = OpenAI(api_key=os.environ["SHAREMYAI_API_KEY"], base_url="https://sharemy.ai/v1")
with open("photo.jpg", "rb") as image, open("mask.png", "rb") as mask:
result = client.images.edit(
model="lama",
image=image,
mask=mask,
prompt="", # The SDK takes a prompt. LaMa ignores it.
extra_body={"grow": 4},
)
Path("edited.png").write_bytes(base64.b64decode(result.data[0].b64_json))import fs from "node:fs";
import OpenAI from "openai";
const client = new OpenAI({ apiKey: process.env.SHAREMYAI_API_KEY, baseURL: "https://sharemy.ai/v1" });
const result = await client.images.edit({
model: "lama",
image: fs.createReadStream("photo.jpg"),
mask: fs.createReadStream("mask.png"),
prompt: "",
grow: 4,
});
fs.writeFileSync("edited.png", Buffer.from(result.data[0].b64_json, "base64"));{
"created": 123,
"data": [
{
"b64_json": "<string>"
}
]
}{
"id": "<string>",
"object": "job",
"created": 123,
"endpoint": "/v1/images/generations",
"status": "queued"
}{
"error": {
"message": "Choose a temperature from 0 to 2.",
"type": "invalid_request_error",
"param": "temperature",
"code": "invalid_value"
}
}{
"error": {
"message": "Send your API token as Authorization: Bearer smai_…. Create one at https://sharemy.ai, account panel, API tokens.",
"type": "invalid_request_error",
"param": null,
"code": "invalid_api_key"
}
}{
"error": {
"message": "This costs 8.192 credits and your balance is 3.000 credits. Add credits at https://sharemy.ai.",
"type": "insufficient_quota",
"param": null,
"code": "insufficient_quota",
"price_credits": 8.192,
"balance_credits": 3
}
}{
"error": {
"message": "This account is suspended. If you think that is a mistake, contact us.",
"type": "invalid_request_error",
"param": null,
"code": "account_suspended"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "model_not_found",
"price_credits": 123,
"balance_credits": 123
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "model_not_found",
"price_credits": 123,
"balance_credits": 123
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "model_not_found",
"price_credits": 123,
"balance_credits": 123
}
}{
"error": {
"message": "At most 4 API calls at once. Wait for one to finish.",
"type": "invalid_request_error",
"param": null,
"code": "rate_limit_exceeded"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "model_not_found",
"price_credits": 123,
"balance_credits": 123
}
}{
"error": {
"message": "The machine running this left the network. (request 69ba81e5-6a67-4cd5-a28b-2e023337b936)",
"type": "api_error",
"param": null,
"code": "network_error"
}
}{
"error": {
"message": "<string>",
"type": "invalid_request_error",
"param": "<string>",
"code": "model_not_found",
"price_credits": 123,
"balance_credits": 123
}
}Upload your picture and a mask that marks what to remove. LaMa fills the marked area using the surrounding picture. You get one PNG at the original resolution. Pixels outside the mask stay unchanged. If you set
Each file can be up to 50 MB (52,428,800 bytes). Neither side can exceed 4,096 pixels. If you set a file’s content type, use its actual image type or
For authentication, balance, concurrency and machine errors, see Errors and limits.
grow, this applies to the expanded mask.
Request
Sendmultipart/form-data. Upload the files themselves in the image and mask fields.
| Field | What to send |
|---|---|
image | Required. A PNG, JPEG or WebP file. |
mask | Required. A PNG with the same width and height as the picture. |
model | lama (default) or its alias inpaint. |
response_format | Only b64_json (default). |
n | Only 1 (default). |
grow | A whole number from 0 to 64. Expands the removal area by this many pixels. Defaults to 0. This is a ShareMyAI extension. |
prompt | Optional. The API accepts this field and ignores it. LaMa takes no prompt. |
async | Send true to get a job id and poll for the result. You can also send Prefer: respond-async. See Image jobs. |
application/octet-stream.
With the OpenAI Python SDK, pass the two open files to client.images.edit(...). Use prompt="" and send grow with extra_body={"grow": 4}.
How to mark the mask
- If any pixel has transparency, only fully transparent pixels are removed. Partly transparent and opaque pixels are kept, whatever their color.
- If every pixel is opaque, white or bright pixels are removed. Dark pixels are kept. On a grayscale mask, 128 through 255 mark pixels to remove.
Price
You pay 3 credits per 4 million pixels in the full picture, with a 3-credit minimum. A 4,000 × 2,000 picture has 8 million pixels and costs 6 credits, even if you mark only a small watermark. See Credits and pricing.Response
The default response is HTTP 200.created is a Unix timestamp in seconds. Decode data[0].b64_json to save the edited PNG. The base64 below is shortened.
{
"created": 1764547200,
"data": [{ "b64_json": "iVBORw0KGgo..." }]
}
X-ShareMyAI-Cost-Credits gives the price. X-ShareMyAI-Balance-Credits gives your balance just after the hold. Every response includes an x-request-id.
Errors
File and field checks can fail at submission. The machine checks the decoded dimensions when it runs the edit. For an async edit, read processing errors in the failed job’serror field.
| Status | error.code | What to check |
|---|---|---|
| 400 | invalid_value | Check the multipart body, upload both files and use a whole number from 0 to 64 for grow. |
| 400 | invalid_input | The machine could not decode a file, or the mask dimensions differ from the picture. Check error.param for image or mask. |
| 400 | model_not_found | Use lama or inpaint. |
| 400 | unsupported_value | Check n and response_format. |
| 413 | file_too_large | The file named in error.param exceeds 50 MB. |
| 413 | image_too_large | The image or mask exceeds 4,096 pixels on a side. |
| 415 | unsupported_image | Check the file format, its header and its declared content type. The mask must be a PNG. |
| 503 | storage_unavailable | Async result storage is unavailable. Try again later. |
Authorizations
Body
multipart/form-data