📘 使用文档

本服务提供 OpenAI 兼容的 API 接口,标准 OpenAI SDK / 客户端可直接接入。

1. 基本信息

API 地址(Base URL)https://trelayai.com/v1(部署后以实际为准)
认证方式请求头 x-api-key: tp_xxxxxxxx
或 Authorization: Bearer tp_xxxxxxxx(OpenAI SDK 默认方式)
支持功能Chat Completions(普通 + 流式 stream)、模型列表、余额查询

2. 快速开始(Python · OpenAI SDK)

from openai import OpenAI

client = OpenAI(
    api_key="tp_xxxxxxxx",                            # 你的 API Key
    base_url="https://trelayai.com/v1",              # 本站地址
)

response = client.chat.completions.create(
    model="模型名",                                    # 用 /v1/models 查询可用模型
    messages=[{"role": "user", "content": "Hello!"}],
    stream=True,                                       # 支持流式输出
)

for chunk in response:
    print(chunk.choices[0].delta.content or "", end="")

3. 快速开始(curl)

curl https://trelayai.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer tp_xxxxxxxx" \
  -d '{"model":"模型名","messages":[{"role":"user","content":"Hello"}]}'

4. 常用接口

接口方法说明
/v1/chat/completionsPOST对话补全(支持 stream)
/v1/modelsGET可用模型列表
/customer/balanceGET查询余额
curl https://trelayai.com/customer/balance -H "x-api-key: tp_xxxxxxxx"

5. 充值

购买充值码:请发送邮件至 punamdew297@gmail.com,注明金额,支持 USDT / 微信 / 支付宝。付款后你会收到充值码,在充值页面输入 API Key 和充值码,余额即时到账,7×24 小时自助完成。

前往充值 →

6. 注意事项

· 请妥善保管 API Key,泄露请立即联系管理员重置
· 余额不足时 API 会返回 402 错误
· 计费按上游返回的实际 token 用量计算,精确到 micro-USD
· 接口兼容 OpenAI 格式,任何支持自定义 Base URL 的客户端软件均可使用

📘 Documentation

OpenAI-compatible API. Standard OpenAI SDKs and clients work out of the box.

1. Basics

Base URLhttps://trelayai.com/v1 (final URL after deployment)
AuthenticationHeader x-api-key: tp_xxxxxxxx
or Authorization: Bearer tp_xxxxxxxx (default for OpenAI SDK)
FeaturesChat Completions (non-stream + stream), model listing, balance query

2. Quick Start (Python · OpenAI SDK)

from openai import OpenAI

client = OpenAI(
    api_key="tp_xxxxxxxx",                        # your API key
    base_url="https://trelayai.com/v1",     # this service
)

response = client.chat.completions.create(
    model="model-name",                           # list via /v1/models
    messages=[{"role": "user", "content": "Hello!"}],
    stream=True,                                  # streaming supported
)

for chunk in response:
    print(chunk.choices[0].delta.content or "", end="")

3. Quick Start (curl)

curl https://trelayai.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer tp_xxxxxxxx" \
  -d '{"model":"model-name","messages":[{"role":"user","content":"Hello"}]}'

4. Endpoints

EndpointMethodDescription
/v1/chat/completionsPOSTChat completions (stream supported)
/v1/modelsGETList available models
/customer/balanceGETQuery your balance
curl https://trelayai.com/customer/balance -H "x-api-key: tp_xxxxxxxx"

5. Top-up

To purchase a recharge code, email punamdew297@gmail.com with your desired amount. We accept USDT, WeChat Pay, and Alipay. After payment you will receive a code; redeem it on the redeem page and your balance is credited instantly.

Redeem a code →

6. Notes

· Keep your API key safe; contact the admin immediately if leaked
· HTTP 402 is returned when balance is insufficient
· Billing is based on actual token usage reported by upstream, in micro-USD precision
· Fully OpenAI-compatible: any client supporting a custom Base URL works