加载中...
加载中...
本页只覆盖对客户公开的开发者接口:推理 API、购卡/充值/查单、自助额度查询和 Key 管理。后台管理路由、支付 webhook、运维排查接口不在公开文档范围内。
https://llm-agent.cc客户端只接受域名、站点地址或 API Host 时使用https://llm-agent.cc/v1OpenAI SDK 和支持 Base URL 的客户端优先使用https://llm-agent.cc/v1/chat/completions客户端只能填写完整端点时使用Authorization: Bearer sk-your-api-keyAPI Key 以 sk- 开头,购买成功后自动交付某些客户端在 URL 校验阶段就会报错。这种情况下不要先怀疑 Key,先检查地址类型是否填对:支持 Base URL 的客户端填 https://llm-agent.cc/v1;只能填完整端点的客户端填 https://llm-agent.cc/v1/chat/completions;只接受站点地址的客户端填 https://llm-agent.cc。
OpenAI-compatible chat completions endpoint used by third-party SDKs and clients.
POST /v1/chat/completions
Content-Type: application/json
Authorization: Bearer sk-your-api-key
{
"model": "your-model-id",
"messages": [
{ "role": "system", "content": "You are a concise assistant." },
{ "role": "user", "content": "Give me a one-line introduction." }
],
"temperature": 0.7
}| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | Yes | Upstream model identifier exposed by your runtime. |
messages | array | Yes | Chat messages in OpenAI format. |
temperature | number | No | Sampling temperature. Common range: 0 to 2. |
max_tokens | integer | No | Upper bound for generated tokens. |
stream | boolean | No | Enable streaming responses when supported upstream. |
user | string | No | Optional caller identifier for tracing and abuse controls. |
{
"id": "chatcmpl_01JEXAMPLE",
"object": "chat.completion",
"created": 1712380800,
"model": "your-model-id",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "This endpoint is compatible with the OpenAI chat format."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 21,
"completion_tokens": 16,
"total_tokens": 37
}
}| 字段 | 类型 | 说明 |
|---|---|---|
id | string | Unique completion identifier. |
choices | array | Returned candidate completions. |
choices[].message | object | Assistant reply content. |
usage | object | Prompt, completion, and total token counts. |
model | string | Model id used for the request. |
先用下面这些最小示例跑通,再迁移到自己的业务代码或第三方客户端。
支持 7+ 种编程语言:Python、Node.js、Go、Java、PHP、C# 和 cURL。
from openai import OpenAI
client = OpenAI(
api_key="sk-your-api-key",
base_url="https://llm-agent.cc/v1"
)
response = client.chat.completions.create(
model="your-model-id",
messages=[
{"role": "system", "content": "You are a concise assistant."},
{"role": "user", "content": "Give me a one-line introduction."}
]
)
print(response.choices[0].message.content)启用流式输出可以实时接收生成的 token,显著提升用户体验。
from openai import OpenAI
client = OpenAI(
api_key="sk-your-api-key",
base_url="https://llm-agent.cc/v1"
)
stream = client.chat.completions.create(
model="your-model-id",
messages=[
{"role": "system", "content": "You are a concise assistant."},
{"role": "user", "content": "Give me a one-line introduction."}
],
stream=True # Enable streaming
)
# Print tokens as they arrive
for chunk in stream:
if chunk.choices[0].delta.content is not None:
print(chunk.choices[0].delta.content, end="")
print() # Newline at the end下面是对客户公开的站内辅助接口,用于购买、充值、查单、额度查询和 Key 管理。
List fixed recharge packages currently available for existing API keys.
GET /api/topup/packages{
"ok": true,
"data": [
{
"id": "pkg_100",
"code": "topup_100",
"name": "100 CNY package",
"currency": "CNY",
"priceCents": 10000,
"baseQuotaAmount": 6000000000,
"bonusQuotaAmount": 1000000000,
"quotaAmount": 7000000000
}
]
}Create a first-purchase order for a plan code and reserve delivery contact details.
{
"email": "[email protected]",
"planCode": "starter",
"sourcePage": "pricing"
}{
"ok": true,
"data": {
"orderNo": "BUY202604060930ABCD",
"amountCents": 29900,
"contactEmail": "[email protected]",
"payUrl": "/pricing/pay?orderNo=BUY202604060930ABCD&contactEmail=buyer%40example.com"
}
}Prepare a payment session for an existing first-purchase order.
{
"orderNo": "BUY202604060930ABCD",
"contactEmail": "[email protected]"
}{
"ok": true,
"data": {
"orderNo": "BUY202604060930ABCD",
"provider": "xunhupay",
"checkoutUrl": "https://pay.example.com/checkout/abc",
"qrcodeUrl": "https://pay.example.com/qrcode/abc"
}
}Query a first-purchase order by order number and contact email.
{
"orderNo": "BUY202604060930ABCD",
"contactEmail": "[email protected]"
}{
"ok": true,
"data": {
"orderNo": "BUY202604060930ABCD",
"status": "PAID",
"deliveryState": "DELIVERED",
"contactEmail": "[email protected]"
}
}Verify that an API key exists and can receive additional credits.
{
"apiKey": "sk-live_example"
}{
"ok": true,
"data": {
"tokenName": "Production Key",
"availableQuota": 5400000000,
"usedQuota": 1600000000,
"totalQuota": 7000000000
}
}Create a recharge order for an existing API key.
{
"apiKey": "sk-live_example",
"packageCode": "topup_100",
"contactEmail": "[email protected]",
"couponCode": "SPRING10"
}{
"ok": true,
"data": {
"orderNo": "TOP202604060935WXYZ",
"amountCents": 9000,
"contactEmail": "[email protected]",
"payUrl": "/topup/pay?orderNo=TOP202604060935WXYZ&contactEmail=buyer%40example.com"
}
}Prepare a payment session for an existing recharge order.
{
"orderNo": "TOP202604060935WXYZ",
"contactEmail": "[email protected]"
}{
"ok": true,
"data": {
"orderNo": "TOP202604060935WXYZ",
"provider": "xunhupay",
"checkoutUrl": "https://pay.example.com/checkout/topup"
}
}Query a recharge order by order number and contact email.
{
"orderNo": "TOP202604060935WXYZ",
"contactEmail": "[email protected]"
}{
"ok": true,
"data": {
"orderNo": "TOP202604060935WXYZ",
"status": "PAID",
"credited": true
}
}Return current credit totals and billing-derived balance information for an API key.
{
"apiKey": "sk-live_example"
}{
"ok": true,
"data": {
"tokenName": "Production Key",
"totalTokens": 7000000000,
"usedTokens": 1600000000,
"remainingTokens": 5400000000,
"responseTimeMs": 283
}
}Return usage log entries for an API key, including cache hit metadata and response times.
{
"apiKey": "sk-live_example"
}{
"ok": true,
"data": {
"items": [
{
"id": "log_01",
"modelName": "gpt-4o-mini",
"quota": 3200,
"hasCacheHit": false
}
],
"total": 1,
"truncated": false
}
}List API keys owned by the currently signed-in dashboard user.
GET /api/tokens{
"ok": true,
"items": [
{
"id": "key_01",
"displayName": "Default Key",
"maskedKey": "sk-****abcd",
"status": "ACTIVE"
}
]
}Create a new API key for the currently signed-in dashboard user.
{
"displayName": "Default Key"
}{
"ok": true,
"token": {
"id": "key_01",
"displayName": "Default Key",
"maskedKey": "sk-****abcd",
"status": "ACTIVE"
},
"plainKey": "sk-live_once_only"
}Disable an API key owned by the currently signed-in dashboard user.
PATCH /api/tokens/key_01/disable{
"ok": true,
"token": {
"id": "key_01",
"status": "REVOKED"
}
}Delete an API key owned by the currently signed-in dashboard user.
DELETE /api/tokens/key_01{
"ok": true
}| HTTP | 名称 | 含义 | 处理建议 |
|---|---|---|---|
400 | INVALID_REQUEST | Malformed JSON, invalid parameters, or unsupported request shape. | Validate the body and compare it with the OpenAI-compatible schema. |
401 | UNAUTHORIZED | Missing, expired, or invalid API key. | Check the Bearer token and verify the key still exists. |
429 | RATE_LIMIT | Too many requests were sent in a short time window. | Retry with backoff and reduce burst traffic. |
500 | UPSTREAM_ERROR | The upstream runtime or proxy returned an internal error. | Retry later and inspect status/monitoring if the issue persists. |
| 错误码 | HTTP | 含义 |
|---|---|---|
invalid_payload | 400 | The JSON body did not match the endpoint schema. |
purchase_order_create_failed | 400 | The first-purchase order could not be created. |
purchase_pay_failed | 400 | Payment session creation for a first purchase failed. |
purchase_order_not_found | 404 | No matching purchase order was found for the order number/email pair. |
topup_preview_failed | 400 | The target API key could not be verified for top-up. |
topup_order_create_failed | 400 | The recharge order could not be created. |
topup_pay_failed | 400 | Payment session creation for a recharge failed. |
topup_order_not_found | 404 | No matching top-up order was found for the order number/email pair. |
INVALID_KEY | 400 | The supplied API key was not accepted by the quota query backend. |
RATE_LIMIT | 500 | The quota query upstream is currently throttling requests. |
SERVER_ERROR | 500 | The quota query upstream is temporarily unavailable. |
| 类型 | 套餐 | 价格 | 原额度 | 赠送 | 到账总额 | 说明 |
|---|---|---|---|---|---|---|
| Purchase | 20 元首购套餐 | ¥20.00 | 1B | 0B | 1B | First-time package that provisions the initial API key after payment. |
| Purchase | 40 元首购套餐 | ¥40.00 | 2B | 0B | 2B | First-time package that provisions the initial API key after payment. |
| Purchase | 60 元首购套餐 | ¥60.00 | 3B | 0B | 3B | First-time package that provisions the initial API key after payment. |
| Purchase | 100 元首购套餐 | ¥100.00 | 5B | 1B | 6B | First-time package that provisions the initial API key after payment. |
| Purchase | 200 元首购套餐 | ¥200.00 | 10B | 2B | 12B | First-time package that provisions the initial API key after payment. |
| Purchase | 1000 元首购套餐 | ¥1,000.00 | 50B | 10B | 60B | First-time package that provisions the initial API key after payment. |
| Top up | 20 元充值套餐 | ¥20.00 | 1B | 0B | 1B | Recharge package for an existing API key. |
| Top up | 40 元充值套餐 | ¥40.00 | 2B | 0B | 2B | Recharge package for an existing API key. |
| Top up | 60 元充值套餐 | ¥60.00 | 3B | 0B | 3B | Recharge package for an existing API key. |
| Top up | 100 元充值套餐 | ¥100.00 | 5B | 1B | 6B | Recharge package for an existing API key. |
| Top up | 200 元充值套餐 | ¥200.00 | 10B | 2B | 12B | Recharge package for an existing API key. |
| Top up | 1000 元充值套餐 | ¥1,000.00 | 50B | 10B | 60B | Recharge package for an existing API key. |
上表来自当前仓库的套餐配置。若后续套餐、赠送策略或货币发生调整,应同步更新文档和购买页。