Talk to the experts
Learn more about Extend and find out if it's the right solution for your business.
May 1, 2025 4:44 PM
In this blog post, we'll explore how to build an AI agent that can interact with the Extend API using LangChain and the React agent pattern. We'll cover the background of these technologies, how they work together, and provide a step-by-step guide to create your own agent.
LangChain is a framework for developing applications powered by language models. It provides a set of abstractions and tools that make it easier to build complex applications with LLMs (Large Language Models). LangChain enables developers to:
LangChain has become a popular choice for developers building AI applications because it simplifies the integration of LLMs into existing systems and workflows.
The React agent pattern (Reasoning and Acting) is a powerful approach to building AI agents that can solve complex tasks. The name "React" comes from the pattern of alternating between:
1. Reasoning: The agent thinks about what to do next
2. Acting: The agent takes an action based on its reasoning
This pattern allows the agent to:
React agents are particularly effective for tasks that require multiple steps or the use of external tools, making them ideal for interacting with APIs like Extend.
The Extend AI Toolkit is an open-source library that provides tools for integrating with the Extend API in various AI agent frameworks, including LangChain.
It enables AI agents to:
The toolkit abstracts away the complexity of API interactions, allowing developers to focus on building powerful AI agents that can help users manage their finances.
Before we start building our agent, let's set up our development environment:
1. Install Python 3.12 or higher if you don't already have it.
2. Create a virtual environment (recommended):
3. Install the required packages:
4. Set up your Extend API credentials:
Create a `.env` file in your project directory with the following content:
You'll need to obtain these credentials from your Extend account. If you don't have an account yet, you can sign up at app.paywithextend.com and follow our Getting Started Guide.
5. Set up your OpenAI API key:
To use LangChain with GPT models, you'll need an OpenAI API key:
1. Go to [OpenAI's platform](https://platform.openai.com/)
2. Sign up for an account or log in if you already have one
3. Navigate to the API keys section
4. Click "Create new secret key"
5. Give your key a name (e.g., "Extend Agent")
6. Copy the generated API key and add it to your `.env` file as `OPENAI_API_KEY`
Now, let's create a Python script that sets up a LangChain React agent with the Extend AI Toolkit. We'll break this down into logical sections to understand each component.
1. Imports and environment setup
First, let's import the necessary libraries and set up our environment variables:
This section handles importing all necessary libraries and setting up environment variables. We use `python-dotenv` to load variables from our `.env` file and validate that all required credentials are present.
2. Language model configuration
Next, we set up our language model:
Here, we're using OpenAI's GPT-4o model through LangChain's `ChatOpenAI` class. You can also use GPT-3.5-turbo for a more cost-effective option, though it may have slightly reduced capabilities.
3. Extend Toolkit configuration
Now, let's configure the Extend AI Toolkit with appropriate permissions:
This section creates an instance of the Extend LangChain toolkit with read permissions for virtual cards, credit cards, and transactions. We then extract the tools from the toolkit, which will be used by our agent.
4. React Agent creation
Now, let's create our React agent:
This creates a React agent using LangGraph's `create_react_agent` function, which combines our language model with the Extend tools.
5. Chat interface implementation
Finally, let's implement the chat interface:
This section implements a simple chat interface that allows users to interact with the agent. It displays a welcome message with available capabilities, processes user input, and displays the agent's responses.
To run the agent, simply execute the script:
You'll be presented with a welcome message and a list of capabilities. You can then ask the agent questions like:
The agent will use the React pattern to:
The Extend AI Toolkit provides many more capabilities that you can add to your agent:
To add these capabilities, simply update the `Configuration` object with the appropriate scopes and actions.
In this blog post, we've explored how to build an AI agent that can interact with the Extend API using LangChain and the React agent pattern. We've covered:
This agent can serve as a foundation for building more complex financial management applications. By combining the power of LangChain with the Extend API, you can create AI assistants that help users manage their finances more effectively.
To learn more about the Extend AI Toolkit, visit the GitHub repository. For more information about LangChain, check out the LangChain documentation.
Happy coding!
Dawn Lewis
Controller at Couranto
Bridget Cobb
Staff Accountant at Healthstream
Brittany Nolan
Sr. Product Marketing Manager at Extend (moderator)
In this blog post, we'll explore how to build an AI agent that can interact with the Extend API using LangChain and the React agent pattern. We'll cover the background of these technologies, how they work together, and provide a step-by-step guide to create your own agent.
LangChain is a framework for developing applications powered by language models. It provides a set of abstractions and tools that make it easier to build complex applications with LLMs (Large Language Models). LangChain enables developers to:
LangChain has become a popular choice for developers building AI applications because it simplifies the integration of LLMs into existing systems and workflows.
The React agent pattern (Reasoning and Acting) is a powerful approach to building AI agents that can solve complex tasks. The name "React" comes from the pattern of alternating between:
1. Reasoning: The agent thinks about what to do next
2. Acting: The agent takes an action based on its reasoning
This pattern allows the agent to:
React agents are particularly effective for tasks that require multiple steps or the use of external tools, making them ideal for interacting with APIs like Extend.
The Extend AI Toolkit is an open-source library that provides tools for integrating with the Extend API in various AI agent frameworks, including LangChain.
It enables AI agents to:
The toolkit abstracts away the complexity of API interactions, allowing developers to focus on building powerful AI agents that can help users manage their finances.
Before we start building our agent, let's set up our development environment:
1. Install Python 3.12 or higher if you don't already have it.
2. Create a virtual environment (recommended):
3. Install the required packages:
4. Set up your Extend API credentials:
Create a `.env` file in your project directory with the following content:
You'll need to obtain these credentials from your Extend account. If you don't have an account yet, you can sign up at app.paywithextend.com and follow our Getting Started Guide.
5. Set up your OpenAI API key:
To use LangChain with GPT models, you'll need an OpenAI API key:
1. Go to [OpenAI's platform](https://platform.openai.com/)
2. Sign up for an account or log in if you already have one
3. Navigate to the API keys section
4. Click "Create new secret key"
5. Give your key a name (e.g., "Extend Agent")
6. Copy the generated API key and add it to your `.env` file as `OPENAI_API_KEY`
Now, let's create a Python script that sets up a LangChain React agent with the Extend AI Toolkit. We'll break this down into logical sections to understand each component.
1. Imports and environment setup
First, let's import the necessary libraries and set up our environment variables:
This section handles importing all necessary libraries and setting up environment variables. We use `python-dotenv` to load variables from our `.env` file and validate that all required credentials are present.
2. Language model configuration
Next, we set up our language model:
Here, we're using OpenAI's GPT-4o model through LangChain's `ChatOpenAI` class. You can also use GPT-3.5-turbo for a more cost-effective option, though it may have slightly reduced capabilities.
3. Extend Toolkit configuration
Now, let's configure the Extend AI Toolkit with appropriate permissions:
This section creates an instance of the Extend LangChain toolkit with read permissions for virtual cards, credit cards, and transactions. We then extract the tools from the toolkit, which will be used by our agent.
4. React Agent creation
Now, let's create our React agent:
This creates a React agent using LangGraph's `create_react_agent` function, which combines our language model with the Extend tools.
5. Chat interface implementation
Finally, let's implement the chat interface:
This section implements a simple chat interface that allows users to interact with the agent. It displays a welcome message with available capabilities, processes user input, and displays the agent's responses.
To run the agent, simply execute the script:
You'll be presented with a welcome message and a list of capabilities. You can then ask the agent questions like:
The agent will use the React pattern to:
The Extend AI Toolkit provides many more capabilities that you can add to your agent:
To add these capabilities, simply update the `Configuration` object with the appropriate scopes and actions.
In this blog post, we've explored how to build an AI agent that can interact with the Extend API using LangChain and the React agent pattern. We've covered:
This agent can serve as a foundation for building more complex financial management applications. By combining the power of LangChain with the Extend API, you can create AI assistants that help users manage their finances more effectively.
To learn more about the Extend AI Toolkit, visit the GitHub repository. For more information about LangChain, check out the LangChain documentation.
Happy coding!
In this blog post, we'll explore how to build an AI agent that can interact with the Extend API using LangChain and the React agent pattern. We'll cover the background of these technologies, how they work together, and provide a step-by-step guide to create your own agent.
LangChain is a framework for developing applications powered by language models. It provides a set of abstractions and tools that make it easier to build complex applications with LLMs (Large Language Models). LangChain enables developers to:
LangChain has become a popular choice for developers building AI applications because it simplifies the integration of LLMs into existing systems and workflows.
The React agent pattern (Reasoning and Acting) is a powerful approach to building AI agents that can solve complex tasks. The name "React" comes from the pattern of alternating between:
1. Reasoning: The agent thinks about what to do next
2. Acting: The agent takes an action based on its reasoning
This pattern allows the agent to:
React agents are particularly effective for tasks that require multiple steps or the use of external tools, making them ideal for interacting with APIs like Extend.
The Extend AI Toolkit is an open-source library that provides tools for integrating with the Extend API in various AI agent frameworks, including LangChain.
It enables AI agents to:
The toolkit abstracts away the complexity of API interactions, allowing developers to focus on building powerful AI agents that can help users manage their finances.
Before we start building our agent, let's set up our development environment:
1. Install Python 3.12 or higher if you don't already have it.
2. Create a virtual environment (recommended):
3. Install the required packages:
4. Set up your Extend API credentials:
Create a `.env` file in your project directory with the following content:
You'll need to obtain these credentials from your Extend account. If you don't have an account yet, you can sign up at app.paywithextend.com and follow our Getting Started Guide.
5. Set up your OpenAI API key:
To use LangChain with GPT models, you'll need an OpenAI API key:
1. Go to [OpenAI's platform](https://platform.openai.com/)
2. Sign up for an account or log in if you already have one
3. Navigate to the API keys section
4. Click "Create new secret key"
5. Give your key a name (e.g., "Extend Agent")
6. Copy the generated API key and add it to your `.env` file as `OPENAI_API_KEY`
Now, let's create a Python script that sets up a LangChain React agent with the Extend AI Toolkit. We'll break this down into logical sections to understand each component.
1. Imports and environment setup
First, let's import the necessary libraries and set up our environment variables:
This section handles importing all necessary libraries and setting up environment variables. We use `python-dotenv` to load variables from our `.env` file and validate that all required credentials are present.
2. Language model configuration
Next, we set up our language model:
Here, we're using OpenAI's GPT-4o model through LangChain's `ChatOpenAI` class. You can also use GPT-3.5-turbo for a more cost-effective option, though it may have slightly reduced capabilities.
3. Extend Toolkit configuration
Now, let's configure the Extend AI Toolkit with appropriate permissions:
This section creates an instance of the Extend LangChain toolkit with read permissions for virtual cards, credit cards, and transactions. We then extract the tools from the toolkit, which will be used by our agent.
4. React Agent creation
Now, let's create our React agent:
This creates a React agent using LangGraph's `create_react_agent` function, which combines our language model with the Extend tools.
5. Chat interface implementation
Finally, let's implement the chat interface:
This section implements a simple chat interface that allows users to interact with the agent. It displays a welcome message with available capabilities, processes user input, and displays the agent's responses.
To run the agent, simply execute the script:
You'll be presented with a welcome message and a list of capabilities. You can then ask the agent questions like:
The agent will use the React pattern to:
The Extend AI Toolkit provides many more capabilities that you can add to your agent:
To add these capabilities, simply update the `Configuration` object with the appropriate scopes and actions.
In this blog post, we've explored how to build an AI agent that can interact with the Extend API using LangChain and the React agent pattern. We've covered:
This agent can serve as a foundation for building more complex financial management applications. By combining the power of LangChain with the Extend API, you can create AI assistants that help users manage their finances more effectively.
To learn more about the Extend AI Toolkit, visit the GitHub repository. For more information about LangChain, check out the LangChain documentation.
Happy coding!
In this blog post, we'll explore how to build an AI agent that can interact with the Extend API using LangChain and the React agent pattern. We'll cover the background of these technologies, how they work together, and provide a step-by-step guide to create your own agent.
LangChain is a framework for developing applications powered by language models. It provides a set of abstractions and tools that make it easier to build complex applications with LLMs (Large Language Models). LangChain enables developers to:
LangChain has become a popular choice for developers building AI applications because it simplifies the integration of LLMs into existing systems and workflows.
The React agent pattern (Reasoning and Acting) is a powerful approach to building AI agents that can solve complex tasks. The name "React" comes from the pattern of alternating between:
1. Reasoning: The agent thinks about what to do next
2. Acting: The agent takes an action based on its reasoning
This pattern allows the agent to:
React agents are particularly effective for tasks that require multiple steps or the use of external tools, making them ideal for interacting with APIs like Extend.
The Extend AI Toolkit is an open-source library that provides tools for integrating with the Extend API in various AI agent frameworks, including LangChain.
It enables AI agents to:
The toolkit abstracts away the complexity of API interactions, allowing developers to focus on building powerful AI agents that can help users manage their finances.
Before we start building our agent, let's set up our development environment:
1. Install Python 3.12 or higher if you don't already have it.
2. Create a virtual environment (recommended):
3. Install the required packages:
4. Set up your Extend API credentials:
Create a `.env` file in your project directory with the following content:
You'll need to obtain these credentials from your Extend account. If you don't have an account yet, you can sign up at app.paywithextend.com and follow our Getting Started Guide.
5. Set up your OpenAI API key:
To use LangChain with GPT models, you'll need an OpenAI API key:
1. Go to [OpenAI's platform](https://platform.openai.com/)
2. Sign up for an account or log in if you already have one
3. Navigate to the API keys section
4. Click "Create new secret key"
5. Give your key a name (e.g., "Extend Agent")
6. Copy the generated API key and add it to your `.env` file as `OPENAI_API_KEY`
Now, let's create a Python script that sets up a LangChain React agent with the Extend AI Toolkit. We'll break this down into logical sections to understand each component.
1. Imports and environment setup
First, let's import the necessary libraries and set up our environment variables:
This section handles importing all necessary libraries and setting up environment variables. We use `python-dotenv` to load variables from our `.env` file and validate that all required credentials are present.
2. Language model configuration
Next, we set up our language model:
Here, we're using OpenAI's GPT-4o model through LangChain's `ChatOpenAI` class. You can also use GPT-3.5-turbo for a more cost-effective option, though it may have slightly reduced capabilities.
3. Extend Toolkit configuration
Now, let's configure the Extend AI Toolkit with appropriate permissions:
This section creates an instance of the Extend LangChain toolkit with read permissions for virtual cards, credit cards, and transactions. We then extract the tools from the toolkit, which will be used by our agent.
4. React Agent creation
Now, let's create our React agent:
This creates a React agent using LangGraph's `create_react_agent` function, which combines our language model with the Extend tools.
5. Chat interface implementation
Finally, let's implement the chat interface:
This section implements a simple chat interface that allows users to interact with the agent. It displays a welcome message with available capabilities, processes user input, and displays the agent's responses.
To run the agent, simply execute the script:
You'll be presented with a welcome message and a list of capabilities. You can then ask the agent questions like:
The agent will use the React pattern to:
The Extend AI Toolkit provides many more capabilities that you can add to your agent:
To add these capabilities, simply update the `Configuration` object with the appropriate scopes and actions.
In this blog post, we've explored how to build an AI agent that can interact with the Extend API using LangChain and the React agent pattern. We've covered:
This agent can serve as a foundation for building more complex financial management applications. By combining the power of LangChain with the Extend API, you can create AI assistants that help users manage their finances more effectively.
To learn more about the Extend AI Toolkit, visit the GitHub repository. For more information about LangChain, check out the LangChain documentation.
Happy coding!
Learn more about Extend and find out if it's the right solution for your business.