Skip to content

Anthropic

Mark edited this page Jun 27, 2025 · 2 revisions

Install

NPM:

npm install @langchain/anthropic --save-dev

Yarn:

yarn add @langchain/anthropic --dev

API Key

Create cypress.env.json:

touch cypress.env.json

Set your Anthropic API key:

{
  "ANTHROPIC_API_KEY": "sk-ant-api..."
}

Code

Set the LLM with cy.aiConfig:

import { ChatAnthropic } from '@langchain/anthropic'
import { prompt } from 'cy-ai'

const llm = new ChatAnthropic({
  model: 'claude-sonnet-4-0',
  apiKey: Cypress.env('ANTHROPIC_API_KEY'),
})

const chain = prompt.pipe(llm)

before(() => {
  cy.aiConfig({ llm: chain });
})

Write your test:

it('visits example.com', () => {
  cy.visit('/')
  cy.ai('see heading "Example Domain"')
})

Clone this wiki locally