Xác thực (Authentication)
Cách lấy và sử dụng API Key để truy cập BizCity API.
API Key Format
API Key của BizCity có định dạng:
text
biz-<32 hex characters> Ví dụ: biz-a1b2c3d4e5f678901234567890abcdef
⚠️ Bảo mật API Key
API Key của bạn là credentials nhạy cảm. Không bao giờ chia sẻ hoặc hardcode trong client-side code. Luôn sử dụng biến môi trường hoặc WordPress options.
Cách sử dụng
Gửi API Key trong header Authorization với prefix Bearer:
bash
curl https://bizgpt.vn/wp-json/bizcity/v1/llm/models \ -H "Authorization: Bearer biz-YOUR_API_KEY"
Python (OpenAI SDK)
python
from openai import OpenAI client = OpenAI( base_url="https://bizgpt.vn/wp-json/bizcity/v1/llm", api_key="biz-YOUR_API_KEY", ) response = client.chat.completions.create( model="deepseek/deepseek-chat-v3-0324:free", messages=[ {"role": "user", "content": "Hello!"} ] ) print(response.choices[0].message.content)
Node.js
javascript
import OpenAI from "openai"; const client = new OpenAI({ baseURL: "https://bizgpt.vn/wp-json/bizcity/v1/llm", apiKey: "biz-YOUR_API_KEY", }); const response = await client.chat.completions.create({ model: "deepseek/deepseek-chat-v3-0324:free", messages: [ { role: "user", content: "Hello!" } ], }); console.log(response.choices[0].message.content);
PHP (WordPress)
php
$response = wp_remote_post( 'https://bizgpt.vn/wp-json/bizcity/v1/llm/chat', [ 'headers' => [ 'Authorization' => 'Bearer ' . $api_key, 'Content-Type' => 'application/json', ], 'body' => wp_json_encode( [ 'model' => 'deepseek/deepseek-chat-v3-0324:free', 'messages' => [ [ 'role' => 'user', 'content' => 'Xin chào!' ], ], ] ), 'timeout' => 60, ] ); $body = json_decode( wp_remote_retrieve_body( $response ), true ); echo $body['choices'][0]['message']['content'];
Lấy API Key
Để lấy API Key, bạn cần:
- Đăng ký tài khoản tại bizcity.vn
- Vào Dashboard → API Keys
- Nhấn "Tạo API Key mới"
- Lưu lại key — key chỉ hiển thị một lần
Bảo mật
| Thuộc tính | Chi tiết |
|---|---|
| Format | biz-<32 hex> |
| Lưu trữ server | SHA256 hash — không lưu plaintext |
| Domain lock | Tùy chọn giới hạn domain được phép |
| Rate limit | Theo tier (Free → Enterprise) |







