llm-provider-connection
Skill0 starsChanged 6 months agoMITView on GitHub
Configures an LLM provider connection in lauren-ai using LLMConfig and LLMModule. Use when setting up a new provider (Anthropic, OpenAI, Ollama), switching models, injecting the LLM into a Lauren DI module, or writing tests that need a zero-network MockTransport.
In this repository65 other files it gives its agents.
- AGENTS.mdAGENTS.md
- skills/building-agents/agents.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- llms-full.txtllms.txt
- llms.txtllms.txt
- adding-guardrailsSkill
- agent-health-timeoutSkill
- agent-permission-scopingSkill
- agent-session-isolationSkill
- agent-step-loggingSkill
- agent-supervisor-routerSkill
- agent-telemetrySkill
- async-agent-backgroundSkill
- building-agentsSkill
- building-teamsSkill
- building-toolsSkill
- calendar-scheduling-toolSkill
- callback-tracing-handlerSkill
- chain-of-thought-promptingSkill
- chat-model-configurationSkill
- code-execution-sandboxSkill
- common-agent-patternsSkill
- context-window-managementSkill
- conversation-memorySkill
- conversation-state-dbSkill
- database-query-toolSkill
- document-loadersSkill
- document-rerankingSkill
- email-notification-toolSkill
- embedding-model-ingestionSkill
- fallback-model-chainSkill
- few-shot-injectionSkill
- filesystem-toolSkill
- human-in-the-loopSkill
- hybrid-searchSkill
- inspecting-streamsSkill
- integrating-with-laurenSkill
- json-schema-enforcementSkill
- llm-rate-limitingSkill
- long-term-vector-memorySkill
- managing-memorySkill
- migrating-to-lauren-aiSkill
- multi-agent-delegationSkill
- multi-tool-orchestrationSkill
- multi-turn-tool-stateSkill
- output-guardrailsSkill
- plan-and-execute-agentSkill
- prompt-injection-defenseSkill
- prompt-versioningSkill
- rag-pipelineSkill
- react-agent-loopSkill
- response-validation-retrySkill
- rest-api-toolSkill
- securing-agentsSkill
- semantic-cacheSkill
- streaming-response-handlerSkill
- structured-output-parsingSkill
- sub-agent-spawningSkill
- system-prompt-templatingSkill
- testing-agentsSkill
- The first 60 shown.
The file
Files
Use
codemap find "SymbolName"to locate any symbol before reading — it gives exact file + line range and is faster than grep across the whole repo.
LLM Provider Connection
Quick start
from lauren_ai import LLMConfig, LLMModule
# Anthropic
cfg = LLMConfig.for_anthropic(model="claude-opus-4-6", api_key="sk-ant-...")
# OpenAI
cfg = LLMConfig.for_openai(model="gpt-4o", api_key="sk-...")
# Ollama (local, no API key needed)
cfg = LLMConfig.for_ollama(model="llama3.2")
# Tests — zero network calls
cfg, mock = LLMConfig.for_testing()LLMConfig parameters
| Parameter | Type | Default | Description |
provider | str | required | "anthropic", "openai", "ollama", or "litellm" |
model | str | required | Model identifier, e.g. "claude-opus-4-6" |
api_key | str | None | None | API key; falls back to env var |
base_url | str | None | None | Override default provider URL |
max_tokens | int | 4096 | Maximum tokens per completion |
temperature | float | 1.0 | Sampling temperature (0.0–2.0) |
timeout | float | 60.0 | HTTP timeout in seconds |
max_retries | int | 3 | Retries on transient errors |
cache_system_prompt | bool | False | Anthropic prompt caching for system prompt |
cache_tools | bool | False | Anthropic prompt caching for tool definitions |
Direct constructor form
from lauren_ai import LLMConfig
# Explicit constructor (all three providers)
cfg_anthropic = LLMConfig(provider="anthropic", model="claude-opus-4-6", api_key="sk-ant-...")
cfg_openai = LLMConfig(provider="openai", model="gpt-4o", api_key="sk-...")
cfg_ollama = LLMConfig(provider="ollama", model="llama3.2") # no key neededWire into Lauren DI
from lauren_ai import LLMModule, LLMConfig
from lauren import module
cfg = LLMConfig.for_anthropic(model="claude-opus-4-6")
LLMProvider = LLMModule.for_root(cfg)
@module(imports=[LLMProvider])
class AppModule: ...Testing pattern
from lauren_ai import LLMConfig
from lauren_ai._transport import Completion, TokenUsage
cfg, mock = LLMConfig.for_testing() # provider="anthropic", model="mock-model"
mock.queue_response(
Completion(
id="c1",
model="mock-model",
content="Hello!",
tool_calls=[],
stop_reason="end_turn",
usage=TokenUsage(input_tokens=10, output_tokens=5),
)
)
# … run your agent code; mock.calls records every requestReference files
| File | Contents |
src/lauren_ai/_config.py | LLMConfig, AgentConfig frozen dataclasses |
src/lauren_ai/_module.py | LLMModule.for_root() DI registration |
src/lauren_ai/_transport/_mock.py | MockTransport queue API |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

