# llm.api

Minimal-dependency LLM chat interface. Part of [cornyverse](https://github.com/cornball-ai).

## Exports

| Function | Purpose |
|----------|---------|
| `chat(prompt, model)` | Chat with any LLM |
| `chat_openai(prompt)` | OpenAI GPT models |
| `chat_claude(prompt)` | Anthropic Claude models |
| `chat_ollama(prompt)` | Local Ollama server |
| `list_ollama_models()` | List Ollama models |
| `llm_base(url)` | Set API endpoint |
| `llm_key(key)` | Set API key |

## Providers

- **openai**: GPT-4o, GPT-4o-mini, o1, o3
- **anthropic**: Claude 3.5 Sonnet, Claude 3.5 Haiku
- **moonshot**: Kimi K2 via Moonshot's OpenAI-compatible API
- **ollama**: Llama 3.2, Mistral, Gemma, Phi, Qwen (via server)

## Usage

```r
# Auto-detect provider from model
chat("Hello", model = "gpt-5.4-mini")
chat("Hello", model = "claude-3-5-sonnet-latest")
chat("Hello", model = "kimi-k2.5")

# Use convenience wrappers
chat_ollama("What is R?")
chat_claude("Explain machine learning")

# Explicit Moonshot/Kimi provider
chat("Write a fast parser in R", provider = "moonshot", model = "kimi-k2.5")

# Conversation history
result <- chat("Hi, I'm Troy")
chat("What's my name?", history = result$history)

# Streaming
chat("Write a story", stream = TRUE)
```

Set `MOONSHOT_API_KEY` to use Moonshot/Kimi without overriding your
OpenAI credentials.

## Dependencies

Only `curl` and `jsonlite`. No tidyverse, no compiled code.
