@o-lang/llm-anthropic
v1.0.0
Published
O-Lang resolver for Anthropic (Claude Haiku / Sonnet / Opus) LLM
Maintainers
Readme
@o-lang/llm-anthropic
O-Lang resolver for Anthropic Claude LLM API
Requirements
ANTHROPIC_API_KEYenvironment variable
Usage
Allow resolvers:
- llm-anthropic
Step 1: Ask llm-anthropic "What is the capital of France?"
Save as responseMulti-turn chat (RAG chatbot, governed chatbot)
Allow resolvers:
- llm-anthropic
Step 1: llm_chat
system_prompt: "You are a helpful support agent."
history: "{{ session.history }}"
user_message: "{{ params.user_message }}"
Save as replyModels
| Constant | Model | Best for |
|---|---|---|
| FAST | claude-haiku-4-5-20251001 | Classification, short answers, data workflows |
| SMART | claude-sonnet-4-6 | RAG, chatbots, document analysis |
| POWER | claude-opus-4-6 | Complex reasoning, synthesis |
Default for llm_chat: claude-sonnet-4-6
Default for llm_complete: claude-haiku-4-5-20251001
Actions
llm_chat — multi-turn conversation
{
"action": "llm_chat",
"context": {
"system_prompt": "You are a helpful assistant.",
"history": [
{ "role": "user", "content": "Hello" },
{ "role": "assistant", "content": "Hi! How can I help?" }
],
"user_message": "What is your refund policy?",
"model": "claude-sonnet-4-6",
"max_tokens": 1024,
"temperature": 0.7
}
}llm_complete — single-turn completion
{
"action": "llm_complete",
"context": {
"prompt": "Summarise this patient data: ...",
"model": "claude-haiku-4-5-20251001",
"max_tokens": 250
}
}Environment variables
ANTHROPIC_API_KEY=your_key_here
# Optional model overrides
LLM_CHAT_MODEL=claude-sonnet-4-6
LLM_COMPLETE_MODEL=claude-haiku-4-5-20251001
LLM_CHAT_MAX_TOKENS=1024Important: Anthropic API difference
Unlike Groq and OpenAI, the Anthropic API takes system_prompt as a
top-level field — not inside the messages array. This resolver handles
that automatically. Your .ol workflows use the same system_prompt field
regardless of which LLM resolver is plugged in.
Running tests
npm test # Jest suite — no API key required
node test-local-resolver.js # Live smoke test — requires ANTHROPIC_API_KEY