Skip to content

Support latest Vercel AI SDK (LanguageModelV3) in AISdkClient / Stagehand #1645

@PerryFinn

Description

@PerryFinn

Is your feature request related to a problem? Please describe.

Yeah,Stagehand’s AISdkClient currently expects an AI SDK model that matches LanguageModelV2, but the latest Vercel AI SDK provider packages (AI SDK v6+) return LanguageModelV3. This causes a TypeScript incompatibility and prevents using Stagehand with up-to-date AI SDK dependencies.
I ran into this while building a demo with these dependencies:

{
  "dependencies": {
    "@ai-sdk/openai": "^3.0.23",
    "@browserbasehq/stagehand": "latest",
    "dotenv": "^16.4.7",
    "zod": "^4.3.6"
  }
}

Minimal repro:

import "dotenv/config";
import { Stagehand, AISdkClient } from "@browserbasehq/stagehand";
import { createOpenAI } from "@ai-sdk/openai";

const openaiProvider = createOpenAI({
  apiKey: "sk-xxxx-xxxx",
});

const llmClient = new AISdkClient({
  model: openaiProvider("gpt-4.1-mini"),
});

async function main() {
  const stagehand = new Stagehand({
    env: "LOCAL",
    verbose: 2,
    logInferenceToFile: true,
    llmClient,
  });

  // ...
}

TypeScript error:

Type 'LanguageModelV3' is not assignable to type 'LanguageModelV2'.
  Types of property 'specificationVersion' are incompatible.
    Type '"v3"' is not assignable to type '"v2"'. ts(2322)
index.d.ts(...): The expected type comes from property 'model' which is declared here on type '{ model: LanguageModelV2; }'

This aligns with the ecosystem shift where AI SDK v6 providers now return LanguageModelV3:
openai/openai-agents-js#868
https://ai-sdk.dev/providers/community-providers/custom-providers (Language Model Specification V3)

Describe the solution you'd like

Update Stagehand’s AISdkClient (and any related typings/adapter code paths) to support the latest Vercel AI SDK model interface:
• Accept LanguageModelV3 as the model type (or support both LanguageModelV2 | LanguageModelV3).
• Ideally keep backward compatibility for users still on AI SDK v5/V2.

Concretely, something like:
• AISdkClient constructor: { model: LanguageModelV3 } (or union)
• Any internal calls/adapters updated for V3’s interfaces/options.
• If maintaining both is hard, provide a new client (e.g. AISdkClientV3) or a small compatibility shim.

Describe alternatives you've considered

  1. Pin/downgrade AI SDK dependencies to an older major version that still returns LanguageModelV2 (not ideal; blocks using the current AI SDK).
  2. Avoid AISdkClient and use Stagehand’s built-in model configuration instead — but this loses the benefits of using the AI SDK provider setup I already use across my codebase.

Are you willing to contribute to implementing this feature or fix?

  • Yes, I can submit a PR
  • Yes, but I need guidance
  • No, I cannot contribute at this time

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions