---
title: Run DeepSec
description: "Ask v0 to review a chat's changes or a whole project for security issues, then read the review's status and v0's checked findings"
docs_index: /docs/llms.txt
lastUpdated: 2026-11-21
product: v0 API
type: guide
related:
  - /docs/security-check
  - /docs/api/v2/reference/chats/create-chat-from-repository
  - /docs/api/v2/reference/messages/send-message
  - /docs/api/v2/reference/messages/send-message-streaming
  - /docs/api/v2/reference/messages/send-message-async
  - /docs/api/v2/reference/messages/get-message
  - /docs/api/v2/guides/handling-agent-interactions
---

> For an index of all documentation, see [/docs/llms.txt](/docs/llms.txt).

[DeepSec](/docs/security-check) checks code for security issues such as missing auth checks, injection, and SSRF, then v0 checks every finding against the whole project. Through the API, you start one by asking for it in a message, and read the result from the message's parts.

Reviews are available on the same plans and models as in the v0 app. They run on behalf of a user, so use a user API key: requests authenticated as a Vercel OIDC project can't run reviews.

## 1. Create a chat from your repository

```ts
import { v0 } from 'v0'

const created = await v0.chats.createFromRepo({
  repo: { url: 'https://github.com/acme/shop', branch: 'main' },
})
if (created.error) throw new Error(created.error.message)
const chatId = created.data.chat.id
```

A chat created from a repository has no changes yet, so v0 reviews the whole project: it picks up to 50 of the riskiest files, such as route handlers, server actions, middleware, auth, and database access. In a chat that has changes, v0 reviews the changes. If you ask for the whole project in a chat that has changes, v0 asks which one you mean before running anything: answer with another message, or resolve its question as described in [Handling agent interactions](/docs/api/v2/guides/handling-agent-interactions).

## 2. Ask for a review

```ts
const sent = await v0.messages.send({
  chatId,
  message: 'Run a security check.',
})
if (sent.error) throw new Error(sent.error.message)
const message = sent.data
```

`messages.send` returns once the review and v0's reply finish. A review usually takes a minute or two and can take up to 15 minutes, so for a better experience use [`messages.sendStream`](/docs/api/v2/reference/messages/send-message-streaming), which shows the review as it runs (reconnect with [`chats.resume`](/docs/api/v2/guides/resuming-streams) if the stream drops), or [`messages.sendAsync`](/docs/api/v2/reference/messages/send-message-async) and poll [`messages.get`](/docs/api/v2/reference/messages/get-message) until `finishReason` is set. A polled message gets the review's part only once the review ends.

## 3. Read the result

v0's final message holds the checked findings, as in the app: its `text` parts list each confirmed finding with its severity, file and line, and a suggested fix, followed by the findings v0 dismissed and why. To get the findings in a fixed format, ask for one in your message, for example: "Run a security check and list the confirmed findings as JSON."

The message also has a `security_review` part for each review v0 ran, with the review's status. v0 may run a review again in the same message, for example when a first attempt couldn't start, so read the last one:

```ts
type Part = (typeof message.parts)[number]

const reply = message.parts
  .filter((part): part is Extract<Part, { type: 'text' }> => part.type === 'text')
  .map((part) => part.text)
  .join('\n\n')

const review = message.parts.findLast(
  (part): part is Extract<Part, { type: 'agent-action' }> =>
    part.type === 'agent-action' && part.name === 'security_review',
)
if (review?.data && 'outcome' in review.data) {
  if (review.data.outcome === 'incomplete') {
    console.log('The review ended without a result:', review.data.reason)
  } else if (review.data.outcome !== 'running') {
    console.log('Potential issues before v0 checked them:', review.data.potentialIssueCount)
  }
}
```

Narrow the part's `data` by `outcome`:

- `running`: the review is still running, which you only see while streaming.
- `clean` or `findings`: the review finished. `potentialIssueCount` and `severities` count what it reported before v0 checked it (`bug` counts non-security bugs), and `durationMs` is how long it ran. The reply says which findings v0 confirmed.
- `incomplete`: the review ended without a result, and `reason` says why: `ai-error`, `credits`, `timeout`, `stopped`, `not-started`, or `interrupted`.

Every outcome includes `files`, the files reviewed, and `contextFileCount`. There's no `security_review` part when v0 didn't run a review, for example when it asked which scope you meant.

v0 doesn't change code during a review; send another message asking it to fix the findings.

## Cost

A review runs on the chat's model and uses v0 credits like other messages.

---

For a semantic overview of all documentation, see [/docs/sitemap.md](/docs/sitemap.md)

For an index of all available documentation, see [/docs/llms.txt](/docs/llms.txt)

For agent-facing discovery, including API and MCP surfaces, see [/docs/agents.md](/docs/agents.md)