Skip to main content

Official Python SDK for the Pedra API — AI photo editing for real estate (virtual staging, renovation, enhancement, video).

Project description

Pedra Python SDK

Official Python SDK for the Pedra API — AI photo editing for real estate: virtual staging, renovation, room emptying, image enhancement, sky replacement, object removal/blur, and property videos.

PyPI version

pip install pedra

Requires Python 3.8+. Zero runtime dependencies (uses the standard library).

Quick start

from pedra import Pedra

pedra = Pedra("YOUR_API_KEY")  # or set PEDRA_API_KEY in the environment

result = pedra.furnish(
    image_url="https://example.com/empty-living-room.jpg",
    room_type="Living room",
    style="Minimalist",
)

print(result.url)   # → the staged image URL
print(result.urls)  # → all generated URLs

Get your API key from your Pedra account settings. Every method blocks until the asset is ready and returns the final URL(s) — there are no job IDs to poll. The API uses a heartbeat to keep long requests (like create_video) alive.

Authentication

pedra = Pedra("YOUR_API_KEY")
# or
pedra = Pedra()  # reads PEDRA_API_KEY from the environment

Options:

pedra = Pedra(
    "YOUR_API_KEY",
    base_url="https://app.pedra.ai/api",  # default
    timeout=600.0,                        # seconds, default 10 min (covers create_video)
)

Responses

Image methods return an ImageResponse, which normalizes the underlying endpoint's output (some return a list, some a single object):

@dataclass
class ImageResponse:
    message: Optional[str]
    urls: List[str]   # every generated asset URL
    raw: Any          # the untouched API response
    # .url -> Optional[str]: convenience for the first URL

Methods

Method Endpoint Returns
enhance(image_url, *, preserve_original_framing=None) /enhance ImageResponse
enhance_and_correct_perspective(image_url, *, preserve_original_framing=None) /enhance_and_correct_perspective ImageResponse
empty(image_url) /empty_room ImageResponse
furnish(image_url, *, room_type=None, style=None, creativity=None) /furnish ImageResponse
renovation(image_url, *, style=None, creativity=None, furnish=None, room_type=None) /renovation ImageResponse
edit_via_prompt(image_url, prompt) /edit_via_prompt ImageResponse
sky(image_url, *, sky_style=None) /sky_blue ImageResponse
remove(image_url, mask_url) /remove_object ImageResponse
blur(image_url, objects_to_blur) /blur ImageResponse
create_video(images, *, music=None, voice=None, branding=None, ending_title=None, ending_subtitle=None, is_vertical=None, property_characteristics=None) /create_video VideoResponse
credits() /credits CreditsResponse
feedback(*, image_url=None, image_id=None, vote=None, comment=None, credit_back=None) /feedback FeedbackResponse

Examples

# Enhance — preserve exact framing (verification verticals)
pedra.enhance(image_url=url, preserve_original_framing=True)

# Empty a room
result = pedra.empty(url)

# Renovate, furnished, high creativity
pedra.renovation(url, style="Scandinavian", creativity="High", furnish=True)

# Edit via prompt
pedra.edit_via_prompt(url, "Add a large green plant in the corner")

# Sky replacement
pedra.sky(url)

# Remove an object using a mask
pedra.remove(url, mask_url)

# Blur faces / plates
pedra.blur(url, ["faces", "license_plates"])

# Credits
info = pedra.credits()
print(info.plan, info.credits_remaining)

# Feedback + credit-back on a bad result
pedra.feedback(image_url=url, vote="down", comment="Artifacts on the wall", credit_back=True)

Creating a video

create_video blocks server-side (up to ~10 minutes) while the video renders, then returns the finished URL inline. Image dicts use snake_case keys — the SDK converts them to the API's wire format for you:

video = pedra.create_video(
    images=[
        {"image_url": "https://example.com/photo1.jpg", "effect": "zoom-in", "title": "Living room"},
        {"image_url": "https://example.com/photo2.jpg", "effect": "zoom-out"},
        {
            "image_url": "https://example.com/before.jpg",
            "effect": "transition",
            "second_image_url": "https://example.com/after.jpg",
        },
    ],
    music={"enabled": True, "track": "calm"},
    branding={"show_watermark": True},
    ending_title="Contact us",
    ending_subtitle="+1 555 0100",
    is_vertical=False,
    property_characteristics=[
        {"label": "Bedrooms", "value": "3"},
        {"label": "Bathrooms", "value": "2"},
    ],
)

print(video.video_url)

Per-image effect is one of zoom-in (default), zoom-out, transition (requires second_image_url), or static. Each non-static image costs 5 credits.

Error handling

from pedra import PedraAPIError, PedraError

try:
    pedra.enhance(url)
except PedraAPIError as err:
    print(err.status, err, err.body)
except PedraError as err:
    print("Client/network error:", err)

PedraAPIError is also raised when a long request fails after the heartbeat has started — the API returns HTTP 200 with an {"error": ...} body in that case, and the SDK surfaces it as an error anyway.

Links

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pedra-0.3.0.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pedra-0.3.0-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file pedra-0.3.0.tar.gz.

File metadata

  • Download URL: pedra-0.3.0.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for pedra-0.3.0.tar.gz
Algorithm Hash digest
SHA256 d3adaf95a2bd9b7ea5df05385479f4807fbc87985e022ea2145cbf403ef65126
MD5 aecbd61c6e7952fe0cd7abfd0f3a322c
BLAKE2b-256 c539b87f615b85f8d29d87b674d8cd3639e2118b7675356c4b9f393c710ec168

See more details on using hashes here.

File details

Details for the file pedra-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: pedra-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for pedra-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 72b279d9bf3a4ae32dd012f47ec21693ea79b8a6e68bdb6ab0b98eef8a87bbee
MD5 d42ca0701ab181b4996131895f35da6b
BLAKE2b-256 8af1b497b9175dc318b98c82ca57546b231dcbd4df71fbeddac0ac9bbc82dae3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page