概述
inkqyf 的 Serverless API 是模力方舟(Gitee AI)为开发者提供的开箱即用的企业级大模型推理 API 服务[reference:132]。无需繁琐的部署和算力配置[reference:133],通过兼容 OpenAI 的 Web API 即可便捷接入[reference:134]。
平台基于 GiEngine 高速推理引擎构建[reference:135],提供自动扩缩容、高性能 GPU 加速和极低延迟的 API 服务[reference:136]。一份 API Token 与一个独立的保障性能的推理通道相对应[reference:137]。
认证方式
所有 API 请求均需在 HTTP Header 中携带 API Token 进行身份认证。
Authorization: Bearer <YOUR_API_TOKEN>
API Token 可在 inkqyf 控制台的「API 密钥」页面获取。一份 Token 与一个独立的推理通道相对应,确保性能隔离[reference:140]。
API 端点
所有 API 请求的基础 URL 为:
https://ai.gitee.com/v1
| 端点 | 方法 | 功能 |
|---|---|---|
/chat/completions | POST | 对话补全(文本生成) |
/images/generations | POST | 图像生成(文生图) |
/embeddings | POST | 文本嵌入向量化 |
/audio/transcriptions | POST | 语音转文本(ASR) |
/audio/speech | POST | 文本转语音(TTS) |
对话补全 API
请求参数
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
model | string | ✅ | 模型名称,如 DeepSeek-R1、Qwen3-4B-Instruct |
messages | array | ✅ | 对话消息列表,格式为 [{"role":"user","content":"..."}] |
temperature | number | ❌ | 采样温度,0-2 之间,默认 1.0 |
max_tokens | integer | ❌ | 最大生成 Token 数,默认 2048 |
stream | boolean | ❌ | 是否流式输出,默认 false |
请求示例
curl https://ai.gitee.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"model": "DeepSeek-R1",
"messages": [
{"role": "user", "content": "解释一下什么是大模型"}
],
"temperature": 0.7,
"max_tokens": 1024
}'
响应示例
{
"id": "chatcmpl-xxx",
"object": "chat.completion",
"created": 1234567890,
"model": "DeepSeek-R1",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "大模型是指..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 10,
"completion_tokens": 200,
"total_tokens": 210
}
}
图像生成 API
请求参数
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
model | string | ✅ | 图像模型,如 stable-diffusion-2-1、FLUX.1 |
prompt | string | ✅ | 图像描述文本 |
size | string | ❌ | 图像尺寸,如 1024x1024 |
n | integer | ❌ | 生成数量,默认 1 |
请求示例
curl https://ai.gitee.com/v1/images/generations \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"model": "stable-diffusion-2-1",
"prompt": "一只金色的凤凰在夜空中飞翔",
"size": "1024x1024"
}'
文本嵌入 API
请求参数
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
model | string | ✅ | 嵌入模型名称 |
input | string 或 array | ✅ | 待向量化的文本 |
请求示例
curl https://ai.gitee.com/v1/embeddings \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"model": "text-embedding-model",
"input": "inkqyf 是下一代 AI 基础设施平台"
}'
错误码
| HTTP 状态码 | 错误码 | 描述 |
|---|---|---|
| 400 | invalid_request | 请求参数错误 |
| 401 | invalid_token | API Token 无效或已过期 |
| 403 | insufficient_quota | 额度不足 |
| 404 | model_not_found | 模型不存在或无权限访问[reference:141] |
| 429 | rate_limit_exceeded | 请求频率超限 |
| 500 | internal_error | 服务内部错误 |
速率限制
inkqyf API 采用按 Token 计费与速率限制相结合的策略:
- RPM(每分钟请求数):根据套餐不同,基础套餐为 60 RPM,企业套餐可提升至 1000+ RPM
- TPM(每分钟 Token 数):基础套餐为 10,000 TPM,企业套餐可定制
- 超出限制时将返回
429状态码,请实现指数退避重试策略
SDK 与生态集成
inkqyf API 完全兼容 OpenAI SDK,您可以使用任何 OpenAI SDK 无缝接入[reference:142]:
Python
from openai import OpenAI
client = OpenAI(
base_url="https://ai.gitee.com/v1",
api_key="YOUR_API_TOKEN"
)
response = client.chat.completions.create(
model="DeepSeek-R1",
messages=[{"role": "user", "content": "你好"}]
)
print(response.choices[0].message.content)
JavaScript
import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'https://ai.gitee.com/v1',
apiKey: 'YOUR_API_TOKEN'
});
const response = await client.chat.completions.create({
model: 'DeepSeek-R1',
messages: [{ role: 'user', content: '你好' }]
});
console.log(response.choices[0].message.content);