What is a Client?

A Client connects your agent to real-world input and output sources. It delivers Messages to your agent and routes responses to their destination.

A Client can be one (or both) of:

  • Input (AgentInput): Provides messages to the agent.
  • Output (AgentOutput): Sends the agent’s responses to their destination.

This design allows your agent to integrate seamlessly with a wide range of sources, from scheduled tasks (like cron jobs) to interactive platforms (like Discord bots).

Adding Clients to Your Agent

Prerequisites

If you don’t have an already working agent built with Galadriel, please go through the quick start.

Gradio Client Example

Clients connect to AgentRuntime, which manages how the agent processes inputs and returns results.

import asyncio
from galadriel import AgentRuntime, CodeAgent
from galadriel.clients import GradioClient
from galadriel.core_agent import LiteLLMModel, DuckDuckGoSearchTool

model = LiteLLMModel(model_id="gpt-4o", api_key="<YOUR_OPENAI_API_KEY>")

agent = CodeAgent(model=model, tools=[DuckDuckGoSearchTool()])

gradio_client = GradioClient()

runtime = AgentRuntime(
    agent=agent,
    inputs=[gradio_client],
    outputs=[gradio_client],
)

asyncio.run(runtime.run())

Supported Clients (or Build Your Own)

We currently provide built-in support for:

  • Discord
  • Telegram
  • Gradio
  • Terminal
  • Cron
  • SimpleMessageClient
  • Twitter

Visit our Clients to learn more about using these clients or creating your own.

Conclusion

Clients allow you to plug your agent into the real world with minimal effort. Need an AI that interacts via Discord, Slack, email, or webhooks? Just write a Client that conforms to AgentInput and AgentOutput, and you’re good to go.

See Next

Happy coding! 🚀