> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cdn-fly.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 介绍

> Starrise AI API 的 Base URL、认证方式、请求格式及错误处理。

## Base URL

所有 API 请求发送到以下地址：

```
https://dayu.cdn-fly.com/
```

## 认证方式

Starrise AI 使用 Bearer Token 认证。在每个请求的 `Authorization` 头中包含你的 API Key：

```
Authorization: Bearer YOUR_API_KEY
```

你可以在 [控制台](https://dayu.cdn-fly.com/console/token) 中生成和管理 API Key。

> [!WARNING]
>
> 请妥善保管你的 API Key，不要将其暴露在客户端代码或公开仓库中。

## 请求格式

所有请求必须使用 `Content-Type: application/json`，请求体为 JSON 编码。

```bash theme={null}
curl https://dayu.cdn-fly.com/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-3-5-sonnet-20241022",
    "messages": [
      {"role": "user", "content": "你好！"}
    ]
  }'
```

## 支持的端点

| 端点 | 说明 |
| - | - |
| `POST /v1/chat/completions` | 对话补全（OpenAI 兼容） |
| `POST /v1/images/generations` | 图片生成（字节跳动 Seedream） |
| `POST /v1/video/generations` | 视频生成（字节跳动 Seedance） |
| `GET /v1/video/generations/{id}` | 查询视频生成任务状态 |
| `POST /kling/v1/videos/text2video` | 快手 Kling 文生视频 |
| `POST /kling/v1/videos/image2video` | 快手 Kling 图生视频 |
| `POST /kling/v1/videos/multi-image2video` | 快手 Kling 多图生视频 |
| `GET /kling/v1/videos/{id}` | 查询 Kling 任务状态 |

## 响应格式

所有响应均为 JSON 编码。成功响应通常包含：

```json theme={null}
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "model": "claude-3-5-sonnet-20241022",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "你好！有什么可以帮你的吗？"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 10,
    "completion_tokens": 12,
    "total_tokens": 22
  }
}
```

## 错误处理

当发生错误时，API 返回包含 `error` 对象的 JSON 响应：

```json theme={null}
{
  "error": {
    "message": "提供的 API Key 无效。",
    "type": "authentication_error",
    "code": "invalid_api_key"
  }
}
```

### HTTP 状态码

| 状态码 | 说明 |
| - | - |
| `200` | 成功 |
| `400` | 请求错误 — 参数无效 |
| `401` | 未授权 — API Key 无效或缺失 |
| `403` | 禁止访问 — 权限不足 |
| `404` | 未找到 — 端点无效 |
| `429` | 请求频率超限 — 请求过多 |
| `500` | 服务器内部错误 |

## 频率限制

频率限制因模型和订阅等级而异。触发频率限制时，API 返回 `429` 状态码。建议实现指数退避策略来优雅地处理频率限制。

## OpenAI SDK 兼容

Starrise AI 兼容 OpenAI SDK，只需更改 `base_url` 即可使用：

```python Python theme={null}
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://dayu.cdn-fly.com/v1"
)
```

```javascript Node.js theme={null}
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: "YOUR_API_KEY",
  baseURL: "https://dayu.cdn-fly.com/v1",
});
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.