Esc to close · ⌘K / Ctrl-K opens search anywhere
एक एजेंट बस एक chat-completions loop है जो tools बुलाता है। BharatRouter उस loop को एक अकेला, governed endpoint देता है — ताकि आपकी routing rules, India residency और per-key budgets हर कदम पर लागू हों जो एक autonomous एजेंट उठाता है, सिर्फ़ पहले पर नहीं। अंदर आने के दो रास्ते हैं।
| तरीक़ा | कब इस्तेमाल करें |
|---|---|
| एजेंट के model client को gateway पर लगाएँ | जब आप एजेंट code नियंत्रित करते हैं (LangChain, अपना loop, कोई SDK) — बस base URL बदलें। |
| MCP से जुड़ें | जब एजेंट host MCP बोलता है (Claude Code, Cursor, …) — कोई code बदलाव नहीं, बस server घोषित करें। |
standard OpenAI tools / tool_calls — एकमात्र बदलाव base URL है, साथ हीdata_policy पिन किया गया ताकि एजेंट बीच-loop में डेटा offshore लीक न कर सके।
import json
from openai import OpenAI
client = OpenAI(base_url="https://api.bharatrouter.com/v1", api_key="br-...")
tools = [{
"type": "function",
"function": {
"name": "get_pincode_city",
"description": "Return the city for an Indian PIN code",
"parameters": {
"type": "object",
"properties": {"pincode": {"type": "string"}},
"required": ["pincode"],
},
},
}]
def get_pincode_city(pincode): return {"560095": "Bengaluru"}.get(pincode, "Unknown")
messages = [{"role": "user", "content": "Which city is PIN 560095?"}]
while True:
r = client.chat.completions.create(
model="gemma-4-e4b-it",
messages=messages,
tools=tools,
extra_body={"data_policy": "india_only"}, # residency on every step
)
msg = r.choices[0].message
messages.append(msg)
if not msg.tool_calls:
print(msg.content)
break
for call in msg.tool_calls:
args = json.loads(call.function.arguments)
result = get_pincode_city(**args)
messages.append({
"role": "tool",
"tool_call_id": call.id,
"content": json.dumps(result),
})BharatRouter bearer auth के साथ streamable HTTP पर एक MCP server देता है, ताकि कोई MCP host बिना code के gateway को खोज और बुला सके। इसे Claude Code में जोड़ें:
claude mcp add --transport http bharatrouter \
https://api.bharatrouter.com/mcp \
--header "Authorization: Bearer br-..."या इसे project .mcp.json में घोषित करें:
{
"mcpServers": {
"bharatrouter": {
"type": "http",
"url": "https://api.bharatrouter.com/mcp",
"headers": { "Authorization": "Bearer br-..." }
}
}
}server को इसके card से programmatically खोजें:
curl -s https://api.bharatrouter.com/.well-known/mcp/server-card.jsonपूरा विवरण — exposed tools, auth, streaming — एजेंटों के लिए MCP पेज पर।
एक autonomous एजेंट दर्जनों कॉल कर सकता है जो आप कभी नहीं देखते। हर कॉल पर (या key के default के रूप में)data_policy: "india_only" पिन करें ताकि हर कदम India-resident routes पर रहे और leak के बजाय fail-closed हो। per-key monthly ₹ budget से खर्च सीमित करें ताकि कोई runaway loop credit न चूसे — देखें API keys और लिमिट।
रेसिपी: Claude Code को gateway से जोड़ें। इसके बजाय सामान्य app बना रहे हैं? Client SDKs देखें।