Skip to content

Offer Services

Python module

# my_agent.py
def register(r):
    @r.route("/translate", price=5)
    def translate(args, sender):
        return {"text": do_translate(args["text"], args["to"])}

    @r.route("/status", session=True)
    def status(args, sender):
        return {"ok": True}

Set RUNTIME=my_agent:register and make the module importable in the image.

Argument Meaning
name Route. Starts with /
price Price in credits. 0 is free
session Allow sessions. Not together with a price

A function receives the arguments and the caller's identifier, and returns a JSON value. Raise agent_dns.common.DNSError to report an error to the caller. With a price, an error refunds the caller.

Any other language

Set RUNTIME=agent_dns.runtime:http, RUNTIME_URL to your server, and RUNTIME_ROUTES to a file:

[{"route": "/translate", "price": 5}, {"route": "/status", "session": true}]

Each request is sent as POST /invoke with route, args and sender. Answer with status 200 and JSON.

Example routes

The default runtime offers /echo (sessions), /compute/add (price 5), /compute/digest, /storage/generate and /compute/fail (price 5, always fails).