AgentRouter: The Definitive Developer Guide AgentRouter, a non-profit OpenAI-compatible API gateway, aggregates over 30 AI models including Claude, GPT, Gemini, and DeepSeek behind a single endpoint, offering new users $200 in free credits via referral. The platform aims to lower barriers to AI experimentation for developers by providing a unified API key, pay-per-token pricing, and no subscription lock-in. TL;DRโ€” AgentRouter is a non-profit, OpenAI-compatible API gateway that aggregates Claude, GPT, Gemini, DeepSeek, and 30+ other models behind a single endpoint. New users get$200 in free creditsvia referral โ€” no credit card required. Ideal for developers who want model flexibility without juggling five subscriptions. ๐Ÿ‘‰ Claim Your $200 Free Credits โ†’ agentrouter.org/register?aff=DWBb https://agentrouter.org/register?aff=DWBb What Is AgentRouter? 1-what-is-agentrouter Free Credits Deep Dive: The $200 Offer Explained 2-free-credits-deep-dive-the-200-offer-explained Full Model Catalog & Pricing Tiers 3-full-model-catalog--pricing-tiers Architecture: How the Gateway Works 4-architecture-how-the-gateway-works Integration Guides 5-integration-guides - 5.1 Claude Code CLI 51-claude-code-cli - 5.2 Cursor AI 52-cursor-ai - 5.3 Continue.dev VS Code 53-continuedev-vs-code - 5.4 LangChain / LangGraph 54-langchain--langgraph - 5.5 LlamaIndex 55-llamaindex - 5.6 N8N Automation 56-n8n-automation - 5.7 Raw HTTP / cURL 57-raw-http--curl - 5.8 Python SDK 58-python-sdk - 5.9 Node.js / TypeScript SDK 59-nodejs--typescript-sdk - 5.1 Practical Use Cases with Code Examples 6-practical-use-cases-with-code-examples Competitive Landscape 7-competitive-landscape Cost Modeling & Credit Optimization 8-cost-modeling--credit-optimization Limitations, Risks & Mitigations 9-limitations-risks--mitigations Security & Privacy Considerations 10-security--privacy-considerations Community Feedback & Real Developer Experiences 11-community-feedback--real-developer-experiences Who Should and Should Not Use AgentRouter 12-who-should-and-should-not-use-agentrouter Step-by-Step Onboarding Walkthrough 13-step-by-step-onboarding-walkthrough Troubleshooting Reference 14-troubleshooting-reference Final Verdict 15-final-verdict AgentRouter is an OpenAI-compatible, unified LLM API gateway operated as a non-profit initiative. It consolidates access to dozens of commercial and open-source AI models โ€” from Anthropic's Claude family to OpenAI's GPT series to Google's Gemini โ€” behind a single base URL and a single API key. | Without AgentRouter | With AgentRouter | |---|---| | Separate API keys per provider | One API key, one endpoint | | Multiple billing dashboards | Single credit balance | | Subscription lock-in per provider | Pay-per-token, model-agnostic | | $40โ€“$100/month in subscriptions to access top models | $0 upfront with $200 free credit | | Code changes required to switch models | Change one string: the model name | Unlike commercial aggregators such as OpenRouter which charges a 5.5% platform fee on credit purchases or Together.ai which targets enterprise throughput , AgentRouter was built around a single premise: lower the barrier to AI experimentation for developers who don't have venture-backed budgets. The platform explicitly states it provides "assistance to developers within our capacity, offering free quotas to support AI Coding." This isn't a freemium funnel โ€” it's an infrastructure-layer gift to the developer community. AgentRouter operates a tiered credit allocation based on how you sign up: Standard sign-up โ†’ $100 free credits Referral sign-up โ†’ $200 free credits โœ… use link below Referring a friend โ†’ +$100 per successful referral ๐Ÿ‘‰ Sign Up via Referral โ†’ Get $200 Instead of $100 https://agentrouter.org/register?aff=DWBb GitHub account OAuth-based authentication โ€” no password needed No credit card required No trial period โ€” credits don't expire on a fixed countdown- Credits are deposited immediately upon account creation Based on developer reports across Reddit r/ClaudeCode, r/buildinpublic, r/MachineLearning and GitHub Gist reviews, here are approximate usage patterns for $200 in credits: | Activity | Estimated Credit Consumption | How Long $200 Lasts | |---|---|---| | Claude Sonnet 3.7 โ€” general coding assistant, 50 msgs/day | ~$1.80/day | ~111 days | | GPT-4o โ€” daily document drafting, 30 msgs/day | ~$0.60/day | ~333 days | | DeepSeek R1 โ€” data analysis pipelines, 200 req/day | ~$0.10/day | ~2,000 days | | Mixed model usage prototyping a SaaS | ~$3โ€“$8/day | 25โ€“65 days | | Batch embeddings job 1M tokens/day | ~$0.10โ€“$0.20/day | ~1,000โ€“2,000 days | Real data point:One developer on r/ClaudeCode reported 362 API requests consuming ~$20 in credits, leaving $279 remaining after combining the initial referral bonus with earned referral credits. Your mileage will vary based on model choice and context length. You sign up via referral โ†’ You receive $200 You refer 1 friend โ†’ You earn +$100 total: $300 You refer 2 friends โ†’ You earn +$200 total: $400 You refer 5 friends โ†’ You earn +$500 total: $700 For developers writing blog posts, building tutorials, or running developer communities, the referral system can effectively make AgentRouter free indefinitely. These models consume $0 from your credit balance and are suitable for high-volume, low-stakes tasks: | Model | Provider | Strengths | Context Window | |---|---|---|---| | GLM-4.5 Air | Z.ai | Fast inference, multilingual | 128K | | GLM-4.6 | Z.ai | Strong reasoning, low latency | 128K | | DeepSeek-V2 Lite | DeepSeek | Code generation, math | 32K | | Qwen2-7B-Instruct | Alibaba | Instruction following | 32K | | Mistral-7B-Instruct | Mistral AI | General purpose, fast | 32K | Best for: classification, routing decisions, background summarization, high-frequency tool calls. | Model | Input Cost | Output Cost | Best Use | |---|---|---|---| | Claude Haiku 3.5 | ~$0.25/1M | ~$1.25/1M | Tool routing, classification | | GPT-3.5 Turbo | ~$0.50/1M | ~$1.50/1M | Chat interfaces, legacy support | | Gemini 1.5 Flash | ~$0.075/1M | ~$0.30/1M | Document parsing, OCR post-processing | | DeepSeek Coder V2 Lite | ~$0.14/1M | ~$0.28/1M | Code completion, refactoring | Best for: production-grade code generation, agentic tasks, complex reasoning. | Model | Input Cost | Output Cost | Context Window | Best Use | |---|---|---|---|---| | Claude Sonnet 4.5 | ~$3/1M | ~$15/1M | 200K | Full agentic coding workflows | | Claude Sonnet 3.7 | ~$3/1M | ~$15/1M | 200K | Complex reasoning + tool use | | GPT-4o | ~$2.50/1M | ~$10/1M | 128K | Vision, structured outputs | | GPT-4o Mini | ~$0.15/1M | ~$0.60/1M | 128K | Cost-efficient GPT-4-class tasks | | Gemini 2.0 Pro | ~$3.50/1M | ~$10.50/1M | 1M | Long-document analysis | | Qwen3 Coder 480B | ~$2/1M | ~$6/1M | 64K | Specialized code generation | Best for: mission-critical generation, extremely long contexts, highest-capability needs. | Model | Input Cost | Output Cost | Context Window | Best Use | |---|---|---|---|---| | Claude Opus 4.5 | ~$15/1M | ~$75/1M | 200K | Deep research, long-form synthesis | | Claude Opus 4.0 | ~$15/1M | ~$75/1M | 200K | Complex multi-step reasoning | | GPT-5 | ~$10/1M | ~$30/1M | 128K | Frontier capability tasks | | Gemini 3 Pro | ~$7/1M | ~$21/1M | 2M | Ultra-long document processing | | DeepSeek R1 | ~$0.55/1M | ~$2.19/1M | 64K | Math, science, STEM reasoning | Cost-saving tip:DeepSeek R1 provides premium-tier reasoning math, science, coding logic at near-free pricing. For structured reasoning tasks that don't require Claude/GPT's conversational polish, R1 is an exceptional value. Understanding AgentRouter's architecture helps you reason about latency, reliability, and data flow. Your Application โ”‚ โ”‚ HTTPS, OpenAI-compatible JSON โ–ผ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ AgentRouter โ”‚ โ”‚ API Gateway Layer โ”‚ โ”‚ โ”‚ โ”‚ โ€ข Auth & key routing โ”‚ โ”‚ โ€ข Model name mapping โ”‚ โ”‚ โ€ข Credit accounting โ”‚ โ”‚ โ€ข Request queuing โ”‚ โ”‚ โ€ข Response passthrough โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ” โ–ผ โ–ผ โ–ผ Anthropic OpenAI Google ...and more Claude GPT Gemini OpenAI-Compatible REST API AgentRouter exposes the /v1/chat/completions endpoint with the same request/response schema as OpenAI. Any library or tool that supports openai.base url configuration will work out of the box. Thin Proxy, Not a Fine-Tune Host AgentRouter does not host or modify model weights. It routes requests to upstream providers. This means: - Response quality is identical to using the provider directly - New model versions appear as soon as providers release them - Prompt/response content is handled as-is see Section 10 for privacy notes Singapore-Based Infrastructure AgentRouter's primary infrastructure appears to be hosted in Singapore. This adds: - ~80โ€“150ms additional latency for US East Coast users - ~20โ€“60ms additional latency for Southeast Asian users - Negligible impact for batch/async workloads Prerequisites:Create your account and generate an API key before starting any integration. - Registration: agentrouter.org/register?aff=DWBb - Token console: agentrouter.org/console/token - Base URL: https://agentrouter.org/v1 Claude Code is Anthropic's official command-line agentic coding tool. It reads your entire codebase, edits files, runs terminal commands, and leverages Claude's reasoning โ€” all via AgentRouter. Installation: npm install -g @anthropic-ai/claude-code Configuration macOS / Linux : Add to ~/.bashrc, ~/.zshrc, or ~/.profile export ANTHROPIC BASE URL="https://agentrouter.org/" export ANTHROPIC AUTH TOKEN="sk-your-agentrouter-key-here" export ANTHROPIC API KEY="sk-your-agentrouter-key-here" Configuration Windows PowerShell : $env:ANTHROPIC BASE URL = "https://agentrouter.org/" $env:ANTHROPIC AUTH TOKEN = "sk-your-agentrouter-key-here" $env:ANTHROPIC API KEY = "sk-your-agentrouter-key-here" Launch: source ~/.zshrc Reload env vars claude Start Claude Code Verify it's working: Inside Claude Code, try: What files are in this directory? Claude should list your project files, confirming it's reading the codebase Recommended model for Claude Code via AgentRouter: claude-sonnet-4-5-20250929 Best balance of speed + reasoning claude-opus-4-5-20250929 For complex architectural tasks claude-haiku-3-5-20241022 For quick edits, low credit consumption Cursor is a VS Code fork with deep AI integration. Configuring it with AgentRouter unlocks any model in the catalog โ€” not just the models Cursor bundles. Step 1: Open Cursor โ†’ Settings โŒ˜+Shift+J or Ctrl+Shift+J โ†’ Models Step 2: Click + Add Model and select OpenAI Compatible Step 3: Fill in: Provider Name: AgentRouter Base URL: https://agentrouter.org/v1 API Key: sk-your-agentrouter-key-here Model Name: claude-sonnet-4-5-20250929 Step 4: Click Verify โ€” Cursor will ping the endpoint with a test request. Step 5: Select your AgentRouter model from the model picker in the Cursor chat panel. Pro tip: Add multiple model entries one for Claude Sonnet, one for GPT-4o, one for DeepSeek R1 so you can switch mid-session without re-entering credentials. Continue is an open-source AI coding assistant for VS Code and JetBrains IDEs. Install the Continue extension , then edit ~/.continue/config.json : { "models": { "title": "Claude Sonnet AgentRouter ", "provider": "openai", "model": "claude-sonnet-4-5-20250929", "apiBase": "https://agentrouter.org/v1", "apiKey": "sk-your-agentrouter-key-here" }, { "title": "DeepSeek R1 Free via AgentRouter ", "provider": "openai", "model": "deepseek-r1", "apiBase": "https://agentrouter.org/v1", "apiKey": "sk-your-agentrouter-key-here" } , "tabAutocompleteModel": { "title": "GLM-4.5 Air Free Autocomplete ", "provider": "openai", "model": "glm-4.5-air", "apiBase": "https://agentrouter.org/v1", "apiKey": "sk-your-agentrouter-key-here" } } Note:Using a free model for tab autocomplete glm-4.5-air keeps your credit burn to near-zero for inline suggestions, while reserving premium models for chat and complex edits. LangChain's ChatOpenAI class accepts a custom base url , making AgentRouter a drop-in replacement. Python: python from langchain openai import ChatOpenAI from langchain core.messages import HumanMessage, SystemMessage Swap in AgentRouter with zero code changes to your chain logic llm = ChatOpenAI model="claude-sonnet-4-5-20250929", openai api key="sk-your-agentrouter-key-here", openai api base="https://agentrouter.org/v1", temperature=0.7, max tokens=2048, Use it exactly like any other LangChain LLM response = llm.invoke SystemMessage content="You are a senior Python engineer." , HumanMessage content="Refactor this code to use async/await: paste code " print response.content LangGraph multi-agent example: python from langchain openai import ChatOpenAI from langgraph.graph import StateGraph, END from typing import TypedDict Define different models for different agents in the same graph planner llm = ChatOpenAI model="claude-opus-4-5-20250929", High-capability for planning openai api key="sk-your-agentrouter-key-here", openai api base="https://agentrouter.org/v1", executor llm = ChatOpenAI model="claude-sonnet-4-5-20250929", Balanced for execution openai api key="sk-your-agentrouter-key-here", openai api base="https://agentrouter.org/v1", reviewer llm = ChatOpenAI model="deepseek-r1", Free model for review openai api key="sk-your-agentrouter-key-here", openai api base="https://agentrouter.org/v1", class AgentState TypedDict : task: str plan: str result: str review: str def plan node state: AgentState : response = planner llm.invoke f"Create a step-by-step plan for: {state 'task' }" return {"plan": response.content} def execute node state: AgentState : response = executor llm.invoke f"Execute this plan:\n{state 'plan' }" return {"result": response.content} def review node state: AgentState : response = reviewer llm.invoke f"Review this output for correctness:\n{state 'result' }" return {"review": response.content} Build the graph graph = StateGraph AgentState graph.add node "plan", plan node graph.add node "execute", execute node graph.add node "review", review node graph.set entry point "plan" graph.add edge "plan", "execute" graph.add edge "execute", "review" graph.add edge "review", END app = graph.compile result = app.invoke {"task": "Write a FastAPI CRUD service for a blog"} python from llama index.llms.openai import OpenAI from llama index.core import Settings, VectorStoreIndex, SimpleDirectoryReader Configure AgentRouter as the LLM backend Settings.llm = OpenAI model="gpt-4o", api key="sk-your-agentrouter-key-here", api base="https://agentrouter.org/v1", Build a RAG pipeline over local documents documents = SimpleDirectoryReader "./docs" .load data index = VectorStoreIndex.from documents documents query engine = index.as query engine response = query engine.query "What are the key findings in the Q3 report?" print response N8N's HTTP Request node can call AgentRouter directly, enabling LLM-powered automation without code. Node configuration: Method: POST URL: https://agentrouter.org/v1/chat/completions Authentication: Header Auth Header Name: Authorization Header Value: Bearer sk-your-agentrouter-key-here Body JSON : { "model": "claude-sonnet-4-5-20250929", "messages": { "role": "system", "content": "You are an email classifier. Respond with JSON only." }, { "role": "user", "content": "Classify this email: {{ $json.email body }}" } , "response format": { "type": "json object" } } Example use cases in N8N: - Classify incoming support emails โ†’ route to Slack channels - Summarize Google Sheets rows โ†’ send digest to email - Parse unstructured form submissions โ†’ write to Airtable - Generate weekly reports from Notion databases โ†’ post to Confluence Use this to test your API key and verify connectivity before integrating into a framework. curl https://agentrouter.org/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer sk-your-agentrouter-key-here" \ -d '{ "model": "claude-sonnet-4-5-20250929", "messages": { "role": "user", "content": "Say hello and tell me your model name." } , "max tokens": 100 }' Expected response shape: { "id": "chatcmpl-abc123", "object": "chat.completion", "model": "claude-sonnet-4-5-20250929", "choices": { "index": 0, "message": { "role": "assistant", "content": "Hello I'm Claude Sonnet, routing through AgentRouter." }, "finish reason": "stop" } , "usage": { "prompt tokens": 14, "completion tokens": 17, "total tokens": 31 } } Streaming response: curl https://agentrouter.org/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer sk-your-agentrouter-key-here" \ -d '{ "model": "gpt-4o", "stream": true, "messages": {"role": "user", "content": "Write a haiku about APIs."} }' Using the official openai Python package with AgentRouter requires only changing two parameters: python from openai import OpenAI client = OpenAI api key="sk-your-agentrouter-key-here", base url="https://agentrouter.org/v1", โ”€โ”€ Basic chat completion โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ response = client.chat.completions.create model="claude-sonnet-4-5-20250929", messages= {"role": "system", "content": "You are an expert software architect."}, {"role": "user", "content": "Design a microservice architecture for an e-commerce platform."} , temperature=0.5, max tokens=2000, print response.choices 0 .message.content โ”€โ”€ Streaming โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ with client.chat.completions.stream model="gpt-4o", messages= {"role": "user", "content": "Explain WebSockets in 3 paragraphs."} , as stream: for chunk in stream: if chunk.choices 0 .delta.content: print chunk.choices 0 .delta.content, end="", flush=True โ”€โ”€ Structured output JSON mode โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ import json response = client.chat.completions.create model="gpt-4o", response format={"type": "json object"}, messages= {"role": "system", "content": "Return only valid JSON."}, {"role": "user", "content": "Give me a JSON object with 3 Python library recommendations and their use cases."} , data = json.loads response.choices 0 .message.content print data โ”€โ”€ Model comparison helper โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ def compare models prompt: str, models: list str - dict: results = {} for model in models: resp = client.chat.completions.create model=model, messages= {"role": "user", "content": prompt} , max tokens=500, results model = { "response": resp.choices 0 .message.content, "tokens": resp.usage.total tokens, } return results Compare Claude vs GPT-4o on the same prompt comparison = compare models prompt="What is the time complexity of a balanced BST lookup?", models= "claude-sonnet-4-5-20250929", "gpt-4o", "deepseek-r1" for model, data in comparison.items : print f"\n--- {model} {data 'tokens' } tokens ---" print data "response" python import OpenAI from "openai"; const client = new OpenAI { apiKey: process.env.AGENTROUTER API KEY , baseURL: "https://agentrouter.org/v1", } ; // โ”€โ”€ Basic completion โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ async function complete prompt: string, model = "claude-sonnet-4-5-20250929" { const response = await client.chat.completions.create { model, messages: { role: "user", content: prompt } , max tokens: 1000, } ; return response.choices 0 .message.content; } // โ”€โ”€ Streaming to the browser Next.js App Router โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ // app/api/chat/route.ts export async function POST req: Request { const { message } = await req.json ; const stream = await client.chat.completions.create { model: "gpt-4o", stream: true, messages: { role: "user", content: message } , } ; const encoder = new TextEncoder ; const readable = new ReadableStream { async start controller { for await const chunk of stream { const text = chunk.choices 0 ?.delta?.content ?? ""; if text controller.enqueue encoder.encode text ; } controller.close ; }, } ; return new Response readable, { headers: { "Content-Type": "text/plain; charset=utf-8" }, } ; } // โ”€โ”€ Tool calling function calling โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ const weatherTool: OpenAI.ChatCompletionTool = { type: "function", function: { name: "get weather", description: "Fetches current weather for a given city", parameters: { type: "object", properties: { city: { type: "string", description: "The city name" }, unit: { type: "string", enum: "celsius", "fahrenheit" }, }, required: "city" , }, }, }; async function agentWithTools userMessage: string { const messages: OpenAI.ChatCompletionMessageParam = { role: "user", content: userMessage }, ; const response = await client.chat.completions.create { model: "claude-sonnet-4-5-20250929", tools: weatherTool , tool choice: "auto", messages, } ; const choice = response.choices 0 ; if choice.finish reason === "tool calls" { const toolCall = choice.message.tool calls 0 ; const args = JSON.parse toolCall.function.arguments ; console.log Tool called: ${toolCall.function.name} , args ; // โ†’ Execute actual weather API call here } } python import subprocess from openai import OpenAI client = OpenAI api key="sk-your-agentrouter-key-here", base url="https://agentrouter.org/v1", def get git diff - str: result = subprocess.run "git", "diff", "--cached" , capture output=True, text=True return result.stdout def review code diff: str - str: response = client.chat.completions.create model="claude-sonnet-4-5-20250929", Strong reasoning model messages= { "role": "system", "content": "You are a senior software engineer performing a code review. " "Focus on: bugs, security issues, performance, readability, and test coverage. " "Format your response as: CRITICAL / MAJOR / MINOR / SUGGESTION sections." , }, { "role": "user", "content": f"Review this git diff:\n\n diff\n{diff}\n ", }, , max tokens=2000, return response.choices 0 .message.content if name == " main ": diff = get git diff if not diff: print "No staged changes to review." else: print review code diff python from openai import OpenAI import time, json client = OpenAI api key="sk-your-agentrouter-key-here", base url="https://agentrouter.org/v1", BENCHMARK PROMPTS = "Implement a binary search tree in Python with insert, delete, and search.", "Explain the CAP theorem to a junior developer.", "Write a regex to validate ISO 8601 datetime strings.", "What is the difference between mutex and semaphore?", MODELS = "claude-sonnet-4-5-20250929", "gpt-4o", "gemini-2-0-pro", "deepseek-r1", def benchmark : results = for prompt in BENCHMARK PROMPTS: prompt results = {"prompt": prompt :60 + "...", "models": {}} for model in MODELS: start = time.time try: resp = client.chat.completions.create model=model, messages= {"role": "user", "content": prompt} , max tokens=800, latency = round time.time - start, 2 prompt results "models" model = { "latency s": latency, "tokens": resp.usage.total tokens, "preview": resp.choices 0 .message.content :100 , } except Exception as e: prompt results "models" model = {"error": str e } results.append prompt results with open "benchmark results.json", "w" as f: json.dump results, f, indent=2 print "Benchmark complete. Results saved to benchmark results.json" benchmark python from openai import OpenAI from pathlib import Path client = OpenAI api key="sk-your-agentrouter-key-here", base url="https://agentrouter.org/v1", def process document file path: str - dict: text = Path file path .read text Step 1: Classify the document cheap model classification = client.chat.completions.create model="glm-4.5-air", Free model for cheap classification messages= {"role": "system", "content": "Classify the document type in one word: contract, report, email, invoice, or other."}, {"role": "user", "content": text :2000 }, , max tokens=10, .choices 0 .message.content.strip .lower Step 2: Extract entities mid-tier model entities = client.chat.completions.create model="gpt-4o-mini", response format={"type": "json object"}, messages= {"role": "system", "content": "Extract key entities as JSON: {parties, dates, amounts, obligations}"}, {"role": "user", "content": text :4000 }, , max tokens=500, .choices 0 .message.content Step 3: Deep analysis premium model, only if contract analysis = None if classification == "contract": analysis = client.chat.completions.create model="claude-opus-4-5-20250929", Premium model for critical legal docs messages= {"role": "system", "content": "You are a legal analyst. Identify risks, obligations, and red flags."}, {"role": "user", "content": text}, , max tokens=3000, .choices 0 .message.content return { "document type": classification, "entities": entities, "legal analysis": analysis, } | Feature | AgentRouter | OpenRouter | |---|---|---| | Model count | ~30โ€“50 models | 400+ models | | Platform fee | 0% non-profit | 5.5% on credits | | Free credit offer | $200 via referral | $1 trial credit | | Enterprise features | None | Routing, fallbacks, A/B testing | | Uptime SLA | None published | 99.9% SLA available | | Best for | Students, indie hackers, prototyping | Production apps, enterprise teams | | Factor | AgentRouter | Direct OpenAI/Anthropic/Google | |---|---|---| | API keys needed | 1 | 1 per provider 3+ | | Latency overhead | +80โ€“150ms Singapore | Baseline regional | | Code to switch models | Change model string only | Change base URL + SDK | | Billing | Single balance | Separate invoices | | Support | Community / email | Tier-based enterprise support | | Privacy | Third-party proxy | Direct with provider | | Cost | Provider pricing | Provider pricing | | Factor | AgentRouter API | Claude Pro $20/mo | ChatGPT Plus $20/mo | |---|---|---|---| | Provider access | All providers | Anthropic only | OpenAI only | | Programmatic access | Yes API | Limited Projects API | Limited | | Cost model | Pay-per-token | Flat monthly | Flat monthly | | Usage limits | Credit-based | Rate limited | Rate limited | | Web UI included | No | Yes | Yes | | Ideal user | Developer | Power user non-dev | Power user non-dev | Verdict: If you're a developer who writes code, AgentRouter almost always wins on economics and flexibility. If you're a non-developer who wants a chat interface, direct subscriptions are simpler. Professional teams and experienced indie developers use a tiered approach to model selection that can reduce costs by 60โ€“90% versus always using premium models: Tier 1 โ†’ Routing / Classification / Triage Use: GLM-4.5 Air, DeepSeek-V2 Lite free When: "Is this question about billing or technical support?" Tier 2 โ†’ Execution / Generation / Standard tasks Use: Claude Haiku, GPT-4o Mini, Gemini Flash When: "Write a 3-sentence summary of this article." Tier 3 โ†’ Complex Reasoning / Critical Paths Use: Claude Sonnet, GPT-4o, DeepSeek R1 When: "Architect this distributed system and identify failure modes." Tier 4 โ†’ Mission-Critical / Long Context Use: Claude Opus, GPT-5, Gemini 3 Pro When: "Analyze this 150-page contract for legal risks." Rough credit cost estimator TOKEN COSTS = { "glm-4.5-air": {"input": 0.0, "output": 0.0}, "claude-haiku-3-5-20241022": {"input": 0.00025, "output": 0.00125}, "gpt-4o-mini": {"input": 0.00015, "output": 0.0006}, "claude-sonnet-4-5-20250929": {"input": 0.003, "output": 0.015}, "gpt-4o": {"input": 0.0025, "output": 0.01}, "claude-opus-4-5-20250929": {"input": 0.015, "output": 0.075}, } def estimate cost model: str, input tokens: int, output tokens: int - float: costs = TOKEN COSTS.get model, {"input": 0.005, "output": 0.015} return input tokens / 1000 costs "input" + output tokens / 1000 costs "output" Example: 1,000 requests with avg 500 input + 300 output tokens for model, in TOKEN COSTS.items : daily cost = estimate cost model, 500, 300 1000 days on 200 = round 200 / daily cost, 1 if daily cost 0 else float "inf" print f"{model:45s} โ†’ ${daily cost:.2f}/day โ†’ ${200} lasts {days on 200} days" - Cache repeated prompts. If your app hits the same system prompt + static context repeatedly, cache the response and only re-call the API when the user input changes. - Use streaming for UX, not for tokens. Streaming doesn't reduce token count โ€” use it for perceived responsiveness, not cost savings. - Trim context aggressively. Claude and GPT charge for input tokens. If your conversation history grows, summarize older turns rather than passing the full history. - Route simple queries to free models. A 3-way classifier Is this: simple FAQ / moderate / complex? using GLM-4.5 Air costs $0 and lets you avoid spending $0.018 per Sonnet call on questions like "What's your return policy?" - Set Without a ceiling, models may generate verbose responses. Setting max tokens explicitly. max tokens: 400 for short answers can halve your output token spend. | Scenario | Typical Overhead | Impact | Mitigation | |---|---|---|---| | Singapore โ†’ US East | +120โ€“180ms per call | Interactive chat: noticeable | Use streaming to mask latency | | Singapore โ†’ EU | +100โ€“140ms per call | Moderate | Stream responses; async UX | | Singapore โ†’ SEA/APAC | +10โ€“50ms per call | Negligible | None needed | | Batch processing | Irrelevant | None | Use async batch jobs | AgentRouter is a non-profit service with no published SLA. This means: - No contractual uptime guarantee - Community/email support only - No incident response commitments Mitigation pattern: python import httpx from openai import OpenAI, APIConnectionError def create client with fallback : """Returns AgentRouter client with fallback to direct Anthropic.""" return { "primary": OpenAI api key="sk-agentrouter-key", base url="https://agentrouter.org/v1" , "fallback": OpenAI api key="sk-anthropic-direct-key", base url="https://api.anthropic.com/v1" , } def robust complete prompt: str, clients: dict - str: for client name, client in clients.items : try: resp = client.chat.completions.create model="claude-sonnet-4-5-20250929", messages= {"role": "user", "content": prompt} , timeout=30.0, return resp.choices 0 .message.content except APIConnectionError, Exception as e: print f" {client name} failed: {e}. Trying next..." raise RuntimeError "All providers failed." AgentRouter's docs cover the essentials but lack: - Video walkthroughs - Advanced configuration guides - Per-model quirks and known issues - Detailed troubleshooting decision trees Mitigation: This document, community threads on r/ClaudeCode and r/LocalLLaMA, and AgentRouter's GitHub issues serve as supplementary documentation. The platform's funding model is not publicly disclosed. Long-term sustainability questions are legitimate. Risk level by use case: Experimentation / learning โ†’ Low risk credits already claimed Side project / prototype โ†’ Low risk not mission-critical Production secondary traffic โ†’ Medium have backup provider Primary production system โ†’ High risk use direct APIs instead As an API proxy, AgentRouter processes every request before forwarding it to the underlying provider. This means: Prompts and system messages pass through AgentRouter's infrastructure Response content is routed back through AgentRouter API key for AgentRouter not your provider keys is transmitted per request - PII governed by GDPR, HIPAA, or CCPA patient records, SSNs, financial account data - Trade secrets or proprietary source code in regulated industries - Authentication credentials passwords, private keys, OAuth tokens - Classified or government-sensitive information - Public documentation, articles, or research - Open-source code - Non-PII product descriptions, marketing copy - General programming questions and coding tasks - Non-sensitive business logic in prototyping contexts Never hardcode API keys โ€” use environment variables export AGENTROUTER API KEY="sk-..." Add to .gitignore echo ".env" .gitignore echo " .env" .gitignore Use a secrets manager in production AWS Secrets Manager / HashiCorp Vault / Doppler python Load from environment, never from code import os api key = os.environ "AGENTROUTER API KEY" Will raise if not set โ€” intentional "It actually works" โ€” The most common first reaction. The credits appear, the API responds, the models are real. "cuz it works, i have used and if i invite someone i get $100 free of charge"โ€” Reddit, r/ClaudeCode Model breadth at zero cost : "That extra credit works across GPT-4, Claude, LLaMA, and other models, so it's pretty handy if you're experimenting or building AI projects."โ€” Reddit, r/buildinpublic Pragmatic endorsement from a careful reviewer: "AgentRouter won't replace a proper Anthropic or OpenAI subscription for serious production work. But for developers who want to tinker, prototype, or learn, it removes the cost barrier completely."โ€” GitHub Gist, "AgentRouter Review 2026" Latency concerns โ€” Users on US-based infrastructure report 100โ€“200ms additional latency versus direct APIs. Universally noted as a non-issue for non-interactive use cases. Documentation gaps โ€” The platform's official docs are functional but terse. Advanced configuration streaming, function calling, vision inputs requires trial-and-error or community guidance. "Is this legit?" skepticism โ€” Multiple users noted initial distrust of a Singapore-based provider offering $200 free credits. Post-verification, the sentiment converged on "it is what it says it is." | Profile | Why AgentRouter Works | |---|---| Students & Learners | $200 gives virtually unlimited experimentation time without financial risk | Solo developers / indie hackers | Defers infrastructure costs until product-market fit is found | Researchers & academics | Single API for cross-model comparison studies; unified billing for grants | Agency / freelance developers | Pay-per-use aligns with unpredictable client project volumes | Hackathon participants | Credits last well beyond a weekend, free models available for high-volume tasks | Educators building curriculum | Easy to teach one API structure instead of three provider SDKs | | Profile | Better Alternative | |---|---| Production systems requiring SLA | Direct provider APIs with uptime contracts | HIPAA / GDPR / regulated data | Direct APIs with DPA agreements signed | Ultra-low latency <50ms requirements | Direct regional provider endpoints | Enterprise teams needing support contracts | OpenRouter Enterprise or direct provider support | Companies requiring audit logs | Direct APIs with your own logging infrastructure | Navigate to the referral link to ensure you receive $200 instead of the standard $100: ๐Ÿ‘‰ agentrouter.org/register?aff=DWBb https://agentrouter.org/register?aff=DWBb Click "Sign in with GitHub" โ†’ Authorize the OAuth app โ†’ Account created. In the AgentRouter console, confirm your balance shows $200.00 before proceeding. If you see $100.00 , you may have signed up without the referral link โ€” contact support. Visit: https://agentrouter.org/console/token Click "Generate New Token" โ†’ Copy the key immediately it will not be shown again . Store it securely: macOS Keychain security add-generic-password -a "$USER" -s "agentrouter" -w "sk-your-key-here" Or in a .env file never commit to git echo 'AGENTROUTER API KEY=sk-your-key-here' .env curl https://agentrouter.org/v1/chat/completions \ -H "Authorization: Bearer sk-your-key-here" \ -H "Content-Type: application/json" \ -d '{"model":"glm-4.5-air","messages": {"role":"user","content":"ping"} ,"max tokens":5}' A successful response confirms your key works and the free GLM model is reachable. Refer to Section 5 for detailed guides. Recommended starting path by profile: Writing code in a terminal? โ†’ Section 5.1 Claude Code Using VS Code daily? โ†’ Section 5.3 Continue.dev Building a Python app? โ†’ Section 5.8 Python SDK Building a Node.js app? โ†’ Section 5.9 Node.js SDK Building automations? โ†’ Section 5.6 N8N Exploring AI frameworks? โ†’ Section 5.4 LangChain Phase 1: Validate your integration works โ€” zero cost model = "glm-4.5-air" Phase 2: Test quality โ€” small spend model = "gpt-4o-mini" Phase 3: Production-quality output model = "claude-sonnet-4-5-20250929" Check your credit balance and usage breakdown in the AgentRouter console regularly. Identify your top token consumers and apply Section 8's optimization tips if needed. Once you've confirmed the platform works for your needs, retrieve your personal referral link from the console. Sharing it with each colleague, student, or community member adds $100 to your balance. | Problem | Likely Cause | Solution | |---|---|---| 401 Unauthorized | Wrong API key or missing Bearer prefix | Verify key at console; ensure header is Authorization: Bearer sk-... | 404 Not Found | Wrong base URL | Use https://agentrouter.org/v1 with /v1 | model not found error | Incorrect model identifier string | Check AgentRouter docs for exact model ID; try gpt-4o or claude-sonnet-4-5-20250929 | Credits showing $0 | Standard signup used instead of referral | Contact support with account email | | Latency 500ms | Peak traffic on AgentRouter servers | Retry with exponential backoff; switch to free model temporarily | | Streaming not working | Missing stream: true in request body | Add "stream": true to request JSON | claude-code ignoring env vars | Shell not reloaded after export | Run source ~/.zshrc or restart terminal | Connection reset by peer | Timeout on long-running requests | Increase timeout parameter; break request into smaller chunks | AgentRouter occupies a unique position in the AI infrastructure stack. It's not trying to compete with OpenRouter's enterprise feature set or replace direct provider APIs for mission-critical production systems. It's doing something more specific and arguably more valuable: removing the cost of entry for developers who want to experiment. The $200 free credits matter less than the psychological shift they enable. The difference between "I can't afford to run 500 test API calls this week" and "I have $200 to burn through experimenting" is the difference between a project idea staying in a Notion doc versus becoming a deployed application. For learners, that shift is how skills are built. For indie developers, it's how MVPs get validated. For researchers, it's how hypotheses get tested. For educators, it's how curriculum gets built without grant-budget anxiety. | Dimension | Score | Notes | |---|---|---| | Value for money | โ˜…โ˜…โ˜…โ˜…โ˜… | $200 free credits with no friction | | Model breadth | โ˜…โ˜…โ˜…โ˜…โ˜† | ~30โ€“50 models; not as deep as OpenRouter's 400+ | | API compatibility | โ˜…โ˜…โ˜…โ˜…โ˜… | Drop-in OpenAI replacement; works with every major framework | | Documentation | โ˜…โ˜…โ˜…โ˜†โ˜† | Functional but terse; this guide fills the gap | | Latency | โ˜…โ˜…โ˜…โ˜†โ˜† | ~100โ€“150ms overhead from Singapore; fine for most use cases | | Reliability | โ˜…โ˜…โ˜…โ˜†โ˜† | No SLA; community support; stable for months per user reports | | Privacy transparency | โ˜…โ˜…โ˜†โ˜†โ˜† | No published data retention policy; use with non-sensitive data only | | Production readiness | โ˜…โ˜…โ˜†โ˜†โ˜† | Not recommended as sole provider for critical systems | Given that it costs nothing to try and $200 to explore every major AI model on the market โ€” what have you been putting off building because the API costs felt prohibitive? Start there. ๐Ÿ‘‰ Claim $200 in Free Credits at AgentRouter โ†’ agentrouter.org/register?aff=DWBb https://agentrouter.org/register?aff=DWBb Last updated: April 2026 ยท Model pricing and availability subject to change โ€” verify current rates in the AgentRouter console.