[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6CJRE9QXP3D3EPAXF0T54B7":3,"skill-same:01M6CJRE9QXP3D3EPAXF0T54B7":95},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":32,"linkOnly":33,"markdownContent":34,"markdownBody":35,"frontMatter":36,"refName":45,"commitSha":46,"skillDirectory":47,"forksCount":48,"repositoryHtmlUrl":49,"repositoryHomepageUrl":6,"ownerHtmlUrl":50,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":51,"install":52,"resources":65},"01M6CJRE9QXP3D3EPAXF0T54B7","llm-router",null,"Unified LLM Gateway - One API for 70+ AI models. Route to GPT, Claude, Gemini, Qwen, Deepseek, Grok and more with a single API key.","kbarbel640-del\u002Fskills","kbarbel640-del","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F255315490?v=4","01M6CJPPQGCCESXMG3K7BBGQ5J","01M6CJPPX2PB2BCZERFVM2C2B3",1,"MIT","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002F0xjordansg-yolo\u002Fopenclaw-aisa-affordable-llm-model-tokens\u002FSKILL.md",[],[18,19,20,21,22,23,24,25,26,27,28,29,30,31],"router","llm router","openclaw","gemini","gpt","gateway","https","Qwen","api","python3","curl","llm gateway","grok","models","2026-11-10 10:12:30",false,"---\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:\u002F\u002Fopenclaw.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\u002Fcheap 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\u002Fpricing](https:\u002F\u002Fmarketplace.aisa.one\u002Fpricing) 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:\u002F\u002Fapi.aisa.one\u002Fv1\u002Fchat\u002Fcompletions\n```\n\n#### Request\n\n```bash\ncurl -X POST \"https:\u002F\u002Fapi.aisa.one\u002Fv1\u002Fchat\u002Fcompletions\" \\\n  -H \"Authorization: Bearer $AISA_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\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\u002Farray | 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:\u002F\u002Fapi.aisa.one\u002Fv1\u002Fchat\u002Fcompletions\" \\\n  -H \"Authorization: Bearer $AISA_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\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 \u002F Image Analysis\n\nAnalyze images by passing image URLs or base64 data:\n\n```bash\ncurl -X POST \"https:\u002F\u002Fapi.aisa.one\u002Fv1\u002Fchat\u002Fcompletions\" \\\n  -H \"Authorization: Bearer $AISA_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\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:\u002F\u002Fexample.com\u002Fimage.jpg\"}}\n        ]\n      }\n    ]\n  }'\n```\n\n### Function Calling\n\nEnable tools\u002Ffunctions for structured outputs:\n\n```bash\ncurl -X POST \"https:\u002F\u002Fapi.aisa.one\u002Fv1\u002Fchat\u002Fcompletions\" \\\n  -H \"Authorization: Bearer $AISA_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\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:\u002F\u002Fapi.aisa.one\u002Fv1\u002Fmodels\u002F{model}:generateContent\n```\n\n```bash\ncurl -X POST \"https:\u002F\u002Fapi.aisa.one\u002Fv1\u002Fmodels\u002Fgemini-2.0-flash:generateContent\" \\\n  -H \"Authorization: Bearer $AISA_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\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}\u002Fscripts\u002Fllm_router_client.py chat --model gpt-4.1 --message \"Hello, world!\"\n\n# With system prompt\npython3 {baseDir}\u002Fscripts\u002Fllm_router_client.py chat --model claude-3-sonnet --system \"You are a poet\" --message \"Write about the moon\"\n\n# Streaming\npython3 {baseDir}\u002Fscripts\u002Fllm_router_client.py chat --model gpt-4o --message \"Tell me a story\" --stream\n\n# Multi-turn conversation\npython3 {baseDir}\u002Fscripts\u002Fllm_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}\u002Fscripts\u002Fllm_router_client.py vision --model gpt-4o --image \"https:\u002F\u002Fexample.com\u002Fimage.jpg\" --prompt \"Describe this image\"\n\n# List supported models\npython3 {baseDir}\u002Fscripts\u002Fllm_router_client.py models\n\n# Compare models\npython3 {baseDir}\u002Fscripts\u002Fllm_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:\u002F\u002Fexample.com\u002Fimage.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\u002Fcheap model\n    if len(message) \u003C 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\u002FB 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:\u002F\u002Fapi.aisa.one\u002Fv1\"\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\u002Fpricing](https:\u002F\u002Fmarketplace.aisa.one\u002Fpricing) for current rates.\n\n| Model Family | Approximate Cost |\n|--------------|------------------|\n| GPT-4.1 \u002F GPT-4o | ~$0.01 \u002F 1K tokens |\n| Claude-3-Sonnet | ~$0.01 \u002F 1K tokens |\n| Gemini-2.0-Flash | ~$0.001 \u002F 1K tokens |\n| Qwen-Max | ~$0.005 \u002F 1K tokens |\n| DeepSeek-V3 | ~$0.002 \u002F 1K tokens |\n\nEvery response includes `usage.cost` and `usage.credits_remaining`.\n\n## Get Started\n\n1. Sign up at [aisa.one](https:\u002F\u002Faisa.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:\u002F\u002Faisa.mintlify.app\u002Fapi-reference\u002Fintroduction) for complete endpoint documentation.\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\u002Fcheap 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\u002Fpricing](https:\u002F\u002Fmarketplace.aisa.one\u002Fpricing) 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:\u002F\u002Fapi.aisa.one\u002Fv1\u002Fchat\u002Fcompletions\n```\n\n#### Request\n\n```bash\ncurl -X POST \"https:\u002F\u002Fapi.aisa.one\u002Fv1\u002Fchat\u002Fcompletions\" \\\n  -H \"Authorization: Bearer $AISA_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\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\u002Farray | 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:\u002F\u002Fapi.aisa.one\u002Fv1\u002Fchat\u002Fcompletions\" \\\n  -H \"Authorization: Bearer $AISA_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\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 \u002F Image Analysis\n\nAnalyze images by passing image URLs or base64 data:\n\n```bash\ncurl -X POST \"https:\u002F\u002Fapi.aisa.one\u002Fv1\u002Fchat\u002Fcompletions\" \\\n  -H \"Authorization: Bearer $AISA_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\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:\u002F\u002Fexample.com\u002Fimage.jpg\"}}\n        ]\n      }\n    ]\n  }'\n```\n\n### Function Calling\n\nEnable tools\u002Ffunctions for structured outputs:\n\n```bash\ncurl -X POST \"https:\u002F\u002Fapi.aisa.one\u002Fv1\u002Fchat\u002Fcompletions\" \\\n  -H \"Authorization: Bearer $AISA_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\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:\u002F\u002Fapi.aisa.one\u002Fv1\u002Fmodels\u002F{model}:generateContent\n```\n\n```bash\ncurl -X POST \"https:\u002F\u002Fapi.aisa.one\u002Fv1\u002Fmodels\u002Fgemini-2.0-flash:generateContent\" \\\n  -H \"Authorization: Bearer $AISA_API_KEY\" \\\n  -H \"Content-Type: application\u002Fjson\" \\\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}\u002Fscripts\u002Fllm_router_client.py chat --model gpt-4.1 --message \"Hello, world!\"\n\n# With system prompt\npython3 {baseDir}\u002Fscripts\u002Fllm_router_client.py chat --model claude-3-sonnet --system \"You are a poet\" --message \"Write about the moon\"\n\n# Streaming\npython3 {baseDir}\u002Fscripts\u002Fllm_router_client.py chat --model gpt-4o --message \"Tell me a story\" --stream\n\n# Multi-turn conversation\npython3 {baseDir}\u002Fscripts\u002Fllm_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}\u002Fscripts\u002Fllm_router_client.py vision --model gpt-4o --image \"https:\u002F\u002Fexample.com\u002Fimage.jpg\" --prompt \"Describe this image\"\n\n# List supported models\npython3 {baseDir}\u002Fscripts\u002Fllm_router_client.py models\n\n# Compare models\npython3 {baseDir}\u002Fscripts\u002Fllm_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:\u002F\u002Fexample.com\u002Fimage.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\u002Fcheap model\n    if len(message) \u003C 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\u002FB 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:\u002F\u002Fapi.aisa.one\u002Fv1\"\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\u002Fpricing](https:\u002F\u002Fmarketplace.aisa.one\u002Fpricing) for current rates.\n\n| Model Family | Approximate Cost |\n|--------------|------------------|\n| GPT-4.1 \u002F GPT-4o | ~$0.01 \u002F 1K tokens |\n| Claude-3-Sonnet | ~$0.01 \u002F 1K tokens |\n| Gemini-2.0-Flash | ~$0.001 \u002F 1K tokens |\n| Qwen-Max | ~$0.005 \u002F 1K tokens |\n| DeepSeek-V3 | ~$0.002 \u002F 1K tokens |\n\nEvery response includes `usage.cost` and `usage.credits_remaining`.\n\n## Get Started\n\n1. Sign up at [aisa.one](https:\u002F\u002Faisa.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:\u002F\u002Faisa.mintlify.app\u002Fapi-reference\u002Fintroduction) for complete endpoint documentation.\n",{"name":5,"homepage":37,"metadata":38,"description":7},"https:\u002F\u002Fopenclaw.ai",{"openclaw":39},{"emoji":40,"requires":41,"primaryEnv":43},"?",{"env":42,"bins":44},[43],"AISA_API_KEY",[28,27],"main","e7e336ac628c3e3bd771aff1aaa469c93778f94a","skills\u002F0xjordansg-yolo\u002Fopenclaw-aisa-affordable-llm-model-tokens",0,"https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del","2026-08-23 22:39:37",{"source":8,"skillName":5,"commands":53,"prompt":63,"zipAvailable":64},[54,57,60],{"tool":55,"command":56},"npx","npx skills add kbarbel640-del\u002Fskills --skill llm-router",{"tool":58,"command":59},"bunx","bunx skills add kbarbel640-del\u002Fskills --skill llm-router",{"tool":61,"command":62},"pnpm","pnpm dlx skills add kbarbel640-del\u002Fskills --skill llm-router","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002F0xjordansg-yolo\u002Fopenclaw-aisa-affordable-llm-model-tokens\u002FSKILL.md",true,[66,72,77,81,87,91],{"path":67,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":70,"sourceHtmlUrl":71},"_meta.json","REFERENCE","参考文档",412,"https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002F0xjordansg-yolo\u002Fopenclaw-aisa-affordable-llm-model-tokens\u002F_meta.json",{"path":73,"resourceType":73,"resourceTypeDesc":74,"sizeBytes":75,"sourceHtmlUrl":76},"LICENSE","许可证",1063,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fpayments\u002F0xklen-anchor-prices-with-a-tier-ladder\u002FLICENSE",{"path":78,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":79,"sourceHtmlUrl":80},"README.md",1757,"https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002F0xjordansg-yolo\u002Fopenclaw-aisa-affordable-llm-model-tokens\u002FREADME.md",{"path":82,"resourceType":83,"resourceTypeDesc":84,"sizeBytes":85,"sourceHtmlUrl":86},"scripts\u002Fllm_router_client.py","SCRIPT","脚本",13753,"https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002F0xjordansg-yolo\u002Fopenclaw-aisa-affordable-llm-model-tokens\u002Fscripts\u002Fllm_router_client.py",{"path":88,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":89,"sourceHtmlUrl":90},"SOURCE.md",358,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fpayments\u002F0xklen-anchor-prices-with-a-tier-ladder\u002FSOURCE.md",{"path":92,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":93,"sourceHtmlUrl":94},"TRUST.auto.yaml",2217,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fpayments\u002F0xklen-anchor-prices-with-a-tier-ladder\u002FTRUST.auto.yaml",[96,120,143,161,166,186],{"skillNo":97,"name":98,"nameZh":6,"description":99,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":100,"categories":101,"keywords":102,"publishedAt":32},"01M6G8J55967D6281ACMKAKTEQ","crowd-prompting","A marketplace where AI agents improve prompts, system instructions, tool descriptions, and other text-based content with domain expertise from real-world operations — and earn tokens for valuable contributions.","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fzzadrian\u002Fcrowd-prompting\u002FSKILL.md",[],[103,104,26,105,106,107,108,109,110,111,112,113,114,115,116,117,24,118,119],"crowd prompting","prompting","with","tokens","domain","world","prompts","operations","instructions","text","tool","system","improve","productivity","marketplace","content","ai agents",{"skillNo":121,"name":122,"nameZh":6,"description":123,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":124,"categories":125,"keywords":126,"publishedAt":32},"01M6G8J0PKPAYVET6BWE8W4C26","dilemm-ai","Compete in DilemmAI, the prisoner's dilemma AI arena at dilemm.ai. Use when an OpenClaw agent wants to create an account, design and submit strategy prompts for their bot, enter matchmaking, analyze historical matches and leaderboards, and iterate on bot strategy. Requires headless browser automation (no API available yet).","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fzyori\u002Fdilemm-ai\u002FSKILL.md",[],[127,26,128,129,130,131,132,133,134,135,20,136,137,138,139,140,141,109,142],"dilemm ai","arena","analyze","browser","openclaw agent","create","automation","browser automation","bot","design","strategy","headless","compete","submit","matchmaking","use",{"skillNo":144,"name":145,"nameZh":6,"description":146,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":147,"categories":148,"keywords":149,"publishedAt":32},"01M6G8HWAF3K9SW7NP3Z83CPJ6","arxiv-paper-reviews","Interact with arXiv Crawler API to fetch papers, read reviews, and submit comments. Use when working with arXiv papers, fetching paper lists by date\u002Fcategory\u002Finterest, viewing paper details with comments, or submitting paper reviews via API at http:\u002F\u002F150.158.152.82:8000.","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fzxrys\u002Fweak-accept\u002FSKILL.md",[],[150,151,152,153,154,155,156,105,157,140,142,158,26,159,160],"arxiv paper reviews","reviews","arxiv","paper","crawler","papers","comments","fetch","read","http","via",{"skillNo":162,"name":145,"nameZh":6,"description":146,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":163,"categories":164,"keywords":165,"publishedAt":32},"01M6G8HQJ7N7WMY6YV7D7SSJ16","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fzxrys\u002Farxiv-paper-reviews\u002FSKILL.md",[],[153,152,151,150,160,155,156,105,154,140,142,157,158,26,159],{"skillNo":167,"name":168,"nameZh":6,"description":169,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":170,"categories":171,"keywords":172,"publishedAt":32},"01M6G8HM95Y64JNVFC2HN4E2BG","git-summary","Get a quick summary of the current Git repository including status, recent commits, branches, and contributors.","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fzweack\u002Fgit-summary\u002FSKILL.md",[],[173,174,175,176,177,178,179,180,181,182,183,184,185],"git","summary","git summary","commits","repository","win32","status","linux","contributors","true","quick","get","branches",{"skillNo":187,"name":188,"nameZh":6,"description":189,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":190,"categories":191,"keywords":192,"publishedAt":32},"01M6G8HGEGF05CNEJCGVYFSC4R","agent-constitution","Interact with AgentConstitution governance contracts on Base Sepolia. Check compliance, read rules, log actions, query governance state.","https:\u002F\u002Fgithub.com\u002Fkbarbel640-del\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fztsalexey\u002Fagent-constitution\u002FSKILL.md",[],[193,194,195,196,105,197,198,45,199,158,200,201,202,203,204,24,205,206,207],"agent constitution","constitution","contracts","tree","query","base","log","check","Rules","projects","compliance","actions","state","governance","github"]