Runware Python SDK

raw JSON →
0.5.10 verified Sat May 09 auth: no python

The Python Runware SDK provides a high-level interface to the Runware API for image and video generation, upscaling, captioning, background removal, and audio generation. It supports models from Runware's gallery and CivitAI, with ControlNet, inpainting, and outpainting. Current version: 0.5.10, requires Python >=3.10. Active development with regular releases.

pip install runware
error ModuleNotFoundError: No module named 'runware'
cause The package is not installed or installed in the wrong environment.
fix
Run 'pip install runware' in the correct Python environment (Python >=3.10).
error TypeError: object NoneType can't be used in 'await' expression
cause Forgetting to call connect() before an API call, or calling a sync method that is actually async.
fix
Ensure you call 'await runware.connect()' at the start of your async function and await all API calls.
error runware.exceptions.RunwareError: Invalid API key
cause Missing or incorrect API key provided to the Runware constructor.
fix
Set the RUNWARE_API_KEY environment variable or pass a valid key to Runware(api_key='...').
gotcha The SDK requires asyncio and Python >=3.10. All API calls are async; forgetting to await or not running inside an event loop will cause runtime errors.
fix Always use async/await and run the script with asyncio.run() or inside an async context.
gotcha The connect() method must be called before any API calls, and disconnect() after. Failing to do so may leave connections open or cause unexpected behavior.
fix Always call await runware.connect() before operations and await runware.disconnect() when done.
deprecated Older versions used a different initialization pattern (e.g., Runware(api_key=...). In 0.5.x, the constructor only accepts api_key as a keyword argument. Passing it positionally may break.
fix Use Runware(api_key='your_key').

Connect to the Runware API, generate an image, and print the result.

import asyncio
from runware import Runware

async def main():
    runware = Runware(api_key=os.environ.get('RUNWARE_API_KEY', ''))
    await runware.connect()
    result = await runware.image_generation(
        model="runware:100@1",
        positive_prompt="a beautiful landscape",
        number_of_images=1,
        height=512,
        width=512,
    )
    print(result)
    await runware.disconnect()

if __name__ == "__main__":
    asyncio.run(main())