Skip to documentation
Anywe

Agent quickstart

Put a working agent in your own contact list, from a terminal, in about ten minutes. You will generate an agent, register it, connect it over the relay, and message it.

The path
  1. Generate

    anywe init

  2. Register

    anywe agent create

  3. Credential

    anywe agent secret

  4. Connect

    anywe listen --relay

  5. Message

    anywe agent test

Before you start

  • Go 1.24 or later. anywe init writes a Go agent, the only language it generates today, and the agent builds with no dependencies. There is no Python or Node generator and no published package for either yet. If you are not using Go, the platform only needs an endpoint that verifies the signature and replies asynchronously: see Integrate an existing service, and the SDK helpers, which sign and verify in TypeScript and Python from a checkout.
  • An Anywe account, the same one you use in the app.

Prepare the CLI

  1. Install the CLI

    Shell
    curl -fsSL https://cli.anywe.dev/install.sh | sh

    The installer covers macOS and Linux on amd64 and arm64 and verifies the download against the published checksums. To build from source instead, see the CLI reference.

  2. Sign in

    Shell
    anywe login --browser

    A browser window opens; the terminal waits for it. On a server, in a container or in CI there is no browser, so sign in by emailed code in two steps:

    Shell
    anywe login --email [email protected]
    anywe login --email [email protected] --code 123456

    The first command sends a six-digit code. On a terminal it then waits for you to type it; with no terminal on stdin it prints the second command and exits. The second command checks the code and never sends one. Confirm the session:

    Shell
    anywe whoami
  3. Create a publisher

    Shell
    anywe publisher create --name "Your Name"

    Agents belong to a publisher, not to a user. One publisher is enough; if you skip this step, anywe agent create stops and tells you to run it.

Register the agent

  1. Generate the agent

    Shell
    anywe init <your-handle>
    cd <your-handle> && go build ./...

    <your-handle> is your agent's handle, and anywe init names the directory after it. Handles are unique across all of Anywe, so pick your own: 3 to 64 lowercase letters, digits and dashes, starting and ending with a letter or digit, such as alex-hello. A handle someone else holds, including any example in these docs, stops with agent_handle_taken.

    anywe init writes a complete agent: an HTTP server that verifies every delivery's signature, acknowledges inside the platform's ten-second budget, and answers on its own goroutine. The only file you will edit later is agent.go.

  2. Register it

    Shell
    anywe agent create --handle <your-handle>

    Use the same handle you gave anywe init.

    No --webhook is needed: this agent will be reached over the relay, and the CLI fills in a placeholder address that is never dialed while the relay is connected. The output ends with a reminder that the agent has no credential yet. That is the next step.

    An account can own three agents. At three, anywe agent create stops with account_agent_limit_reached. To free a slot, delete an agent you own by naming its handle back, or add --yes to skip that:

    Shell
    anywe agent delete agt_01ARZ3NDEKTSV4RRFFQ69G5FAV <your-handle>

    Deleting withdraws the agent for good: its handle stays reserved, and conversations keep its past messages. Only the agent's owner can delete it.

  3. Issue its credential

    Shell
    anywe agent secret agt_01ARZ3NDEKTSV4RRFFQ69G5FAV

    Use the agt_ id the previous step printed. The secret is shown exactly once and no command returns it again. The command prints export lines; paste them into your shell, or into a file you source. CLI v0.3.0 prints both sets, these ANYWE_* names and their former AICONNECT_* names, so an agent generated by either release reads them. If you still run v0.2.0, it prints only AICONNECT_AGENT_ID, AICONNECT_CREDENTIAL_ID and AICONNECT_AGENT_SECRETS:

    Shell
    export ANYWE_AGENT_ID=agt_01ARZ3NDEKTSV4RRFFQ69G5FAV
    export ANYWE_CREDENTIAL_ID=cred_01ARZ3NDEKTSV4RRFFQ69G5FAV
    export ANYWE_AGENT_SECRETS=the-secret-printed-once

Prove the loop

Three terminals: the agent, the relay, and you.

One delivery, end to end
  1. You

    anywe agent test

  2. Platform

    delivery queued

  3. Relay

    anywe listen

  4. Your agent

    ack, then Answer()

  5. Platform

    reply stored

  6. You

    reply printed

  1. Start the agent

    In the <your-handle> directory, with the three variables exported:

    Shell
    go run .

    It listens on port 9092 and serves POST /webhook, which is why the relay below forwards to that path. If something else already holds 9092, pick another port with AGENT_LISTEN and use the same port in the relay's --forward-to:

    Shell
    AGENT_LISTEN=:19092 go run .
  2. Connect it over the relay

    In a second terminal, with the same three variables exported:

    Shell
    anywe listen --relay --forward-to http://localhost:9092/webhook

    The relay holds an outbound connection to the platform and forwards deliveries to your local process. No public DNS, no inbound port, no tunnel. Close this terminal and the agent is offline; the platform sees that directly rather than inferring it from failed deliveries.

  3. Message it

    In a third terminal:

    Shell
    anywe agent test "$ANYWE_AGENT_ID" "Hello from the terminal"

    This creates a real conversation, sends the message, and waits for the reply. It is the same path a user takes from the app. The reply is asynchronous: the platform acknowledges the delivery within ten seconds, and the agent answers afterwards. If the delivery fails (for example, the relay is not connected), the command stops at once and prints the platform's error code, last error and hint, so the reason is on screen rather than in a log file; if nothing arrives before the timeout, it reads the delivery log and prints the same.

Open the app and the conversation you just started is in your inbox. The agent is private by default, so only you can message it for now.

When something does not work

Shell
anywe check --agent-id "$ANYWE_AGENT_ID"
anywe logs "$ANYWE_AGENT_ID" --follow

anywe check confirms the platform is reachable and the credential is valid, and needs no account for its local checks. A relay-connected agent publishes no endpoint, so check does not probe one; for that, anywe logs --follow is the command with the answer. It shows each delivery's status and last error as it happens, including relay_not_connected when the anywe listen terminal is closed.

Do not register a localhost address as a webhook to work around the relay: deliveries carry conversation content, and the platform refuses non-HTTPS endpoints for that reason.

Circuit breaker

After five consecutive failed deliveries to one agent, the platform stops dispatching to it for about a minute, and anywe logs shows breaker open: ... retrying automatically until <time> on the waiting deliveries. That is a pause, not a fault to fix: repair whatever was failing (a wrong --forward-to path is the usual one, and the relay prints each delivery's status, so a 404 there names it), wait for the time in that line, and the queued deliveries go out on their own. A 429 from your agent does not count toward the five.

Next steps

Make it yours. agent.go is one function. It runs after the platform has been acked, so it may take as long as a language model needs:

Go
func Answer(ctx context.Context, question string, locale string) (string, error) {
	if strings.TrimSpace(question) == "" {
		return "", errors.New("empty message")
	}
	return "You said: " + question, nil
}

locale is the user's language tag (vi, en), passed on every delivery, so answering in their language costs one comparison. Return an error to send nothing; the failure is logged.

  • Reply with blocks. You receive text and send blocks; the reply workflows guide covers cards, tables and forms, and the block reference lists every type.
  • Ship it on a server. For an agent with its own HTTPS endpoint, register a real --webhook and verify each delivery as the request-signing reference describes.
  • Let others message it. Change the access policy with anywe agent policy; see the CLI reference.
  • Work on it from Claude Code. Anywe runs an MCP server, and there is a Claude Code plugin that installs in two commands; see Use Anywe from Claude Code.