Source: https://ailoot.ai/docs/zh-hant-tw/connect/curl/
Canonical: https://ailoot.ai/docs/zh-hant-tw/connect/curl/
Language: zh-hant-tw

[連線設定](https://ailoot.ai/docs/zh-hant-tw/) 

# HTTP 請求 (curl)

[Markdown](https://ailoot.ai/docs/zh-hant-tw/connect/curl/index.md)

不使用 SDK 呼叫 API：任何能傳送 HTTP 請求的語言與工具皆可使用。

所有請求都傳送至`https://api.ailoot.ai` ，使用 HTTPS，主體為 JSON (上傳檔案時使用 multipart)。金鑰放在其中一個授權標頭中。

金鑰放在變數中

```bash
export AILOOT_API_KEY="sk-..."
```

## [](https://ailoot.ai/docs/zh-hant-tw/connect/curl/#chat)OpenAI Chat Completions

```bash
curl https://api.ailoot.ai/v1/chat/completions \
  -H "Authorization: Bearer $AILOOT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-5-5",
    "messages": [
      {"role": "user", "content": "用兩句話解釋 API 是什麼。"}
    ]
  }' 
```

## [](https://ailoot.ai/docs/zh-hant-tw/connect/curl/#stream)串流回應

旗標`-N`會停用 curl 的緩衝，讓事件一抵達就立即顯示。每個事件以此開頭：`data:`，串流則以此行結束：`data: [DONE]`。

Ailoot 會在費用計算完成後傳回付費文字回應。因此，使用`stream: true`時，格式仍是串流 (SSE)，但文字會在模型完成後以單一區塊傳回，而非逐字傳回。若回應準備時間超過約 15 秒，Chat Completions、Responses與Messages 串流會先傳送服務訊息`: ping` (約每 10 秒一次)，接著傳送`: ailoot-charged-usd …` ，其中包含扣款金額，最後傳送實際資料。SDK 會略過這類服務訊息。

```bash
curl -N https://api.ailoot.ai/v1/chat/completions \
  -H "Authorization: Bearer $AILOOT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "deepseek-v4-pro", "stream": true,
       "messages": [{"role": "user", "content": "數到五"}]}' 
```

## [](https://ailoot.ai/docs/zh-hant-tw/connect/curl/#responses)OpenAI Responses

```bash
curl https://api.ailoot.ai/v1/responses \
  -H "Authorization: Bearer $AILOOT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "gpt-6.1-sol", "input": "為同事的生日擬一段祝酒詞"}' 
```

## [](https://ailoot.ai/docs/zh-hant-tw/connect/curl/#messages)Anthropic Messages

```bash
curl https://api.ailoot.ai/v1/messages \
  -H "x-api-key: $AILOOT_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-5-5",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "你好！你能做些什麼？"}]
  }' 
```

## [](https://ailoot.ai/docs/zh-hant-tw/connect/curl/#gemini)Gemini

```bash
curl "https://api.ailoot.ai/v1beta/models/gemini-3.8-flash:generateContent" \
  -H "x-goog-api-key: $AILOOT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [
      {"role": "user", "parts": [{"text": "為咖啡店想三個名字。"}]}
    ]
  }' 
```

## [](https://ailoot.ai/docs/zh-hant-tw/connect/curl/#models)模型清單

```bash
curl -s https://api.ailoot.ai/v1/models \
  -H "Authorization: Bearer $AILOOT_API_KEY" | jq -r '.data[].id'
```

## [](https://ailoot.ai/docs/zh-hant-tw/connect/curl/#headers)回應標頭

加入`-i`即可查看標頭。`X-Request-ID` —請求識別碼，也會顯示在錯誤文字中。`X-Ailoot-Charged-USD` —付費文字回應的扣款金額。所有標頭請見此頁面：[運作方式](https://ailoot.ai/docs/zh-hant-tw/how-it-works/#headers)。

還有疑問嗎？請提供 Request ID與問題描述，我們會協助釐清。[聯絡支援](mailto:support@ailoot.ai)

## Ailoot · 公司及其專案組合





Ailoot以累積的營運經驗、廣大的客戶群、穩定的服務及持續的KPI管理為基礎。





公司及其專案組合：數百萬客戶，每月銷售額達數十億。





Ailoot將這些營運經驗用於API存取，讓客戶的產品、代理、應用程式及自動化流程使用AI功能。
