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.
Prerequisites
Section titled “Prerequisites”- Python 3.9 – 3.13 (3.14+ is not yet supported)
- pip, uv, or any PEP 517 installer
- Node.js 20+ and TypeScript 5.0+
- Use standard TypeScript decorators; leave
experimentalDecoratorsunset.
Install
Section titled “Install”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:
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.whlUse 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.
Install the TypeScript package from Forgejo packages using the Aster registry scope below.
Add this scope mapping to your project’s .npmrc:
@aster-rpc:registry=https://forge.emrul.dev/api/packages/Aster/npm/Then install the pinned preview and TypeScript compiler:
npm install @aster-rpc/aster@0.3.893npm install --save-dev typescript@^5 @types/nodeConfigure package.json and tsconfig.json as shown in TypeScript build setup before continuing.
Define a service
Section titled “Define a service”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 dataclassfrom aster import service, rpc, wire_type
@wire_type("hello/HelloRequest")@dataclassclass HelloRequest: name: str = ""
@wire_type("hello/HelloResponse")@dataclassclass HelloResponse: message: str = ""
@serviceclass 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.
Create service.ts:
import { Service, Rpc, WireType } from '@aster-rpc/aster';
@WireType("hello/HelloRequest")export class HelloRequest { name = ""; constructor(init?: Partial<HelloRequest>) { if (init) Object.assign(this, init); }}
@WireType("hello/HelloResponse")export class HelloResponse { message = ""; constructor(init?: Partial<HelloResponse>) { if (init) Object.assign(this, init); }}
@Service({ name: "HelloService", version: 1 })export class HelloService { @Rpc() async sayHello(req: HelloRequest): Promise<HelloResponse> { return new HelloResponse({ message: `Hello, ${req.name}!`, }); }}@Service identifies the service, @Rpc exposes its method, and @WireType gives each exported data type an explicit wire tag. See Defining services and types for the contract rules.
Before running, generate type metadata with npx aster-gen — this reads your TypeScript source and emits aster-rpc.generated.ts, which AsterServer auto-imports on startup. See TypeScript Build Setup for details and bundler plugin options.
Run a producer
Section titled “Run a producer”A producer is the node that hosts the service.
Create producer.py:
import asynciofrom hello_service import HelloServicefrom 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())python producer.pyGenerate type metadata, then create producer.ts:
npx aster-genimport { AsterServer } from '@aster-rpc/aster';import { HelloService } from './service.js';
const server = new AsterServer({ services: [new HelloService()], allowAllConsumers: true, // Development only: no enrollment required.});await server.start();console.log("Producer ready at:", server.address);// Keep this standalone Node process alive while native work is pending.const keepAlive = setInterval(() => {}, 60_000);try { await server.serve();} finally { clearInterval(keepAlive); await server.close();}npx tscnode producer.jsThe timer keeps a standalone Node producer alive: native
pending work alone may not keep the JavaScript event loop alive. Keep it until
serve() completes and clear it during shutdown. Without it, the producer can
exit with an unsettled top-level-await warning and leave consumers waiting.
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.
Run a consumer
Section titled “Run a consumer”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 asynciofrom 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:
# macOS / LinuxASTER_ENDPOINT_ADDR="<paste from producer output>" python consumer.py# Windows (PowerShell)$env:ASTER_ENDPOINT_ADDR="<paste from producer output>"; python consumer.pyAsterClient 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.
Create consumer.ts:
import { AsterClientWrapper } from '@aster-rpc/aster';import { HelloService, HelloRequest } from './service.js';import { SERVICES, WIRE_TYPES, BUILD_ALL_TYPES } from './aster-rpc.generated.js';
const client = new AsterClientWrapper({ address: process.env.ASTER_ENDPOINT_ADDR!, generated: { SERVICES, WIRE_TYPES, buildAllTypes: BUILD_ALL_TYPES },});try { await client.connect();
const hello = await client.client(HelloService); const resp = await hello.sayHello(new HelloRequest({ name: "World" })); console.log(resp.message); // Hello, World!} finally { await client.close();}Run it, passing the producer’s address:
# macOS / Linuxnpx tscASTER_ENDPOINT_ADDR="<paste from producer output>" node consumer.js# Windows (PowerShell)npx tsc$env:ASTER_ENDPOINT_ADDR="<paste from producer output>"; node consumer.jsConnection behavior
Section titled “Connection behavior”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.
Check the result
Section titled “Check the result”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-genandnpx tscfrom 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 issayHello.
Build with an agent
Paste the instruction into your coding harness, or follow the steps below.
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.
Next steps
Section titled “Next steps”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.