docs/aiand.md
CodexBar reads organization spend from ai&'s documented request-log API. ai& (aiand.com) is an OpenAI/Anthropic-compatible inference gateway that can back Claude Code, Codex CLI, and opencode (all three have dedicated integration guides in the ai& docs).
Create an API key in the ai& console (Settings → API Keys → Create). Keys use the sk-
prefix and are shown once at creation time. Add the key in CodexBar Settings → Providers → ai&.
You can also set the environment variable:
export AIAND_API_KEY="..."
Or configure it through the CLI:
printf '%s' "$AIAND_API_KEY" | codexbar config set-api-key --provider aiand --stdin
CodexBar requests:
GET https://api.aiand.com/logs?range=30days&limit=100, following next_after/next_after_id cursor pagination
(both cursors are always passed together, as the docs require) for up to 10 pages per refresh.Spend is the sum of each log row's cost field, parsed as decimal strings — never floating point — in the
organization's billing currency (currency per row: USD or JPY). Requests use Authorization: Bearer <AIAND_API_KEY>.
CodexBar does not read ai& browser cookies, console sessions, or inference prompts; only per-request cost/currency
metadata from the log rows is used.
Why the log endpoint: as of 2026-07-17 the documented cost_usd field is missing from live
GET /analytics/summary responses (the endpoint returns only request/token counts and a token timeseries), and
/analytics/metrics has no cost series either. /logs matches its documentation exactly and is the only public
endpoint that reports cost, so CodexBar sums spend from it.
The menu shows the last 30 days of organization spend, in the organization's billing currency, as an API-spend row. ai& bills prepaid credits with no quota windows, so no session or weekly meters are shown. The remaining credit balance is only available in the ai& console; the public API does not expose it.
Notes:
codexbar usage --provider aiand
ai& and ai-and also work as provider aliases.
401 means ai& rejected the API key; create a new key in the console (keys are shown only once).402 means the organization is out of prepaid credits; top up at console.aiand.com.429 means the per-minute rate limit was hit; CodexBar retries on the next refresh cycle.