Python SDK for the Xences AI execution runtime
pip install xences-ai The client signs authentication requests with your application's RSA private key. Keep the private key in a server-side secret store — never expose it to clients or ship it in a browser or mobile application.
import os from xences_ai import Xences, Principal xences = Xences( app_id=os.environ["XENCES_APP_ID"], private_key=os.environ["XENCES_PRIVATE_KEY"], base_url="https://xences.app", ) result = xences.goals.create( request="Reschedule my appointment to Friday", principal=Principal(external_id=user.id), # "human" is the default type ) For async applications use await xences.goals.acreate(...).
Expose handlers for operations the platform can invoke on your application, then register them once at startup:
xences.expose( "orders.refund", method="POST", path="/orders/:id/refund", input_schema={ "type": "object", "required": ["orderId"], "properties": {"orderId": {"type": "string"}}, }, )(lambda input, context: orders.refund(input["orderId"])) xences.register() The decorator form is also supported:
xences = Xences( app_id=os.environ["XENCES_APP_ID"], private_key=os.environ["XENCES_PRIVATE_KEY"], xences_public_key=os.environ["XENCES_PUBLIC_KEY"], # verifies inbound calls base_url="https://xences.app", ) The default invoke path (/.well-known/xences/invoke) is sent to the platform when you call register(). Mount it in your web framework:
from flask import Flask, request from xences_ai import XencesError app = Flask(__name__) @app.post("/.well-known/xences/invoke") def invoke(): try: return xences.handle_request( body=request.get_json(), headers=dict(request.headers), ) except XencesError as e: return {"success": False, "error": str(e)}, e.status or 500 FastAPI from fastapi import FastAPI, Request from fastapi.responses import JSONResponse from xences_ai import XencesError app = FastAPI() @app.post("/.well-known/xences/invoke") async def invoke(request: Request): try: return await xences.ahandle_request( body=await request.json(), headers=dict(request.headers), ) except XencesError as e: return JSONResponse( {"success": False, "error": str(e)}, status_code=e.status or 500, ) handle_request and ahandle_request verify the platform's app identity, timestamp freshness, replay protection, and RSA signature before dispatching. They raise XencesError with a status code on any failure.
Rotation is opt-in. Set allow_key_rotation=True and call rotate_key() only after registering the new public key with the platform operator:
xences = Xences( ..., allow_key_rotation=True, ) xences.rotate_key(new_public_key_pem) Key dates PyPI data Data sourced directly from PyPI's database. Released: Oct 10, 2026 Latest release 1 maintainer PyPI data Data sourced directly from PyPI's database. xences-ai License MIT License (MIT)
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.




