What you will be able to do
- Identify which AI Gateway features apply to an agent deployed via Agent Framework, and which of them are billed
- Enable inference tables for an agent endpoint and query them, including joining to system.serving.served_entities
- Explain what the system.serving usage tables record, who can read them, and how token counts are estimated
- Configure endpoint, default-user, custom-user and group rate limits, and predict which limit is enforced
Key concept
AI Gateway on a serving endpoint — AI Gateway is a governance layer on a Model Serving endpoint. You switch on its features one at a time: payload logging to inference tables, usage tracking in system tables, and rate limits. Each feature's data ends up in Unity Catalog, where you can query it to see what your deployed LLM or agent is doing.
1.What AI Gateway can track on an agent endpoint
When you deploy an agent with Agent Framework, it runs behind a Model Serving endpoint. AI Gateway is configured on that endpoint, not inside the agent code. On the endpoint creation page, the AI Gateway section lets you turn each feature on separately. The features this lesson covers are payload logging (inference tables), usage tracking (system tables), and rate limiting. All of their data is logged into Delta tables in Unity Catalog, so you analyse it with ordinary SQL or notebooks.
| Feature | What it does | Databricks agents | Foundation Model APIs pay-per-token endpoint |
|---|---|---|---|
| Payload logging | Monitor and audit data being sent to model APIs using inference tables | Supported | Supported |
| Usage tracking | Monitor operational usage on endpoints and associated costs using system tables | Not supported | Supported |
| Permission and rate limiting | Control who has access and how much access | Not supported | Supported |
| AI Guardrails | Prevent unwanted and unsafe data in requests and responses | Not supported | Supported |
| Available in Unity Gateway | Use enhanced Unity Gateway features | Not supported | Supported |
Read the table carefully. Inference tables are the AI Gateway feature you can count on for an agent endpoint. The matrix marks usage tracking and rate limiting as Not supported for Databricks agents. However, the rate-limit configuration guide only says that *TPM* limits cannot be applied to agent endpoints (see the rate-limiting section below). The sources don't reconcile these two statements, so treat 'inference tables for agents' as the firm fact. The usage tables and rate limits are fully supported on the Foundation Model APIs, external model and custom model endpoints. The newer Unity Gateway experience is also marked Not supported for agents, so this lesson uses the serving-endpoint version of AI Gateway throughout.
Cost matters too. AI Gateway charges per feature you enable. The two tracking features are billed, and the controls are free.
Checkpoint 1 of 9· Check yourself
A team enables inference tables, usage tracking and rate limits on a serving endpoint. Which of these add AI Gateway charges?
The docs name inference tables and usage tracking as the paid features. Rate limiting, query permissions, fallbacks and traffic splitting are free.
“Paid features include inference tables and usage tracking.”Source: docs.databricks.com
2.Turning on inference tables for an agent
An inference table captures the requests coming into an endpoint and the responses going out, and logs them as a Unity Catalog Delta table. Agent endpoints get one extra thing: the agent's inference table stores payload and request details as well as MLflow Trace logs. That means you can follow each step the agent took, not only its final answer.
How you enable it depends on how you deployed:
- **Agents deployed with
mlflow.deploy()** have inference tables enabled automatically. - Programmatic deployments need the
ENABLE_MLFLOW_TRACINGenvironment variable set toTruein the endpoint configuration. - Any endpoint in the Serving UI can have them switched on in the AI Gateway section, either when you create it or later with *Edit AI Gateway*. Clearing the *Enable inference table* checkbox there disables them.
Checkpoint 2 of 9· Put it in order
Put the UI steps for enabling inference tables while creating a new endpoint in order
- 1.In the AI Gateway section, select Enable inference tables
- 2.Click Create serving endpoint
- 3.Click Serving in the Databricks UI
Start in Serving, create the endpoint, then tick the checkbox in that endpoint's AI Gateway section.
“In the AI Gateway section, select Enable inference tables.”Source: docs.databricks.com
Some prerequisites catch people out. The workspace needs Unity Catalog and serverless compute enabled. Both the person who creates the endpoint and anyone who modifies it need Can Manage on the endpoint. In Unity Catalog they also need USE CATALOG, USE SCHEMA and CREATE TABLE on the target catalog and schema. You can't use an OpenSharing catalog as the target.
Databricks creates the table for you, and you can't point it at an existing table. After that, leave the table alone. If you change its schema, rename it or delete it, logging can stop or the table can become corrupted. The user who enabled the inference table owns it, and access is governed by standard Unity Catalog ACLs.
Logging is not real-time. Rows appear less than an hour after the endpoint is queried. Payloads larger than 1 MiB are not logged. Streaming responses are supported: the logged response combines all the chunks returned.
Checkpoint 3 of 9· Exam question
A team enables AI Gateway-enabled inference tables on a model serving endpoint that hosts an Agent Framework agent, hoping to debug why a handful of agent turns take unusually long to finish. Once enabled, what does the gateway automatically capture for each request-response pair, and where is it stored?
Correct answer: B — Request and response JSON, HTTP status code, execution duration, and MLflow trace data for the agent, written to a Delta table in Unity Catalog.
- A. Incorrect. Token counts, cost and requester identity belong to AI Gateway usage tracking, which is a separate capability from inference tables. That data cannot show the payloads, durations or traces of individual agent turns, so it does not help explain why a few turns ran long.
- B. Correct. Inference tables record the request and response JSON, the HTTP status code and the execution duration for each call. For Agent Framework agents they also include MLflow trace data. The records are written to a Delta table governed by Unity Catalog, so individual slow turns can be queried and inspected.
- C. Incorrect. Inference tables log each request-response pair rather than a sample, and rate limit settings only control throughput, not which calls are captured. A sampled log could miss the few slow turns being investigated, and it would also leave out the agent's MLflow trace data.
- D. Incorrect. Interval-level request counts, latency percentiles and error rates are the system metrics shown on the serving endpoint dashboard. Inference tables instead store row-level records in a Unity Catalog Delta table. Aggregates cannot identify which specific turns were slow or why.
3.Reading an inference table to monitor the agent
Once the endpoint is serving, every request and its response go into the inference table automatically. You can open the table from the endpoint page, which takes you to Catalog Explorer. You can also query it from Databricks SQL or a notebook, or through the REST API. The docs list four common uses:
- Debug production issues. The table records HTTP status codes, request and response JSON, model run times and traces.
- Monitor data and model quality with data profiling dashboards and alerts.
- Build a training corpus by joining the logs with ground truth labels.
- Monitor deployed agents through the MLflow traces stored alongside the payloads.
| Column | Type | What it tells you |
|---|---|---|
| databricks_request_id | STRING | Databricks-generated identifier attached to every model serving request |
| client_request_id | STRING | Your own request identifier, if you passed one in the request body |
| status_code | INT | HTTP status code returned from the model |
| execution_duration_ms | BIGINT | Time the model spent on inference, excluding network overhead |
| request / response | STRING | Raw JSON bodies sent to and returned by the endpoint |
| sampling_fraction | DOUBLE | Between 0 and 1; 1 means 100% of requests were included |
| logging_error_codes | ARRAY | Why a row couldn't be logged, e.g. MAX_REQUEST_SIZE_EXCEEDED |
| requester | STRING | User or service principal whose permissions were used for the call |
execution_duration_ms counts only the time the model spent generating predictions. It leaves out network overhead, so latency that users experience outside the model doesn't appear in this column.
The inference table holds a served_entity_id but nothing about what that entity actually is. Those details live in the system.serving.served_entities system table, so you join the two on served_entity_id.
Checkpoint 4 of 9· Fill the gap
Which system table completes this join that adds details about the served model to each logged request?
SELECT * FROM <catalog>.<schema>.<payload_table> payload
JOIN system.serving. ? se on payload.served_entity_id = se.served_entity_idFoundation model details are stored in system.serving.served_entities, which is keyed by served_entity_id. endpoint_usage holds per-request token counts, not entity metadata.
Source: docs.databricks.comSources3
4.Usage tables: token counts and endpoint metadata
Inference tables answer the question *what was said*. Usage tracking answers *how much was used, and by whom*. To turn it on, select Enable usage tracking in the AI Gateway section. Unity Catalog must be enabled. Two system tables are then shared automatically:
| System table | Records | Example columns |
|---|---|---|
| system.serving.endpoint_usage | Token counts for each request to the endpoint | requester, status_code, request_time, input_token_count, output_token_count, usage_context |
| system.serving.served_entities | Metadata for each served entity | served_entity_id, endpoint_name, entity_type, entity_name, entity_version, task |
A few details are commonly tested:
- Token counts can be estimates. If the model doesn't return a token count, AI Gateway estimates input and output tokens as
(text_length+1)/4. - Custom models show zero.
input_token_count,output_token_countand the character-count columns are 0 for custom model requests. - Attribution.
usage_contextis a user-provided map that identifies the end user or customer application making the call. Use it to attribute cost beyond therequesteridentity. - Entity types. In
served_entities,entity_typecan be FEATURE_SPEC, EXTERNAL_MODEL, FOUNDATION_MODEL or CUSTOM_MODEL. For pay-per-token endpoints,created_byis System-User.
Remember from the support matrix that usage tracking is marked Not supported for Databricks agents, and Supported for external model, Foundation Model APIs and custom model endpoints. The sources don't explain how an agent's token consumption is attributed in these tables. The documented use is per-endpoint usage on the supported endpoint types.
Checkpoint 5 of 9· Check yourself
An ML engineer with CAN MANAGE on an endpoint enables usage tracking. Who can query system.serving.endpoint_usage by default?
The endpoint manager must enable usage tracking, but only account admins can view or query these tables. Admins can grant access to system tables to other users.
“Only account admins have permission to view or query the served_entities table or endpoint_usage table”Source: docs.databricks.com
Checkpoint 6 of 9· Exam question
An admin configures a 100 QPM service-level rate limit on an AI Gateway-enabled endpoint, then adds a 20 QPM group limit for a data science group, and finally sets a 5 QPM custom limit for one user in that group who has been issuing an unusually high volume of test calls. When that specific user sends requests, which limit governs their traffic, and what happens once it is exceeded?
Correct answer: D — The 5 QPM user-level limit applies to this user, and calls above that rate are rejected by the gateway with an HTTP 429 Too Many Requests response.
- A. The service-level limit is the ceiling for the whole endpoint, but a limit set for a specific user is more specific and takes priority for that user's traffic. AI Gateway also rejects excess calls instead of holding them in a queue.
- B. A limit set for one named user takes priority over the limit for the group that user belongs to, so this user is held to 5 QPM, not 20 QPM. Excess calls also return HTTP 429, not HTTP 503.
- C. Rate limits are not summed. The most specific limit, here the one set for this user, applies on its own, so the user is held to 5 QPM, not 25 QPM. Excess calls return HTTP 429, not HTTP 403.
- D. Correct: a limit set for an individual user takes priority over group and service-level limits, so this user is held to 5 QPM. Calls above that rate are rejected with HTTP 429 Too Many Requests.
Sources2
5.Rate limits: capping how hard the endpoint can be hit
Rate limits come in two kinds: queries per minute (QPM) and tokens per minute (TPM). As the predict showed, TPM is off the table for agent and custom model endpoints. (The support matrix goes further and marks permission and rate limiting as Not supported for Databricks agents. Check which endpoint type a question describes.) Rate limits only apply to users who have permission to query the endpoint, and by default none are configured. You can set limits at four levels:
| Level | Scope | Precedence |
|---|---|---|
| Endpoint | All traffic to the endpoint, regardless of user | Global maximum: if exceeded, all requests are blocked regardless of user or group limits |
| User (Default) | Every user of the endpoint without a more specific limit | Overridden by any custom rate limit |
| Custom: individual user or service principal | One identity | Takes priority over user group custom limits |
| Custom: user group | Shared limit for all members of the group | User-specific limit wins when both apply |
Three more rules complete the picture:
- When an endpoint, user or service principal has both a QPM and a TPM limit, the more restrictive one is enforced.
- When a user belongs to several groups with different limits, they are throttled only once they exceed all of their groups' QPM limits, or all of their groups' TPM limits.
- An endpoint can have at most 20 rate limits, of which at most 5 are group-specific.
Rate limits are only as strong as your endpoint permissions. To stop people bypassing throughput limits, restrict endpoint creation and CAN MANAGE to admins, and give everyone else query permission only on approved endpoints.
Checkpoint 7 of 9· Match them up
Match each scenario to the limit that governs it
Tap a term, then the definition that fits it.
The endpoint limit is a global ceiling. A user-specific limit beats a group limit, any custom limit overrides the default, and when QPM and TPM both apply, the stricter one wins.
“If a user belongs to both a user-specific limit and a group-specific limit, the user-specific limit is enforced.”Source: docs.databricks.com
Checkpoint 8 of 9· Check yourself
Bob is in two groups: Analysts (100 QPM) and Interns (20 QPM). He has no user-specific limit. When is Bob rate limited on QPM?
With several groups, the user is throttled only after exceeding every group's QPM limit, so effectively at the most generous one. The 'more restrictive wins' rule applies to QPM versus TPM, not to multiple groups.
“the user is rate limited if they exceed all of the QPM rate limits or all of the TPM rate limits”Source: docs.databricks.com
Checkpoint 9 of 9· Exam question
An engineer configures both a 50 QPM limit and a 5,000 TPM limit on the same pay-per-token endpoint serving an agent. During a traffic burst, most incoming requests use very few tokens each, so the request count crosses 50 QPM well before the token budget is anywhere near 5,000 TPM. What does AI Gateway do in this situation?
Correct answer: A — Returns HTTP 429 when the request count passes 50 QPM; the two limits are enforced independently, so the spare token budget does not prevent rejection.
- A. Correct. Request-based and token-based limits on one endpoint are enforced independently, and the first one reached triggers HTTP 429. Many small requests reach 50 QPM while token usage is still far below 5,000 TPM, and the unused token budget does not offset that.
- B. Rejection does not wait for both limits to be reached. Each configured limit is enforced on its own, so reaching 50 QPM is enough to return HTTP 429 even though token usage is low.
- C. A TPM limit does not take precedence over a QPM limit, and pay-per-token endpoints do not switch the request cap off. Both limits stay active, so the burst of small requests is rejected once the request count passes 50 QPM.
- D. AI Gateway does not merge the two limits into one threshold or convert requests into tokens using an average. QPM and TPM are tracked separately, and whichever is reached first produces the HTTP 429.
Sources2
Sources
(3)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“All data is logged into Delta tables in Unity Catalog.”
↩︎ What AI Gateway can track on an agent endpoint“AI Gateway incurs charges on an enabled feature basis.”
↩︎ What AI Gateway can track on an agent endpoint“It is a centralized service that brings governance, monitoring, and production readiness to model serving endpoints.”
↩︎ Key concept“Features such as query permissions, rate limiting, fallbacks, and traffic splitting are free of charge.”
↩︎ Exam trap 5“Paid features include inference tables and usage tracking.”
↩︎ Checkpoint - 2.
“In the AI Gateway section of the endpoint creation page, you can individually configure Unity Gateway features.”
↩︎ What AI Gateway can track on an agent endpoint“Payload logging data populates these tables less than an hour after querying the endpoint.”
↩︎ Turning on inference tables for an agent“Payloads larger than 1 MiB are not logged.”
↩︎ Turning on inference tables for an agent“system.serving.endpoint_usage, which captures token counts for each request to the endpoint.”
↩︎ Usage tables: token counts and endpoint metadata“The token count of the input. This will be 0 for custom model requests.”
↩︎ Usage tables: token counts and endpoint metadata“The user provided map containing identifiers of the end user or the customer application”
↩︎ Usage tables: token counts and endpoint metadata“Rate limits only apply to users who have permission to query the endpoint.”
↩︎ Rate limits: capping how hard the endpoint can be hit“The endpoint rate limit is a global maximum.”
↩︎ Rate limits: capping how hard the endpoint can be hit“A maximum of 20 rate limits and up to 5 group-specific rate limits can be specified on an endpoint.”
↩︎ Rate limits: capping how hard the endpoint can be hit“the more restrictive rate limit is enforced”
↩︎ Rate limits: capping how hard the endpoint can be hit“To prevent bypassing guardrails or throughput limits, restrict endpoint creation and CAN MANAGE to admins”
↩︎ Rate limits: capping how hard the endpoint can be hit“TPM rate limits cannot be applied to serving endpoints that serve custom models or agents.”
↩︎ Exam trap 1“If a user belongs to both a user-specific limit and a group-specific limit, the user-specific limit is enforced.”
↩︎ Exam trap 2“The input and output token count are estimated as (text_length+1)/4 if the token count is not returned by the model.”
↩︎ Exam trap 3“Only account admins have permission to view or query the served_entities table or endpoint_usage table”
↩︎ Checkpoint“TPM rate limits cannot be applied to serving endpoints that serve custom models or agents.”
↩︎ Prediction“If a user belongs to both a user-specific limit and a group-specific limit, the user-specific limit is enforced.”
↩︎ Checkpoint“the user is rate limited if they exceed all of the QPM rate limits or all of the TPM rate limits”
↩︎ Checkpoint - 3.
“these inference tables store payload and request details as well as MLflow Trace logs.”
↩︎ Turning on inference tables for an agent“Agents deployed using the mlflow.deploy() API have inference tables automatically enabled.”
↩︎ Turning on inference tables for an agent“For programmatic deployments, set the ENABLE_MLFLOW_TRACING environment variable to True in the endpoint configuration.”
↩︎ Turning on inference tables for an agent“Serverless compute has to be enabled in the workspace.”
↩︎ Turning on inference tables for an agent“Inference tables log data like HTTP status codes, request and response JSON code, model run times, and traces output during model run times.”
↩︎ Reading an inference table to monitor the agent“This does not include overhead network latencies and only represents the time it took for the model to generate predictions.”
↩︎ Reading an inference table to monitor the agent“Foundation model details are captured in the system.serving.served_entities system table.”
↩︎ Reading an inference table to monitor the agent“Specifying an existing table is not supported.”
↩︎ Exam trap 4“Monitor deployed agents. Inference tables can also store MLflow traces for agents”
↩︎ Prediction“In the AI Gateway section, select Enable inference tables.”
↩︎ Checkpoint