---
title: "Gateway Quickstart"
url: "/docs/learn/gateway_quickstart"
canonical_url: "https://docs.litellm.ai/docs/learn/gateway_quickstart"
type: "docs"
last_updated: "2026-10-08"
summary: "啟動 LiteLLM Gateway，新增模型與金鑰，然後將應用程式與 SDK 連接到單一共用端點。"
related:
  - "/docs/learn/sdk_quickstart"
  - "/docs/learn/enterprise_quickstart"
---
# Gateway Quickstart

> Index of all LiteLLM docs: https://docs.litellm.ai/llms.txt

如果您需要為團隊或平台提供一個共用的 OpenAI 相容端點，請使用此路徑。

如果您需要 Docker 或以資料庫優先的設定，請使用 [快速入門](/docs/proxy/docker_quick_start)。否則，請使用以下步驟快速取得可用的請求。

## 1. 安裝閘道 {#1-install-the-gateway}

```bash
uv tool install 'litellm[proxy]'
```

## 2. 設定一個提供者金鑰 {#2-set-one-provider-key}

```bash
export OPENAI_API_KEY="your-api-key"
```

## 3. 建立 `config.yaml` {#3-create-configyaml}

```yaml
model_list:
  - model_name: gpt-5.6-luna
    litellm_params:
      model: openai/gpt-5.6-luna
      api_key: os.environ/OPENAI_API_KEY

general_settings:
  master_key: os.environ/LITELLM_MASTER_KEY
  database_url: postgresql://llmproxy:dbpassword9090@db:5432/litellm
```

## 4. 啟動閘道 {#4-start-the-gateway}

```bash
litellm --config config.yaml
```

您應該會看到 proxy 在 `http://0.0.0.0:4000` 啟動。

## 5. 傳送您的第一個請求 {#5-send-your-first-request}

```bash
curl -X POST 'http://0.0.0.0:4000/chat/completions' \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $LITELLM_API_KEY" \
  -d '{
    "model": "gpt-5.6-luna",
    "messages": [
      {"role": "user", "content": "Hello from LiteLLM Gateway"}
    ]
  }'
```

## 6. 檢查回應 {#6-check-the-response}

如果請求成功，proxy 會回傳 `200 OK`，並附上 OpenAI 風格的回應。

助理文字將位於：

```text
choices[0].message.content
```

如果您的閘道路由到 OpenAI，實際回應可能如下所示：

```json
{
  "id": "chatcmpl-abc123",
  "created": 1677858242,
  "model": "gpt-5.6-luna",
  "object": "chat.completion",
  "system_fingerprint": "fp_406d6473f8",
  "choices": [
    {
      "finish_reason": "stop",
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I assist you today?",
        "tool_calls": null,
        "function_call": null,
        "annotations": []
      }
    }
  ],
  "usage": {
    "completion_tokens": 9,
    "prompt_tokens": 13,
    "total_tokens": 22,
    "completion_tokens_details": {
      "accepted_prediction_tokens": 0,
      "audio_tokens": 0,
      "reasoning_tokens": 0,
      "rejected_prediction_tokens": 0
    },
    "prompt_tokens_details": {
      "audio_tokens": 0,
      "cached_tokens": 0
    }
  },
  "service_tier": "default"
}
```

`id`、`created`、解析後的模型版本、token 數量與訊息文字都會依請求而有所不同。其他提供者可能會回傳較少或略有不同的一組欄位，但 `choices[0].message.content` 是主要需要讀取的欄位。

## 7. 新增金鑰與 UI {#7-add-keys-and-the-ui}

如果您需要虛擬金鑰、支出追蹤或管理 UI，請先新增資料庫。

- 在 `general_settings` 下新增 `database_url`
- 使用 [虛擬金鑰](/docs/proxy/virtual_keys) 進行金鑰建立與預算設定
- 使用 [管理介面](/docs/proxy/ui) 管理模型與金鑰
- 如果您想要更完整的設定，請使用 [快速入門](/docs/proxy/docker_quick_start)

## 8. 選擇您的下一步 {#8-pick-your-next-step}

- [進行 LLM 請求](https://docs.litellm.ai/docs/proxy/user_keys): 將 LiteLLM 或相容於 OpenAI 的用戶端指向閘道。
- [模型設定](https://docs.litellm.ai/docs/proxy/configs): 新增更多模型與閘道設定。
- [虛擬金鑰](https://docs.litellm.ai/docs/proxy/virtual_keys): 建立金鑰、預算與存取控制。
- [新增記錄](https://docs.litellm.ai/docs/proxy/logging): 擷取記錄、支出與追蹤。
- [負載平衡](https://docs.litellm.ai/docs/proxy/load_balancing): 跨部署、區域或提供者進行路由。
- [新增防護欄](https://docs.litellm.ai/docs/proxy/guardrails/quick_start): 新增安全檢查與政策執行。
- [可靠性](https://docs.litellm.ai/docs/proxy/reliability): 設定重試、備援與逾時。

## 何時改用 SDK 路徑 {#when-to-use-the-sdk-path-instead}

如果您只需要從單一應用程式呼叫模型，且不需要集中式驗證或共用基礎架構，請改從 [SDK Quickstart](/docs/learn/sdk_quickstart) 開始。

## Related pages

- [SDK 快速入門](https://docs.litellm.ai/docs/learn/sdk_quickstart.md)
- [Enterprise 快速入門](https://docs.litellm.ai/docs/learn/enterprise_quickstart.md)
