# LLM (Large Language Model) (/docs/voice-agent/llm)

## LLM (Large Language Model)

Pipeline 모드에서 텍스트 응답을 생성하는 빌트인 Provider입니다.

아래 제공자들은 모두 **검증 전** 상태입니다. 검증 상태는 [제공자 호환성](/docs/voice-agent/providers) 문서에서 확인하세요.

## OpenAILLM

OpenAI Chat Completions API 기반 스트리밍 텍스트 생성입니다. Tool 호출을 지원합니다.

```python
from clawops.agent.pipeline import OpenAILLM

llm = OpenAILLM(
    model="gpt-4o-mini",
    temperature=0.8,
    max_tokens=4096,
)
```

### 파라미터

| 파라미터 | 타입 | 기본값 | 설명 |
|----------|------|--------|------|
| `api_key` | `str \| None` | `None` | OpenAI API 키. 미지정 시 `OPENAI_API_KEY` 환경변수 사용 |
| `model` | `str` | `"gpt-4o-mini"` | OpenAI 모델 |
| `temperature` | `float` | `0.8` | 응답 다양성 (0.0~2.0) |
| `max_tokens` | `int` | `4096` | 최대 응답 토큰 수 |

## AnthropicLLM

Anthropic Claude API 기반 스트리밍 텍스트 생성입니다. Tool 호출을 지원합니다.

```python
from clawops.agent.pipeline import AnthropicLLM

llm = AnthropicLLM(
    model="claude-sonnet-4-6",
    temperature=0.8,
    max_tokens=4096,
)
```

### 파라미터

| 파라미터 | 타입 | 기본값 | 설명 |
|----------|------|--------|------|
| `api_key` | `str \| None` | `None` | Anthropic API 키. 미지정 시 `ANTHROPIC_API_KEY` 환경변수 사용 |
| `model` | `str` | `"claude-sonnet-4-6"` | Anthropic 모델 |
| `temperature` | `float` | `0.8` | 응답 다양성 (0.0~1.0) |
| `max_tokens` | `int` | `4096` | 최대 응답 토큰 수 |

## GeminiLLM

Google Gemini API 기반 스트리밍 텍스트 생성입니다. Tool 호출을 지원합니다.

```python
from clawops.agent.pipeline import GeminiLLM

llm = GeminiLLM(
    model="gemini-2.5-flash",
    temperature=0.8,
    max_tokens=4096,
)
```

### 파라미터

| 파라미터 | 타입 | 기본값 | 설명 |
|----------|------|--------|------|
| `api_key` | `str \| None` | `None` | Google API 키. 미지정 시 `GOOGLE_API_KEY` 환경변수 사용 |
| `model` | `str` | `"gemini-2.5-flash"` | Gemini 모델 |
| `temperature` | `float` | `0.8` | 응답 다양성 (0.0~2.0) |
| `max_tokens` | `int` | `4096` | 최대 응답 토큰 수 |

### Vertex AI 사용

`GOOGLE_API_KEY` 없이 Google Cloud Vertex AI 백엔드를 사용할 수 있습니다. `GeminiRealtime`과 `GeminiLLM` 모두 동일하게 적용됩니다.

```bash
export GOOGLE_GENAI_USE_VERTEXAI=true
export GOOGLE_CLOUD_PROJECT="your-project-id"
export GOOGLE_CLOUD_LOCATION="us-central1"
```

Vertex AI는 ADC(Application Default Credentials)로 인증합니다.

**로컬 개발:**

```bash
gcloud auth application-default login
```

**서버/CI 환경:** 서비스 계정 키 경로를 지정합니다.

```bash
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/service-account-key.json"
```

**Google Cloud 환경** (GCE, Cloud Run, GKE): 별도 설정 없이 자동 인증됩니다.

## OllamaLLM

Ollama 로컬 LLM 기반 스트리밍 텍스트 생성입니다. OpenAI 호환 API를 사용하며 Tool 호출을 지원합니다.

```python
from clawops.agent.pipeline import OllamaLLM

llm = OllamaLLM(
    model="llama3.2",
    temperature=0.8,
    max_tokens=4096,
)
```

### 파라미터

| 파라미터 | 타입 | 기본값 | 설명 |
|----------|------|--------|------|
| `model` | `str` | `"llama3.2"` | Ollama 모델 |
| `base_url` | `str \| None` | `None` | Ollama 서버 URL. 미지정 시 `OLLAMA_BASE_URL` 환경변수 또는 `http://localhost:11434/v1` |
| `temperature` | `float` | `0.8` | 응답 다양성 (0.0~2.0) |
| `max_tokens` | `int` | `4096` | 최대 응답 토큰 수 |

## MistralLLM

Mistral AI 기반 스트리밍 텍스트 생성입니다. OpenAI 호환 API를 사용하며 Tool 호출을 지원합니다.

```python
from clawops.agent.pipeline import MistralLLM

llm = MistralLLM(
    model="mistral-small-latest",
    temperature=0.8,
    max_tokens=4096,
)
```

### 파라미터

| 파라미터 | 타입 | 기본값 | 설명 |
|----------|------|--------|------|
| `api_key` | `str \| None` | `None` | Mistral API 키. 미지정 시 `MISTRAL_API_KEY` 환경변수 사용 |
| `model` | `str` | `"mistral-small-latest"` | Mistral 모델 |
| `temperature` | `float` | `0.8` | 응답 다양성 (0.0~2.0) |
| `max_tokens` | `int` | `4096` | 최대 응답 토큰 수 |

## GroqLLM

Groq 기반 초저지연 스트리밍 텍스트 생성입니다. OpenAI 호환 API를 사용하며 Tool 호출을 지원합니다.

```python
from clawops.agent.pipeline import GroqLLM

llm = GroqLLM(
    model="meta-llama/llama-4-scout-17b-16e-instruct",
    temperature=0.8,
    max_tokens=4096,
)
```

### 파라미터

| 파라미터 | 타입 | 기본값 | 설명 |
|----------|------|--------|------|
| `api_key` | `str \| None` | `None` | Groq API 키. 미지정 시 `GROQ_API_KEY` 환경변수 사용 |
| `model` | `str` | `"meta-llama/llama-4-scout-17b-16e-instruct"` | Groq 모델 |
| `temperature` | `float` | `0.8` | 응답 다양성 (0.0~2.0) |
| `max_tokens` | `int` | `4096` | 최대 응답 토큰 수 |

## PerplexityLLM

Perplexity 기반 스트리밍 텍스트 생성입니다. OpenAI 호환 API를 사용하며 웹 검색 기반 응답을 제공합니다.

```python
from clawops.agent.pipeline import PerplexityLLM

llm = PerplexityLLM(
    model="sonar",
    temperature=0.8,
    max_tokens=4096,
)
```

### 파라미터

| 파라미터 | 타입 | 기본값 | 설명 |
|----------|------|--------|------|
| `api_key` | `str \| None` | `None` | Perplexity API 키. 미지정 시 `PERPLEXITY_API_KEY` 환경변수 사용 |
| `model` | `str` | `"sonar"` | Perplexity 모델 |
| `temperature` | `float` | `0.8` | 응답 다양성 (0.0~2.0) |
| `max_tokens` | `int` | `4096` | 최대 응답 토큰 수 |

## TogetherLLM

Together AI 기반 스트리밍 텍스트 생성입니다. OpenAI 호환 API를 사용하며 Tool 호출을 지원합니다.

```python
from clawops.agent.pipeline import TogetherLLM

llm = TogetherLLM(
    model="meta-llama/Llama-4-Scout-17B-16E-Instruct",
    temperature=0.8,
    max_tokens=4096,
)
```

### 파라미터

| 파라미터 | 타입 | 기본값 | 설명 |
|----------|------|--------|------|
| `api_key` | `str \| None` | `None` | Together API 키. 미지정 시 `TOGETHER_API_KEY` 환경변수 사용 |
| `model` | `str` | `"meta-llama/Llama-4-Scout-17B-16E-Instruct"` | Together AI 모델 |
| `temperature` | `float` | `0.8` | 응답 다양성 (0.0~2.0) |
| `max_tokens` | `int` | `4096` | 최대 응답 토큰 수 |

## FireworksLLM

Fireworks AI 기반 스트리밍 텍스트 생성입니다. OpenAI 호환 API를 사용하며 Tool 호출을 지원합니다.

```python
from clawops.agent.pipeline import FireworksLLM

llm = FireworksLLM(
    model="accounts/fireworks/models/llama4-scout-instruct-basic",
    temperature=0.8,
    max_tokens=4096,
)
```

### 파라미터

| 파라미터 | 타입 | 기본값 | 설명 |
|----------|------|--------|------|
| `api_key` | `str \| None` | `None` | Fireworks API 키. 미지정 시 `FIREWORKS_API_KEY` 환경변수 사용 |
| `model` | `str` | `"accounts/fireworks/models/llama4-scout-instruct-basic"` | Fireworks 모델 |
| `temperature` | `float` | `0.8` | 응답 다양성 (0.0~2.0) |
| `max_tokens` | `int` | `4096` | 최대 응답 토큰 수 |

## DeepSeekLLM

DeepSeek 기반 스트리밍 텍스트 생성입니다. OpenAI 호환 API를 사용하며 Tool 호출을 지원합니다.

```python
from clawops.agent.pipeline import DeepSeekLLM

llm = DeepSeekLLM(
    model="deepseek-chat",
    temperature=0.8,
    max_tokens=4096,
)
```

### 파라미터

| 파라미터 | 타입 | 기본값 | 설명 |
|----------|------|--------|------|
| `api_key` | `str \| None` | `None` | DeepSeek API 키. 미지정 시 `DEEPSEEK_API_KEY` 환경변수 사용 |
| `model` | `str` | `"deepseek-chat"` | DeepSeek 모델 |
| `temperature` | `float` | `0.8` | 응답 다양성 (0.0~2.0) |
| `max_tokens` | `int` | `4096` | 최대 응답 토큰 수 |

## XaiLLM

xAI Grok 기반 스트리밍 텍스트 생성입니다. OpenAI 호환 API를 사용하며 Tool 호출을 지원합니다.

```python
from clawops.agent.pipeline import XaiLLM

llm = XaiLLM(
    model="grok-4-1-fast",
    temperature=0.8,
    max_tokens=4096,
)
```

### 파라미터

| 파라미터 | 타입 | 기본값 | 설명 |
|----------|------|--------|------|
| `api_key` | `str \| None` | `None` | xAI API 키. 미지정 시 `XAI_API_KEY` 환경변수 사용 |
| `model` | `str` | `"grok-4-1-fast"` | xAI 모델 |
| `temperature` | `float` | `0.8` | 응답 다양성 (0.0~2.0) |
| `max_tokens` | `int` | `4096` | 최대 응답 토큰 수 |
