Implementation:AMAP ML SkillClaw run llm
| Knowledge Sources | |
|---|---|
| Domains | LLM_Client, Utility |
| Last Updated | 2026-10-22 00:00 GMT |
Overview
Concrete tool for synchronous LLM chat completions with provider routing (OpenAI or AWS Bedrock), provided by the SkillClaw client package.
Description
The run_llm function is a synchronous utility used by the proxy for system prompt compression and other one-off LLM calls. It routes to either `_run_llm_openai` (standard OpenAI-compatible API) or `_run_llm_bedrock` (AWS Bedrock via BedrockChatClient) based on the config's LLM provider setting. Unlike AsyncLLMClient, this is blocking and intended for use within `asyncio.to_thread` calls.
Usage
Import and use when you need to:
- Make synchronous LLM calls from the proxy server
- Compress system prompts for OpenClaw
- Route between OpenAI and Bedrock providers
Code Reference
Source Location
- Repository: SkillClaw
- File: `skillclaw/utils.py:L48-53`
Signature
def run_llm(messages, config: Optional["SkillClawConfig"] = None) -> str:
"""Run a synchronous LLM chat completion.
Routes to _run_llm_openai or _run_llm_bedrock based on config provider.
Returns the assistant response content text.
"""
Import
from skillclaw.utils import run_llm
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| messages | list[dict] | Yes /// Chat messages | |
| config | None | No /// Config (determines provider, API keys) |
Outputs
| Name | Type | Description |
|---|---|---|
| Returns | str | Assistant response content |
Usage Examples
System Prompt Compression
from skillclaw.utils import run_llm
import asyncio
# Compress a verbose system prompt (used by SkillClawAPIServer)
compressed = asyncio.run(asyncio.to_thread(
run_llm,
[{"role": "user", "content": verbose_system_prompt}],
config,
))