Network Adapters#
Network Adapters in FastAgency provide a way to integrate your workflows with various communication protocols and interfaces. They allow you to expose your workflows through different channels, making it easier to interact with them from various client applications.
FastAgency uses chainable network adapters that can be easily combined to create scalable, production-ready architectures for serving your workflows. These adapters enable you to deploy your workflows in distributed environments and handle high volumes of requests.
Why Use Network Adapters?#
- Production Deployment: You can use network adapters to deploy agentic workflows in production settings. They provide a way for you to scale up workloads and deploy fully distributed systems, ensuring high availability and performance.
-
API Integration: You can utilize an adapter like
FastAPIAdapter
to expose your workflows as a REST API. This allows other applications to interact with your workflows through standard HTTP requests, making it easy for you to integrate with existing systems. -
Messaging Systems: You can use message queue adapters like
NatsAdapter
to scale your workflows and handle high volumes of requests. This enables you to implement distributed processing and asynchronous communication between different components of your system, allowing for efficient resource utilization and improved performance.
Available Adapters#
FastAPI#
The FastAPIAdapter
allows you to expose your FastAgency workflows as a REST API using the FastAPI framework.
When to Use the FastAPIAdapter
:
-
Custom Client Applications: If you want to build your own client applications in a different language, (e.g., HTML/JavaScript, Go, Java, etc.), that interacts with your FastAgency workflows using REST API and WebSockets.
-
Moderate User Demand: This adapter is a good fit for scenarios where workflows need to be executed by multiple workers to efficiently handle higher machine load.
-
Simplified Production Setup: This adapter is a good choice when you need a simple and easy-to-manage setup for deploying FastAgency workflows as an ASGI server in production.
Learn more about FastAPI adapter →
FastAPI + Nats.io#
Combining the FastAPIAdapter
and NatsAdapter
in FastAgency provides the most scalable setup. It harnesses the power of the FastAPI framework to build and expose workflows as REST APIs while utilizing the Nats.io message broker for scalable and asynchronous communication. This setup is preferred for running large workloads in production.
When to Use the FastAPIAdapter
and NatsAdapter
Together
-
High User Demand: If you need to scale beyond what multiple workers of the FastAPIAdapter can achieve, you can use Nats.io with a message queue and multiple workers to consume and produce messages. This distributed message-queue architecture allows scaling not only across multiple workers but also across multiple machines and clusters.
-
Observability: If you need the ability to audit workflow executions both in realtime and retrospectively, the
NatsAdapter
provides the necessary infrastructure to enable this feature. -
Security features of FastAPI: If you want to leverage the security features of FastAPI, such as authentication, authorization, along with the distributed architecture of NATS, this setup is the most suitable option. Please check the securing your FastAPIAdapter documentation for more information.
Learn more about FastAPI + NATS.io adapter →
Nats.io#
The NatsAdapter
in FastAgency enables seamless integration of your workflows with the Nats.io MQ message broker, providing a scalable and flexible solution for building distributed applications.
When to Use the NatsAdapter
:
-
High User Demand: If you need to scale beyond what multiple workers of the FastAPIAdapter can achieve, you can use Nats.io with a message queue and multiple workers to consume and produce messages. This distributed message-queue architecture allows scaling not only across multiple workers but also across multiple machines and clusters.
-
Observability: If you need the ability to audit workflow executions both in realtime and retrospectively, the
NatsAdapter
provides the necessary infrastructure to enable this feature.