build.nvidia.comからgpt-oss-120bを使ってみた

に公開

今回はbuild.nvidia.comで利用できるgpt-oss-120bを利用してみました。

build.nvidia.comとは?

build.nvidia.comはNVIDIAが提供しているNIMのAPIを試せる環境となっています。NIMとは公式ページにて以下のように説明されています。

NVIDIA NIM™ は、クラウド、データセンター、ワークステーション、エッジなど、あらゆる NVIDIA アクセラレーテッド インフラストラクチャに最新の AI モデルを迅速にデプロイできるように、最適化された事前構築済みの推論マイクロサービスを提供します。

要はマイクロサービスとして様々なAIモデルを実行できる基盤を提供するサービスになります。build.nvidia.comではNIMとして利用できるモデルの中から検証のために様々なモデルを提供してくれるサービスとなります。利用可能なモデルについてはExploreから参照できます。今回は省略しますが様々なモデルがありますのでぜひ試してみてください。なお、APIキーは無料で作成させてもらえますが、あくまで技術検証のためのものなので、本番環境などサービスに組み込む場合はbuild.nvidia.com上のAPIキーは利用しないでください。

https://build.nvidia.com/

https://build.nvidia.com/explore/discover

https://www.nvidia.com/ja-jp/ai-data-science/products/nim-microservices/

gpt-oss-120bを利用してみる

それではbuild.nvidia.com上に展開されているgpt-oss-120bを利用してみましょう。

webブラウザ上での実行

build.nvidia.com上でgpt-oss-120bを動かす方法は二つあり、まずはブラウザ上で実行してみようと思います。以下のリンクにアクセスいただくと2025/10/21時点では以下のような画面となっています。

https://build.nvidia.com/openai/gpt-oss-120b

入力欄があるのでそこに入力するとチャット結果が表示されます。例えばWhat is your profession?と聞くと以下のような返答が即時に生成されました。

またチャット欄の右上にあるParametersからパラメータ設定も可能です。

プログラムからの呼び出し

次はPythonプログラムから呼び出してみます。

まずはuvを利用して環境を構築します。

uv init gpt_oss_120b_build_nvidia_com -p 3.12
cd gpt_oss_120b_build_nvidia_com
uv add openai

次にソースコードですが、web画面の右上にView Codeがあり、そこを選択すると以下のようにサンプルコードが表示されます。

APIキーについて設定する必要がありますが、同画面内にGenerate API Keyがあり、それを選択するとAPIキー入りのソースコードが生成されます。

gpt_oss_120b_build_nvidia_com.py
from openai import OpenAI

client = OpenAI(
  base_url = "https://integrate.api.nvidia.com/v1",
  api_key = "$API_KEY_REQUIRED_IF_EXECUTING_OUTSIDE_NGC"
)

completion = client.chat.completions.create(
  model="openai/gpt-oss-120b",
  messages=[{"role":"user","content":"What is your profession?"}],
  temperature=1,
  top_p=1,
  max_tokens=4096,
  stream=True
)

for chunk in completion:
  reasoning = getattr(chunk.choices[0].delta, "reasoning_content", None)
  if reasoning:
    print(reasoning, end="")
  if chunk.choices[0].delta.content is not None:
    print(chunk.choices[0].delta.content, end="")

利用する際は以下のmessagesにプロンプトを入力する必要があります。先ほどと同じWhat is your profession?を入れております。

completion = client.chat.completions.create(
  model="openai/gpt-oss-120b",
  messages=[{"role":"user","content":"What is your profession?"}],
  temperature=1,
  top_p=1,
  max_tokens=4096,
  stream=True
)

それでは早速このコードを実行してみます。

uv run gpt_oss_120b_build_nvidia_com.py

# 結果
The user asks: "What is your profession?" This is a straightforward question. The user is likely asking about the assistant's "profession." The assistant should respond by explaining it is an AI language model developed by OpenAI, not a human with a profession. It can describe its role: conversational AI, generating text, answering questions, providing assistance, etc. Possibly mention that it's a large language model, trained on diverse dataset.

The user might want an answer like: "I'm a virtual assistant/ AI language model." Should be friendly, concise.

We should also ensure we are consistent with policies: No disallowed content. Provide straightforward answer. There's no request for disallowed content.

We should keep it short: "I'm an AI language model..." Provide some info.

Also, we could ask a follow-up: "Do you need help with something?" But as direct answer works.

Thus final answer: "I am ChatGPT, an AI language model developed by OpenAI, designed to help with answering questions, providing explanations, etc."

We should be careful about describing "profession." Could say "My function is to assist with information..." So final.I’m not a person with a traditional job—I’m ChatGPT, an AI language model created by OpenAI. My “profession,” so to speak, is to understand and generate human‑like text to help answer questions, explain concepts, brainstorm ideas, and assist with a wide range of conversational tasks.

先ほどの結果より長い文章にはなっていますが、どのような得意か答えてくれています。実際に運用で利用する場合はライセンスを購入した上でAPIキーを発行する形になろうかと思います。

まとめ

今回はbuild.nvidia.comからgpt-oss-120bを呼び出してみました。build.nvidia.comでは様々なモデルが検証できるようになっており、GPUサーバをご自身で持っていなくても検証することができますので、ぜひ確認してみてください。

Discussion