360 Secure SkillHub
360 安全技能中心

Free AI API Discovery and Routing

通过 Python 标准库短超时探测候选 AI API 提供方的网络可达性,在用户批准后只用最小必要凭据验证,逐项确认聊天、模型列表、语音或图像能力,最终输出可达提供方、按任务类型的最低成本可靠路由建议、成本配额说明与风险缺口;强调密钥不入库、日志脱敏、建议基于实测结果。

xuxuclassmate
xuxuclassmate
热度 40.67
最近更新 2026-05-11 17:44:10
分类:搜索依赖:代码执行 / 第三方 API应用场景:API 集成 / 研究 / 自动化脚本 / DevOps

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add free-api-discovery
Metadata
name
free-api-discovery
description
Discover which free or low-cost AI APIs are reachable from the current environment, verify them safely, and recommend a task-to-provider routing plan.
tags
["ai","api","discovery","llm","model","free","devops"]
version
1.0.1

Free AI API Discovery and Routing

When to use

  • You need to find which AI APIs are reachable from the current environment.
  • You want a low-cost fallback when a preferred provider is unavailable.
  • You need a simple routing recommendation for chat, code, speech, or multimodal tasks.

Workflow

  1. Check network reachability. Probe candidate endpoints with a short timeout and record whether the host is reachable.
  2. Verify credentials only after approval. Ask for the minimum key needed and avoid printing full secrets in logs.
  3. Test one capability at a time. Confirm chat, model listing, speech, or image endpoints separately.
  4. Recommend routing. Map each task type to the lowest-cost reliable provider that actually worked.

Example reachability probe

import socket
import ssl
import urllib.error
import urllib.request

socket.setdefaulttimeout(8)
ctx = ssl.create_default_context()

services = {
    "Groq": "https://api.groq.com",
    "OpenRouter": "https://openrouter.ai/api/v1",
    "DeepSeek": "https://api.deepseek.com",
    "Mistral": "https://api.mistral.ai/v1",
}

for name, url in services.items():
    try:
        req = urllib.request.Request(url)
        with urllib.request.urlopen(req, context=ctx, timeout=6) as resp:
            print(f"{name}: HTTP {resp.status}")
    except urllib.error.HTTPError as exc:
        print(f"{name}: HTTP {exc.code} (reachable, auth may be required)")
    except Exception as exc:
        print(f"{name}: not reachable ({exc})")

Recommended output

  • Reachable providers
  • Providers that need valid credentials
  • Best provider by task type
  • Cost or quota notes
  • Risks or missing coverage

Guardrails

  • Do not store API keys unless the user explicitly approves it.
  • Mask secrets in notes and logs.
  • Keep routing recommendations based on verified results, not assumptions.
  • Treat provider availability and quotas as time-sensitive and re-check when needed.