Using Skill in AI Agents
TIP
SwanLab Skill requires SDK version >= 0.8; some swanlab api commands (e.g. run series) require SDK >= 0.9.0. Make sure your SDK meets these requirements.
SwanLab-Skill enables AI agents like Claude Code, Codex and OpenCode to automatically log experiment data and query/analyze experiment results on the SwanLab platform. It covers two use cases:
- Writing training tracking code with the Python SDK (
swanlab.init/swanlab.log/swanlab.finish+ multimedia logging) - Querying experiment metrics, logs, summaries and media with the
swanlab apiCLI
The agent first reads the corresponding capability reference based on the task, then generates code or runs queries, avoiding API misuse.
Installation
Install via Agent (Recommended)
If you are using a coding agent like Claude Code or Codex, simply send it the following message to complete the installation automatically:
Fetch the installation guide and follow it: https://raw.githubusercontent.com/SwanHubX/SwanLab-Skill/main/README.mdManual Installation
Global installation is recommended:
npx skills add SwanHubX/SwanLab-Skill -y -gbunx skills add SwanHubX/SwanLab-Skill -y -g
npx skillsis a utility for installing skills into AI agent CLIs. Use-gfor a global install (installed into.agents/skillsunder your home directory, reusable across multiple agent CLIs for the same user). See the skills docs for details.
You can also install via SkillHub or ModelScope:
- 🐧 SkillHub: swanlab-skill
- 🤖 ModelScope: swanlab-skill
To update SwanLab Skill later, run:
npx skills update swanlab-skill -g -yLog in to SwanLab
Before using, make sure your API Key is saved:
pip install swanlab
swanlab login # paste your API key from https://swanlab.cn
swanlab ping # (optional) check connectivity
swanlab verify # (optional) validate credentialsCapabilities
| Capability | Method |
|---|---|
| Log metrics and media objects (image / audio / text) during training/finetuning | Python SDK |
| View a run's metrics, logs, summary, columns and media | swanlab api run ... CLI |
| Filter experiments by config or summary conditions | swanlab api run filter CLI |
| Manage projects, self-hosted users and other resources | swanlab api project / user CLI |
| Plot scalar metric curves for a single run | Helper script plot_metrics.py |
| Compare the same metric across multiple runs (normalized + ranking) | Helper script runs_benchmark.py |