# url-shortener

## 功能

将长 URL 转换为短链接。当需要分享链接、生成短 URL、或在对话中提供可点击的简短地址时使用。

## 使用方法

将此文件内容放入 AI Agent 的系统提示词或 Skill 配置中，Agent 即可自动调用。

## 工具定义

### tool: create_short_url

**description:** 创建短链接。输入一个长 URL，返回一个可通过 `short.shxai.space/{slug}` 访问的短链地址。需要 API Key。

**parameters:**

| 参数 | 类型 | 必填 | 默认值 | 说明 |
|------|------|------|--------|------|
| url | string | 是 | - | 目标 URL，必须是完整格式（含 https:// 或 http://） |
| key | string | 是 | - | API Key |

**api endpoint:**

```
POST https://short.shxai.space/create?key={key}&url={url}
```

**response:**

```json
{
  "short": "https://short.shxai.space/a1b2c3",
  "slug": "a1b2c3",
  "url": "https://github.com"
}
```

**error responses:**

| HTTP 状态 | 说明 |
|--------|------|
| 400 | 缺少 url 参数或 URL 格式无效 |
| 401 | 缺少 API Key |
| 403 | API Key 无效 |

## 短链访问

短链创建后，通过 GET 请求访问即可自动 302 跳转到原始 URL：

```
GET https://short.shxai.space/a1b2c3
→ HTTP 302 → https://github.com
```

## 示例

```bash
# 创建短链
curl -X POST "https://short.shxai.space/create?key=sk-xxxxx&url=https://github.com"
# → {"short":"https://short.shxai.space/a1b2c3","slug":"a1b2c3","url":"https://github.com"}

# 访问短链
curl -L https://short.shxai.space/a1b2c3
# → HTTP 302 → https://github.com
```

## 获取 API Key

访问 [shxai.space](https://shxai.space) 注册获取。

---

> Skill 版本: 1.0 | 平台: shxai.space | 更新: 2026-08
