# `Rho.Usage.Fetch`
[🔗](https://github.com/GenericJam/rho/blob/v0.1.0/lib/rho/usage/fetch.ex#L1)

Asks a provider's OAuth usage endpoint what its subscription has left,
with the sign-in's access token (`Rho.Auth.credential/1`), as omp
does (subscriptions only: an API key has no such endpoint):

  * Claude: `GET https://api.anthropic.com/api/oauth/usage` with the
    `oauth-2025-04-20` beta and Claude Code's user agent
  * ChatGPT: `GET https://chatgpt.com/backend-api/wham/usage` with the
    `chatgpt-account-id`

`refresh/3` stores the result (`Rho.Usage.put_endpoint/5`). The
token goes only into the request's `authorization` header; errors never
include it.

# `fetch`

```elixir
@spec fetch(Rho.Auth.provider(), keyword()) :: {:ok, map()} | {:error, String.t()}
```

`provider`'s usage JSON, or why there is none: signed out, an API key
(no subscription), an expired sign-in, or the endpoint's HTTP status and
message (it answers 429 when asked too often).

# `refresh`

```elixir
@spec refresh(Path.t(), Rho.Auth.provider(), keyword()) :: :ok | {:error, String.t()}
```

Fetches and stores `provider`'s windows. `opts`: `:credential` (default
`Rho.Auth.credential/1`), `:respond` (a test's fake response for
the `Req.Request`), `:now`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
