GPT呼び出しをGPT-5系に移行する際のパラメータの注意
執筆日
2025/09/30
概要
先日OpenAIのGPT-5リリース時の発表内容をまとめた記事を書きましたが、そこに書かれていなかった(見落としただけかも)落とし穴があったのでその紹介です。
GPT-5系列は基本的に推論モデルとして動作するため、考えれば当然ではあるのですが今までのチャット用汎用モデルで使っていたパラメータが一部使えなくなっています。
テストスクリプト
Azure OpenAIでgpt-5-mini
のサンプルですが、本家OpenAIのAPIやgpt-5-chat
を含む他のモデルでも同じです。
クライアント呼び出し
from openai import AzureOpenAI
OPENAI_ENDPOINT = ""
OPENAI_KEY = ""
OPENAI_API_VERSION = "2025-03-01-preview"
client = AzureOpenAI(
azure_endpoint = OPENAI_ENDPOINT,
api_key=OPENAI_KEY,
api_version=OPENAI_API_VERSION
)
chat API
response = client.chat.completions.create(
model="gpt-5-mini",
messages=[
{"role": "system", "content": "あなたは親切なアシスタントです"},
{"role": "user", "content": "こんにちは"}
],
max_completion_tokens=1000, # OK
# max_tokens=1000,
seed=40, # OK
temperature=1, # 非推奨
top_p=1, # 非推奨
frequency_penalty=0, # 非推奨
presence_penalty=0, # 非推奨
)
print(response.choices[0].message.content)
-
temperature
:1
(float) のみ -
top_p
:1
(float) のみ -
penalty
:0
(float) のみ
いずれも設定しないのが吉ですが、OSS等の利用で必ず設定しなければならない場合はデフォルト値を入れると良いでしょう。
-
max_tokens
は完全にサポート対象外。デフォルト値的なものがあるかもしれないが確認できませんでした。max_completion_tokens
に置き換えてください。 -
seed
: 設定できますが推論モデルで設定してもあまり意味はないと思います。
許可されていないパラメータを入れた場合のエラー
openai.BadRequestError: Error code: 400 - {'error': {'message': "Unsupported value: 'temperature' does not support 0.9 with this model. Only the default (1) value is supported.", 'type': 'invalid_request_error', 'param': 'temperature', 'code': 'unsupported_value'}}
openai.BadRequestError: Error code: 400 - {'error': {'message': "Unsupported parameter: 'top_p' is not supported with this model.", 'type': 'invalid_request_error', 'param': 'top_p', 'code': 'unsupported_parameter'}}
どちらも1だけはエラーが出ませんが、temperatureは「1だけがサポートされています」と表示されるのに対して、top_pは「このモデルではサポートされていません」というメッセージが出ます。penaltyの2種に関しては0以外を入れるとtop_pと同じエラーが出ます。
openai.BadRequestError: Error code: 400 - {'error': {'message': "Unsupported parameter: 'max_tokens' is not supported with this model. Use 'max_completion_tokens' instead.", 'type': 'invalid_request_error', 'param': 'max_tokens', 'code': 'unsupported_parameter'}}
推論モデルなので内部で多くトークンが消費されるため、最終出力トークンの量を制限するmax_completion_tokens
に置き換えられており、全体のトークン使用量を制限するmax_tokens
は使えません。
responses API
from openai.types.responses import ResponseOutputMessage
response = client.responses.create(
model="gpt-5-mini",
input=[
{"role": "system", "content": "あなたは親切なアシスタントです"},
{"role": "user", "content": "こんにちは"}
],
temperature=1, # 非推奨
top_p=1, # 非推奨
# frequency_penalty=0, # responses API非対応
# presence_penalty=0, # responses API非対応
# seed=42, # responses API非対応
# max_tokens=100, # responses API非対応
# max_completion_tokens=100 # responses API非対応
max_output_tokens=1000, # OK
)
for item in response.output:
print(type(item))
if isinstance(item, ResponseOutputMessage):
print(item.content[0].text)
-
temperature
:1
(float) のみ -
top_p
:1
(float) のみ -
penalty
,seed
: 存在しない -
max_tokens
,max_completion_tokens
: 存在しない
トークン制限はmax_output_tokens
になっておりchat APIと違うので注意。
許可されていないパラメータを入れた場合のエラー
openai.BadRequestError: Error code: 400 - {'error': {'message': "Unsupported parameter: 'temperature' is not supported with this model.", 'type': 'invalid_request_error', 'param': 'temperature', 'code': None}}
openai.BadRequestError: Error code: 400 - {'error': {'message': "Unsupported parameter: 'top_p' is not supported with this model.", 'type': 'invalid_request_error', 'param': 'top_p', 'code': None}}
chat APIと変わってどちらも「このモデルではサポートされていません」というエラーが出ます。
まとめ
モデルをgpt-5
に以降の際は、temperature
, top_p
, frequency_penalty
, presence_penalty
, seed
, max_tokens
を設定している場合は削除が推奨です、という話でした。
おわり
GPT-5
は今までのモデルと結構性質が違うのでGPT-4
系で色々チューニングしていたチャットボットはプロンプトも含め再検証が必要になる可能性が高いです。頑張りましょう。
Discussion