agentleFS
lauren-frameworklauren-framework/lauren-ai/skills/llm-provider-connection/SKILL.md

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.

The file

Files
SKILL.md

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

ParameterTypeDefaultDescription
providerstrrequired"anthropic", "openai", "ollama", or "litellm"
modelstrrequiredModel identifier, e.g. "claude-opus-4-6"
api_keystr | NoneNoneAPI key; falls back to env var
base_urlstr | NoneNoneOverride default provider URL
max_tokensint4096Maximum tokens per completion
temperaturefloat1.0Sampling temperature (0.0–2.0)
timeoutfloat60.0HTTP timeout in seconds
max_retriesint3Retries on transient errors
cache_system_promptboolFalseAnthropic prompt caching for system prompt
cache_toolsboolFalseAnthropic 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 needed

Wire 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 request

Reference files

FileContents
src/lauren_ai/_config.pyLLMConfig, AgentConfig frozen dataclasses
src/lauren_ai/_module.pyLLMModule.for_root() DI registration
src/lauren_ai/_transport/_mock.pyMockTransport queue API

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.