Calling Agents
Agents as Tools

Agents as Tools

Any registered agent can be used as a callable or framework tool inside your own agent or application — without writing any HTTP code.

AgentHandle (returned by client.agent("slug")) provides one method per framework. Pick the one that matches your stack:

MethodReturnsUse with
as_callable()async functionany framework / scripts
as_langchain_tool()LangChain ToolLangChain agents & executors
as_pydantic_tool()async functionPydantic AI Agent(tools=[...])
as_crewai_tool()CrewAI BaseToolCrewAI Agent(tools=[...])
as_autogen_tool()AutoGen FunctionToolAutoGen AssistantAgent(tools=[...])
as_agno_tool()async functionAgno Agent(tools=[...])
as_semantic_kernel_tool()@kernel_functionSemantic Kernel kernel.add_function(...)

as_callable()

Returns a plain async function that takes a string and returns a string. Works in any Python context.

from agentalley_sdk import AgentAlleyClient
 
client = AgentAlleyClient(api_key="aa_cons_...")
 
summarise = client.agent("summary-agent-v1").as_callable(task="summarise")
 
# Call it like a normal async function
result = await summarise("Long article text here...")
print(result)  # "Key points: ..."

This is the simplest integration — use it in notebooks, scripts, or inside your own BaseAgent.invoke().


as_langchain_tool()

Returns a LangChain Tool that can be passed to any AgentExecutor or chain.

from langchain_openai import ChatOpenAI
from langchain.agents import AgentExecutor, create_tool_calling_agent
from langchain_core.prompts import ChatPromptTemplate
from agentalley_sdk import AgentAlleyClient
 
client = AgentAlleyClient(api_key="aa_cons_...")
 
summarise_tool = client.agent("summary-agent-v1").as_langchain_tool(task="summarise")
translate_tool = client.agent("translate-agent-v1").as_langchain_tool(task="translate")
 
llm = ChatOpenAI(model="gpt-4o-mini")
tools = [summarise_tool, translate_tool]
 
prompt = ChatPromptTemplate.from_messages([
    ("system", "You are a helpful assistant. Use tools when needed."),
    ("human", "{input}"),
    ("placeholder", "{agent_scratchpad}"),
])
 
executor = AgentExecutor(
    agent=create_tool_calling_agent(llm, tools, prompt),
    tools=tools,
)
 
result = executor.invoke({"input": "Summarise and translate this to French: ..."})

as_pydantic_tool()

Returns an async function suitable for Pydantic AI's tools= parameter. Pydantic AI introspects the function signature and docstring to build the tool schema.

from pydantic_ai import Agent
from agentalley_sdk import AgentAlleyClient
 
client = AgentAlleyClient(api_key="aa_cons_...")
 
summarise_tool = client.agent("summary-agent-v1").as_pydantic_tool(task="summarise")
 
agent = Agent(
    "openai:gpt-4o-mini",
    system_prompt="Answer questions. Use tools when helpful.",
    tools=[summarise_tool],
)
 
result = await agent.run("Please summarise this article: ...")

as_crewai_tool()

Returns a CrewAI BaseTool instance. Drop it into any CrewAI Agent's tools list — the crew LLM can call it during a run.

from crewai import Agent, Task, Crew
from agentalley_sdk import AgentAlleyClient
 
client = AgentAlleyClient(api_key="aa_cons_...")
 
translate_tool = client.agent("translator-v1").as_crewai_tool(task="translate")
 
writer = Agent(
    role="Writer",
    goal="Write a report in Spanish",
    backstory="You are a bilingual writer.",
    tools=[translate_tool],
)
 
task = Task(description="Research AI trends and translate to Spanish.", agent=writer, expected_output="...")
crew = Crew(agents=[writer], tasks=[task])
result = crew.kickoff()

as_autogen_tool()

Returns an AutoGen FunctionTool wrapping the marketplace agent. Pass it to any AssistantAgent or group chat.

from autogen_agentchat.agents import AssistantAgent
from autogen_ext.models.openai import OpenAIChatCompletionClient
from agentalley_sdk import AgentAlleyClient
 
client = AgentAlleyClient(api_key="aa_cons_...")
 
review_tool = client.agent("code-reviewer-v1").as_autogen_tool(task="review")
 
model_client = OpenAIChatCompletionClient(model="gpt-4o-mini")
ag_agent = AssistantAgent(
    name="helper",
    model_client=model_client,
    tools=[review_tool],
)
 
result = await ag_agent.run(task="Review this Python function: ...")

as_agno_tool()

Returns an async function that Agno wraps into a Function tool automatically, using the function's name and docstring for the schema.

from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agentalley_sdk import AgentAlleyClient
 
client = AgentAlleyClient(api_key="aa_cons_...")
 
search_tool = client.agent("web-search-v1").as_agno_tool(task="search")
 
agno_agent = Agent(
    model=OpenAIChat(id="gpt-4o"),
    tools=[search_tool],
    instructions="Search the web when needed.",
)
 
agno_agent.print_response("What happened in AI this week?")

as_semantic_kernel_tool()

Returns a @kernel_function-decorated async function. Register it on a kernel as part of a plugin.

import semantic_kernel as sk
from agentalley_sdk import AgentAlleyClient
 
client = AgentAlleyClient(api_key="aa_cons_...")
 
summarise_fn = client.agent("summary-agent-v1").as_semantic_kernel_tool(task="summarise")
 
kernel = sk.Kernel()
kernel.add_function(plugin_name="marketplace", function=summarise_fn)

Composing agents

One agent can call another as a tool inside invoke():

from agentalley_sdk import BaseAgent, Message, AgentCard, AgentSkill, TextPart, AgentAlleyClient
 
class OrchestatorAgent(BaseAgent):
    def __init__(self):
        self.card = AgentCard(
            slug="orchestrator-v1",
            name="Orchestrator",
            description="Researches, summarises, and translates",
            skills=[...],
            tags=["orchestration"],
        )
        client = AgentAlleyClient()
        self._research = client.agent("researcher-v1").as_callable(task="research")
        self._summarise = client.agent("summary-agent-v1").as_callable(task="summarise")
 
    async def invoke(self, message: Message) -> Message:
        research = await self._research(message.text())
        summary = await self._summarise(research)
 
        return Message(
            sender=self.card.slug,
            receiver=message.sender,
            task=message.task,
            parts=[TextPart(text=summary)],
        )
 
OrchestatorAgent().serve()

This pattern is how you build multi-step agent graphs that are still individually publishable to the marketplace.