1
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?

【qiitaで多分最速】OpenAI on AWS試してみた

1
Posted at

はじめに

ついにAWSでOpenAIがつかえるようになったぞ!ということで
呼び出しできるのかだけ試してみました。

検証

以下の記事にサンプルコードが載っていたので、それに準じています。

利用可能リージョン

モデル リージョン
GPT-5.5 us-east-2(Ohio)
GPT-5.4 us-east-2(Ohio)、us-west-2(Oregon)

テスト用スクリプト

※IAM権限は個人テスト用のため、Admin権限となっています。

main.py
from openai import OpenAI
from aws_bedrock_token_generator import provide_token

REGION = "us-east-2"
ENDPOINT = f"https://bedrock-mantle.{REGION}.api.aws/openai/v1"

print(f"Generating Bedrock API token for {REGION}...")
token = provide_token(region=REGION)
print("Token generated successfully.\n")

client = OpenAI(base_url=ENDPOINT, api_key=token)

# --- GPT-5.5 ---
print("=== GPT-5.5 Test ===")
try:
    response = client.responses.create(
        model="openai.gpt-5.5",
        input=[
            {"role": "developer", "content": "You are a helpful assistant."},
            {"role": "user", "content": "Say hello in Japanese in one sentence."},
        ],
    )
    print(f"Response: {response.output_text}\n")
except Exception as e:
    print(f"Error: {e}\n")

# --- GPT-5.4 ---
print("=== GPT-5.4 Test ===")
try:
    response = client.responses.create(
        model="openai.gpt-5.4",
        input=[
            {"role": "developer", "content": "You are a helpful assistant."},
            {"role": "user", "content": "What is 2 + 3? Answer with just the number."},
        ],
    )
    print(f"Response: {response.output_text}\n")
except Exception as e:
    print(f"Error: {e}\n")

実行結果

=== GPT-5.5 Test ===
Response: こんにちは。

=== GPT-5.4 Test ===
Response: 5

実行時に登録されたメールアドレスで各モデルへのサブスクリプション登録完了メールが来ていました

注意点:通常のBedrock APIには表示されない

aws bedrock list-foundation-models でモデル一覧を確認しましたが、GPT-5.5/5.4は表示されず、既存のオープンウェイトモデルのみ表示されていました。

まとめ

AWSでもGPT系モデルが使えるようになったということで最速検証目指してまとめました。
AWS内の様々なサービスでClaudeかGPTか選べるようになっていくと嬉しいなと思いました!

参考URL

1
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
1
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?