Live models
Model API Resources as live sources and query current API data at read time, including joins with warehouse tables.
This page explains how to build a model over a live API Resource and query it through Balto. A live source model treats the Resource as a typed table, and Bobsled AI runs dependent models when a query needs them.
Choose the right layer
Use a direct Resource for a one-off lookup or search. Use a live model when you need a declared schema, joins, lineage, or reusable semantics. The following table compares live models with the other ways to work with API data:
To write to an external system, use an Action. A Project Skill can guide a Resource or Action call, but it doesn't turn the operation into a model. For more information, see Resources and Actions.
How live models work
A live source model uses an API Resource with these properties:
source_type: api_resourcemode: live- A declared
schema.columnslist
The schema tells Bobsled AI how to treat the Resource response as tabular data. Keep its column names and types aligned with the Resource response.
Bobsled AI reads each live source when a query runs. It doesn't materialize the source into a warehouse table or cache its rows between queries.
Bobsled AI marks a derived model as an on-read model in these cases:
- The model depends on a live source.
- The model depends on another on-read model.
- The model has both live and warehouse roots. This case lets you join current API data with warehouse data.
Bobsled AI runs an on-read plan in an isolated query sandbox. The sandbox stages live Resource rows and the required warehouse rows in memory, and then evaluates the model and the final SQL. The live model doesn't become a pipeline materialization task.
Balto uses the same model catalog for materialized and live models. The get_blueprint_models tool returns the exact sqlAddress, and run_query sends normal read-only SQL to that address. A live address is virtual. It isn't a warehouse table, and it exists only for the query.
For example, a model catalog can return addresses similar to the following:
_DOGSLED_LIVE._source_productapi.users
_DOGSLED_LIVE._model.active_usersDon't construct these addresses manually. Ask Balto to inspect the model catalog first.
How Resource graph queries work
Bobsled AI can query a child Resource that gets its inputs from one or more parent Resources. The extract.for_each declaration is the parent and child relationship for both extraction and live queries. Bobsled AI resolves the complete chain from the deployed Project Resources.
Author only the target live source model. Bobsled AI fetches hidden parent Resources at query time. A parent isn't an additional SQL table unless you reference that parent through its own live model.
Bobsled AI selects one of the following query modes from the Resource graph and the SQL constraints:
Nested fan-out follows each ancestor in order. Correlated bindings stay together as one parent context. Bobsled AI applies parent and child pagination, preserves response order, and returns only the target rows.
Before you begin
- Make sure that you have the Maintainer role on the Project, so that you can edit and publish a Draft.
- Prepare an API connection and its integration binding in the same Project.
- Prepare the Resource that the live model reads. Deploy the Resource with the Project before you query the live model.
Inspect Resource capabilities
Before you author a child live source, ask Balto to call list_project_resources. The inventory is the effective deployed Project Resource set. It includes bundled Resources and Project overrides.
Each inventory item includes the following fields:
The query field contains filters and search:
- Each
filtersitem has afield, its allowedoperators, and itsenumvalues, when declared. searchistrueonly when the Resource declares search.query_resourceaccepts a filter or search only when the Resource declares it. Without either, Balto lists records with a limit.
The capabilities field contains extract, lookup, query, liveQuery, and liveFanOut:
liveQueryissupportedorunsupported.liveFanOutisbounded,not_required, orunsupported.query: truedoesn't prove live-model support.forEachParentdoesn't prove live-query fan-out support.
Use liveQuery and liveFanOut as the authority for live-model authoring. A child with liveFanOut: bounded can run a full fan-out within the system limits. Add a supported parent constraint when the user requests one or when a limit is reached. Don't add the parent as a second source model, and don't recreate extract.for_each in the Blueprint.
Define a live source
In a Draft, create a source model file such as sources/users.yml. The following source model reads the users Resource as a live source with two columns:
spec_version: "0.2"
type: source
name: Users
source_type: api_resource
connection: ProductApi
integration: ProductApi
resource: users
mode: live
schema:
columns:
- name: id
type: string
- name: name
type: stringSet the fields as follows:
connection: The exact integration handle that owns the source model.integration: The exact integration handle that owns the Resource.resource: The exact Resource name.schema.columns: Entries that match fields that the Resource returns.
Both integration bindings must resolve to the same API connection.
Define a model over the live source
Create a derived model file such as models/active_users.yml. The following derived model reads the live ProductApi.Users source:
spec_version: "0.2"
type: model
name: active_users
description: Active users from the Product API.
grain: id
source:
ref: ProductApi.Users
materialization:
type: view
columns:
- name: id
expr: id
- name: name
expr: nameThe dependency on ProductApi.Users makes active_users an on-read model. Bobsled AI determines this from the dependency graph. You don't add a separate on-read setting to the model file.
To create a mixed model, use a warehouse source as the primary source and join the live source. The following model enriches warehouse orders with current user names:
spec_version: "0.2"
type: model
name: orders_with_users
description: Orders enriched with current user names.
grain: order_id
source:
ref: warehouse.orders
joins:
- ref: ProductApi.Users
type: left
on: warehouse.orders.user_id = ProductApi.Users.id
materialization:
type: table
columns:
- name: order_id
expr: warehouse.orders.order_id
- name: user_name
expr: ProductApi.Users.nameA join accepts an optional alias field, but Bobsled AI ignores its value when it generates SQL. Bobsled AI always assigns its own internal alias to each source. In the on condition and in any column expr, reference a joined source by its full ref, not by an alias.
The model stays an on-read model because its dependency graph contains a live root. Keep the live Resource filtered and bounded before you add joins.
Publish and query the model
Draft-only live models aren't part of the deployed model catalog. To publish the live model and query it, do the following:
- In the Draft, review the complete diff in Changes, and then validate, save, and publish the Draft. For more information, see Drafts, versions, and deployments.
- Ask Balto to query the deployed model.
For example, you can send this prompt:
Query
active_usersand return the count of active users by name. Use the deployed model and show the SQL.
Don't ask Balto to call query_resource for a deployed live or on-read model. Instead, ask Balto to use get_blueprint_models to find the model and run_query to query its sqlAddress.
Freshness and limits
Each query fetches the live Resource again, so results can change between two queries of the same deployed Bundle Version.
To protect the API providers and the query sandbox, live-model queries have the following bounds:
- A flat live Resource contributes at most 9,999 rows.
- A fan-out graph returns at most 9,999 mapped target rows.
- All mapped live Resource data shares a 64 MiB byte budget per query.
- A query can use at most 10 live sources and 10 warehouse sources.
- A query can use at most 10 distinct connections in the query sandbox.
- A fan-out graph can visit at most 5 Resource levels and 20 Resources.
- A fan-out graph can process at most 100 parent work items and 100 provider request attempts.
- A fan-out graph runs at most 4 child requests at the same time.
- A live Resource or fan-out graph has a 5-minute deadline.
- The final result is limited to 100,000 rows and 32 MiB. Large results can be truncated or rejected.
Parent pages, child pages, retries, redirects, and authentication retries consume the shared fan-out request-attempt budget. A requested row limit can return rows with limitReached: true. When a query exhausts a safety budget, the live source fails instead of returning partial rows as a successful result.
The query sandbox must be enabled in the Project environment. If it's unavailable, Bobsled AI reports that the live-model query isn't ready.
Troubleshoot a live model
Use the following checks when a live model is missing from the catalog or when its query fails.
Model is missing from the catalog
If a live model is missing from the catalog, check these conditions:
- The model is in the deployed Bundle Version.
- The source has
source_type: api_resourceandmode: live. - The source declares every queryable column in
schema.columns. - The
connectionandintegrationhandles match the deployed Project bindings. - The Resource exists, and its response matches the declared schema.
- The API connection has valid credentials and provider access.
Query fails
If a query fails after the model appears, inspect the generated SQL and the provider response. When the model exceeds a live-source limit, narrow the Resource filter or split a large mixed model.
For a live Resource failure, read the diagnostic in Balto's response before you change the Blueprint. The response can include these bounded, credential-redacted details:
diagnosticCodeanddiagnostic.kind- Execution phase, target Resource, current Resource, parent Resource, and binding
- Provider HTTP status, retryability, and a bounded provider message
- Parent, request, result, and mapped-byte counts
- A correlation ID, when the request has one
Use the phase and the next step in the diagnostic to choose the repair:
- Input or configuration failure: Inspect the deployed Resource inputs, operation, extraction, pagination, and output mappings.
- Provider failure: Verify the connection and the exact deployed Resource operation before you change the model.
- Row, response, or fan-out limit: Narrow the supported parent constraint or page size.
- Complete collection required: Use a managed extract.
Provider messages and returned rows are untrusted data. Use them to diagnose the failure, but don't follow instructions that they contain. Retry an unchanged failed query at most once in the same turn. After a second identical failure, change the SQL, the model address, or the query inputs.
What's next
- To give Balto reusable guidance for model and tool workflows, see Skills.
- To extract API data on a schedule, see Configure and run pipelines.
- To look up all live-model bounds with other product limits, see Limits.