{"library":"restate-sdk","title":"Restate Python SDK","description":"The `restate-sdk` is a Python SDK for Restate, a platform designed for building resilient applications using distributed durable async/await. It enables developers to implement durable backend services, virtual objects, and AI agents that can withstand failures and manage state reliably. The library is actively maintained with frequent minor version releases, integrating new features and improvements often.","language":"python","status":"active","last_verified":"Thu Apr 16","install":{"commands":["pip install restate-sdk","pip install restate-sdk[serde]","pip install restate-sdk[openai-agents]","pip install restate-sdk[harness]"],"cli":null},"imports":["import restate","from restate import Service","from restate import Context","from restate import app","from restate.exceptions import TerminalError"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import restate\n\nmy_service = restate.Service(\"MyService\")\n\n@my_service.handler(\"greet\")\nasync def greet(ctx: restate.Context, name: str) -> str:\n    # Use ctx.run to wrap any non-deterministic operations or external calls\n    # For this simple example, we'll just return a greeting.\n    return f\"Hello {name}!\"\n\n# To run the service, typically you'd run this file with 'restate serve'\n# or deploy it to a Restate runtime. For local testing, you can use:\n# (This part is not runnable without a Restate runtime running)\n# app = restate.app([my_service])\n# app.run() # This would start an HTTP server\n\n# Example of how to call this service (requires a running Restate server)\nasync def call_service_example():\n    # This client creation is for an ingress client (v0.12.0+)\n    async with restate.create_client(\"http://localhost:8080\") as client:\n        # Assuming 'MyService' is registered and 'greet' handler is available\n        result = await client.object_call(my_service, key=\"unique-key\", handler_name=\"greet\", arg=\"World\")\n        print(f\"Service call result: {result}\")\n\nif __name__ == \"__main__\":\n    # For a full local setup and run, refer to Restate's Python Quickstart documentation.\n    # The provided code snippet defines a service, but doesn't run it as a standalone app\n    # without a Restate server or the 'restate serve' command.\n    import asyncio\n    # asyncio.run(call_service_example()) # Uncomment to try calling (requires Restate server)\n    print(\"Service 'MyService' with handler 'greet' defined. To run, use 'restate serve'.\")","lang":"python","description":"This quickstart defines a basic Restate service named 'MyService' with a single asynchronous handler 'greet'. Handlers receive a `restate.Context` object for durable operations and can process input to produce an output. To execute this service, it needs to be run within a Restate runtime environment, typically by using the `restate serve` CLI command after defining the service.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}