Skip to content

Commit dcd20eb

Browse files
nhilth-vngcloudgitbook-bot
authored andcommitted
GITBOOK-1482: No subject
1 parent a997c32 commit dcd20eb

File tree

2 files changed

+13
-74
lines changed

2 files changed

+13
-74
lines changed

Vietnamese/ai-stack/ai-platform/bat-dau-voi-ai-platform.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ Truy cập vào phần [API Keys](https://aiplatform.console.vngcloud.vn/keys) t
4040

4141
Sau khi hoàn thành các bước trên, API key của bạn sẽ được tạo và hiển thị trong danh sách
4242

43+
#### Lấy API Key 
44+
4345
Bạn có thể xem và sao chép API key bằng cách:
4446

4547
1. Nhấn nào biểu tượng ︙ở cột "Hành động"

Vietnamese/ai-stack/ai-platform/inference.md

Lines changed: 11 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -47,77 +47,14 @@ Tính năng **Inference** giúp bạn triển khai mô hình AI thành một d
4747

4848
## Hướng dẫn serving endpoint
4949

50-
Tài liệu này hướng dẫn bạn cách **gọi Inference Endpoint vừa tạo** thông qua việc xác thực bằng Service Account và thực hiện inference chuẩn OpenAI-like API (đặc biệt hữu ích với GenAI models).
51-
52-
### **Bước 1: Tạo Service Account có quyền với AI Platform**
53-
54-
1. Truy cập vào trang quản lý **IAM** trong hệ thống VNG Cloud.
55-
2. Tạo một **Service Account** mới.
56-
3. Gán quyền truy cập **AI Platform** (ví dụ: `aiplatform.viewer`, `aiplatform.user` hoặc cao hơn tùy nhu cầu).
57-
4. Sau khi tạo thành công, bạn sẽ nhận được:
58-
* `client_id`
59-
* `client_secret`
60-
61-
> 🔐 Hai thông tin này sẽ được dùng để lấy `access_token` nhằm xác thực khi gọi Inference API.
62-
63-
Tham khảo hướng dẫn tạo Service Account [tại đây](https://docs.vngcloud.vn/vng-cloud-document/vn/identity-and-access-management-iam/cac-loai-dinh-danh-iam/tai-khoan-service-accounts).
64-
65-
### **Bước 2: Lấy Access Token**
66-
67-
Đầu tiên, mã hóa `client_id``client_secret` theo chuẩn Base64 theo định dạng:base64("client\_id:client\_secret")
68-
69-
**Ví dụ**
70-
71-
```sh
72-
echo -n "a5d532c8-38ac-445f-b06c-cd54b2d68f67:1910628f-57b7-42b8-8f9e-e148866fd407" | base64 -w 0
73-
74-
output >> YTVkNTMyYzgtMzhhYy00NDVmLWIwNmMtY2Q1NGIyZDY4ZjY3OjE5MTA2MjhmLTU3YjctNDJiOC04ZjllLWUxNDg4NjZmZDQwNw==
75-
```
76-
77-
**Thực hiện lệnh `curl` để lấy token**
78-
79-
```sh
80-
curl --location 'https://iamapis.vngcloud.vn/accounts-api/v2/auth/token' \
81-
--header 'Authorization: Basic YTVkNTMyYzgtMzhhYy00NDVmLWIwNmMtY2Q1NGIyZDY4ZjY3OjE5MTA2MjhmLTU3YjctNDJiOC04ZjllLWUxNDg4NjZmZDQwNw==' \
82-
--header 'Content-Type: application/json' \
83-
--data '{
84-
"grant_type":"client_credentials",
85-
"scope":"email"
86-
}'
87-
```
88-
89-
**Kết quả trả về**
90-
91-
```sh
92-
{
93-
  "token_type": "Bearer",
94-
  "access_token": "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJlckVaZFpkNkRsc21pdjhsMDZIaVB3bHZYWnotLVlGYXlZcVJiczlxc09rIn0",
95-
  "expires_in": 1800,
96-
  "refresh_expires_in": 0
97-
}
98-
```
99-
100-
### Bước 3: Gọi Inference với Access Token
101-
102-
Sau khi đã có `access_token`, bạn có thể gọi API để thực hiện inference theo mẫu sau, inference theo chuẩn của openai.
103-
104-
```sh
105-
curl -X POST "https://inference-aiplatform-hcm.api.vngcloud.vn/v1/<endpoint-id>/v1/chat/completions" \
106-
  -H "Content-Type: application/json" \
107-
  -H "Authorization: Bearer <access_token>" \
108-
  -d '{
109-
    "model": "<model name>",
110-
    "messages": [
111-
      {
112-
        "role": "system",
113-
        "content": "assistant"
114-
      },
115-
      {
116-
        "role": "user",
117-
        "content": "How are you"
118-
      }
119-
    ],
120-
    "temperature": 0.7,
121-
    "max_tokens": 500
122-
}'
123-
```
50+
Tài liệu này hướng dẫn bạn cách **gọi Inference Endpoint vừa tạo** thông qua việc xác thực bằng API Key
51+
52+
### **Bước 1: Lấy API Key**
53+
54+
### **Bước 2: Lấy Endpoint URL**
55+
56+
57+
58+
### Bước 3: Gọi Inference&#x20;
59+
60+
Sau khi đã có API Key, bạn có thể gọi API để thực hiện inference.

0 commit comments

Comments
 (0)