Tài liệu

Tích hợp Codex Gateway như OpenAI API.

Đổi base URL về gateway, gửi Bearer token của user và sử dụng các route OpenAI-compatible đang có.

Hướng dẫn quan trọng

Tài liệu hướng dẫn cấu hình vào Codex

Khách hàng có thể mở nhanh tài liệu này để cấu hình Codex dùng gateway, base URL và API key được cấp.

Xác thực

Mỗi request API cần header Authorization với token của user. Token có thể lấy sau khi khách hàng đăng ký/đăng nhập ở trang nạp quota.

Authorization: Bearer USER_API_TOKEN

Endpoints hỗ trợ

RouteMethodMục đích
/v1/modelsGETLấy danh sách model allowed.
/v1/responsesPOSTGọi Responses API.
/v1/responses/compactPOSTGọi compact responses nếu client cần.
/v1/chat/completionsPOSTTương thích Chat Completions.

Ví dụ Responses API

curl http://codex.dichvumang86.net/v1/responses \ -H "Authorization: Bearer USER_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-5.5", "input": "Viết một đoạn giới thiệu ngắn về sản phẩm." }'

Ví dụ Chat Completions

curl http://codex.dichvumang86.net/v1/chat/completions \ -H "Authorization: Bearer USER_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-5.5", "messages": [ {"role": "user", "content": "Xin chào"} ], "stream": true }'

Tính quota và usage

Gateway sẽ pre-consume quota trước khi gọi upstream nếu user token hợp lệ. Sau khi có usage thực tế, hệ thống tính lại chi phí theo input, output, cache read và hoàn/thu thêm quota nếu cần.

Input

Token người dùng gửi lên model.

Cache read

Token đọc từ cache với giá riêng.

Output

Token model sinh ra trong phần trả lời.