continuum-llm-providers
Skill84 starsChanged 6 months agoApache-2.0View on GitHub
Pick the right LLM provider, configure structured outputs, control context-window compression, and use the LLMClient directly. Provider routing is by model-string prefix; LiteLLM has been removed. Also covers Smart Gateway integration for multi-provider routing. Invoke when the user asks about "switch to Claude", "Gemini structured output", "context length error", "rate limiting", "JSON schema", "Smart Gateway", "gateway_mode", or "how does the LLM client work".
- Reads credentials
In this repository49 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .claude/commands/monitoring/agents.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/continuum.mdcCursor rule
- AgentDB Advanced FeaturesSkill
- AgentDB Learning PluginsSkill
- AgentDB Memory PatternsSkill
- AgentDB Performance OptimizationSkill
- AgentDB Vector SearchSkill
- browserSkill
- continuum-agentSkill
- continuum-claude-codeSkill
- continuum-codexSkill
- continuum-cursorSkill
- continuum-evaluationSkill
- continuum-handoffsSkill
- continuum-memorySkill
- continuum-observabilitySkill
- continuum-quickstartSkill
- continuum-recipesSkill
- continuum-streamingSkill
- continuum-temporalSkill
- continuum-testingSkill
- continuum-tools-mcpSkill
- continuum-workflowsSkill
- github-code-reviewSkill
- github-multi-repoSkill
- github-project-managementSkill
- github-release-managementSkill
- github-workflow-automationSkill
- Hooks AutomationSkill
- Pair ProgrammingSkill
- ReasoningBank with AgentDBSkill
- ReasoningBank IntelligenceSkill
- Skill BuilderSkill
- sparc-methodologySkill
- stream-chainSkill
- swarm-advancedSkill
- Swarm OrchestrationSkill
- V3 CLI ModernizationSkill
- V3 Core ImplementationSkill
- V3 DDD ArchitectureSkill
- V3 Deep IntegrationSkill
- V3 MCP OptimizationSkill
- V3 Memory UnificationSkill
- V3 Performance OptimizationSkill
- V3 Security OverhaulSkill
- V3 Swarm CoordinationSkill
- Verification & Quality AssuranceSkill
The file
We split this skill into the rules it gives an agent
10 rules. About 0 are common, 1 is distinctive, and 9 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
9
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 18
When SMART_GATEWAY_URL is not set, routing is by model-string prefix:
- Very specific: line 36
When SMART_GATEWAY_URL is set, all agents automatically route through GatewayProvider regardless of the model field.
- Very specific: line 46
No code changes needed — get_provider() detects the env var and switches automatically.
- Very specific: line 242
Gemini + tools + JSON mode: not supported simultaneously.
- Very specific: line 253
Don't suggest LiteLLM (from litellm import …) — it's gone.
- Very specific: line 254
Don't expect Claude to honour response_format natively — it doesn't.
- Distinctive: line 256
Don't run JSON mode + tools on Gemini and expect both to work — pick one.
- Very specific: line 258
Don't hammer the API — use LLMConfig.rate_limit_rpm=N for predictable pacing under tier limits.
- Very specific: line 260
Don't pass bare model names like "gpt-4o-mini" when using the gateway directly — use "openai/gpt-4o-mini" or "auto/mid" for proper routing.
- Very specific: line 262
Don't set gateway_mode without SMART_GATEWAY_URL — it has no effect when the gateway is not configured.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Continuum LLM Providers Skill
Authoritative source: docs/llm.md.
⚠️ LiteLLM is removed. All providers are called directly via their official SDKs. Don't suggest
litellm.*imports or any LiteLLM code paths.
Provider routing (by model-string prefix)
When SMART_GATEWAY_URL is not set, routing is by model-string prefix:
| Prefix | Provider | SDK |
gemini/..., google/... | Gemini | OpenAI SDK against Gemini's OpenAI-compat endpoint |
claude/..., anthropic/..., claude-... | Anthropic | Anthropic SDK |
anything else (gpt-*, azure/..., openai/...) | OpenAI | OpenAI SDK |
agent.model = "gpt-4o-mini" # OpenAI
agent.model = "claude-sonnet-4-20250514" # Anthropic
agent.model = "gemini/gemini-2.5-flash" # GeminiSmart Gateway (multi-provider routing)
When SMART_GATEWAY_URL is set, all agents automatically route through
GatewayProvider regardless of the model field. The gateway speaks
OpenAI-compatible API and translates to the upstream provider internally.
SMART_GATEWAY_URL=http://localhost:8787/v1
SMART_GATEWAY_API_KEY=your-key
SMART_GATEWAY_DEFAULT_MODE=modest # strict | modest | qualityNo code changes needed — get_provider() detects the env var and switches
automatically.
Per-agent routing mode
Override the default mode on any agent:
agent = BaseAgent(
name="high-quality-agent",
instructions="...",
model="gpt-4o-mini", # sent to gateway as hint
gateway_mode="quality", # overrides SMART_GATEWAY_DEFAULT_MODE
)gateway_mode | Gateway tier | Model category |
"strict" | cheap | ultra-cheap / small models |
"modest" | mid | small / mid models (default) |
"quality" | quality | frontier models |
How the model field works with gateway
The gateway re-encodes the model as auto/<tier> internally:
"gpt-4o-mini"→"auto/mid"(when mode is modest)- Pass
"openai/gpt-4o-mini"to explicitly pin provider + model - Pass
"auto/quality"to let the gateway choose the best quality model
Smart layer env vars (tier classifier)
LLM_ROUTE_TIER_CLASSIFIER=qwen # classifier backend
LLM_ROUTE_ROUTER_MODEL=... # classifier model id
LLM_ROUTE_ROUTER_API_BASE=... # classifier endpoint
LLM_ROUTE_ROUTER_API_KEY=... # classifier key
LLM_ROUTE_FORCE_COMPLETION_MODEL=... # bypass classifier, always use thisLLMClient (direct usage)
from continuum.llm import LLMClient, LLMConfig, ChatMessage
client = LLMClient() # default config
# Async (primary)
resp = await client.chat(
[ChatMessage(role="user", content="Hi")],
config=LLMConfig(model="gpt-4o-mini", temperature=0.3),
tools=None, tool_choice=None,
session_id=None, # auto-loads history if set
auto_session=True,
)
# Stream
async for chunk in client.chat_stream(messages):
if chunk.content:
print(chunk.content, end="", flush=True)Sync mirrors: chat_sync, chat_stream_sync. Aliases: complete,
stream, acomplete.
LLMConfig essentials
LLMConfig(
model="gpt-4o-mini",
fallback_models=["gemini/gemini-1.5-flash"],
temperature=0.7,
max_tokens=4096,
timeout=60,
max_retries=3,
enable_fallback=True,
# Structured output
response_format=None, # dict | type[BaseModel] | None
json_mode=False, # plain JSON object mode
# Rate limiting
rate_limit_rpm=None, # token-bucket if set
# Tracing metadata
metadata={},
)Structured outputs (3 patterns)
Plain JSON
config = LLMConfig(model="gpt-4o-mini", json_mode=True)
resp = await client.chat(messages, config=config)
# resp.content is valid JSONPydantic schema (recommended)
from pydantic import BaseModel
class Result(BaseModel):
sentiment: str
confidence: float
config = LLMConfig(model="gpt-4o-mini", response_format=Result)
resp = await client.chat(messages, config=config)
parsed = Result.model_validate_json(resp.content)Via BaseAgent (agent runner parses for you)
agent = BaseAgent(name="...", instructions="...", output_schema=Result)
resp = await runner.run(agent, "...")
parsed: Result = resp.structured_outputCapability checks
from continuum.llm.utils import (
check_response_format_support, check_json_schema_support,
supports_tools_with_json_mode,
)
check_response_format_support("claude-sonnet-4-20250514") # False
supports_tools_with_json_mode("gemini/gemini-2.5-pro") # False — Gemini can't do bothContext window management
Hardcoded limits per model (GPT-4o = 128K, Claude family = 200K, Gemini 2.5 = 1M, …). 25% of the window is reserved for the response by default.
from continuum.llm import (
ContextWindowManager, TruncationStrategy, get_context_window_manager,
ContextManagementConfig, get_progressive_context_manager, CompressionStrategy,
)
mgr = get_context_window_manager()
limits = mgr.get_model_limits("gpt-4o-mini")
mgr.will_exceed_limit(messages, "gpt-4o-mini") # bool
truncated, result = mgr.truncate_messages(messages, "gpt-4o-mini",
strategy=TruncationStrategy.SMART)Proactive compression (the runner does this for you):
cfg = ContextManagementConfig(
enabled=True, compression_threshold=0.8,
summarization_model="gpt-4o-mini", keep_recent_messages=10,
compression_strategy=CompressionStrategy.SMART,
)
mgr = get_progressive_context_manager(config=cfg)
new_msgs, result = await mgr.compress_if_needed(messages, model="gpt-4o-mini")Tool calling
tools = [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Current weather for a city",
"parameters": {"type": "object",
"properties": {"city": {"type":"string"}},
"required": ["city"]},
},
}]
resp = await client.chat(messages, tools=tools, tool_choice="auto")
# tool_choice: "auto" | "required" | "none" | {"function": {"name": "..."}}Provider quirks (handled automatically)
- Gemini + tools + JSON mode: not supported simultaneously; framework
drops
json_modeif tools are present. - Anthropic message format: system messages extracted, tool results wrapped — done transparently.
- Anthropic
max_tokens: required by SDK; defaults to 4096 when unset.
Don't
- Don't suggest LiteLLM (
from litellm import …) — it's gone. - Don't expect Claude to honour
response_formatnatively — it doesn't. Instruct it via the system prompt and parse manually. - Don't run JSON mode + tools on Gemini and expect both to work — pick one.
- Don't hammer the API — use
LLMConfig.rate_limit_rpm=Nfor predictable pacing under tier limits. - Don't pass bare model names like
"gpt-4o-mini"when using the gateway directly — use"openai/gpt-4o-mini"or"auto/mid"for proper routing. - Don't set
gateway_modewithoutSMART_GATEWAY_URL— it has no effect when the gateway is not configured.
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.

