model-providers
Select and configure smolagents Model wrappers for Hugging Face Inference Providers, LiteLLM, OpenAI-compatible APIs, Azure OpenAI, Amazon Bedrock, local Transformers/MLX/vLLM, and custom Model subclasses without hardcoding credentials.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- model-providers
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Select and configure smolagents Model wrappers for Hugging Face Inference Providers, LiteLLM, OpenAI-compatible APIs, Azure OpenAI, Amazon Bedrock, local Transformers/MLX/vLLM, and custom Model subclasses without hardcoding credentials.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/api-reference.md7.6 KB
- 参考文档references/provider-matrix.md5.1 KB
- 参考文档references/troubleshooting.md5.9 KB
- 参考文档references/workflows.md5.6 KB
- 脚本scripts/check_model_config.py9.2 KB
03 SKILL.md 正文
Model Providers
Use this sub-skill when a task needs to choose, configure, debug, or serialize a smolagents model object. Agent loop design belongs in ../agent-workflows/SKILL.md; tool schemas and integrations belong in ../tools-and-integrations/SKILL.md; CLI model flags belong in ../cli-and-ui/SKILL.md; sandbox and executor choices belong in ../execution-and-safety/SKILL.md.
Fast Routing
- Identify the runtime: hosted API, OpenAI-compatible endpoint, Azure, Bedrock, local GPU/Apple/vLLM, or a custom adapter.
- Pick the wrapper from
references/provider-matrix.mdand install only the optional extra it needs. - Read constructor details in
references/api-reference.md, especially credential parameters and role/message formatting knobs. - Follow setup patterns in
references/workflows.mdfor environment variables, token limits, streaming, and agent attachment. - If the config fails before generation, use
references/troubleshooting.mdandscripts/check_model_config.pybefore making live provider calls.
Common Patterns
import os
from smolagents import CodeAgent, InferenceClientModel
model = InferenceClientModel(
model_id="Qwen/Qwen3-Next-80B-A3B-Thinking",
provider="together",
token=os.getenv("HF_TOKEN"),
max_tokens=2048,
)
agent = CodeAgent(tools=[], model=model)
import os
from smolagents import OpenAIModel
model = OpenAIModel(
model_id="gpt-4o-mini",
api_base="https://api.openai.com/v1",
api_key=os.getenv("OPENAI_API_KEY"),
temperature=0.2,
)
For provider-specific unsupported parameters, pass the sentinel from smolagents.models:
from smolagents import LiteLLMModel, REMOVE_PARAMETER
model = LiteLLMModel(model_id="xai/grok-4", api_key="...", stop=REMOVE_PARAMETER)
Local Validation Helper
Run the bundled helper against a JSON or YAML model config before wiring it into an agent:
python sub-skills/model-providers/scripts/check_model_config.py model-config.json
The helper validates shape, class-specific fields, credential source references, and optional-extra hints. It does not import provider SDKs, instantiate smolagents classes, read secret values, or call network APIs.
References
references/provider-matrix.mdmaps providers and deployment styles to wrappers, extras, credentials, and caveats.references/api-reference.mdrecords constructor signatures and behavior notes.references/workflows.mdshows selection, environment, streaming, and custom model workflows.references/troubleshooting.mdcovers optional imports, credentials, endpoint URLs, local memory/device failures, token limits, streaming, and custom return formatting.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).