logo apicheap.store Online Gateway
Vào Portal Quản trị →
TÀI LIỆU KỸ THUẬT & TÍCH HỢP HỆ THỐNG

Tài liệu kết nối API apicheap.store Trực Tuyến

Cổng API AI đám mây tốc độ cao, hỗ trợ chuẩn OpenAI & Anthropic Claude cho mọi CLI và ứng dụng.

Khuyến khích tạo và sử dụng Combo định tuyến để tự động chuyển tiếp model dự phòng khi có sự cố, giúp công việc của bạn luôn thông suốt và ổn định.

🌐 Cổng Online 100%: https://apicheap.store
⚠️
🔹 Cách 1: Dùng Model lẻ (Đơn giản nhất - Dùng được ngay)

Điền trực tiếp bất kỳ mã model đối tác nào có trong tài khoản của bạn (ví dụ: cxs/gpt-6-sol, claude-3-5-sonnet... xem danh sách đầy đủ tại tab "Mô hình AI"). Cách này không cần tạo combo, điền vào là chạy ngay.

⚡ Cách 2: Dùng Bộ Combo (Tự động đổi model dự phòng khi lỗi)

BẮT BUỘC PHẢI TẠO COMBO TRƯỚC: Bạn phải vào tab "Bộ combo" ➔ Bấm "Tạo combo mới" (đặt tên ví dụ là smart-live-combo hoặc tên tùy thích) ➔ Chọn các model dự phòng mong muốn ➔ Bấm "Lưu lại". Sau khi đã tạo combo trong tài khoản thì mới điền tên combo vào cấu hình.

⚠️
🔹 Option 1: Use Standalone Model (Simplest - Instant)

Directly specify any partner model ID available in your account (e.g. cxs/gpt-6-sol, claude-3-5-sonnet... see full list in "AI Models" tab). No combo needed, ready to run instantly.

⚡ Option 2: Use a Combo (Automatic failover on error)

YOU MUST CREATE THE COMBO FIRST: Go to "Combos" tab ➔ Click "Create Combo" (e.g. name it smart-live-combo or any name) ➔ Select fallback models ➔ Click "Save". Only enter this combo name into your configuration after saving it.

🚀 Thiết lập tự động 1-Click cho Windows (Khuyên dùng)

Chạy lệnh sau trong PowerShell để tự động chọn Model/Combo, lưu biến môi trường User vĩnh viễn và cấu hình Codex App / CLI:

📥 Tải setup.ps1 📥 Tải setup.bat
irm https://apicheap.store/setup.ps1 | iex 📋 Sao chép lệnh PowerShell
Hoặc nếu dùng CMD thông thường (Command Prompt):
curl.exe -fsSL https://apicheap.store/setup.bat -o setup.bat && setup.bat 📋 Sao chép lệnh CMD
🤖 Claude Code CLI trên Windows

Thiết lập thủ công bằng PowerShell nếu không chạy script tự động:

Cài đặt biến môi trường User (Chỉ cần chạy 1 lần):
[System.Environment]::SetEnvironmentVariable('ANTHROPIC_BASE_URL', 'https://apicheap.store', 'User')
[System.Environment]::SetEnvironmentVariable('ANTHROPIC_AUTH_TOKEN', 'sk-YOUR_API_KEY', 'User')
# Lưu ý: Thay 'smart-live-combo' bằng tên combo bạn đã tạo (tab 'Bộ combo') hoặc mã model lẻ (tab 'Mô hình AI')
[System.Environment]::SetEnvironmentVariable('ANTHROPIC_MODEL', 'smart-live-combo', 'User')
Khởi chạy Claude trong Terminal mới:
claude Sao chép
💻 OpenAI Codex App & CLI trên Windows

Đường dẫn file: %USERPROFILE%\.codex\config.toml

model = "smart-live-combo"
model_provider = "quotarouter"

[model_providers.quotarouter]
name = "apicheap.store"
base_url = "https://apicheap.store/v1"
env_key = "OPENAI_API_KEY"
wire_api = "responses"
http_headers = { Authorization = "Bearer sk-YOUR_API_KEY" }

[agents.subagent]
model = "smart-live-combo"
Cài đặt API Key trong PowerShell:
[System.Environment]::SetEnvironmentVariable('OPENAI_API_KEY', 'sk-YOUR_API_KEY', 'User')
File đăng nhập auth.json (bắt buộc để Codex App nhận trạng thái Đã đăng nhập):

Đường dẫn: %USERPROFILE%\.codex\auth.json

{
  "auth_mode": "apikey",
  "OPENAI_API_KEY": "sk-YOUR_API_KEY"
}

Hoặc đăng nhập nhanh bằng lệnh:

echo sk-YOUR_API_KEY | codex login --with-api-key 📋 Sao chép
👁️ Hỗ trợ Vision & Đọc Ảnh Trực Tiếp Đã kiểm thử 100% OK

Server hỗ trợ xử lý hình ảnh xuyên suốt cả 2 chuẩn giao thức Anthropic và OpenAI:

  • Anthropic Base64: Chuẩn {"type": "image", "source": {"type": "base64", "media_type": "image/png", "data": "..."}}.
  • OpenAI Image URL: Chuẩn {"type": "image_url", "image_url": {"url": "data:image/png;base64,..."}} hoặc link ảnh HTTP.
  • Trải nghiệm thực tế: Trong Claude Code CLI, Cursor, hoặc Codex, bạn có thể dán ảnh chụp màn hình UI, kéo thả ảnh diagram để AI phân tích lỗi CSS/layout và đọc tài liệu dạng ảnh.
  • Model hỗ trợ Vision tốt nhất: smart-live-combo, claude-3-5-sonnet, gpt-4o, gemini-2.5-flash.
  • Anthropic Base64: the {"type": "image", "source": {"type": "base64", "media_type": "image/png", "data": "..."}} shape.
  • OpenAI Image URL: the {"type": "image_url", "image_url": {"url": "data:image/png;base64,..."}} shape, or a plain HTTP image link.
  • In practice: inside Claude Code CLI, Cursor or Codex you can paste a UI screenshot or drop a diagram so the AI analyses CSS/layout bugs and reads image-based documents.
  • Best Vision models: smart-live-combo, claude-3-5-sonnet, gpt-4o, gemini-2.5-flash.
🛠️ Tool Calling, Function Calling & Sửa File Đã kiểm thử 100% OK

Đảm bảo các tác vụ lập trình tự động của Claude Code CLI và Codex hoạt động chuẩn xác:

  • Anthropic Tool Use: Chuyển đổi hai chiều giữa schema input_schema của Claude và parameters OpenAI, trả về stop_reason: "tool_use" đúng đặc tả.
  • Đọc, ghi và thay thế file: Các công cụ như edit_file, replace_file, read_file, bash, grep hoạt động mượt mà, không gặp lỗi HTTP 500/400.
  • Subagent & Codex wire_api: Hỗ trợ luồng responses và function calls giúp Codex tự động phân rã tác vụ con và commit code.
  • Anthropic Tool Use: two-way conversion between Claude's input_schema and OpenAI parameters, returning stop_reason: "tool_use" per spec.
  • Read, write and replace files: tools such as edit_file, replace_file, read_file, bash and grep run smoothly, without HTTP 500/400 errors.
  • Subagent & Codex wire_api: the responses flow and function calls let Codex break work into subtasks and commit code automatically.
🔄 Hướng dẫn ĐỔI MODEL HOẶC COMBO bất kỳ lúc nào

Sau khi setup xong, bạn hoàn toàn có thể tự do đổi qua lại giữa các Combo hoặc Model lẻ khác nhau một cách linh hoạt:

1. Đổi trong Claude Code CLI:
  • Cách 1 (Khi khởi chạy): Thêm tham số --model:
    claude --model smart-live-combo hoặc claude --model claude-3-5-sonnet
  • Cách 2 (Đang chat trong Claude): Gõ lệnh trực tiếp:
    /model rồi gõ tên model muốn đổi (ví dụ: smart-live-combo hoặc claude-3-5-sonnet).
  • Cách 3 (Đổi mặc định): Chạy lại lệnh setup tự động 1-Click và chọn model mới.
  • Option 1 (at launch): add the --model flag:
    claude --model smart-live-combo or claude --model claude-3-5-sonnet
  • Option 2 (while chatting): type the command directly:
    /model, then the model name you want (for example smart-live-combo or claude-3-5-sonnet).
  • Option 3 (change the default): run the 1-click setup again and pick a new model.
2. Đổi trong OpenAI Codex App & CLI:
  • Cách 1 (Codex CLI): Thêm cờ -m khi chạy lệnh:
    codex -m smart-live-combo hoặc codex -m gpt-4o
  • Cách 2 (Codex Desktop App): Bấm vào thanh chọn Model ở góc dưới màn hình và chọn model bạn muốn.
  • Cách 3 (Sửa config): Mở file ~/.codex/config.toml và sửa dòng:
    model = "tên_model_mới"
  • Option 1 (Codex CLI): add the -m flag when running the command:
    codex -m smart-live-combo or codex -m gpt-4o
  • Option 2 (Codex Desktop App): click the Model selector at the bottom of the window and choose the model you want.
  • Option 3 (edit the config): open ~/.codex/config.toml and change the line:
    model = "new_model_name"
🎯 Cấu hình Cursor / Windsurf / VS Code (Continue, Roo Code)

Chọn nhà cung cấp OpenAI Compatible và điền thông số sau:

Pick OpenAI Compatible as the provider and fill in these values:

Base URL: https://apicheap.store/v1

API Key: sk-YOUR_API_KEY

Model Name: smart-live-combo, claude-3-5-sonnet, gpt-4o

🐍 Mẫu kết nối Python (OpenAI SDK)
from openai import OpenAI

client = OpenAI(
    base_url="https://apicheap.store/v1",
    api_key="sk-YOUR_API_KEY"
)

# Chế độ Stream (Thời gian thực)
response = client.chat.completions.create(
    model="smart-live-combo",
    messages=[
        {"role": "system", "content": "Bạn là chuyên gia viết kịch bản kịch tính."},
        {"role": "user", "content": "Viết đoạn mở đầu câu chuyện kinh dị bí ẩn."}
    ],
    stream=True
)

for chunk in response:
    content = chunk.choices[0].delta.content or ""
    print(content, end="", flush=True)
🔌 Tham chiếu HTTP API (endpoint thật trong server)

Các endpoint dưới đây là route CÓ THẬT trong server. Base URL: https://apicheap.store

Header xác thực — server chấp nhận 1 trong 3 dạng:
x-api-key: sk-YOUR_API_KEY
anthropic-api-key: sk-YOUR_API_KEY
Authorization: Bearer sk-YOUR_API_KEY
Biến môi trường cho SDK / CLI trỏ về:
OPENAI_BASE_URL=https://apicheap.store/v1
OPENAI_API_KEY=sk-YOUR_API_KEY
ANTHROPIC_BASE_URL=https://apicheap.store
ANTHROPIC_AUTH_TOKEN=sk-YOUR_API_KEY
1) Liệt kê model khả dụng

GET /v1/models — BẮT BUỘC kèm API key hợp lệ; thiếu key hoặc key đã tắt sẽ nhận 401.

curl https://apicheap.store/v1/models \
  -H "x-api-key: sk-YOUR_API_KEY"
2) Chat Completions (chuẩn OpenAI)

POST /v1/chat/completions — thêm "stream": true để nhận SSE theo thời gian thực.

curl https://apicheap.store/v1/chat/completions \
  -H "Authorization: Bearer sk-YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "smart-live-combo",
    "messages": [
      {"role": "user", "content": "Hello"}
    ]
  }'
3) Messages (chuẩn Anthropic Claude)

POST /v1/messages — bắt buộc có max_tokens; nên gửi kèm anthropic-version cho đúng đặc tả Anthropic.

curl https://apicheap.store/v1/messages \
  -H "x-api-key: sk-YOUR_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "smart-live-combo",
    "max_tokens": 256,
    "messages": [
      {"role": "user", "content": "Hello"}
    ]
  }'
4) Responses (chuẩn OpenAI Codex)

POST /v1/responses — Codex App / CLI dùng wire_api = "responses" để gọi route này.

curl https://apicheap.store/v1/responses \
  -H "Authorization: Bearer sk-YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "smart-live-combo",
    "input": "Hello"
  }'
5) Đếm token (ước lượng)

POST /v1/messages/count_tokens — trả input_tokens ước lượng, không gọi model nên không tốn phí.

curl https://apicheap.store/v1/messages/count_tokens \
  -H "x-api-key: sk-YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "smart-live-combo",
    "messages": [{"role": "user", "content": "Hello"}]
  }'
Tóm tắt nhanh theo từng hệ client:
Hạng mục OpenAI / Codex Claude / Anthropic OpenClaw
Base URL https://apicheap.store/v1 https://apicheap.store (không /v1) https://apicheap.store/v1
Header xác thực Authorization: Bearer sk-... x-api-key: sk-... Authorization: Bearer sk-...
Endpoint chính /v1/chat/completions, /v1/responses /v1/messages /v1/chat/completions
Model gợi ý smart-live-combo claude-3-5-sonnet gpt-4o
Kiểm tra nhanh OpenClaw:
openclaw infer model run --local --json \
  --model smart-live-combo --prompt "hello"
📦 Tên model hợp lệ

Dùng API key của bạn để gọi GET /v1/models: danh sách gồm combo của tài khoản bạn và model lẻ mà key được phép gọi. Model lẻ của đối tác là danh mục chung, không phải model riêng do từng tài khoản tạo.

Ví dụ combo bạn đã tạo trong tài khoản: smart-live-combo
Model lẻ tham khảo: claude-3-5-sonnet, gpt-4o, gemini-2.5-flash
TÊN MODEL / COMBO LOẠI DÙNG CHO
smart-live-combo Combo Đa dụng, tự dự phòng khi một model lỗi
claude-3-5-sonnet Model lẻ Lập trình, sửa file, tool calling
gpt-4o Model lẻ Suy luận sâu, tác vụ phức tạp
gemini-2.5-flash Model ngoài Vision & đọc ảnh tốc độ cao
⚠️ Mã lỗi thường gặp

Lỗi trả về đúng hình dạng của từng giao thức (OpenAI hoặc Anthropic) để SDK tự hiểu.

MÃ Ý NGHĨA CÁCH XỬ LÝ
400 JSON body không hợp lệ hoặc thiếu trường bắt buộc. Với /v1/messages phải có max_tokens; kiểm tra body là JSON hợp lệ.
401 Thiếu API key, hoặc key không hợp lệ / đã bị vô hiệu hoá. Kiểm tra biến môi trường: giá trị phải bắt đầu bằng sk- và key còn hoạt động trong Portal.
404 Model không tồn tại hoặc chưa được kích hoạt. Gọi GET /v1/models để lấy đúng tên model đang bật cho tài khoản của bạn.
429 Vượt giới hạn tốc độ (rate limit). Đọc header retry-after rồi thử lại; giảm số luồng chạy song song.
502 Lỗi từ upstream (nhà cung cấp). Thử lại; nếu dùng combo, hệ thống tự dự phòng sang tài khoản khác.
503 Model đang tạm dừng hoặc đang bảo trì. Đổi sang model/combo khác, hoặc xem trạng thái trong Portal.