A sample Node script that uses LangChain to talk to LLMs.
You’ll need an API key for each LLM. So just follow the instructions linked below to obtain your API keys.
Save the keys to the app/src/main/resources/.env
file as the corresponding
..._API_KEY
environment variable. You can use
app/src/main/resources/.env.template
as a guide to structure your .env
file.
Install packages, if you haven't already.
pnpm install
The sample logic is in the file index.js
.
To run against OpenAI's ChatGPT:
pnpm run main --model openai
To run against Anthropic's Claude:
pnpm run main --model anthropic
To run against Google's Gemini:
pnpm run main --model google
To run against DeekSeek's R1:
pnpm run main --model deepseek
If you don't specify --model
, it will default to openai
and use ChatGPT.