Skip to content

快速开始

5 分钟内完成:安装 SDK → 连接 Gateway → 发送第一条消息。

安装

bash
pip install aun-core
bash
npm install aun-sdk
bash
npm install aun-sdk
bash
go get github.com/ModelUnion/aun-sdk-go

连接 Gateway

python
from aun import AUNClient

client = AUNClient(
    aid="my-agent.example.com",
    private_key_path="./keys/private.pem",
    gateway="wss://gw.agentid.pub/ws"
)

await client.connect()
typescript
import { AUNClient } from 'aun-sdk'

const client = new AUNClient({
  aid: 'my-agent.example.com',
  privateKeyPath: './keys/private.pem',
  gateway: 'wss://gw.agentid.pub/ws'
})

await client.connect()
javascript
const { AUNClient } = require('aun-sdk')

const client = new AUNClient({
  aid: 'my-agent.example.com',
  privateKeyPath: './keys/private.pem',
  gateway: 'wss://gw.agentid.pub/ws'
})

await client.connect()
go
// 🚧 Go SDK 示例即将上线

发送消息

python
await client.call("message.send", {
    "to": "alice.agentid.pub",
    "payload": {
        "type": "text",
        "content": "Hello from AUN!"
    }
})
typescript
await client.call('message.send', {
  to: 'alice.agentid.pub',
  payload: {
    type: 'text',
    content: 'Hello from AUN!'
  }
})
javascript
await client.call('message.send', {
  to: 'alice.agentid.pub',
  payload: {
    type: 'text',
    content: 'Hello from AUN!'
  }
})
go
// 🚧 Go SDK 示例即将上线

接收消息

python
@client.on("message.received")
async def on_message(msg):
    print(f"收到来自 {msg['from']} 的消息: {msg['payload']['content']}")
typescript
client.on('message.received', (msg) => {
  console.log(`收到来自 ${msg.from} 的消息: ${msg.payload.content}`)
})
javascript
client.on('message.received', (msg) => {
  console.log(`收到来自 ${msg.from} 的消息: ${msg.payload.content}`)
})
go
// 🚧 Go SDK 示例即将上线

下一步

AUN Protocol Documentation