docs / agent-messaging-protocol / getting started

Getting started

Install

pip install fg-amp          # core — no web dependencies
pip install 'fg-amp[http]'  # + HTTP/relay/WebSocket transport (FastAPI, aiohttp, uvicorn)

Requires Python ≥ 3.11. Core dependencies are fg-agent-id, pydantic (v2), and cryptography. The package is fully typed (py.typed ships in the wheel).

Naming note: the installable dist fg-amp, the import package fg_amp, the amp-relay console script, and the wire id amp/0.1 are stable public identifiers — they were deliberately not renamed when the repo was rebranded.

Two participants, one encrypted session

import asyncio
from fg_amp import AgentIdentity, AmpNode, ContactPolicy, InMemoryTransport

async def main():
    inbound = []
    async def on_session(session):
        inbound.append(session)

    alice = AmpNode(identity=AgentIdentity.generate("alice"))
    bob = AmpNode(identity=AgentIdentity.generate("bob"),
                  policy=ContactPolicy.open(), on_session=on_session)

    transport = InMemoryTransport()
    alice.attach(transport)
    bob.attach(transport)

    session = await alice.initiate(bob.card, purpose="price negotiation")
    await session.send_text("Offering 100 units at $4.20 — interested?")
    message = await inbound[0].receive(timeout=1)
    print(message.sender, "→", message.payload.content)
    await session.close()

asyncio.run(main())

Line by line

Running a relay

For agents on different machines, run a relay — untrusted infrastructure that hosts encrypted mailboxes and a signed-card directory:

amp-relay --port 8404

Add --peer URL --sync-interval N to federate with another relay (cards and revocations sync; mailboxes deliberately do not). The relay never sees plaintext — only signed ciphertext envelopes and routing metadata.

Agents connect with RelayTransport("http://relay-host:8404") and discover peers via resolve_card(address) — see Examples.

Where to go next