ai-supply.store
PublishSign in
← Community
Tutorials

Connect your framework: LangChain, CrewAI, and AutoGen

@ai-supply · 38m ago

Connect your framework: LangChain, CrewAI, and AutoGen

This guide shows how to expose the ai-supply REST API as an agent tool in the three most popular Python orchestration frameworks. The same requests-based functions underpin all three; only the registration wrapper differs.

Shared helper functions

Put these in a module your framework code imports:

import os
import requests

AIM_BASE = "https://ai-supply.store"
AIM_HEADERS = {
    "Authorization": f"Bearer {os.environ['AIM_API_KEY']}",
    "Content-Type": "application/json",
}

def search_ai_supply(query: str = "", kind: str = "", price: str = "free") -> dict:
    """Search the ai-supply marketplace catalog."""
    params = {k: v for k, v in {"q": query, "kind": kind, "price": price}.items() if v}
    resp = requests.get(f"{AIM_BASE}/api/v1/listings", headers=AIM_HEADERS, params=params)
    resp.raise_for_status()
    return resp.json()

def install_ai_supply(slug: str) -> dict:
    """Install a free listing by its slug."""
    resp = requests.post(f"{AIM_BASE}/api/v1/listings/{slug}/install", headers=AIM_HEADERS)
    resp.raise_for_status()
    return resp.json()

def download_ai_supply(slug: str) -> dict:
    """Get the download URL for an installed listing."""
    resp = requests.get(f"{AIM_BASE}/api/v1/listings/{slug}/download", headers=AIM_HEADERS)
    resp.raise_for_status()
    return resp.json()

LangChain

from langchain.tools import tool
from langchain_openai import ChatOpenAI
from langchain.agents import AgentExecutor, create_tool_calling_agent
from langchain_core.prompts import ChatPromptTemplate

@tool
def search_marketplace(query: str, kind: str = "MCP") -> str:
    """Search ai-supply.store for AI capabilities. Returns a JSON list of listings."""
    return str(search_ai_supply(query=query, kind=kind))

@tool
def install_capability(slug: str) -> str:
    """Install a capability from ai-supply.store by slug."""
    return str(install_ai_supply(slug))

llm = ChatOpenAI(model="gpt-4o")
prompt = ChatPromptTemplate.from_messages([
    ("system", "You are a helpful agent that can discover and install AI capabilities."),
    ("placeholder", "{chat_history}"),
    ("human", "{input}"),
    ("placeholder", "{agent_scratchpad}"),
])
agent = create_tool_calling_agent(llm, [search_marketplace, install_capability], prompt)
executor = AgentExecutor(agent=agent, tools=[search_marketplace, install_capability])

result = executor.invoke({"input": "Find a free MCP server for web search and install it."})
print(result["output"])

CrewAI

from crewai import Agent, Task, Crew
from crewai.tools import tool as crewai_tool

@crewai_tool("Search AI Supply Marketplace")
def crew_search(query: str) -> str:
    """Search ai-supply.store for free AI capabilities matching the query."""
    return str(search_ai_supply(query=query))

@crewai_tool("Install AI Supply Listing")
def crew_install(slug: str) -> str:
    """Install a capability from ai-supply.store given its slug."""
    return str(install_ai_supply(slug))

capability_scout = Agent(
    role="Capability Scout",
    goal="Find and install the best free AI capabilities for the team.",
    tools=[crew_search, crew_install],
    verbose=True,
)

task = Task(
    description="Search ai-supply.store for a free web-search MCP server and install the top result.",
    agent=capability_scout,
    expected_output="The slug and install confirmation of the chosen capability.",
)

Crew(agents=[capability_scout], tasks=[task]).kickoff()

AutoGen

import autogen

tools_config = [
    {
        "name": "search_ai_supply",
        "description": "Search ai-supply.store marketplace. Args: query (str), kind (str), price (str).",
        "function": search_ai_supply,
    },
    {
        "name": "install_ai_supply",
        "description": "Install a listing from ai-supply.store by slug.",
        "function": install_ai_supply,
    },
]

assistant = autogen.AssistantAgent(name="CapabilityAgent", llm_config={"model": "gpt-4o"})
user_proxy = autogen.UserProxyAgent(
    name="User",
    human_input_mode="NEVER",
    function_map={t["name"]: t["function"] for t in tools_config},
)

user_proxy.initiate_chat(
    assistant,
    message="Search ai-supply.store for a free MCP web-search tool, then install it.",
)

Tips

  • All frameworks share the same underlying HTTP calls — only the decorator/wrapper differs.
  • Set AIM_API_KEY in your environment before running any of the above.
  • For read-only discovery agents, mint a session with only the read scope (see API key guide).
  • Browse available capabilities at /agents.