# Gọi request tới AI Gateway

Sau khi khởi tạo xong một AI Gateway, bạn có thể bắt đầu gửi request đến mô hình AI đã cấu hình theo các bước sau:

**Bước 1:** Truy cập [AI Gateway Portal](http://aigateway.console.vngcloud.vn/), tìm đến gateway mà bạn vừa tạo.

**Bước 2:** Trong mục **Providers & Model**, tìm mô hình AI bạn đã cấu hình. Tại mô hình đó, nhấn vào biểu tượng **Curl command** để lấy câu lệnh mẫu.

<figure><img src="/files/s1anC5CJXhNBpHmxRjD5" alt=""><figcaption></figcaption></figure>

**Bước 3:** Sao chép đoạn lệnh `curl` được hiển thị và thực thi lệnh đó trên máy tính cá nhân của bạn (qua Terminal hoặc Command Prompt).

<figure><img src="/files/LpbI2Agk9T4bxy9xurHW" alt=""><figcaption></figcaption></figure>

Ví dụ:

```bash
curl -X POST https://user-60108-gateway-0b50037b-93.ai-gateway.vngcloud.vn/deepseek/deepseek-chat/chat/completions \
     --header 'Authorization: Bearer {AUTHENTICATION_TOKEN}' \
     --header 'Content-Type: application/json' \
     --data '{
       "model": "deepseek-chat",
       "messages": [
         {
           "role": "user",
           "content": "What is AI?"
         }
       ]
     }'
```

**Lưu ý:**

* Thay thế `{AUTHENTICATION_TOKEN}` bằng token được cung cấp sau khi tạo Gateway.
* Bạn có thể chỉnh sửa nội dung của prompt (nội dung câu hỏi) trong phần `"content"` để phù hợp với mục đích sử dụng của mình.
* Nếu AI Gateway mà bạn đang sử dụng **được bật chế độ xác thực (Authenticated Gateway)**, bạn cần t**hêm một header tên là `cf-aig-authorization`** vào request HTTP của bạn.

Ví dụ, thay vì dùng header thông thường kiểu:

```http
Authorization: Bearer {AUTHENTICATION_TOKEN}
```

Bạn phải dùng:

```http
cf-aig-authorization: Bearer {AUTHENTICATION_TOKEN}
```

Sau khi thực hiện, bạn sẽ nhận được phản hồi từ mô hình AI theo đúng định dạng JSON.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.vngcloud.vn/vng-cloud-document/vn/ai-stack/ai-gateway/ai-gateway/goi-request-toi-ai-gateway.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
