Ví dụ về cuộc gọi curl
Ví dụ về cuộc gọi curl
Ví dụ dưới đây là một cách nhanh chóng để kiểm tra xem API PuLu AI có đáp ứng đúng không. Thay thế {此处填写ApiKey} bằng Key API mà bạn đã tạo trong bảng điều khiển.
Tips
Windows PowerShell dùng dấu ngoặc kép, macOS và Linux dùng dấu gạch chéo ngược. Ba cách viết hoàn toàn giống nhau.
Giao diện OpenAI Responses
Windows PowerShell
curl.exe https://www.puluai.com/v1/responses `
-H "Content-Type: application/json" `
-H "Authorization: Bearer {此处填写ApiKey}" `
-d '{
"model": "gpt-5.2",
"input": [
{
"type": "message",
"role": "user",
"content": [
{
"type": "input_text",
"text": "你好"
}
]
}
],
"stream": true
}'macOS
curl https://www.puluai.com/v1/responses \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer {此处填写ApiKey}' \
-d '{
"model": "gpt-5.2",
"input": [
{
"type": "message",
"role": "user",
"content": [
{
"type": "input_text",
"text": "你好"
}
]
}
],
"stream": true
}'Linux
curl https://www.puluai.com/v1/responses \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer {此处填写ApiKey}' \
-d '{
"model": "gpt-5.2",
"input": [
{
"type": "message",
"role": "user",
"content": [
{
"type": "input_text",
"text": "你好"
}
]
}
],
"stream": true
}'Giao diện Chat Completions
Windows PowerShell
curl.exe https://www.puluai.com/v1/chat/completions `
-H "Content-Type: application/json" `
-H "Authorization: Bearer {此处填写ApiKey}" `
-d '{
"model": "gpt-5.2",
"messages": [
{
"role": "user",
"content": "你好"
}
],
"stream": true
}'macOS
curl https://www.puluai.com/v1/chat/completions \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer {此处填写ApiKey}' \
-d '{
"model": "gpt-5.2",
"messages": [
{
"role": "user",
"content": "你好"
}
],
"stream": true
}'Linux
curl https://www.puluai.com/v1/chat/completions \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer {此处填写ApiKey}' \
-d '{
"model": "gpt-5.2",
"messages": [
{
"role": "user",
"content": "你好"
}
],
"stream": true
}'Thông tin
Câu trả lời của /v1/chat/completions được chuyển đổi bởi /v1/responses và có thể có sự khác biệt về tương thích giữa một số phần mềm hoặc plugin. Khi yêu cầu khả năng tương thích và bộ nhớ đệm tối ưu, ưu tiên sử dụng cấu hình được khuyến cáo cho công cụ.
Giao diện Claude Messages
Windows PowerShell
curl.exe https://www.puluai.com/v1/messages `
-H "Content-Type: application/json" `
-H "x-api-key: {此处填写ApiKey}" `
-d '{
"model": "claude-sonnet-4-5-20250929",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "你好",
"cache_control": { "type": "ephemeral" }
}
]
}
],
"max_tokens": 32000,
"stream": true
}'macOS
curl https://www.puluai.com/v1/messages \
-H 'Content-Type: application/json' \
-H 'x-api-key: {此处填写ApiKey}' \
-d '{
"model": "claude-sonnet-4-5-20250929",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "你好",
"cache_control": { "type": "ephemeral" }
}
]
}
],
"max_tokens": 32000,
"stream": true
}'Linux
curl https://www.puluai.com/v1/messages \
-H 'Content-Type: application/json' \
-H 'x-api-key: {此处填写ApiKey}' \
-d '{
"model": "claude-sonnet-4-5-20250929",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "你好",
"cache_control": { "type": "ephemeral" }
}
]
}
],
"max_tokens": 32000,
"stream": true
}'Đầu yêu cầu xác thực tương thích với Authorization và x-api-key, có thể được lựa chọn tùy theo yêu cầu của khách hàng.
Giao diện Gemini
Windows PowerShell
curl.exe --location "https://www.puluai.com/v1beta/models/gemini-3-pro-preview:streamGenerateContent?alt=sse" `
--header "connection: keep-alive" `
--header "x-goog-api-key: {此处填写ApiKey}" `
--header "content-type: application/json" `
--data '{
"generationConfig": {
"temperature": 1
},
"contents": [
{
"role": "user",
"parts": [
{
"text": "你好"
}
]
}
]
}'macOS
curl --location 'https://www.puluai.com/v1beta/models/gemini-3-pro-preview:streamGenerateContent?alt=sse' \
--header 'connection: keep-alive' \
--header 'x-goog-api-key: {此处填写ApiKey}' \
--header 'content-type: application/json' \
--data '{
"generationConfig": {
"temperature": 1
},
"contents": [
{
"role": "user",
"parts": [
{
"text": "你好"
}
]
}
]
}'Linux
curl --location 'https://www.puluai.com/v1beta/models/gemini-3-pro-preview:streamGenerateContent?alt=sse' \
--header 'connection: keep-alive' \
--header 'x-goog-api-key: {此处填写ApiKey}' \
--header 'content-type: application/json' \
--data '{
"generationConfig": {
"temperature": 1
},
"contents": [
{
"role": "user",
"parts": [
{
"text": "你好"
}
]
}
]
}'