skip to content

docs / Models and agents

Models

Configure a model with your own subscription, an API key, or a local server.

Agent steps use the model you set in e2e.config.ts. There is no default. The model comes from an AI SDK provider: a gateway, a direct API key, a local server, or your subscription. For a first setup, e2e init writes the config. See the quickstart.

Tests without agent steps need no model. The built-in agent needs a model that supports tool calls and images. Decision models such as Clef or Jev run through a custom executor instead.

Pick a gateway or a provider

The built-in agent needs the ai package, whatever the provider:

npm install -D ai

The provider reads its own key from the environment. A gateway reaches many providers with one key. To switch, replace the model import and the model value. Where a snippet defines agent, use it as agents.default:

gateway comes with the ai package. Set AI_GATEWAY_API_KEY, or use a Vercel OIDC token with no key.

e2e.config.ts
import type { E2EConfig } from 'e2e';
import { web } from '@e2e-dev/web';
import { gateway } from 'ai';

export default {
  targets: [{ engine: web(), app: { url: 'http://localhost:3000' } }],
  agents: { default: { model: gateway('openai/gpt-6-luna-fast') } },
} satisfies E2EConfig;

Gateways usually use provider/model IDs. Direct providers use their own.

Vercel OIDC instead of a key

Without AI_GATEWAY_API_KEY, gateway() signs in with a short-lived Vercel OIDC token, which it refreshes. Sign in to the Vercel CLI and link the project one time:

npx vercel login
npx vercel link
npx e2e run

The gateway uses a valid VERCEL_OIDC_TOKEN. Else it gets a token for the project in .vercel/project.json, found from the working directory upward. e2e loads no .env file, so a token from npx vercel env pull works only when your shell exports it, or when the config loads the file with process.loadEnvFile().

AI SDK providers

Every AI SDK provider that supports tool calls works. Each provider’s package and variables are on its AI SDK provider page. Select yours:

provider docs ↗

A provider that is not in the list also works if it implements the AI SDK language model specification v2 or later.

  1. 1
    Install the provider package

    Install ai and the provider package:

    install · Vercel AI Gateway
    npm install -D ai
  2. 2
    Set the credentials

    Export the variables in your shell or CI, or load a .env file in the config with process.loadEnvFile().

    environment · Vercel AI Gateway
    export AI_GATEWAY_API_KEY=...

    You can use a Vercel OIDC token from a linked project instead of a key.

  3. 3
    Add the model to the config

    Set the model in agents.default. The model ID is an example.

    e2e.config.ts · Vercel AI Gateway
    import type { E2EConfig } from 'e2e';
    import { web } from '@e2e-dev/web';
    import { gateway } from 'ai';
    
    export default {
      targets: [{ engine: web(), app: { url: 'http://localhost:3000' } }],
      agents: { default: { model: gateway('openai/gpt-6-luna-fast') } },
    } satisfies E2EConfig;
Models that refuse a forced tool choice

Agent steps ask every model for a tool call on every turn. Claude Opus 5.5, Sonnet 5.5, and Fable 5.1 reject that request shape, DeepSeek’s V4 models (@ai-sdk/deepseek) refuse it because they think by default, and Muse Spark models accept only auto. e2e continues with auto, and later steps on that model start that way. Thinking can stay on.

Claude Opus 5.5, Sonnet 5.5, and Fable 5.1

These models bind each thinking block to the system prompt and the messages before it, and reject a request that replays the block after either changed. An agent step keeps its prompt fixed, and once it elides a superseded screen or screenshot from an earlier message it stops sending the thinking from that message on. The step’s --debug transcript notes it.

Several models in one config

Give each model its own agent name, then pick one with --agent or in a test. See Agents and personas. To switch a model without editing the config, read an environment variable:

Agent setup
const agent = {
  model: gateway(process.env.MODEL ?? 'openai/gpt-6-luna-fast'),
};

Pick a model by the key that is set

When teammates hold different keys, choose the model by the variable that is set. Keep one agent name, so everyone replays the same recordings:

Agent setup
import { anthropic } from '@ai-sdk/anthropic';
import { gateway } from 'ai';

const agent = {
  model: process.env.ANTHROPIC_API_KEY
    ? anthropic('claude-sonnet-5-5')
    : gateway('openai/gpt-6-luna-fast'),
};

Make gateway() the fallback: Vercel OIDC signs it in with no variable to test. A key in .env counts only when process.loadEnvFile() runs before this code.

A step recorded with the other model still replays and names that model. See What must match.

A judge of its own

By default, one model drives agent.act and answers agent.assert, agent.waitFor, and agent.extract. Set judge to use another model for those checks:

Agent setup
const agent = {
  model: gateway('openai/gpt-6-luna-fast'),
  judge: gateway('anthropic/claude-sonnet-5'),
};

Built-in agent.assert with explore: true runs the tool loop on agents.<name>.model, even when judge is set.

Reports name the model of each judgment. judge takes an AI SDK language model. For Clef or Jev, use the decision executor. See what a judgment sees.

Data retention and compliance

Model input is the redacted screen, the step instruction, and the screenshots the agent asks for. e2e reads nothing back from the provider after a response, so a run needs no state stored by the provider.

Every model request names e2e: a User-Agent that starts with e2e/<version> (<platform>; <arch>), plus HTTP-Referer: https://tester.army/e2e and X-Title: e2e for Vercel AI Gateway and OpenRouter. They replace the same headers set on the provider instance.

OpenAI and Azure OpenAI: zero data retention

Every request to a Responses model (openai(...), azure(...), or openai/* on the gateway) carries store: false and a prompt cache key. Chat Completions models and OpenAI-compatible providers get neither. The provider keeps no copy of the conversation, and the prompt cache still works. Organizations with zero data retention need no configuration.

To keep stored responses, set store in providerOptions. For Azure OpenAI, the key is azure:

Agent setup
const agent = {
  model: openai('gpt-6-luna'),
  providerOptions: { openai: { store: true } },
};
Anthropic under a BAA

Agent steps use the Messages API with tool use, prompt caching, images, and structured outputs. All are eligible under Anthropic’s HIPAA readiness.

The agreement covers api.anthropic.com only. Call it with @ai-sdk/anthropic, not through a gateway or OpenRouter. Leave judge unset, so one agreement covers every request. Anthropic’s Covered Models need 30-day retention, so organizations with zero data retention can’t use them.

What fails, and where

ProblemCodeFix
A model is a string instead of an AI SDK instanceINVALID_CONFIGConstruct it, for example gateway('openai/gpt-6-luna-fast').
The built-in agent has no modelMODEL_UNAVAILABLESet agents.<name>.model.
GitHub Copilot doesn’t serve the model to your accountMODEL_UNAVAILABLEPick an id your plan serves. See Pick a model.
A provider that reads its key at config load has noneCONFIG_LOAD_FAILEDSet the key.
Authentication fails on the first model callMODEL_PROVIDER_FAILEDCheck the provider’s API key, or run npx e2e login for a subscription. For Vercel OIDC the message names only AI_GATEWAY_API_KEY. Check vercel login and .vercel/project.json.
The ai package is missingMODEL_UNAVAILABLEInstall ai. See Pick a gateway or a provider.
A step’s second turn fails with Item with id 'rs_…' not foundMODEL_PROVIDER_FAILEDLeave store off in providerOptions, the default, or call OpenAI directly instead of through a gateway.
A custom executor’s own model or judge differs from the agents entry’sINVALID_CONFIGSee Custom executors.

Next

was this page helpful?