# Bring Jev to BigQuery with Cloud Run

> Turn unstructured support tickets into typed, queryable BigQuery columns by routing a SQL remote function through a private Cloud Run adapter to TypeSafe’s Jev API.

- Format: Writing
- Date: Sep 2026 (2026-09-22)
- Series: Typed AI in BigQuery (Part 1)
- Length: 6 min read
- Topics: BigQuery, Cloud Run, Jev, SQL
- URL: https://jeffn.dev/writing/bring-jev-to-bigquery-with-cloud-run/
- Read on Medium: https://medium.com/google-cloud/bring-jev-to-bigquery-with-cloud-run-bdecfa11fdaa
- Repository: https://github.com/jeffonelson/jev-bigquery-cloudrun

[Jev](https://typesafe.ai/blog/introducing-system-one-models-and-jev) launched last week and has been getting a lot of attention across the tech space for how fast and cheap it runs. It promises fast classification with typed outputs, so naturally I wanted to try it out with a database. I was curious whether it could turn the judgment calls we make every day about business data into columns we can use in SQL. Support tickets seemed like a good place to start.

Imagine receiving a ticket with the subject *“Nightly import failed.”* The message body states:

> Our nightly import has failed twice. Finance needs updated numbers before the end of day tomorrow. We’re still able to query yesterday’s data.

The ticket has a deadline requiring attention, but the reporter can still work with yesterday’s data while today’s import problem is resolved. It’s a very different situation than something like a company-wide login outage with no workaround, even if both tickets were marked as urgent.

These are the kinds of distinctions I want to turn into queryable columns in my database. Once each ticket has scores for urgency and blocking, we can combine them with the ticket’s status to answer a very basic question: **which active tickets need attention first?**

Here’s the query we’ll build toward, which uses urgency and blocking scores from Jev:

```sql
SELECT ticket_id, subject, route, urgent_probability, blocked_probability
FROM jev_demo.enriched_tickets
WHERE status != 'closed'
  AND urgent_probability >= 0.80
  AND blocked_probability >= 0.80
ORDER BY ticket_id;
```

Across our 30-ticket sample dataset, this query only surfaces four tickets: an unapplied seat purchase, an SSO outage, an import that couldn’t start, and exports timing out before a deadline. Meanwhile, the *“Nightly import failed”* ticket above is classified as *urgent*, but stays out of this fire drill because it falls below the *blocked* threshold.

## Turning ticket text into typed answers

[Jev](https://docs.typesafe.ai/introduction/quickstart) is TypeSafe’s model for typed evaluations. You provide input, called *state*, along with questions about it, and specify the kind of answer each question should return. **Choice** selects from categories you define, **Noul** returns a probability between 0 and 1, and **Score** rates the input against an ordered scale you specify. For this example, we’ll use Choice to assign an owning team and Noul to estimate the probabilities of urgency and blocking.

Here I define urgency as a concrete need for prompt action, and blocking as a workflow that cannot continue without a usable workaround. Both concern the situation when the ticket was submitted.

[BigQuery](https://cloud.google.com/bigquery?utm_campaign=CDR_0xaea1deef_default_b564655402&utm_medium=external&utm_source=blog) already supports these kinds of tasks through `AI.CLASSIFY`, `AI.IF`, and `AI.SCORE` — and a [follow-up blog](https://jeffn.dev/writing/jev-and-bigquery-ai-functions-from-one-row-to-ten-million/) will compare Jev with BigQuery AI functions. But for this walkthrough, I wanted to explore how Jev fits into a SQL workflow. Just yesterday MotherDuck [introduced Jev in SQL](https://motherduck.com/blog/motherduck-supports-jev/), and here, we’ll connect it to BigQuery through [Cloud Run](https://cloud.google.com/run?utm_campaign=CDR_0xaea1deef_default_b564655402&utm_medium=external&utm_source=blog).

The [example dataset](https://github.com/jeffonelson/jev-bigquery-cloudrun/blob/main/sql/01_create_tickets.sql) contains 30 fictional tickets. I’d encourage you to inspect the examples and change the wording yourself to see how Jev responds.

## Connecting Jev, Cloud Run, and BigQuery

I started by creating a TypeSafe account and following its [official quickstart](https://docs.typesafe.ai/introduction/quickstart) in the playground. Then I created an API key and placed it in Google Cloud’s [Secret Manager](https://cloud.google.com/security/products/secret-manager?utm_campaign=CDR_0xaea1deef_default_b564655402&utm_medium=external&utm_source=blog). The Python adapter runs as a private Cloud Run service.

![Architecture diagram showing BigQuery (SQL remote function) sending ticket batches to Cloud Run (private Python adapter), which sends state and questions to the TypeSafe Jev API (model inference) and returns typed answers as one JSON result per ticket.](https://jeffn.dev/images/jev-cloudrun/architecture.webp)

*Connecting BigQuery to Jev through Cloud Run*

Cloud Run hosts the adapter and TypeSafe’s API runs Jev inference. The adapter translates BigQuery’s batched `calls` into Jev questions, then returns one JSON object per ticket in the ordered `replies` array. The [adapter source](https://github.com/jeffonelson/jev-bigquery-cloudrun/blob/main/support.py) contains the category definitions and question wording.

To deploy it yourself, follow the [setup guide](https://github.com/jeffonelson/jev-bigquery-cloudrun/blob/main/docs/setup.md) on GitHub. It includes the setup for secrets, service account, and to deploy a Cloud Run service. Before connecting BigQuery, test the deployed service with Cloud Run’s auth’d proxy:

```bash
gcloud run services proxy jev-support-demo \
  --project=YOUR_PROJECT_ID --region=us-west1 --port=8787
```

Your signed-in account needs permission to invoke the service. Leave the proxy running and, from the repository directory in another terminal, send [examples/two-tickets.json](https://github.com/jeffonelson/jev-bigquery-cloudrun/blob/main/examples/two-tickets.json), which pairs the nightly import ticket from earlier with a second ticket for an SSO outage:

- **Import data ticket (T013 — Nightly import failed):** *“Our nightly import has failed twice. Finance needs updated numbers before the end of day tomorrow. We’re still able to query yesterday’s data.”*
- **SSO ticket (T007 — Company-wide SSO outage):** *“After our identity-provider change this morning, SSO fails for every employee. Nobody can sign in and there is no alternative login enabled.”*

```bash
curl --fail-with-body --silent --show-error \
  http://127.0.0.1:8787/tickets \
  -H 'Content-Type: application/json' \
  --data-binary @examples/two-tickets.json | jq .
```

Here’s the response from Cloud Run:

![Terminal screenshot of a curl request to http://127.0.0.1:8787/tickets piped to jq, showing Jev’s JSON classification results: the first labeled “Import data ticket” routed to ingestion with urgent_probability 0.86 and blocked_probability 0.17, and the second labeled “SSO ticket” routed to identity with urgent_probability 0.98 and blocked_probability 0.96.](https://jeffn.dev/images/jev-cloudrun/proxy-curl-response.webp)

*Scoring two sample tickets with the Cloud Run proxy*

Both tickets require prompt attention, but the SSO outage blocks access entirely. The urgency and blocking probabilities Jev returned reflect that difference. This test also confirms that the deployed service can access the API key, call Jev, and return results.

Next, I created a BigQuery dataset called `jev_demo` and used a BigQuery [Cloud Resource connection](https://cloud.google.com/bigquery/docs/create-cloud-resource-connection?utm_campaign=CDR_0xaea1deef_default_b564655402&utm_medium=external&utm_source=blog) to let BigQuery invoke the adapter. The connection’s service account has the Cloud Run Invoker role on the service, while the adapter’s runtime identity has permission to read the secret.

This is where BigQuery’s [remote functions](https://cloud.google.com/bigquery/docs/remote-functions?utm_campaign=CDR_0xaea1deef_default_b564655402&utm_medium=external&utm_source=blog) are super useful — they let a SQL query call your code running outside BigQuery. In this example, the code runs in Cloud Run and calls Jev. I register the remote function with the connection and my Cloud Run service URL:

```sql
CREATE OR REPLACE FUNCTION jev_demo.classify_ticket(ticket JSON)
RETURNS JSON
REMOTE WITH CONNECTION `YOUR_PROJECT_ID.US.jev_cloud_run`
OPTIONS (
  endpoint = 'CLOUD_RUN_SERVICE_URL/bigquery-tickets',
  max_batching_rows = 5
);
```

I set `max_batching_rows` to 5, meaning BigQuery sends up to five tickets per request to Cloud Run. You can change this for your workload, keeping Jev’s input limits in mind.

## Querying the ticket queue

I then called the remote function for each ticket and saved the results in BigQuery:

```sql
CREATE OR REPLACE TABLE jev_demo.ticket_scores AS
SELECT
  ticket_id,
  CURRENT_TIMESTAMP() AS scored_at,
  jev_demo.classify_ticket(
    TO_JSON(STRUCT(subject, description, status, resolution))
  ) AS features
FROM jev_demo.support_tickets;
```

The [full scoring script](https://github.com/jeffonelson/jev-bigquery-cloudrun/blob/main/sql/03_score_tickets.sql) in GitHub also creates an `enriched_tickets` view, which joins results back to the tickets and extracts JSON fields into columns. If you’re following along, run that script to create both the saved results and the view.

Saving the results lets me experiment with different queue rules without calling Jev each time. Once the probabilities are available as columns, it’s straightforward to summarize active workloads by team with SQL:

```sql
SELECT
  route,
  COUNT(*) AS active_tickets,
  COUNTIF(urgent_probability >= 0.80) AS urgent_tickets,
  COUNTIF(blocked_probability >= 0.80) AS blocked_tickets
FROM jev_demo.enriched_tickets
WHERE status != 'closed'
GROUP BY route
ORDER BY active_tickets DESC, route;
```

Here’s what the query returns in my run:

![Screenshot of BigQuery query results showing five support routes (billing, identity, ingestion, other, performance), each with 4 active_tickets, alongside varying counts of urgent_tickets and blocked_tickets.](https://jeffn.dev/images/jev-cloudrun/bigquery-summary-results.webp)

*Summarizing active, urgent, and blocked tickets in BigQuery*

Each team has an equal number of active tickets in this dataset, but the counts of urgent and blocked tickets show a different picture of the team’s work. I can also use the query from the opening of this blog to find tickets that meet both thresholds (`urgent_probability >= 0.80 AND blocked_probability >= 0.80`).

This is where my interest in Jev + BigQuery stems from — judgements about ticket text become columns that I can filter, group, and join to other business data. The repo includes [other examples](https://github.com/jeffonelson/jev-bigquery-cloudrun/blob/main/sql/04_examples.sql) for assigning review queues and checking whether resolution notes support closing a ticket.

I use 0.80 as an example cutoff, but that figure needs testing against your own tickets and priorities for real-world use cases. If missing a blocked customer is more costly than reviewing another ticket, you might consider a lower cutoff for blocking. Saving the probabilities to a table lets you explore that tradeoff without calling Jev again.

This also made me curious about how Jev compares with BigQuery’s existing AI functions. I’ll explore this in a [separate blog](https://jeffn.dev/writing/jev-and-bigquery-ai-functions-from-one-row-to-ten-million/) by comparing Jev with `AI.IF` on real-world data, to dig into quality, latency, and token usage as the data grows.

But for now, the [GitHub repo](https://github.com/jeffonelson/jev-bigquery-cloudrun) gives a useful starting point to try it yourself!
