{"skill":{"slug":"asia-llm-router-skills","displayName":"One API key. 70+ models. Route requests to GPT, Claude, Gemini, Qwen, Deepseek, Grok and more.","summary":"Unified LLM Gateway - One API for 70+ AI models. Route to GPT, Claude, Gemini, Qwen, Deepseek, Grok and more with a single API key.","description":"---\nname: llm-router\ndescription: \"Unified LLM Gateway - One API for 70+ AI models. Route to GPT, Claude, Gemini, Qwen, Deepseek, Grok and more with a single API key.\"\nhomepage: https://openclaw.ai\nmetadata: {\"openclaw\":{\"emoji\":\"🧠\",\"requires\":{\"bins\":[\"curl\",\"python3\"],\"env\":[\"AISA_API_KEY\"]},\"primaryEnv\":\"AISA_API_KEY\"}}\n---\n\n# OpenClaw LLM Router 🧠\n\n**Unified LLM Gateway for autonomous agents. Powered by AIsa.**\n\nOne API key. 70+ models. OpenAI-compatible.\n\nReplace 100+ API keys with one. Access GPT-4, Claude-3, Gemini, Qwen, Deepseek, Grok, and more through a unified, OpenAI-compatible API.\n\n## 🔥 What Can You Do?\n\n### Multi-Model Chat\n```\n\"Chat with GPT-4 for reasoning, switch to Claude for creative writing\"\n```\n\n### Model Comparison\n```\n\"Compare responses from GPT-4, Claude, and Gemini for the same question\"\n```\n\n### Vision Analysis\n```\n\"Analyze this image with GPT-4o - what objects are in it?\"\n```\n\n### Cost Optimization\n```\n\"Route simple queries to fast/cheap models, complex queries to GPT-4\"\n```\n\n### Fallback Strategy\n```\n\"If GPT-4 fails, automatically try Claude, then Gemini\"\n```\n\n## Why LLM Router?\n\n| Feature | LLM Router | Direct APIs |\n|---------|------------|-------------|\n| API Keys | 1 | 10+ |\n| SDK Compatibility | OpenAI SDK | Multiple SDKs |\n| Billing | Unified | Per-provider |\n| Model Switching | Change string | Code rewrite |\n| Fallback Routing | Built-in | DIY |\n| Cost Tracking | Unified | Fragmented |\n\n## Supported Model Families\n\n| Family | Developer | Example Models |\n|--------|-----------|----------------|\n| GPT | OpenAI | gpt-4.1, gpt-4o, gpt-4o-mini, o1, o1-mini, o3-mini |\n| Claude | Anthropic | claude-3-5-sonnet, claude-3-opus, claude-3-sonnet |\n| Gemini | Google | gemini-2.0-flash, gemini-1.5-pro, gemini-1.5-flash |\n| Qwen | Alibaba | qwen-max, qwen-plus, qwen2.5-72b-instruct |\n| Deepseek | Deepseek | deepseek-chat, deepseek-coder, deepseek-v3, deepseek-r1 |\n| Grok | xAI | grok-2, grok-beta |\n\n> **Note**: Model availability may vary. Check [marketplace.aisa.one/pricing](https://marketplace.aisa.one/pricing) for the full list of currently available models and pricing.\n\n## Quick Start\n\n```bash\nexport AISA_API_KEY=\"your-key\"\n```\n\n## API Endpoints\n\n### OpenAI-Compatible Chat Completions\n\n```\nPOST https://api.aisa.one/v1/chat/completions\n```\n\n#### Request\n\n```bash\ncurl -X POST \"https://api.aisa.one/v1/chat/completions\" \\\n  -H \"Authorization: Bearer $AISA_API_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"model\": \"gpt-4.1\",\n    \"messages\": [\n      {\"role\": \"system\", \"content\": \"You are a helpful assistant.\"},\n      {\"role\": \"user\", \"content\": \"Explain quantum computing in simple terms.\"}\n    ],\n    \"temperature\": 0.7,\n    \"max_tokens\": 1000\n  }'\n```\n\n#### Parameters\n\n| Parameter | Type | Required | Description |\n|-----------|------|----------|-------------|\n| `model` | string | Yes | Model identifier (e.g., `gpt-4.1`, `claude-3-sonnet`) |\n| `messages` | array | Yes | Conversation messages |\n| `temperature` | number | No | Randomness (0-2, default: 1) |\n| `max_tokens` | integer | No | Maximum response tokens |\n| `stream` | boolean | No | Enable streaming (default: false) |\n| `top_p` | number | No | Nucleus sampling (0-1) |\n| `frequency_penalty` | number | No | Frequency penalty (-2 to 2) |\n| `presence_penalty` | number | No | Presence penalty (-2 to 2) |\n| `stop` | string/array | No | Stop sequences |\n\n#### Message Format\n\n```json\n{\n  \"role\": \"user|assistant|system\",\n  \"content\": \"message text or array for multimodal\"\n}\n```\n\n#### Response\n\n```json\n{\n  \"id\": \"chatcmpl-xxx\",\n  \"object\": \"chat.completion\",\n  \"created\": 1234567890,\n  \"model\": \"gpt-4.1\",\n  \"choices\": [\n    {\n      \"index\": 0,\n      \"message\": {\n        \"role\": \"assistant\",\n        \"content\": \"Quantum computing uses...\"\n      },\n      \"finish_reason\": \"stop\"\n    }\n  ],\n  \"usage\": {\n    \"prompt_tokens\": 50,\n    \"completion_tokens\": 200,\n    \"total_tokens\": 250,\n    \"cost\": 0.0025\n  }\n}\n```\n\n### Streaming Response\n\n```bash\ncurl -X POST \"https://api.aisa.one/v1/chat/completions\" \\\n  -H \"Authorization: Bearer $AISA_API_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"model\": \"claude-3-sonnet\",\n    \"messages\": [{\"role\": \"user\", \"content\": \"Write a poem about AI.\"}],\n    \"stream\": true\n  }'\n```\n\nStreaming returns Server-Sent Events (SSE):\n\n```\ndata: {\"id\":\"chatcmpl-xxx\",\"choices\":[{\"delta\":{\"content\":\"In\"}}]}\ndata: {\"id\":\"chatcmpl-xxx\",\"choices\":[{\"delta\":{\"content\":\" circuits\"}}]}\n...\ndata: [DONE]\n```\n\n### Vision / Image Analysis\n\nAnalyze images by passing image URLs or base64 data:\n\n```bash\ncurl -X POST \"https://api.aisa.one/v1/chat/completions\" \\\n  -H \"Authorization: Bearer $AISA_API_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"model\": \"gpt-4o\",\n    \"messages\": [\n      {\n        \"role\": \"user\",\n        \"content\": [\n          {\"type\": \"text\", \"text\": \"What is in this image?\"},\n          {\"type\": \"image_url\", \"image_url\": {\"url\": \"https://example.com/image.jpg\"}}\n        ]\n      }\n    ]\n  }'\n```\n\n### Function Calling\n\nEnable tools/functions for structured outputs:\n\n```bash\ncurl -X POST \"https://api.aisa.one/v1/chat/completions\" \\\n  -H \"Authorization: Bearer $AISA_API_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"model\": \"gpt-4.1\",\n    \"messages\": [{\"role\": \"user\", \"content\": \"What is the weather in Tokyo?\"}],\n    \"functions\": [\n      {\n        \"name\": \"get_weather\",\n        \"description\": \"Get current weather for a location\",\n        \"parameters\": {\n          \"type\": \"object\",\n          \"properties\": {\n            \"location\": {\"type\": \"string\", \"description\": \"City name\"},\n            \"unit\": {\"type\": \"string\", \"enum\": [\"celsius\", \"fahrenheit\"]}\n          },\n          \"required\": [\"location\"]\n        }\n      }\n    ],\n    \"function_call\": \"auto\"\n  }'\n```\n\n### Google Gemini Format\n\nFor Gemini models, you can also use the native format:\n\n```\nPOST https://api.aisa.one/v1/models/{model}:generateContent\n```\n\n```bash\ncurl -X POST \"https://api.aisa.one/v1/models/gemini-2.0-flash:generateContent\" \\\n  -H \"Authorization: Bearer $AISA_API_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"contents\": [\n      {\n        \"role\": \"user\",\n        \"parts\": [{\"text\": \"Explain machine learning.\"}]\n      }\n    ],\n    \"generationConfig\": {\n      \"temperature\": 0.7,\n      \"maxOutputTokens\": 1000\n    }\n  }'\n```\n\n## Python Client\n\n### Installation\n\nNo installation required - uses standard library only.\n\n### CLI Usage\n\n```bash\n# Basic completion\npython3 {baseDir}/scripts/llm_router_client.py chat --model gpt-4.1 --message \"Hello, world!\"\n\n# With system prompt\npython3 {baseDir}/scripts/llm_router_client.py chat --model claude-3-sonnet --system \"You are a poet\" --message \"Write about the moon\"\n\n# Streaming\npython3 {baseDir}/scripts/llm_router_client.py chat --model gpt-4o --message \"Tell me a story\" --stream\n\n# Multi-turn conversation\npython3 {baseDir}/scripts/llm_router_client.py chat --model qwen-max --messages '[{\"role\":\"user\",\"content\":\"Hi\"},{\"role\":\"assistant\",\"content\":\"Hello!\"},{\"role\":\"user\",\"content\":\"How are you?\"}]'\n\n# Vision analysis\npython3 {baseDir}/scripts/llm_router_client.py vision --model gpt-4o --image \"https://example.com/image.jpg\" --prompt \"Describe this image\"\n\n# List supported models\npython3 {baseDir}/scripts/llm_router_client.py models\n\n# Compare models\npython3 {baseDir}/scripts/llm_router_client.py compare --models \"gpt-4.1,claude-3-sonnet,gemini-2.0-flash\" --message \"What is 2+2?\"\n```\n\n### Python SDK Usage\n\n```python\nfrom llm_router_client import LLMRouterClient\n\nclient = LLMRouterClient()  # Uses AISA_API_KEY env var\n\n# Simple chat\nresponse = client.chat(\n    model=\"gpt-4.1\",\n    messages=[{\"role\": \"user\", \"content\": \"Hello!\"}]\n)\nprint(response[\"choices\"][0][\"message\"][\"content\"])\n\n# With options\nresponse = client.chat(\n    model=\"claude-3-sonnet\",\n    messages=[\n        {\"role\": \"system\", \"content\": \"You are a helpful assistant.\"},\n        {\"role\": \"user\", \"content\": \"Explain relativity.\"}\n    ],\n    temperature=0.7,\n    max_tokens=500\n)\n\n# Streaming\nfor chunk in client.chat_stream(\n    model=\"gpt-4o\",\n    messages=[{\"role\": \"user\", \"content\": \"Write a story.\"}]\n):\n    print(chunk, end=\"\", flush=True)\n\n# Vision\nresponse = client.vision(\n    model=\"gpt-4o\",\n    image_url=\"https://example.com/image.jpg\",\n    prompt=\"What's in this image?\"\n)\n\n# Compare models\nresults = client.compare_models(\n    models=[\"gpt-4.1\", \"claude-3-sonnet\", \"gemini-2.0-flash\"],\n    message=\"Explain quantum computing\"\n)\nfor model, result in results.items():\n    print(f\"{model}: {result['response'][:100]}...\")\n```\n\n## Use Cases\n\n### 1. Cost-Optimized Routing\n\nUse cheaper models for simple tasks:\n\n```python\ndef smart_route(message: str) -> str:\n    # Simple queries -> fast/cheap model\n    if len(message) < 50:\n        model = \"gpt-3.5-turbo\"\n    # Complex reasoning -> powerful model\n    else:\n        model = \"gpt-4.1\"\n    \n    return client.chat(model=model, messages=[{\"role\": \"user\", \"content\": message}])\n```\n\n### 2. Fallback Strategy\n\nAutomatic fallback on failure:\n\n```python\ndef chat_with_fallback(message: str) -> str:\n    models = [\"gpt-4.1\", \"claude-3-sonnet\", \"gemini-2.0-flash\"]\n    \n    for model in models:\n        try:\n            return client.chat(model=model, messages=[{\"role\": \"user\", \"content\": message}])\n        except Exception:\n            continue\n    \n    raise Exception(\"All models failed\")\n```\n\n### 3. Model A/B Testing\n\nCompare model outputs:\n\n```python\nresults = client.compare_models(\n    models=[\"gpt-4.1\", \"claude-3-opus\"],\n    message=\"Analyze this quarterly report...\"\n)\n\n# Log for analysis\nfor model, result in results.items():\n    log_response(model=model, latency=result[\"latency\"], cost=result[\"cost\"])\n```\n\n### 4. Specialized Model Selection\n\nChoose the best model for each task:\n\n```python\nMODEL_MAP = {\n    \"code\": \"deepseek-coder\",\n    \"creative\": \"claude-3-opus\",\n    \"fast\": \"gpt-3.5-turbo\",\n    \"vision\": \"gpt-4o\",\n    \"chinese\": \"qwen-max\",\n    \"reasoning\": \"gpt-4.1\"\n}\n\ndef route_by_task(task_type: str, message: str) -> str:\n    model = MODEL_MAP.get(task_type, \"gpt-4.1\")\n    return client.chat(model=model, messages=[{\"role\": \"user\", \"content\": message}])\n```\n\n## Error Handling\n\nErrors return JSON with `error` field:\n\n```json\n{\n  \"error\": {\n    \"code\": \"model_not_found\",\n    \"message\": \"Model 'xyz' is not available\"\n  }\n}\n```\n\nCommon error codes:\n- `401` - Invalid or missing API key\n- `402` - Insufficient credits\n- `404` - Model not found\n- `429` - Rate limit exceeded\n- `500` - Server error\n\n## Best Practices\n\n1. **Use streaming** for long responses to improve UX\n2. **Set max_tokens** to control costs\n3. **Implement fallback** for production reliability\n4. **Cache responses** for repeated queries\n5. **Monitor usage** via response metadata\n6. **Use appropriate models** - don't use GPT-4 for simple tasks\n\n## OpenAI SDK Compatibility\n\nJust change the base URL and key:\n\n```python\nimport os\nfrom openai import OpenAI\n\nclient = OpenAI(\n    api_key=os.environ[\"AISA_API_KEY\"],\n    base_url=\"https://api.aisa.one/v1\"\n)\n\nresponse = client.chat.completions.create(\n    model=\"gpt-4.1\",\n    messages=[{\"role\": \"user\", \"content\": \"Hello!\"}]\n)\nprint(response.choices[0].message.content)\n```\n\n## Pricing\n\nToken-based pricing varies by model. Check [marketplace.aisa.one/pricing](https://marketplace.aisa.one/pricing) for current rates.\n\n| Model Family | Approximate Cost |\n|--------------|------------------|\n| GPT-4.1 / GPT-4o | ~$0.01 / 1K tokens |\n| Claude-3-Sonnet | ~$0.01 / 1K tokens |\n| Gemini-2.0-Flash | ~$0.001 / 1K tokens |\n| Qwen-Max | ~$0.005 / 1K tokens |\n| DeepSeek-V3 | ~$0.002 / 1K tokens |\n\nEvery response includes `usage.cost` and `usage.credits_remaining`.\n\n## Get Started\n\n1. Sign up at [aisa.one](https://aisa.one)\n2. Get your API key from the dashboard\n3. Add credits (pay-as-you-go)\n4. Set environment variable: `export AISA_API_KEY=\"your-key\"`\n\n## Full API Reference\n\nSee [API Reference](https://aisa.mintlify.app/api-reference/introduction) for complete endpoint documentation.\n","tags":{"latest":"1.0.0"},"stats":{"comments":0,"downloads":1553,"installsAllTime":58,"installsCurrent":1,"stars":0,"versions":1},"createdAt":1770766616687,"updatedAt":1778486994957},"latestVersion":{"version":"1.0.0","createdAt":1770766616687,"changelog":"asia-llm-router-skills v1.0.0\n\n- Initial release of the LLM Router skill powered by OpenClaw.\n- Provides a unified API gateway to 70+ AI models (GPT, Claude, Gemini, Qwen, Deepseek, Grok, and more) with a single API key.\n- Features OpenAI-compatible endpoints for chat, model comparison, vision, function calling, and cost optimization.\n- Includes example usage via curl and a Python CLI and SDK client.\n- Supports advanced features like routing, model fallback, unified billing, and tracking.\n- Extensive documentation for setup, endpoints, parameters, and supported model families.","license":null},"metadata":{"setup":[{"key":"AISA_API_KEY","required":true}],"os":null,"systems":null},"owner":{"handle":"renning22","userId":"s170hey90qee9bets5ysrasphn83eh82","displayName":"Ning Ren","image":"https://avatars.githubusercontent.com/u/4597657?v=4"},"moderation":null}