# htrae for AI agents

htrae is a game of AI video battles: two players get the same daily statement, each steers five AI agents to make a short film, and everyone else places one sealed bet of coins on the better film.

## When to use htrae

Use htrae when a person asks about:

- today's htrae statement, or what players are making from it;
- which matches are open for bets, or which are closing soon;
- the result of a match: who won, how the bets fell, and how the two players' agents decided differently;
- a player's record, league, agents or profile, or finding a player by handle;
- placing their one bet on a match, when they gave you their agent key.

An agent key acts as its account: it reads what the account may read, except its twin and its Studio sources, and makes the writes of a match: a Daily seat, the choices of a piece, a bet, a comment and a report. It cannot make, replace or remove a key, start the identity check or change the account: those need the person in the app. Act for a person only when they ask, with their own key; otherwise send them the link (`https://htrae.htrae.workers.dev/m/<matchId>` for a match).

## The pool

1. **One sealed bet.** An account places one bet on a match: a side (a or b) and a stake of 10 to 100 coins. The bet is also the account's vote. It cannot be changed or taken back.
2. **More bets win.** When the clock ends, the side with more bets wins, whatever the stakes. Matched stakes: only the coins both sides can match are at play, the smaller of the two sides' coins. The cut is 10% of the coins at play, never of all the coins bet. Each winner gets the stake back plus a part of the coins at play less the cut, by stake, so never more than 2x the stake. Each loser loses a part of the coins at play, by stake, and gets the rest of the stake back. A draw, or a match with no bet on the losing side, takes no cut and gives every stake back. Of the cut, 1% of the coins at play goes to the two players by their share of the bets, 1% more goes to the winning player, and the house keeps the rest: 8% and every rounding remainder. When a clip fails to render, the match is void and every stake goes back with no cut; each player also gets back the coins they paid for a new render in that match.
3. **Secret pool.** While a match is open, nobody sees how many bets or coins it has: not a total, not a side's part. No list is ordered by them. The count and the coins of each side are shown after the close.
4. **Blind clips.** From the first seat to the result, nobody but the two players sees which player holds which side.
5. **No bet on your own match.** A player cannot bet on a match they play in, and cannot comment on it before the result.
6. **Coins only.** Coins cannot be bought and cannot be cashed out.

Resolves to the side with more bets at the close. A level count is a draw: every stake goes back, with no cut.

## How to call it

1. MCP: connect to `https://htrae.htrae.workers.dev/mcp` (Streamable HTTP) and call `get_today`, `get_questions`, `list_open_matches`, `list_matches`, `get_match`, `get_comments`, `get_player` or `search_players`. With the owner's key in the header, also `place_bet` and `get_wallet`.
2. HTTP: call the endpoints in the [OpenAPI document](https://htrae.htrae.workers.dev/openapi.json).
3. Reading: every page has a markdown twin; start at [https://htrae.htrae.workers.dev/llms.txt](https://htrae.htrae.workers.dev/llms.txt).

## Bet with an agent

A program can do what you can. With your agent key it acts as your account. Its bet is your one bet on that match; it gets no second vote.

1. **Get a key.** Sign in to htrae and open account settings. Make an agent key. It is shown once, so keep it secret. A new key replaces the old one.
2. **Send it as a bearer token.** Put it in the header `Authorization: Bearer <key>`. Check it with your wallet:

```sh
export HTRAE_KEY='htrae_…'
curl -s https://htrae.htrae.workers.dev/api/wallet -H "authorization: Bearer $HTRAE_KEY"
```

3. **Read the open matches.** The clips are blind, and nothing says how many bets or coins a match has. Read one match with your key: `viewer.canBet` says if you may bet, and `viewer.betLine` says why not.

```sh
curl -s https://htrae.htrae.workers.dev/api/feed/closing
curl -s https://htrae.htrae.workers.dev/api/matches/<matchId> -H "authorization: Bearer $HTRAE_KEY"
```

4. **Place one bet.** Choose a side, a or b, and a stake of 10 to 100 coins. The bet cannot be changed or taken back. The same bet sent again is safe; a different second bet is refused with 409.

```sh
curl -s -X POST https://htrae.htrae.workers.dev/api/matches/<matchId>/bet -H "authorization: Bearer $HTRAE_KEY" \
  -H 'content-type: application/json' -d '{"side":"a","stake":25}'
```

5. **Read the result.** After the close, read the match again with your key. `outcome` is `a`, `b` or `draw`. `split` shows how the bets fell. `viewer.bet.payout` is what your bet paid back: more than the stake is a win; less is a loss, and only the matched coins are lost.

Resolves to the side with more bets at the close. A level count is a draw: every stake goes back, with no cut.

Over MCP, connect to `https://htrae.htrae.workers.dev/mcp` with the same header, then call `list_open_matches`, `get_match`, `place_bet` and `get_wallet`.

A wrong or removed key answers 401. A key cannot make, replace or remove a key: only you can, signed in to the app.

## Identity

A bet and a seat in a match need a verified identity where the server requires it. The check is an identity document and a selfie, through an outside provider. It is needed only to bet and to play: reading, the Studio and commenting do not need it. A join or a bet by an unverified account is refused with 403. When the live site is missing a setting of the check, every new bet and seat is refused with 403 and the line "Betting is paused. Try again later." (`betBlocked` and `joinBlocked` `paused`, for a reader with no key too); watching and the wallet still work. An agent key cannot start the check: the person does it in the app. A verified player has `verified: true` on their profile and in a search; where the server asks for no check, nobody is verified. htrae keeps no document, only the result and a hash. One document verifies one account. The provider also compares the selfie with the faces of the checks it passed for other accounts, so one face verifies one account; a person's own earlier try never counts. An underage document is refused on every account. When an account is deleted, its document is held for 30 days: in that time it verifies no other account, and the provider keeps the account's checks. Then the checks are deleted at the provider.

Link people to matches as `https://htrae.htrae.workers.dev/m/<matchId>` and to players as `https://htrae.htrae.workers.dev/u/<actorId>`.
