---
title: "v0"
url: "/docs/providers/v0"
canonical_url: "https://docs.litellm.ai/docs/providers/v0"
type: "docs"
last_updated: "2026-10-08"
related:
  - "/docs/providers/triton-inference-server"
  - "/docs/providers/valkey_vector_stores"
---
# v0

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


## 概觀 {#overview}

| 屬性 | 詳細資訊 |
|-------|-------|
| 說明 | v0 提供針對程式碼產生最佳化的 AI 模型，特別適合建立 Next.js 應用程式、React 元件與現代 Web 開發。 |
| LiteLLM 提供者路由 | `v0/` |
| 提供者文件連結 | [v0 API 文件 ↗](https://v0.dev/docs/v0-model-api) |
| Base URL | `https://api.v0.dev/v1` |
| 支援的操作 | [`/chat/completions`](/docs/providers/v0#usage---litellm-python-sdk) |

<br />
<br />

https://v0.dev/docs/v0-model-api

**我們支援所有 v0 模型，只要在傳送 completion 請求時將 `v0/` 設為前綴即可**

## 可用模型 {#available-models}

| 模型 | 說明 | 上下文視窗 | Max Output |
|-------|-------------|----------------|------------|
| `v0/v0-1.5-lg` | 用於進階程式碼產生與推理的大型模型 | 512,000 tokens | 512,000 tokens |
| `v0/v0-1.5-md` | 用於日常程式碼產生工作的中型模型 | 128,000 tokens | 128,000 tokens |
| `v0/v0-1.0-md` | 舊版中型模型 | 128,000 tokens | 128,000 tokens |

## 必要變數 {#required-variables}

```python showLineNumbers title="Environment Variables"
os.environ["V0_API_KEY"] = ""  # your v0 API key from v0.dev
```

注意：v0 API 存取需要 Premium 或 Team 方案。請前往 [v0.dev/chat/settings/billing](https://v0.dev/chat/settings/billing) 升級。

## 用法 - LiteLLM Python SDK {#usage---litellm-python-sdk}

### 非串流 {#non-streaming}

```python showLineNumbers title="v0 Non-streaming Completion"
import os
import litellm
from litellm import completion

os.environ["V0_API_KEY"] = ""  # your v0 API key

messages = [{"content": "Create a React button component with hover effects", "role": "user"}]

# v0 call
response = completion(
    model="v0/v0-1.5-md", 
    messages=messages
)

print(response)
```

### 串流 {#streaming}

```python showLineNumbers title="v0 Streaming Completion"
import os
import litellm
from litellm import completion

os.environ["V0_API_KEY"] = ""  # your v0 API key

messages = [{"content": "Create a React button component with hover effects", "role": "user"}]

# v0 call with streaming
response = completion(
    model="v0/v0-1.5-md", 
    messages=messages,
    stream=True
)

for chunk in response:
    print(chunk)
```

### 影像/多模態支援 {#visionmultimodal-support}

所有 v0 模型都支援影像輸入，讓您可以將圖片與文字一併傳送：

```python showLineNumbers title="v0 Vision/Multimodal"
import os
import litellm
from litellm import completion

os.environ["V0_API_KEY"] = ""  # your v0 API key

messages = [{
    "role": "user",
    "content": [
        {
            "type": "text",
            "text": "Recreate this UI design in React"
        },
        {
            "type": "image_url",
            "image_url": {
                "url": "https://example.com/ui-design.png"
            }
        }
    ]
}]

response = completion(
    model="v0/v0-1.5-lg",
    messages=messages
)

print(response)
```

### 函式呼叫 {#function-calling}

v0 支援用於結構化輸出的函式呼叫：

```python showLineNumbers title="v0 Function Calling"
import os
import litellm
from litellm import completion

os.environ["V0_API_KEY"] = ""  # your v0 API key

tools = [
    {
        "type": "function",
        "function": {
            "name": "create_component",
            "description": "Create a React component",
            "parameters": {
                "type": "object",
                "properties": {
                    "component_name": {
                        "type": "string",
                        "description": "The name of the component"
                    },
                    "props": {
                        "type": "array",
                        "items": {"type": "string"},
                        "description": "List of component props"
                    }
                },
                "required": ["component_name"]
            }
        }
    }
]

response = completion(
    model="v0/v0-1.5-md",
    messages=[{"role": "user", "content": "Create a Button component with onClick and disabled props"}],
    tools=tools,
    tool_choice="auto"
)

print(response)
```

## 用法 - LiteLLM Proxy {#usage---litellm-proxy}

將下列內容加入您的 LiteLLM Proxy 設定檔：

```yaml showLineNumbers title="config.yaml"
model_list:
  - model_name: v0-large
    litellm_params:
      model: v0/v0-1.5-lg
      api_key: os.environ/V0_API_KEY

  - model_name: v0-medium
    litellm_params:
      model: v0/v0-1.5-md
      api_key: os.environ/V0_API_KEY

  - model_name: v0-legacy
    litellm_params:
      model: v0/v0-1.0-md
      api_key: os.environ/V0_API_KEY
```

啟動您的 LiteLLM Proxy 伺服器：

```bash showLineNumbers title="Start LiteLLM Proxy"
litellm --config config.yaml

# RUNNING on http://0.0.0.0:4000
```

**OpenAI SDK**

```python showLineNumbers title="v0 via Proxy - Non-streaming"
from openai import OpenAI

# Initialize client with your proxy URL
client = OpenAI(
    base_url="http://localhost:4000",  # Your proxy URL
    api_key="your-proxy-api-key"       # Your proxy API key
)

# Non-streaming response
response = client.chat.completions.create(
    model="v0-medium",
    messages=[{"role": "user", "content": "Create a React card component"}]
)

print(response.choices[0].message.content)
```

```python showLineNumbers title="v0 via Proxy - Streaming"
from openai import OpenAI

# Initialize client with your proxy URL
client = OpenAI(
    base_url="http://localhost:4000",  # Your proxy URL
    api_key="your-proxy-api-key"       # Your proxy API key
)

# Streaming response
response = client.chat.completions.create(
    model="v0-medium",
    messages=[{"role": "user", "content": "Create a React card component"}],
    stream=True
)

for chunk in response:
    if chunk.choices[0].delta.content is not None:
        print(chunk.choices[0].delta.content, end="")
```

**LiteLLM SDK**

```python showLineNumbers title="v0 via Proxy - LiteLLM SDK"
import litellm

# Configure LiteLLM to use your proxy
response = litellm.completion(
    model="litellm_proxy/v0-medium",
    messages=[{"role": "user", "content": "Create a React card component"}],
    api_base="http://localhost:4000",
    api_key="your-proxy-api-key"
)

print(response.choices[0].message.content)
```

```python showLineNumbers title="v0 via Proxy - LiteLLM SDK Streaming"
import litellm

# Configure LiteLLM to use your proxy with streaming
response = litellm.completion(
    model="litellm_proxy/v0-medium",
    messages=[{"role": "user", "content": "Create a React card component"}],
    api_base="http://localhost:4000",
    api_key="your-proxy-api-key",
    stream=True
)

for chunk in response:
    if hasattr(chunk.choices[0], 'delta') and chunk.choices[0].delta.content is not None:
        print(chunk.choices[0].delta.content, end="")
```

**cURL**

```bash showLineNumbers title="v0 via Proxy - cURL"
curl http://localhost:4000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your-proxy-api-key" \
  -d '{
    "model": "v0-medium",
    "messages": [{"role": "user", "content": "Create a React card component"}]
  }'
```

```bash showLineNumbers title="v0 via Proxy - cURL Streaming"
curl http://localhost:4000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your-proxy-api-key" \
  -d '{
    "model": "v0-medium",
    "messages": [{"role": "user", "content": "Create a React card component"}],
    "stream": true
  }'
```

如需有關使用 LiteLLM Proxy 的更詳細資訊，請參閱 [LiteLLM Proxy 文件](../providers/litellm_proxy)。

## 支援的 OpenAI 參數 {#supported-openai-parameters}

v0 支援以下與 OpenAI 相容的參數：

| 參數 | 類型 | 說明 |
|-----------|------|-------------|
| `messages` | array | **必要**。具有 'role' 與 'content' 的訊息物件陣列 |
| `model` | string | **必要**。模型 ID (v0-1.5-lg, v0-1.5-md, v0-1.0-md) |
| `stream` | boolean | 選用。啟用串流回應 |
| `tools` | array | 選用。可用工具/函式清單 |
| `tool_choice` | string/object | 選用。控制工具/函式呼叫 |

注意：與完整的 OpenAI API 相比，v0 支援的參數集合較少。像 `temperature`、`max_tokens`、`top_p` 等參數不受支援。

## 進階用法 {#advanced-usage}

### 自訂 API Base {#custom-api-base}

如果您使用的是自訂的 v0 部署：

```python showLineNumbers title="Custom API Base"
import litellm

response = litellm.completion(
    model="v0/v0-1.5-md",
    messages=[{"role": "user", "content": "Hello"}],
    api_base="https://your-custom-v0-endpoint.com/v1",
    api_key="your-api-key"
)
```

## 定價 {#pricing}

v0 模型需要 Premium 或 Team 訂閱。請前往 [v0.dev/chat/settings/billing](https://v0.dev/chat/settings/billing) 取得目前定價資訊。

## 其他資源 {#additional-resources}

- [v0 官方文件](https://v0.dev/docs)
- [v0 模型 API 參考](https://v0.dev/docs/v0-model-api)

## Related pages

- [Triton Inference Server](https://docs.litellm.ai/docs/providers/triton-inference-server.md)
- [Valkey - 向量儲存](https://docs.litellm.ai/docs/providers/valkey_vector_stores.md)
