---
title: "新增模型定價與上下文視窗"
url: "/docs/provider_registration/add_model_pricing"
canonical_url: "https://docs.litellm.ai/docs/provider_registration/add_model_pricing"
type: "docs"
last_updated: "2026-10-08"
related:
  - "/docs/contributing/adding_openai_compatible_providers"
  - "/docs/providers/openai"
---
# 新增模型定價與上下文視窗

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

若要為模型新增定價或上下文視窗資訊，只需對此檔案提出 PR：

**[模型價格與上下文視窗.json](https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json)**

### 範例規格 {#sample-spec}

以下是包含所有可用欄位的完整規格：

```json
{
    "sample_spec": {
        "aliases": ["optional list of alternate names for this model, e.g. dated versions like sample_spec-20250101"],
        "code_interpreter_cost_per_session": 0.0,
        "computer_use_input_cost_per_1k_tokens": 0.0,
        "computer_use_output_cost_per_1k_tokens": 0.0,
        "deprecation_date": "date when the model becomes deprecated in the format YYYY-MM-DD",
        "file_search_cost_per_1k_calls": 0.0,
        "file_search_cost_per_gb_per_day": 0.0,
        "input_cost_per_audio_token": 0.0,
        "input_cost_per_token": 0.0,
        "litellm_provider": "one of https://docs.litellm.ai/docs/providers",
        "max_input_tokens": "max input tokens, if the provider specifies it. if not default to max_tokens",
        "max_output_tokens": "max output tokens, if the provider specifies it. if not default to max_tokens",
        "max_tokens": "LEGACY parameter. set to max_output_tokens if provider specifies it. IF not set to max_input_tokens, if provider specifies it.",
        "mode": "one of: chat, embedding, completion, image_generation, audio_transcription, audio_speech, image_generation, moderation, rerank, search",
        "output_cost_per_reasoning_token": 0.0,
        "output_cost_per_token": 0.0,
        "search_context_cost_per_query": {
            "search_context_size_high": 0.0,
            "search_context_size_low": 0.0,
            "search_context_size_medium": 0.0
        },
        "supported_regions": [
            "global",
            "us-west-2",
            "eu-west-1",
            "ap-southeast-1",
            "ap-northeast-1"
        ],
        "supports_audio_input": true,
        "supports_audio_output": true,
        "supports_function_calling": true,
        "supports_parallel_function_calling": true,
        "supports_prompt_caching": true,
        "supports_reasoning": true,
        "supports_response_schema": true,
        "supports_system_messages": true,
        "supports_vision": true,
        "supports_web_search": true,
        "vector_store_cost_per_gb_per_day": 0.0
    }
}
```

### 批次計價鍵 {#batch-pricing-keys}

當批次 API 項目帶有 `*_batches` 鍵時，就依這些鍵計費。未帶有這些鍵的項目則以其標準費率的一半計費

| Key | 計費內容 |
| --- | --- |
| `input_cost_per_token_batches` | prompt token |
| `output_cost_per_token_batches` | completion token |
| `cache_read_input_token_cost_batches` | 已快取的 prompt token |
| `cache_creation_input_token_cost_batches` | 快取寫入 token |
| `input_cost_per_token_above_272k_tokens_batches` | prompt token，prompt 超過 272K |
| `output_cost_per_token_above_272k_tokens_batches` | completion token，prompt 超過 272K |
| `cache_read_input_token_cost_above_272k_tokens_batches` | 已快取的 prompt token，prompt 超過 272K |
| `cache_creation_input_token_cost_above_272k_tokens_batches` | 快取寫入 token，prompt 超過 272K |

`above_272k` 鍵適用於 prompt 超過 272K token 的批次列，也就是 OpenAI 計價所採用的長上下文閾值。項目未填寫的任何層級鍵，皆回退為該項目對相同 token 的固定 `*_batches` 費率

### 範例 {#examples}

#### Anthropic Claude {#anthropic-claude}

```json
{
    "claude-3-5-haiku-20241022": {
        "cache_creation_input_token_cost": 1e-06,
        "cache_creation_input_token_cost_above_1hr": 6e-06,
        "cache_read_input_token_cost": 8e-08,
        "deprecation_date": "2025-10-01",
        "input_cost_per_token": 8e-07,
        "litellm_provider": "anthropic",
        "max_input_tokens": 200000,
        "max_output_tokens": 8192,
        "max_tokens": 8192,
        "mode": "chat",
        "output_cost_per_token": 4e-06,
        "search_context_cost_per_query": {
            "search_context_size_high": 0.01,
            "search_context_size_low": 0.01,
            "search_context_size_medium": 0.01
        },
        "supports_assistant_prefill": true,
        "supports_function_calling": true,
        "supports_pdf_input": true,
        "supports_prompt_caching": true,
        "supports_vision": true
    }
}
```

#### Vertex AI Gemini {#vertex-ai-gemini}

```json
{
    "vertex_ai/gemini-3-pro-preview": {
        "cache_read_input_token_cost": 2e-07,
        "cache_read_input_token_cost_above_200k_tokens": 4e-07,
        "cache_creation_input_token_cost_above_200k_tokens": 2.5e-07,
        "input_cost_per_token": 2e-06,
        "input_cost_per_token_above_200k_tokens": 4e-06,
        "input_cost_per_token_batches": 1e-06,
        "litellm_provider": "vertex_ai",
        "max_audio_length_hours": 8.4,
        "max_audio_per_prompt": 1,
        "max_images_per_prompt": 3000,
        "max_input_tokens": 1048576,
        "max_output_tokens": 65535,
        "max_pdf_size_mb": 30,
        "max_tokens": 65535,
        "max_video_length": 1,
        "max_videos_per_prompt": 10,
        "mode": "chat",
        "output_cost_per_token": 1.2e-05,
        "output_cost_per_token_above_200k_tokens": 1.8e-05,
        "output_cost_per_token_batches": 6e-06,
        "supports_function_calling": true,
        "supports_parallel_function_calling": true,
        "supports_prompt_caching": true,
        "supports_system_messages": true,
        "supports_vision": true
    }
}
```

### 使用別名 {#using-aliases}

許多提供者會以多個名稱釋出同一個模型，例如 `latest` 標籤和像 `claude-sonnet-4-5-20250929` 這樣的日期版本。與其複製整個項目，不如使用 `aliases` 欄位：

```json
{
    "claude-sonnet-4-5": {
        "aliases": ["claude-sonnet-4-5-20250929"],
        "input_cost_per_token": 3e-06,
        "output_cost_per_token": 1.5e-05,
        "litellm_provider": "anthropic",
        "max_input_tokens": 200000,
        "max_output_tokens": 64000,
        "mode": "chat",
        "supports_function_calling": true,
        "supports_tool_choice": true
    }
}
```

在載入時，每個別名都會展開為頂層項目，並與標準項目共享相同的資料。上方範例會讓 `claude-sonnet-4-5` 和 `claude-sonnet-4-5-20250929` 都以相同的定價與功能解析。

:::info
這與 [`model_alias_map`](../completion/model_alias.md) 不同；後者是執行階段 SDK/代理程式功能，用來將使用者可見的模型名稱對應到 LiteLLM 模型識別碼。此處的 `aliases` 欄位僅用於 model cost JSON，並可避免對於具有相同計價與能力的模型建立重複項目。
:::

## Related pages

- [Add OpenAI-Compatible Provider (JSON)](https://docs.litellm.ai/docs/contributing/adding_openai_compatible_providers.md)
- [OpenAI](https://docs.litellm.ai/docs/providers/openai.md)
