AAPIHubapi gateway reseller

Tài liệu API

Một API key, endpoint tương thích OpenAI

APIHub cung cấp gateway non-streaming cho chat completions. Tài liệu và danh sách model bên dưới lấy trực tiếp từ database; key trong ví dụ chỉ là placeholder.

Base URL

Mọi request gateway dùng Bearer API key. Không gửi key thật trong tài liệu hoặc mã nguồn công khai.

https://apihub-api.apihubvn.workers.dev
GET /v1/modelsPOST /v1/chat/completionsKhông hỗ trợ stream: true

Ví dụ curl

Thay ah_live_REPLACE_WITH_YOUR_KEY bằng key tạo trong dashboard. Không dùng key thật trong tài liệu.

curl -X POST "https://apihub-api.apihubvn.workers.dev/v1/chat/completions" \
  -H "Authorization: Bearer ah_live_REPLACE_WITH_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "your-model",
    "messages": [
      {"role": "user", "content": "Xin chào APIHub"}
    ],
    "stream": false
  }'

Response mock và live

Mock mode

  • • Nội dung có nhãn [MOCK].
  • • Header X-ApiHub-Mode: mock.
  • • Token ước lượng, lưu tokenSource ESTIMATED.

Live mode

  • • Chuyển tiếp tới upstream bằng key server-side.
  • • Header X-ApiHub-Mode: live.
  • • Upstream lỗi trả 502, không fallback mock.

Danh sách model

Dùng đúng slug trong trường model. Giá chi tiết xem tại bảng giá.

Lỗi thường gặp

HTTPCodeÝ nghĩa
400invalid_request / stream_not_supportedBody sai hoặc dùng streaming.
401missing_api_key / invalid_api_keyThiếu, sai hoặc key đã thu hồi.
402insufficient_balanceSố dư phải lớn hơn 0.
403account_bannedTài khoản đang bị khóa.
404model_not_foundModel không tồn tại hoặc đang tắt.
429rate_limit_exceededVượt giới hạn mỗi phút của key.
502upstream_errorUpstream lỗi; gateway không tự chuyển mock.