> ## Documentation Index
> Fetch the complete documentation index at: https://puzzlet-9ba7bb98.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Vercel integration

> Apps deployed on Vercel attribute AgentMark traces to the right environment automatically, with no per-deployment configuration.

When your app runs on Vercel, AgentMark attributes its traces to the right [environment](/concepts/environments) automatically: a Production deployment to your promoted environment, and each Preview deployment to that pull request's preview environment. The environment selector isn't a secret, so the SDK derives it from the git context Vercel already exposes rather than injecting it per deployment.

## Automatic environment derivation

`@agentmark-ai/sdk`'s `initTracing()` reads Vercel's system environment variables and picks the target environment for you. A Vercel deploy needs no selector configuration.

| `VERCEL_ENV`  | Signal                                              | Traces attributed to                      |
| ------------- | --------------------------------------------------- | ----------------------------------------- |
| `preview`     | An open pull request (`VERCEL_GIT_PULL_REQUEST_ID`) | That PR's preview environment             |
| `preview`     | A branch deploy with no open PR                     | An environment named after the branch ref |
| `development` | (none)                                              | The `dev` environment                     |
| `production`  | (none)                                              | The key's pinned or promoted environment  |

The derived selector is the lowest-precedence source. An explicit `initTracing({ environment, prNumber })` option, or the `AGENTMARK_ENVIRONMENT` / `AGENTMARK_PR_NUMBER` environment variables, override it. See [Attributing traces to an environment](/observe/tracing-setup#attributing-traces-to-an-environment).

## What the deployment needs

For derivation to authorize the right environment, the deployment's `AGENTMARK_API_KEY` should be a key scoped to environment **kinds** (with Preview included, and Production if production traces should flow), not a key pinned to a single environment. A kind-scoped key lets the SDK select the target per request, and the gateway authorizes the derived environment against the key's allowed kinds. See [API key environment scope](/api-reference/authentication#api-key-environment-scope).

Set these on the Vercel project (the same three values the SDK and client read everywhere):

* `AGENTMARK_API_KEY`, a kind-scoped key (Preview, plus Production if needed).
* `AGENTMARK_APP_ID`.
* `AGENTMARK_BASE_URL`, the gateway URL.

These values don't vary per deployment; only the derived selector does.

<Note>
  A one-click Vercel Marketplace connect that writes these three values into your Vercel project for you isn't available yet. Until it ships, set the three variables in the Vercel project's environment-variable settings yourself. The SDK already ships the automatic environment derivation described above, so it works as soon as you set those variables.
</Note>

<div className="mt-8 rounded-lg bg-blue-50 p-6 dark:bg-blue-900/30">
  <h3 className="font-semibold mb-3">Have questions?</h3>
  <p className="mb-4">Reach out any time:</p>

  <ul>
    <li>
      Email the team at <a href="mailto:hello@agentmark.co" className="text-blue-600 hover:text-blue-800 dark:text-blue-400 dark:hover:text-blue-200">[hello@agentmark.co](mailto:hello@agentmark.co)</a> for support
    </li>

    <li>
      Schedule an <a href="https://cal.com/ryan-randall/enterprise" className="text-blue-600 hover:text-blue-800 dark:text-blue-400 dark:hover:text-blue-200">Enterprise Demo</a> to learn about AgentMark's business solutions
    </li>
  </ul>
</div>
