0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

背景

GitHub の Credit 化もあって、安くいいものを使える道を模索してる

今回は、GPT5.5/Opus 4.8 相当とも言われる GLM-5.2 がイベント企画で $50 分無料で試せるってことで、GitHub Copilot で使う方法をまとめてみた
※公式で対応記載無し :sweat_smile:

Hugging Face の Score は以下
image.png

概要

GitHub Copilot は、Integration には記載がないんですが、OpenAI Compatible ってことなので、動くと信じてやってみます :laughing:

image.png

ai & Inference の登録

以下に従い進めていく

以下の手順どおりに

1. https://console.aiand.com にてユーザー登録

image.png
User連携か、e-mail入力

image.png
名前入力と、通貨選択

image.png
自分の状態を選択

image.png
目的を選択

image.png
何を気にする?

image.png
で、完了

2. ホーム画面の右上にある「Credits:$0.00」をクリック

image.png

3. Enter Amountで$50を選択し、「Purchase」をクリック

日本円にしちゃってると、ここで、$50 やれないんだけど、
あわてず騒がず、8000円を入れておく。

$1 = 160円 なので、あーーーって嘆かなくて大丈夫でした :laughing:

4. プロモーションコードを追加で

プロモーションコードは以下で確認します

image.png
すると、ぴったし0円になるので、購入へ :heart_eyes:

image.png
無事登録完了

playground もあるので、色んなモデルを簡易的に試せます。

ここら辺は、LLM 提供してるとこなら大体似たような感じなので、触ればわかる感じ。
image.png
うちの会社のシステムにも、見て分かるUI、を勉強して欲しい、たとえそれが外部からの購入物であったとしても・・ :anger:

さて、本題の、GitHub Copilot で動かせるか?

モデル追加 (Add Models)で、Custom Endpoint を選択

image.png

グループ名を付ける

image.png

API Key の取得と設定

image.png
適当に名前を付けて作成して、その後に出てくるKeyをコピー

image.png
key を入力すると自動的に、Secretへ

apiType

chat-completions を選択

model 設定:最終形

以下の設定でとりあえず動いた。

glm-5.2
	{
		"name": "ai & Inference",
		"vendor": "customendpoint",
		"apiKey": "${input:chat.lm.secret.32f0963}",
		"apiType": "chat-completions",
		"models": [
			{
				"id": "zai-org/glm-5.2",
				"name": "zai-org/glm-5.2",
				"url": "https://api.aiand.com/v1/chat/completions",
				"toolCalling": true,
				"vision": false,
				"maxInputTokens": 1000000,
				"maxOutputTokens": 128000,
				"streaming": false
			}
		]
	}

無事会話が出来ました

image.png

トラブルシュート

当初の設定では動かなかった

bad settings
{
    "name": "ai & Inference",
    "vendor": "customendpoint",
    "apiKey": "...",
    "apiType": "chat-completions",
    "models": [
        {
            "id": "zai-org/glm-5.2",
            "name": "zai-org/glm-5.2",
            "url": "https://api.aiand.com/v1/chat/completions",
            "maxInputTokens": 128000,
            "maxOutputTokens": 16000
        }
    ]
}

vision 未対応

vision: true にしても、エラー

Model 'zai-org/glm-5.2' does not support image input. Use a model with the 'vision' capability

試行、apiType の問題?

curl で試したところ、chat-completions で行けることを確認

chat-completions
$headers = @{                                   
>>     "Authorization" = "Bearer sk-*****"                      
>>     "Content-Type"  = "application/json"
>> }
>>           
>> $body = @{                   
>>     model = "zai-org/glm-5.2"
>>     messages = @(
>>         @{               
>>             role = "user" 
>>             content = "hi"
>>         }
>>     )                      
>> } | ConvertTo-Json -Depth 5
>>                    
>> Invoke-RestMethod `                                   
>>     -Uri "https://api.aiand.com/v1/chat/completions" `
>>     -Method POST `     
>>     -Headers $headers `
>>     -Body $body

普通に返ってくる

response
id                 : chatcmpl-b191f8ec-7d68-4ee5-8f5e-8aaa3dbcceb9
object             : chat.completion
created            : 1782915004
model              : zai-org/GLM-5.2-FP8
choices            : {@{index=0; message=; logprobs=; finish_reason=stop; stop_
                     reason=154827; token_ids=; routed_experts=}}
service_tier       : 
system_fingerprint : vllm-0.23.0-tp8-1f140d10
usage              : @{prompt_tokens=13; total_tokens=178; completion_tokens=16
                     5; prompt_tokens_details=}
prompt_logprobs    : 
prompt_token_ids   : 
prompt_text        : 
kv_transfer_params : 

Stream は??

stream
$headers = @{                                   
>>     "Authorization" = "Bearer sk------"
>>     "Content-Type"  = "application/json"
>> }
>> 
>> $body = @{
>>     model = "zai-org/glm-5.2"  
>>     stream = $true
>>     messages = @(
>>         @{               
>>             role = "user" 
>>             content = "hi"
>>         }
>>     )                      
>> } | ConvertTo-Json -Depth 5
>>                    
>> Invoke-RestMethod `                                   
>>     -Uri "https://api.aiand.com/v1/chat/completions" `
>>     -Method POST `     
>>     -Headers $headers `
>>     -Body $body

比較結果からすると、stream が怪しい、ってことで、streaming: false にしたところ、無事動作した。

項目 OpenAI Chat Completions (期待) ai& GLM-5.2 (実際) 評価
Content-Type text/event-stream text/event-stream OK
SSE形式 data: {json} OK
object chat.completion.chunk OK
id あり OK
model あり OK
delta.role 最初だけ OK
delta.content 文字列が順番に来る ⚠️ 最初は空、その後 reasoning 怪しい
delta.reasoning 通常なし(Chat Completions) ❌ あり 怪しい
finish_reason 最後にstop 未確認 要確認
data: [DONE] 最後に必須 未確認 要確認

あとは、token 合わせて終わり

公式情報を基に変更しただけ

あとがき

始めた時は、対応してねーのか!!と一瞬諦めかけたし、
途中、
image.png
これの連続だったときは、ほんと、もういいかな、とも思いました。

が、やっぱり最後まで信じて出来た時の喜びは、格別ですね。

無事動かせて良かった。

ただ、streaming: false なので、体感はあまりよくないです。
とはいえ、並行作業してればいいだけですしね! :laughing:

Happy Coding! :beers:

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?