# xkrelay-examples **Repository Path**: duoduo_jiang/xkrelay-examples ## Basic Information - **Project Name**: xkrelay-examples - **Description**: 深空 API 接入示例 | Python & Node.js examples | 官网 https://xkrelay.com | GitHub: Jiang1756/xkrelay-examples - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-11-16 - **Last Updated**: 2026-11-16 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 深空 API · 接入示例 [English](README.en.md) · **[官网 xkrelay.com](https://xkrelay.com/)** · [接入文档](https://xkrelay.com/landing/docs/) · [模型与价格](https://xkrelay.com/pricing) 深空 API 是面向开发者的第三方 AI API 中转与多模型接入服务。本仓库维护最小接入示例,不包含服务端业务源码。模型、分组、价格与协议支持以官网实时信息为准;第三方兼容接入不代表模型厂商官方服务或背书。 ## 快速开始 1. 在[官网注册](https://xkrelay.com/sign-up),创建[服务 API 密钥](https://xkrelay.com/keys)。 2. 在模型广场选择支持 **Chat Completions** 的准确模型 ID 与可用分组。 3. 在本地环境或密钥管理器设置 `XKRELAY_API_KEY`、`XKRELAY_MODEL`。不要把真实密钥提交到 Git 或 Issue。 4. 运行一个示例(会产生实际 API 调用,费用以所选分组为准): ```sh # Python 3.10+,仅使用标准库 python3 examples/chat.py # Node.js 22+,无需安装依赖 node examples/chat.mjs ``` API 基础地址为 `https://xkrelay.com/v1`;示例向 `/chat/completions` 发起请求。其他协议与工具的地址格式请按相应教程配置。示例设置 60 秒超时,不自动重试,以免重复调用;超时不等于请求未处理,请核对用量日志。 ## 工具接入 - [Claude Code](https://xkrelay.com/landing/docs/claude-code.html) - [Codex](https://xkrelay.com/landing/docs/codex.html) - [Cherry Studio](https://xkrelay.com/landing/docs/cherry-studio.html) - [OpenCode](https://xkrelay.com/landing/docs/opencode.html) - [CC Switch](https://xkrelay.com/landing/docs/cc-switch.html) ## 排查与选型 | 状态 | 检查项 | | --- | --- | | 401 | 服务密钥是否正确、有效 | | 403 | 账号、分组或访问限制 | | 404 | 模型 ID、协议和地址 | | 429 | 额度、频率与线路容量;不要紧密循环重试 | | 5xx / 超时 | 线路状态与用量记录;重试可能产生额外调用 | 比较服务时,用相同模型、任务和输入,核对缓存、输入输出与附加费用,再观察延迟、错误率及实际任务结果。参考[服务说明](https://xkrelay.com/landing/docs/service-overview.html)、[线路质量](https://xkrelay.com/performance)、[隐私说明](https://xkrelay.com/landing/docs/privacy.html)与[退款说明](https://xkrelay.com/landing/docs/refund.html)。 ## 测试与反馈 ```sh python3 -m unittest discover -s tests node --test tests/chat.test.mjs ``` 测试使用模拟响应,不发送付费请求;通过测试不代表所有模型和协议均已实测。Issue 用于示例问题,请提供脱敏后的错误状态与复现步骤;账单或账号问题请通过官网支持入口处理。