Skip to main content

Agent Frameworks (LangChain, OpenAI Agents SDK & Google ADK)

Agentic frameworks can route both LLM inference (/v1 or /anthropic) and tool/agent protocols (MCP and A2A) through GoRoute AI Gateway.


1. LangChain (Python & TypeScript)​

Point ChatOpenAI or ChatAnthropic at GoRoute using your Virtual Key (sk-gw-...):

from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
model="reasoning",
base_url="http://localhost:8080/v1",
api_key="sk-gw-your-virtual-key",
)

resp = llm.invoke("Design a fallback chain for 503 outages.")
print(resp.content)

2. OpenAI Agents SDK​

The OpenAI Agents SDK works with GoRoute by passing a custom AsyncOpenAI client configured with base_url="http://localhost:8080/v1" and your Virtual Key:

from openai import AsyncOpenAI
from agents import Agent, Runner, set_default_openai_client

client = AsyncOpenAI(
base_url="http://localhost:8080/v1",
api_key="sk-gw-your-virtual-key",
)
set_default_openai_client(client)

agent = Agent(
name="TriageAgent",
model="gpt-4.1-mini",
instructions="Route infrastructure questions concisely.",
)

result = await Runner.run(agent, "How does GoRoute enforce SSRF protection?")
print(result.final_output)

3. Google ADK (Agent Development Kit)​

In Google ADK, you can either route model calls through GoRoute's OpenAI-compatible /v1 endpoint or expose/consume remote agents over GoRoute's A2A v1.0 plane:

  1. Model Routing via /v1: Set OPENAI_BASE_URL="http://localhost:8080/v1" and OPENAI_API_KEY="sk-gw-your-virtual-key" for OpenAI-compatible model wrappers, with Gemini models declared in GoRoute's model_list (e.g., gemini/gemini-2.5-flash).
  2. A2A Agent Discovery & Dispatch: GoRoute serves A2A agent cards at GET /.well-known/agent-card.json and task endpoints under /a2a/v1/agents/{agentSlug}/ (POST /, GET /tasks, GET /tasks/{taskID}, POST /tasks/{taskID}:cancel, GET|POST /tasks/{taskID}:subscribe). See A2A Agent Cards.

4. Connecting Frameworks to GoRoute MCP​

Any framework supporting Streamable HTTP MCP or REST tool calls can consume tools governed by GoRoute's MCP Virtual Hub:

ProtocolEndpointAuth HeaderGuide
MCP Virtual Hub (All Allowed Tools)POST http://localhost:8080/mcpAuthorization: Bearer sk-gw-...MCP Hub & REST
Scoped MCP ServerPOST http://localhost:8080/mcp/{serverSlug}Authorization: Bearer sk-gw-...MCP Overview
Curated MCP ToolsetPOST http://localhost:8080/mcp/toolsets/{toolsetSlug}Authorization: Bearer sk-gw-...Progressive Discovery
MCP REST BridgeGET /mcp-rest/tools/list, POST /mcp-rest/tools/callAuthorization: Bearer sk-gw-...MCP Hub & REST