My Actor 1
Pricing
Pay per usage
Pricing
Pay per usage
Rating
0.0
(0)
Developer

Jalen Hurts
Actor stats
0
Bookmarked
2
Total users
1
Monthly active users
3 days ago
Last modified
Share
LangGraph.js agent template
LangGraph is a library for building stateful, multi-actor applications with LLMs, used to create agent and multi-agent workflows.
This template provides a basic structure and an example of a LangGraph ReAct agent that answers questions using web search.
How it works
The LangGraph agent follows these steps:
- Determines whether to answer questions using internal knowledge or by searching the web.
- If a web search is needed, it uses the RAG Web Browser to gather relevant data from websites.
- Utilizes the gathered data to generate an answer using the OpenAI model.
In LangGraph.js, agents use tools, which are functions designed to perform specific tasks.
This agent has one tool, webSearchTool, defined in src/tools.js, which allows it to search the web for relevant data.
Sample query
- How to build a LangGraph agent on the Apify platform?
Before you start
To run this template locally or on the Apify platform, you need:
- An Apify account and an Apify API token.
- An OpenAI account and API key.
When running the agent locally, set the OpenAI API key as an environment variable:
$export OPENAI_API_KEY=your-openai-api-key
When running the agent on the Apify platform, set the OpenAI API key in the environment variables of the Actor.
To do this, go to Actor settings → Source → Code, then scroll down to the Environment variables tab and add a new variable named OPENAI_API_KEY with your OpenAI API key.
Monetization
This template uses the Pay Per Event (PPE) monetization model, which provides flexible pricing based on defined events.
To charge users, define events in JSON format and save them on the Apify platform. Here is an example of .actor/pay_per_event.json with the task-completed event:
[{"task-completed": {"eventTitle": "Task completed","eventDescription": "Cost per query answered.","eventPriceUsd": 0.1}}]
In the Actor, trigger the event with:
await Actor.charge({ eventName: 'task-completed' });
This approach allows you to programmatically charge users directly from your Actor, covering the costs of execution and related services, such as LLM input/output tokens.
Resources
Useful resources to help you get started:
- Apify Actors
- LangGraph documentation
- LangGraph examples
- LangGraph with Apify (Python)
- What are AI agents?
- 11 AI agent use cases on Apify
- Pay-per-event Monetization
- Web Scraping Data for Generative AI
Getting started
For complete information see this article. In short, you will:
- Build the Actor
- Run the Actor
Pull the Actor for local development
If you would like to develop locally, you can pull the existing Actor from Apify console using Apify CLI:
-
Install
apify-cliUsing Homebrew
$brew install apify-cliUsing NPM
$npm -g install apify-cli -
Pull the Actor by its unique
<ActorId>, which is one of the following:- unique name of the Actor to pull (e.g. "apify/hello-world")
- or ID of the Actor to pull (e.g. "E2jjCZBezvAZnX8Rb")
You can find both by clicking on the Actor title at the top of the page, which will open a modal containing both Actor unique name and Actor ID.
This command will copy the Actor into the current directory on your local machine.
$apify pull <ActorId>
Documentation reference
To learn more about Apify and Actors, take a look at the following resources: