Skip to content

Your first Python or TypeScript service

A remote procedure call (RPC) lets one process invoke a method hosted by another. You will run a producer that hosts a greeting service and a consumer that calls it and prints Hello, World!. Use the Python or TypeScript tab consistently for this first run; the cross-language example connects different languages afterward.

The service definition describes the request and response. The producer prints an address ticket, which the consumer uses to find and authenticate that peer. Start both processes on the same machine before trying separate networks.

  • Python 3.9 – 3.13 (3.14+ is not yet supported)
  • pip, uv, or any PEP 517 installer

Install the Python package from Forgejo packages. Choose the wheel for your platform from the Python artifact list: Apple Silicon macOS, Linux x86-64 or ARM64 (glibc 2.34+), or Windows x86-64.

For example, on Apple Silicon macOS:

Terminal window
python -m pip install https://forge.emrul.dev/api/packages/Aster/generic/aster-python/0.3.893/aster_rpc-0.3.893-cp39-abi3-macosx_11_0_arm64.whl

Use the corresponding wheel URL on other platforms. Python 3.9–3.13 is required. The optional CLI is independently versioned; see the CLI reference for installation and its validation limits.

A service is a class that exposes one or more methods callable by remote consumers. You write it like a regular class; Aster handles the wire format, transport, and remote dispatch.

Create hello_service.py:

from dataclasses import dataclass
from aster import service, rpc, wire_type
@wire_type("hello/HelloRequest")
@dataclass
class HelloRequest:
name: str = ""
@wire_type("hello/HelloResponse")
@dataclass
class HelloResponse:
message: str = ""
@service
class HelloService:
@rpc
async def say_hello(self, req: HelloRequest) -> HelloResponse:
return HelloResponse(message=f"Hello, {req.name}!")

@dataclass defines the data fields, @wire_type gives each type an explicit wire tag, @service identifies the service, and @rpc exposes the method. See Defining services and types for the contract rules.

A producer is the node that hosts the service.

Create producer.py:

import asyncio
from hello_service import HelloService
from aster import AsterServer
async def main():
async with AsterServer(services=[HelloService()], allow_all_consumers=True) as srv:
print("Producer ready at:", srv.address)
await srv.serve()
asyncio.run(main())
Terminal window
python producer.py

These examples explicitly allow unenrolled consumers for development. With no identity configured, the server:

  • Generates an ephemeral node identity.
  • Opens the consumer gate so consumers can connect without credentials.
  • Serves RPC, blobs, docs, and gossip on a single endpoint.
  • Prints an aster1... address for consumers to connect to.

A consumer calls a producer’s service. The Python example uses a dynamic proxy that reads the published contract. The TypeScript example shares the service definition to get a statically typed client.

The producer and consumer can run on separate networks. Aster attempts a direct connection and uses a relay when needed. Connectivity still requires a reachable direct or relay path. The aster1... address contains the endpoint identity and connection hints.

Create consumer.py:

import asyncio
from aster import AsterClient
async def main():
async with AsterClient() as c:
# The dynamic proxy builds XLANG requests from the published contract --
# methods are discovered from the producer's published contract.
hello = await c.proxy("HelloService")
resp = await hello.say_hello({"name": "World"})
print(resp["message"]) # Hello, World!
asyncio.run(main())

Run it, passing the producer’s address:

Terminal window
# macOS / Linux
ASTER_ENDPOINT_ADDR="<paste from producer output>" python consumer.py
Terminal window
# Windows (PowerShell)
$env:ASTER_ENDPOINT_ADDR="<paste from producer output>"; python consumer.py

AsterClient reads ASTER_ENDPOINT_ADDR from the environment and connects to the producer. await c.proxy("HelloService") returns a dynamic stub – call methods on it like regular async functions. If you’d rather have typed classes (for IDE autocomplete and static checking), share the service definition module between producer and consumer and use await c.client(HelloService) instead – see Defining Services and Types.

The producer publishes its contract and prints an aster1... address. The consumer uses that address to connect, discover the contract, and invoke the greeting method. Transport authentication verifies the endpoint key; open development mode admits consumers without enrollment credentials.

Development mode uses an ephemeral identity, so the address changes after a restart. To try separate machines, copy the current address into the consumer’s ASTER_ENDPOINT_ADDR. Each machine needs a reachable direct or relay path.

The consumer should print Hello, World! and exit. The producer remains running until you stop it with Ctrl+C. If the result does not appear:

  • Confirm the producer is still running and copy its current address again.
  • If TypeScript reports missing metadata, run npx aster-gen and npx tsc from the project directory before starting the producer.
  • If admission is refused, check the explicit development admission flag instead of assuming that a new identity opens access.
  • If the call reports an unknown service or method, use the matching tab for both processes: the Python method is say_hello, the TypeScript method is sayHello.

Build with an agent

Paste the instruction into your coding harness, or follow the steps below.

Prompt draft
Download .txt
Read the instruction
Build a small Aster Python service and client in the current workspace.

Sources:
- https://sdk.getaster.now/docs/quickstart/python
- https://sdk.getaster.now/docs/bindings/python
- https://github.com/aster-rpc/aster-rpc

Read the linked Python quickstart before writing code. Use the public wheel from Forgejo as directed by the guide, and record the exact Aster and Python
versions you install. If the published package and guide disagree, identify the
mismatch and stop rather than inventing APIs or using private dependencies.

Create an isolated environment and a project containing request and response
types, a HelloService with a say_hello method, a producer, and a consumer. The
producer should print its Aster address. The consumer should take that address
as configuration, call the service with the name World, and print Hello, World!

Use the guide's explicit allow_all_consumers=True development configuration for this local demonstration. Do not
describe it as a production authorization setup. Do not open public firewall
ports, commit credentials, or change machine-wide networking settings.

Start the producer locally, capture its actual address, and run the consumer
against it. Confirm the expected response using the real Aster connection. Add
a short README with installation, startup, consumer, and shutdown commands.
Record dependency versions so the project can be reproduced. Stop the processes
you started after verification unless I ask you to keep them running.

Report the files created, installed versions, commands run, observed response,
and any remaining problems. If network access, native package installation, or
execution is unavailable, report that limit; do not claim the example passed.

This prompt is a draft for the documentation design preview and has not yet been
validated in a coding harness.

This instruction has not yet been tested in a harness. It is included here to review the tutorial format.

Choose a task in What’s next, or try the Python-to-JavaScript call.

The Mission Control walkthrough explores streaming, sessions, and capability requirements. It remains a draft for the full multi-chapter workflow. See the trust model before exposing a service beyond development.