agp-api documentationο
Welcome to the official documentation for agp-api!
agp-api is a Python-based API framework designed to create clients and servers for the Agent Gateway Protocol efficiently. It provides a robust and scalable architecture for processing messages, interacting with remote services, and handling agent workflows.
Featuresο
π Supports structured logging with JSON output.
π Built-in FastAPI integration for handling API requests.
π Stateless message processing with LangGraph.
π Configurable and extensible agent framework.
Installationο
To install agp-api, run:
pip install agp-api
Usage Exampleο
Hereβs a simple example of how to create a client and publish a message using agp-api:
from agp_api.gateway.gateway_container import GatewayContainer, AgentContainer
gateway_container = GatewayContainer()
gateway_container.set_fastapi_app(create_app())
agent_container = AgentContainer()
gateway_container.set_config(endpoint="http://127.0.0.1:46357", insecure=True)
# Call connect_with_retry
conn_id = await gateway_container.connect_with_retry(
agent_container=agent_container,
max_duration=10,
initial_delay=1,
remote_agent="server",
)
# Assert that the connection ID is returned
self.assertIsInstance(conn_id, int)
# Publish a message
_ = await gateway_container.publish_messsage(
message=json.dumps(self.payload),
agent_container=agent_container,
remote_agent="server",
)
Further Readingο
π Check out the API Reference for detailed module documentation.
π― Learn about Pydantic Models for structured data handling.
π Visit the official GitHub repository for source code and contributions.
Contents: