😵💫
私はGitHub modelsのモデルのIDを調べたいだけなんだ
2025-05-08 直った(?)
$ gh models list
Showing 45 available chat models
ID DISPLAY NAME
ai21-labs/ai21-jamba-1.5-large AI21 Jamba 1.5 Large
ai21-labs/ai21-jamba-1.5-mini AI21 Jamba 1.5 Mini
cohere/cohere-command-a Cohere Command A
cohere/cohere-command-r Cohere Command R
IDがみれるようになった、ヤッター!
GitHub modelsが遊べそう…なんだけど?
- モデルのIDの一覧なくない??
ghコマンドにmodels サブコマンドを追加する
- ghコマンドを入れる
- ghコマンドにmodels拡張を入れる https://github.com/github/gh-models
# install
$ gh extension install https://github.com/github/gh-models
$ gh extension upgrade github/gh-models
# help
$ gh models -h
GitHub Models CLI extension allows you to experiment with AI models from the command line.
To see a list of all available commands, run `gh models help`. To run the extension in
interactive mode, run `gh models run`. This will prompt you to select a model and then
enter a prompt. The extension will then return a response from the model.
For more information about what you can do with GitHub Models extension, see the manual
at https://github.com/github/gh-models/blob/main/README.md.
ℹ︎ Azure hosted. AI powered, can make mistakes. Not intended for production/sensitive data.
For more information, see https://github.com/github/gh-models
Usage:
gh models [command]
Available Commands:
completion Generate the autocompletion script for the specified shell
help Help about any command
list List available models
run Run inference with the specified model
view View details about a model
しかし…
色々検索すると、gh models list
で見れるというし、READMEにもあるし
でも、実際実行するとIDのリストがなくない?
$ gh models list
Showing 45 available chat models
DISPLAY NAME MODEL NAME
AI21 Jamba 1.5 Large AI21-Jamba-1.5-Large
AI21 Jamba 1.5 Mini AI21-Jamba-1.5-Mini
Codestral 25.01 Codestral-2501
Cohere Command A cohere-command-a
Cohere Command R Cohere-command-r
Cohere Command R 08-2024 Cohere-command-r-08-2024
とりあえず見つかった方法
- https://github.com/marketplace/models/
- プルダウンでモデルをえらんで、開始する
- コードをひらき、見る
ワイ「嘘でしょ、本当に?」
余談: ghコマンドをつかってREPLをつかう
gh models run
gh models run [model] [prompt] [flags]
だからぁあ、ここのmodelに指定する文字列どこにあるの???
gh replに聞いてみた!
$ gh models run o3
>>> どうやったらGitHub ModelsのモデルのIDリストを取得できますか?
(2024 年6月時点)
GitHub で “モデル” を扱う場合は、内部的には
「GitHub Packages(ghcr.io)に登録された package のうち
package_type が model になっているもの」
という扱いになっています。
したがって「モデル ID の一覧」を取り出すには
GitHub Packages 用の API で package を列挙し、
id フィールドだけ抜き出す、という手順になります。
1. パーソナルアクセストークンを用意
(repo か read:packages 権限があれば OK)
```
export GH_TOKEN=ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
```
2. 対象範囲を決めて API を呼ぶ
例:自分が持つすべてのモデル package を取得する場合
――REST API――
```
curl -s -H "Authorization: Bearer ${GH_TOKEN}" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/user/packages?package_type=model" | jq -r '.[].id'
```
例:ある組織(org)のモデル一覧
```
curl -s -H "Authorization: Bearer ${GH_TOKEN}" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/orgs/<ORG_NAME>/packages?package_type=model" \
| jq -r '.[].id'
```
例:あるリポジトリに紐付いたモデル一覧
```
curl -s -H "Authorization: Bearer ${GH_TOKEN}" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/<OWNER>/<REPO>/packages?package_type=model" \
| jq -r '.[].id'
```
――GitHub CLI――
```
gh api -H "Accept: application/vnd.github+json" \
"user/packages?package_type=model" --paginate \
| jq -r '.[].id'
```
3. GraphQL で取りたい場合(例:組織配下の package を取得)
```
gh api graphql -f query='
query($org:String!) {
organization(login: $org) {
packages(first: 100, packageType: MODEL) {
nodes { id name latestVersion { version } }
pageInfo { hasNextPage endCursor }
}
}
}' -f org=<ORG_NAME> | jq -r '.data.organization.packages.nodes[].id'
```
ポイント
• package_type=model を付けないと “container” や “npm” など他の
パッケージも混ざるので注意
• ページングがあるので 100 個以上ある場合は
--paginate(CLI)あるいは pageInfo を使って繰り返し取得します
• 取得できる id は GraphQL ではグローバル ID、
REST では単なる整数値です
これで “GitHub Models” に登録されているモデル ID の一覧を取得できます。
らしいですが、 まあ嘘です。
まとめ
- GitHub models、Previewだからしかたないね?
- repl、地味に便利(まだ無料らしいし)
Discussion