Skip to main content

Overview

CrewAI can interact with Kovrex in two ways:
  1. CrewAI as an A2A server — you run crew.serve(...) and Kovrex can proxy calls to your agent.
  2. CrewAI as an A2A client — your CrewAI agent delegates work to a Kovrex marketplace agent through the gateway.

CrewAI as an A2A server

pip install 'crewai[a2a]'
from crewai import Agent, Crew, Task
from crewai.a2a import A2AServerConfig

analyst = Agent(
    role="News Analyst",
    goal="Assess whether news is material to a company",
    backstory="Expert at filtering signal from noise in financial news",
    llm="gpt-4o",
    a2a=A2AServerConfig(
        url="https://your-server.com",
        port=8000,
    ),
)

task = Task(
    description="Analyze the given news item for the specified company",
    expected_output="Salience assessment with rationale",
    agent=analyst,
)

crew = Crew(agents=[analyst], tasks=[task])

if __name__ == "__main__":
    crew.serve(port=8000)
Your agent card is available at:
https://your-server.com/.well-known/agent.json

CrewAI as an A2A client (call a Kovrex marketplace agent)

If you want CrewAI to delegate a task to a Kovrex marketplace agent through the gateway, use CrewAI’s A2A client utilities. Endpoint format
  • https://gateway.kovrex.ai/a2a/{your-agent-slug}
Auth Send your Kovrex API key as an X-API-Key header.
pip install 'crewai[a2a]' python-dotenv
import os
from dotenv import load_dotenv

from crewai.a2a.auth.client_schemes import APIKeyAuth
from crewai.a2a.utils.delegation import execute_a2a_delegation

load_dotenv()

endpoint = os.environ["KOVREX_AGENT_URL"]  # e.g. https://gateway.kovrex.ai/a2a/your-agent-slug
api_key = os.environ["KOVREX_API_KEY"]

result = execute_a2a_delegation(
    endpoint=endpoint,
    auth=APIKeyAuth(api_key=api_key, name="X-API-Key", location="header"),
    timeout=120,
    task_description="Analyze the given news item for Microsoft and return salience score + rationale",
)

print(result.status.state)
print(result.output)

Response shape note

CrewAI uses a2a-sdk under the hood. Per the A2A spec, message/send success responses are:
  • result: Task | Message
Kovrex’s gateway returns a spec-compliant Task result.

Runnable example

See the runnable script in our examples repo: