Skip to main content

GPT Image text-to-image and edit-image client for RunAPI

Project description

GPT Image Python SDK for RunAPI

The GPT Image Python SDK is the language-specific package for GPT Image on RunAPI. Use it for text-to-image and edit-image flows when your application needs JSON request bodies, task status lookup, and consistent RunAPI errors in Python.

For model details, use https://runapi.ai/models/gpt-image; for API reference, use https://runapi.ai/docs#gpt-image; for SDK docs, use https://runapi.ai/docs#sdk-gpt-image.

Install

pip install runapi-gpt-image

Quick start

from runapi.gpt_image import GptImageClient

client = GptImageClient()  # reads RUNAPI_API_KEY, or pass api_key="sk-..."

task = client.text_to_image.create(
    model="gpt-image-1.5",
    prompt="A futuristic cityscape at dusk, cinematic",
    aspect_ratio="1:1",
    quality="high",
)
status = client.text_to_image.get(task.id)

edit = client.edit_image.create(
    model="gpt-image-1.5",
    prompt="Transform into an oil painting",
    source_image_urls=["https://example.com/source.jpg"],
    aspect_ratio="1:1",
    quality="high",
)

Use create to submit a task and return quickly, get to fetch the latest task state, and run to create and poll until completion:

result = client.text_to_image.run(
    model="gpt-image-1.5",
    prompt="A serene mountain lake at dawn",
    aspect_ratio="3:2",
    quality="high",
)
print(result.images[0].url)

In web request handlers, prefer create plus webhook or later get polling so a worker is not held open.

RunAPI-generated file URLs are temporary. Download and store generated images in your own durable storage within 7 days; do not treat returned URLs as long-term assets.

Language notes

Pass parameters as keyword arguments and catch the runapi.gpt_image error classes when building image jobs or scripts. The available resources are text_to_image and edit_image. Keep RUNAPI_API_KEY in the environment or your secret manager; never commit API keys or callback secrets.

Links

License

Licensed under the Apache License, Version 2.0.

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

runapi_gpt_image-0.1.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

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

runapi_gpt_image-0.1.0-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file runapi_gpt_image-0.1.0.tar.gz.

File metadata

  • Download URL: runapi_gpt_image-0.1.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.6

File hashes

Hashes for runapi_gpt_image-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cc1cd7ae460fc97f30043476ec165a7b8379db4f51952372f40ecf77cfbf7b36
MD5 50df3b0a38dc7ecea6e71f79158137bd
BLAKE2b-256 c7d2ad68b7efd3e8043222197f905be4ebfc6c45064d84159cf25154fd074e08

See more details on using hashes here.

File details

Details for the file runapi_gpt_image-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for runapi_gpt_image-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d65b6935f2cc6dace569d86831cd04145242c154ef8a178b0cb89aeac71d2ab0
MD5 815512a76680d5f62f3c39b9fa84a972
BLAKE2b-256 f7f0bd0e86209a9b35bac386f3e6d85a2ac9467c9b7a4aff4a0f235f734edbb9

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