# Run from Snowflake

> Install the Cotera Native App from the Snowflake Marketplace and run agents directly from SQL.

Source: https://cotera.co/docs/deploy/run-from-snowflake

---

If your data lives in Snowflake, agents can come to it. The Cotera Native App lets you call an agent per row from plain SQL (enrich prospects, classify records, summarize text) with results landing right back in your query.

For the full story, see the [Snowflake integration page](https://cotera.co/integrations/snowflake).

## Install

1. In Snowflake, open the **Marketplace** and search for **Cotera**, then click **Get**.
2. Approve outbound network access to `app.cotera.co` (requires an admin).
3. In Cotera, create an [API key](https://cotera.co/docs/deploy/run-via-api.md) and store it as a secret in the app's setup.

## Run an agent from SQL

```sql
SELECT
  company_name,
  cotera.agents.agent(
    agent_id => 'your-agent-id',
    input => object_construct('company_name', company_name)
  )::VARCHAR AS enrichment
FROM companies
WHERE status = 'prospect';
```

Each row becomes one agent run: durable, retried on failure, and able to use every tool the agent has (Salesforce, Slack, the web) even though it was called from SQL.

## Things to know

* Create and test the agent in Cotera first; you reference it by ID from SQL.
* Give the agent [structured output](https://cotera.co/docs/quickstart.md#5-define-the-output) and results come back as parseable JSON rather than prose.
* This is the reverse direction from [connecting Snowflake as a warehouse](https://cotera.co/docs/reference/data-warehouse/snowflake.md) (which feeds Snowflake data into Cotera datasets). The two work well together.

