Skip to content

m7 ai

Last updated: 2026-11-25T17:18:19-03:00 (UTC-3)

Most questions about a gateway are a filter and a group-by away: “how much did each team spend on each model per hour yesterday?”, “which keys got the most 429s, and were they ours or the provider’s?”, “what blocked these requests?”, “how do I set up a fallback?”. m7 ai answers them in plain language from the console, in any language you ask in, with the data you are allowed to see and nothing else. It shows every step it took, so you can check where a number came from.

Flags: ask_ai (off in the shipped configuration) and usage_analytics (on). Permission: analytics:read. With the separate flag ask_ai_actions (off), m7 ai can also propose administrative changes that run only after you confirm them.

The m7 ai launcher, the round button with m7 inside in the bottom-right corner of the console, opens the chat. You pick a chat model; your question goes to that model through this gateway, with a fixed set of read-only tools. The model decides which tools to call; the gateway runs them and returns the results to the model, for up to eight rounds, and the model answers from those results.

Every tool reads through one of the console’s own GET endpoints, called with your session. m7 ai therefore never sees more than your screens do: the same role permissions, the same team scope, the same flags and plan entitlements, the same 90-day range. A team viewer asking about another team gets the same refusal the Analytics screen gives (team_forbidden), and the model is told to say so.

These tools only read. No tool creates, changes, deletes, sends or runs anything, and nothing runs a program on the gateway’s host: the text search below is implemented inside the gateway. The only exception is opt-in: with ask_ai_actions, propose_* tools prepare a change that you review and confirm yourself (see Administrative actions); even they change nothing on their own.

Tool What it answers Reads
usage_query Totals, rankings, breakdowns and time series over every matching request: any combination of dimensions, a time bucket in a time zone, metrics, filters, order and row limit GET /api/v1/admin/analytics/query
usage_report The Analytics screen’s summary with the previous period and the top groups GET /api/v1/admin/analytics
request_logs A sample of individual requests (metadata only), newest first GET /api/v1/admin/logs
search_text Regular-expression search, like grep and sed, over request log metadata, audit events, the effective configuration, the documentation and the API reference the matching console endpoint, the documentation build and the embedded OpenAPI
read_document A range of lines of one documentation page or of the OpenAPI file the documentation build, the embedded OpenAPI
read_console One console resource: session, configuration (and its features, models and providers sections), keys, teams, console users (administrators only), organizations, guardrails, guardrail policies, alert channels and deliveries, quota status and alerts, rate limits, routing status, resilience, price book, MCP health, savings, or one request by ID the resource’s console endpoint
  1. Turn on ask_ai (Settings & sources → Features, or features.ask_ai: true in YAML). usage_analytics must be on.
  2. Open any console page and click the m7 ai launcher. Choose the model in the panel header; the choice is remembered in this browser.
  3. Type the question and press Enter or the send button (Shift+Enter starts a new line). Follow-up questions carry the conversation (the last six turns).
  4. Open Steps under an answer to see what ran: each tool, its arguments, the HTTP status and a summary such as 10 rows of 191 groups. For usage_query, the step shows the structured query in one line, for example by team, model · per hour (America/Sao_Paulo) · cost_usd, requests · order cost_usd desc · limit 10, including whether it covered every team or only yours.

Answers render tables, code blocks and bold text. Links are never rendered: a URL that came from logged data stays plain text.

m7 in the launcher is live: it breathes, blinks and follows the pointer with its eyes, and hops when you press the launcher. With reduced motion turned on in the operating system (prefers-reduced-motion), it stays still and only blinks; with reduced transparency (prefers-reduced-transparency), the chat panel is opaque.

Any enabled chat alias that is not auto-routed works. How well a model follows tool instructions matters more than its size: in our tests a small current model answered most of the example questions below correctly in one or two rounds, while an older small model more often guessed filter values or put the time bucket in the wrong field. The tools correct the common mistakes (see Limits), and a stronger model needs fewer rounds. Check the steps when a number matters.

Question What the model does
Cost per team per model per hour in the last 24 hours, top 10 usage_query with group_by [team, model], bucket hour, metrics [cost_usd], order_by cost_usd, limit 10
Which keys had the most 429s yesterday, and from which provider? Ours or theirs? usage_query filtered on status 429, grouped by key_id, provider, error_code: rate_limited is the gateway’s own limit, an empty code is the provider’s 429
Find timeout errors in the logs usage_query with non_empty [timeout_kind], grouped by timeout_kind, model, provider
Which guardrail blocked the most requests? usage_query grouped by guardrail with non_empty [guardrail]
How do I configure a fallback? search_text over docs for fallback, then read_document on the best page
Who changed something in the control plane today? search_text over audit with pattern . and count_by actor
Which teams and models are configured, and is m7 ai on? read_console for teams, models and features

With evaluation_metrics, m7 ai also answers quality questions with the same tool: pass rate, mean score, feedback count and judge spend per evaluation, by any dimension of the judged request.

GET /api/v1/admin/analytics/query is also a plain API, for dashboards and scripts. It needs analytics:read and usage_analytics, like the report it generalizes. The server builds the SQL from fixed names; nothing the caller sends is ever SQL text.

Terminal window
curl -s -b cookies.txt "http://localhost:8080/api/v1/admin/analytics/query?group_by=team,model&bucket=hour&timezone=America/Sao_Paulo&metrics=cost_usd,requests&order_by=cost_usd&limit=10"
{
"query": {"from": "2026-11-07T12:25:00Z", "to": "2026-11-08T12:25:00Z", "group_by": ["team", "model"], "bucket": "hour",
"timezone": "America/Sao_Paulo", "metrics": ["cost_usd", "requests"], "order_by": "cost_usd", "order": "desc", "limit": 10, "scope": "all"},
"columns": ["bucket", "team", "model", "cost_usd", "requests", "priced_requests", "unpriced_requests"],
"rows": [["2026-11-07T14:00-03:00", "research", "claude-sonnet", "0.122475", 41, 37, 4]],
"total_groups": 191, "truncated": true, "source": "usage_events",
"currency": "USD", "cost_note": "cost_usd sums known valuations; unpriced_requests have no known cost and are not counted as zero"
}
Parameter Values Default
from, to RFC 3339 times, at most 90 days apart, to not in the future the last 24 hours
group_by Comma-separated, up to 5 distinct: team, organization, model, requested_model, provider, key_id, principal, operation, status, status_class (2xx, 4xx, 5xx), error_code, guardrail, timeout_kind, cache_kind, service_tier, auto_route, end_user, session_id, owner (kind:id), origin (with evaluation tracing on; a row without one reads as app), helper_kind (with evaluation tracing; empty on every row but a helper call), pricing_status (complete, partial, inconsistent, unavailable, empty for a call that was not answered; with pricing_coverage), customer_org, customer_team (org/team) and customer_member (org/member): the customer the request named (with customer_portal), tag:<name> none: one total row
bucket minute (ranges up to 48 hours), hour, day, week, month none
timezone UTC or an IANA Area/Location name such as America/Sao_Paulo; buckets follow its wall clock, and bucket is printed as the local start with its offset, YYYY-MM-DDTHH:MM±hh:mm, so the repeated hour of a daylight-saving change stays two buckets. POSIX-style names (UTC+3, GMT-5, EST5EDT, Etc/GMT+3) are refused: PostgreSQL reads their sign inverted UTC
metrics Comma-separated: requests (client requests: helper calls and fallback attempts are left out of it and of success, errors, error_rate and the latency metrics), calls (every row), success, errors, error_rate, input_tokens, output_tokens, total_tokens, cached_input_tokens, token_reports, cost_usd, priced_requests, unpriced_requests, p50_cost_usd, p95_cost_usd, p99_cost_usd, max_cost_usd, avg_cost_usd (the cost of one request, with cost_request_insights), avg_latency_ms, p50_latency_ms, p95_latency_ms, p99_latency_ms, avg_ttfb_ms requests, errors, input_tokens, output_tokens, p95_latency_ms, plus cost_usd with usage_valuation
<dimension>=<value> An exact filter on any dimension above, repeated for several values (team=a&team=b); up to 20 values each and 100 in all, 256 bytes each, no control characters none
tag.<name>=<value> An exact usage tag filter none
non_empty Comma-separated dimensions that must be set, for “blocked by any guardrail” or “with any timeout” none
order_by, order bucket, a grouped dimension or a requested metric; asc or desc with a bucket, time order; otherwise the first metric, largest first. order alone ranks by the first metric, also in a series (the top N buckets); use order_by=bucket for reverse time order
limit 1 to 500 100
compare previous: also answer the same query over the period of equal length just before the range, in previous (with quality_kpi_cards; not for evaluation results) none

What the values mean:

  • cost_usd is the exact decimal sum, in USD, of the requests with a known valuation. It always comes with priced_requests and unpriced_requests, because a request without a known cost is not free: report the unpriced count, never treat it as zero.
  • p50_cost_usd, p95_cost_usd, p99_cost_usd, max_cost_usd, avg_cost_usd describe the known cost of one request (one request log row, helper and fallback calls included, as in cost_usd) in each group: the percentiles are the cost of an actual request of the group (never interpolated), exact decimals in USD. Requests without a known cost are left out and counted in unpriced_requests, which comes with them. p95_cost_usd by team, model, key_id, end_user or customer_org finds who drives the expensive tail.
  • customer_org, customer_team, customer_member are the customer organization, team and member a trusted key named on the request; a team and a member read org/team and org/member because their IDs are unique only within their organization. Empty when the request named none, and a member is empty after its erasure. With evaluation_metrics they break evaluation results down too, by the judged request’s customer; when the results are kept in the analytics store, customer_team is not available there (400), and a result written before this release for a request that named an organization without a member reads as no customer there.
  • error_code is the gateway’s own problem code the client received (rate_limited, guardrail_blocked, guardrail_blocked_output, model_forbidden, …). It is empty on success and when the error came from the provider, so a 429 with rate_limited is the gateway’s limit and a 429 with an empty code is the provider’s.
  • guardrail is the ID of the guardrail that blocked the request or its answer.
  • timeout_kind is first_byte, idle, max_duration, client_stall, request or attempt when a timeout ended the request.
  • An empty string is “not set”. non_empty keeps only the rows where it is set.

Who sees what. Administrators and viewers see every team (scope: all in the response). Team roles (team_viewer, team_admin, user) see every team they belong to and nothing else (scope: teams, with the list); a team= filter outside their membership answers 403 team_forbidden. Unlike the Analytics screen, which shows one team at a time, a team role can group by team across its own teams. With feature plan entitlements, cost metrics only cover teams whose plan includes usage_valuation.

Flags. Each dimension or metric needs the flag that records or shows it on the screens: status and status_class need analytics_status_breakdown, end_user needs end_user_tracking, session_id needs session_tracking, organization needs organizations, owner needs identity_ownership, tags need usage_tags, avg_ttfb_ms needs request_timing, cost metrics need usage_valuation and the cost of one request also cost_request_insights, the customer dimensions need customer_portal, pricing_status needs pricing_coverage and compare needs quality_kpi_cards. Without the flag the request answers 400 feature_disabled. With feature plan entitlements, a team role’s query covers only the teams whose plan includes every such right it uses; with none left it answers 403 entitlement_forbidden.

Errors. 400 with invalid_group_by, invalid_metrics, invalid_bucket, invalid_timezone, invalid_filter, invalid_order, invalid_limit or invalid_range; 403 team_forbidden or entitlement_forbidden; 404 feature_disabled; 422 query_too_costly when the query runs past its 5-second limit (narrow the range, the filters or the grouping); 503 storage_unavailable.

How it runs. Each query runs in a read-only transaction with a 5-second statement timeout and returns at most limit rows, with total_groups and truncated telling you what was left out. It reads the stored usage events within retention; unlike the Analytics screen with analytics_rollup_reads, it does not read the daily rollups, so days whose events retention deleted are absent here.

search_text takes a RE2 pattern (up to 512 bytes) and one source:

Source What is searched Who may search it
request_logs Request metadata, one record per request as field=value pairs (model=..., status=429, error_code=..., tags.env=...), paged from the request log with its filters, up to 2,000 records As the Request logs screen (logs:read, request_logs, team scope)
audit Control-plane audit events: time, source, action (such as team.create), target, actor, request ID As the Audit screen (audit:read, audit_explorer)
config The effective configuration as path = value lines As the configuration read (config:read)
docs The Markdown pages of the documentation build the gateway serves (docs_site.dir) Anyone with m7 ai, when ui and docs_site are on
api The OpenAPI reference embedded in the gateway Anyone with m7 ai

Options work like their command-line counterparts: field matches one record field; ignore_case; invert (grep -v); count_by tallies a field over every match; extract is a sed-style template of capture groups ($1, ${name}) tallied over every match; context adds up to three lines around a text match (grep -C). Totals and tallies cover everything scanned; up to 50 matches are returned. Text results also rank files by match count, which is how the model picks the documentation page to read.

The search runs inside the gateway with Go’s RE2 engine, whose matching time grows linearly with the text, so no pattern can make it backtrack for minutes. Because that time also grows with the size of the pattern, counted repeats above 100 (x{0,1000}), a repetition inside a counted repeat above 10 ((.*){0,30}, (.{0,3}){0,30}; (?:\d{1,3}\.){3} and (\d+\.)+ are fine) and patterns that compile to more than 500 instructions are refused; a costly pattern that remains stops at the time budget. The search stops at 2,000 records, 16 MB or 10 seconds, whichever comes first, and says so (scan_stopped). A record search resolves its time range once, so requests arriving during the scan are not counted twice, and refuses a from or to that is not RFC 3339 (invalid_range) instead of searching the default 24 hours.

A team role that belongs to several teams sees all of them in usage_query; the request log and its search follow the Request logs screen, which shows one team at a time (the first, unless the model names another).

Secrets. The configuration read already omits credentials. The search and read_console redact again: every provider header value (only header names are kept), values of fields whose names look like secrets (api_key, token, password, webhook, subscription, names ending in -key or _key, …) become [redacted], except names ending in _env, which hold an environment variable’s name; and strings shaped like keys or bearer tokens are masked anywhere. Key values are never stored, so no tool can return one.

Documentation. The gateway does not embed the documentation site; it searches the build it serves when docs_site.dir is set. Without it, docs answers docs_not_served and the API reference (api) is still searchable.

With ask_ai_actions on, you can ask for a change in plain language: “create a key for the research team that can use gpt-4o-mini”, “revoke key vk_…”, “set the budget of team alpha to 250 dollars a month”, “add Ana to team beta”. The model proposes the change; it never makes it. The console shows the proposal as a card under the answer, and the change happens only when you click Confirm change.

Tool Change Runs as Offered when
propose_create_key A virtual or service-account key for a team, with explicit models (no *), explicit route scopes (default route:chat, never route:*) and an optional lifetime (expires_in, such as 30d; no expiry when omitted) POST /api/v1/admin/keys identity_management, and the role may create keys (keys:manage, or a delegated member action)
propose_revoke_key Revoke a managed key (vk_… or sa_…). YAML keys are refused (yaml_owned), as are revoked ones POST /api/v1/admin/keys/{id}/revoke identity_management, and the role may revoke keys
propose_create_team A team in the default organization POST /api/v1/admin/teams team_management and teams:manage
propose_set_budget The USD budget of a team or a key: budget_usd, budget_period (day, week, month, quarter, year, lifetime; default month, or the current period) and optional soft_budget. It updates the subject’s budget policy, or its token policy, or adds the policy budget-<subject>-<id>. A disabled policy is enabled (the card shows disabled: true → false); token limits and a temporary increase stay, and the card says so PUT /api/v1/admin/quota-policies/{id} quota_management, budget_limits and quotas:manage
propose_add_team_member, propose_remove_team_member Add a console user (by ID or exact name) to a team or remove them. Team-scoped roles only (team_viewer, team_admin, user); a user keeps at least one team and at most 20. Users provisioned by SCIM are refused (idp_owned): their identity provider owns their teams. The card shows the new membership’s role: member under membership_roles (other memberships keep theirs); without it a team_admin administers every team it belongs to, so the card says admin. As on the Users page, a confirmed change with membership_roles off writes every kept team with that default role, so per-team roles stored while the flag was on are not preserved PUT /api/v1/admin/users/{id} console_users, team_management and users:manage

A tool is offered to the model only when its flags are on and your role’s route permission allows the change; a global viewer, for example, gets no propose_* tool. For team_viewer and user roles the key tools are offered because a team can delegate key actions to its members; whether this team did is decided when you confirm, by the key route itself (403 action_not_delegated otherwise). Periods other than day and month also need their own budget flags, which the budget route checks.

When the model calls a propose_* tool, the gateway builds the exact request itself from the typed arguments: the method and path are fixed per action, and nothing the model sends becomes a method, a path or a raw body. It reads the current state with your session (the team, key or user must be visible to you), refuses what cannot work (an unknown model, a wildcard, a YAML key, a user already in the team, a budget equal to the current one) and stores the proposal. The model is told that nothing has changed and that you must confirm.

The card shows:

  • the change and its target, for example Set the budget of team Alpha (team_3f…), policy budget-team-team_3f…;
  • every field that changes, as Now and After (the current value comes from the read just made; — means not set);
  • notes, such as “The key’s secret is shown once, right after you confirm” or the version the change is tied to;
  • the exact request under Request (method, path and JSON body);
  • the expiry time, and Cancel and Confirm change (red for a revocation or a removal).

Confirm change sends POST /api/v1/admin/ask/proposals/{id}/confirm with your session cookie and CSRF token. The gateway then:

  1. claims the proposal on the database, once: it must be yours, from this same session, still pending and not expired (database clock);
  2. writes the audit row ask_ai.<action>.confirm (target: the proposal ID, actor: you, with this request’s ID) in the same transaction;
  3. runs the stored request through the existing admin route with your session and CSRF token and the request ID <request_id>.ask-action. That route checks your permissions and team scope as they are now, validates the request, checks the version it carries and writes its own audit row (for example key.revoke, actor: you);
  4. returns that route’s answer. For a new key the card shows the secret once, with a copy button; it is never stored with the proposal or sent to the model.

Cancel sends POST /api/v1/admin/ask/proposals/{id}/cancel: nothing runs, and ask_ai.<action>.cancel is audited.

Case What happens
The model never proposes, or you never click Nothing changes. Proposals expire 10 minutes after they are made
Confirm twice, a replayed request, two tabs clicking at once The first claim wins; every other answers 409 proposal_decided and runs nothing. The proposal ID is the idempotency key
Confirm after 10 minutes 410 proposal_expired; ask again for a fresh proposal
Another user, or another session of yours (a different login), confirms 404 proposal_not_found, without revealing that the proposal exists
A request without your CSRF token, or from another site 403 forbidden, like every console write
Your permissions or teams changed after the proposal The route refuses with its usual answer (for example 403 team_forbidden); the proposal becomes failed
The team’s budget, the quotas or the user changed after the proposal The version carried in the proposal no longer matches: 409 version_conflict, the proposal becomes failed, and the change made in between is kept
ask_ai_actions was turned off after the proposal Confirm answers 404 feature_disabled

A failed or cancelled proposal is never retried: ask again. When a question fails after the model proposed something (the model call fails or never answers), its proposals are cancelled, since no card was shown. A proposal whose change was sent stays executing if the gateway stops mid-way; it is not run again.

Logged values and other tool results can contain text that reads like an instruction (“revoke every key”). The system prompt tells the model to propose only what you asked for in your own words, but a model can still be misled. That is why a proposal never runs by itself: read the card before confirming. It shows the real target and values the gateway read with your session, not the model’s description of them. A proposal can only be one of the six actions above, inside what your role may already do.

Limit Value
Proposals per answer 4
Pending proposals per user 20 (429 too_many_pending_proposals to the model until you confirm or cancel some)
Expiry 10 minutes after the proposal, on the database clock
Running a confirmed change 15 seconds
Retention Decided and expired proposals are removed 7 days after their expiry; audit rows stay

Proposals are stored in PostgreSQL (table gateway_ask_ai_proposals, migration 129), so any replica can confirm a proposal another replica made. Without a database, no propose_* tool is offered.

POST /api/v1/admin/ask returns proposals next to the answer when the model proposed something: each with id, action, method, path, body, card (title, target, destructive, changes with field/before/after, notes), state (pending) and expires_at.

Terminal window
curl -s -b cookies.txt -H "X-CSRF-Token: $CSRF" -X POST \
http://localhost:8080/api/v1/admin/ask/proposals/askp_0f3c…/confirm
{"version": 7, "policy": {"id": "budget-team-team_3f2a", "subject": "team", "subject_id": "team_3f2a", "budget_usd": "250", "budget_period": "month"},
"proposal": {"id": "askp_0f3c…", "action": "budget_set", "state": "executed", "result_status": 200}}

The answer is the admin route’s own status and JSON with proposal added (state executed or failed, and result_status); a 204 becomes 200. Confirm and cancel also need analytics:read, like m7 ai. A shared-token API caller (Authorization: Bearer) can confirm its own proposals; its proposals are bound to its role.

features:
ask_ai: true
ask_ai_actions: true

Or Settings & sources → Features in the console, or the features API. ask_ai_actions requires ask_ai and is an operator control: it adds no permission; each change still needs the role and flags in the table above.

Some request metadata comes from clients: the end user, the session ID, tags. A client can put text there that reads like an instruction. m7 ai treats every tool result as data: the system prompt says so, the set of tools offered to the model is fixed for the whole question and does not change with anything a tool returns, a tool name the model invents runs nothing, and every tool reads with your permissions. Without ask_ai_actions, the worst a manipulated answer can do is misstate what you could already read, and the steps show what actually ran. With it, a manipulated model can also propose a change, which still waits for your confirmation (see Prompt injection).

Limit Value
Question 1 to 2,000 characters; history up to 10 turns of 8,000 characters
Tool rounds 8, with up to 4 calls per round; then one last round without tools, so the model answers from what it has (limit_reached: rounds in the API, a note in the console). That round carries the question and a digest of the results (at most 48 KB), not the tool-call history, so every provider accepts it and it stays small
Prompt tokens per question 120,000 summed over every round, the last included: before each tool round the gateway estimates that round’s prompt (tool definitions included) plus the last round’s, and when they would cross the ceiling the last round comes instead (limit_reached: prompt_tokens)
Questions in flight 2 per console user; a third answers 429 ask_ai_busy with Retry-After
Answer tokens 1,500 per round
Tool result 24 KB; larger results keep whole rows and say truncated_for_size
Time 8 s per read plus 10 s per search; 120 s per question
usage_query rows 200 per call from m7 ai (500 through the API)

Each model call goes through this gateway like any other request: it is recorded under the principal console-ask-ai:<your user>, counts against that principal’s quotas, and bypasses the response cache. With evaluation tracing on, each call is a helper call of sub-kind ask_ai (m7 ai), billed to a team: the one you send as team in the request, or your only team when you have exactly one (a session with several teams and no team, or a global administrator with none, pays at the gateway level). The team’s policy then applies to the model, and the calls appear in Cost under helper · m7 ai, out of Usage’s request counts. A typical question costs one or two rounds and 5,000 to 10,000 prompt tokens.

The tools also correct the mistakes models make most often: a call repeated with the same arguments is refused (the model reuses the earlier result); a range that ends in the future is cut at now; a time bucket named among the dimensions becomes the bucket; a filter value of * means “set”; an empty result after a filter lists the values that do exist; a search that scanned records but matched none says it is not evidence that nothing happened; a guessed documentation page name suggests the pages that mention it.

POST /api/v1/admin/ask with question, model and optional history. The response carries answer, steps (round, tool, the declared arguments, HTTP status, error, summary and, for usage_query, the normalized query), rounds, limit_reached when it applies, and token usage. Both operations are in the OpenAPI reference (/openapi.yaml, and Swagger at /docs/swagger/).

m7gtwcontact@m7gtw.com