Skip to main content
Create a .env file in your project root. The AgentMark CLI automatically loads it before running commands.

AgentMark core

The scaffolded client routes automatically: AGENTMARK_API_KEY present → ApiLoader.cloud; absent → ApiLoader.local (local dev server). No extra env vars needed.
Don’t confuse AGENTMARK_BASE_URL with AGENTMARK_API_URL (see CLI configuration). They share the same default (https://api.agentmark.co) but different code paths read them: AGENTMARK_BASE_URL configures the SDK/client loader (ApiLoader.cloud()), while AGENTMARK_API_URL configures CLI tooling: agentmark run-experiment’s baseline fetch and the agentmark-mcp server. Set the one that matches what you’re running.

Example: local dev vs cloud

AI provider API keys

Configure API keys for the AI providers you use. Only set the keys for providers you actually call.
When you set these in the AgentMark Dashboard (your app → Settings → Environment variables), AgentMark stores the values encrypted in the vault, scopes them to the app, decrypts them only at runtime, and keeps them out of logs. Each variable targets one or more environment kinds (Development, Preview, Production, or All Environments) or a single specific environment, with the most specific target winning, so a fresh Preview environment inherits the Preview and All-Environments keys it was never configured with. See Security → Provider API keys for the storage details.

OpenAI

Anthropic

Google

AWS Bedrock

Azure OpenAI

*Required only if you use models from that provider. You don’t need to set keys for providers you don’t use.

MCP server configuration

AgentMark doesn’t read any MCP-specific env vars itself. MCP servers reference whatever env vars you configure in your agentmark.json mcpServers block or pass via env: to a stdio server:

Using env() interpolation

Reference environment variables in the mcpServers block of your agentmark.json with env('VAR_NAME') (single or double quotes). Variable names must be uppercase letters, digits, and underscores. Interpolation is whole-string only: the entire value must be the env(...) expression, so a composed string like "Bearer env('TOKEN')" passes through literally. Put the full value, prefix included, in the variable itself. Values resolve from the process environment when AgentMark connects the MCP server; a missing variable throws Missing environment variable: VAR_NAME.
agentmark.json
Then set the variables in .env:

Observability and tracing

You control tracing by calling sdk.initTracing() in your code, not through an environment variable. The SDK derives the OTLP endpoint from its configured baseUrl, and you can’t override it via OTEL_EXPORTER_OTLP_ENDPOINT.

Gateway MCP server

For the gateway MCP server:

CLI configuration

Webhook configuration

Variables for alert webhook endpoints.

Complete example

Here’s a complete .env file for a typical project:

Loading environment variables

Automatic loading

The AgentMark CLI automatically loads .env files from your project root before running any command.

Manual loading (application code)

For your application code, use a package like dotenv:
Or in Next.js, the framework loads environment variables from .env.local automatically.

CI/CD

In CI/CD, set environment variables through your CI/CD provider’s secrets management:
  • GitHub Actions: repository secrets or environment secrets
  • Vercel: project environment variables
  • AWS: Secrets Manager or Parameter Store

Have questions?

Reach out any time: