| 68 | |
| 69 | |
| 70 | def test_bedrock_live_response() -> None: |
| 71 | model = os.environ.get("BEDROCK_LIVE_MODEL") or "openai.gpt-oss-120b" |
| 72 | region = os.environ.get("BEDROCK_LIVE_REGION") or None |
| 73 | profile = os.environ.get("BEDROCK_LIVE_PROFILE") or None |
| 74 | base_url = os.environ.get("AWS_BEDROCK_BASE_URL") or None |
| 75 | if base_url is None: |
| 76 | raise RuntimeError( |
| 77 | "Set AWS_BEDROCK_BASE_URL to the Bedrock GPT-OSS endpoint, for example " |
| 78 | "https://bedrock-mantle.us-west-2.api.aws/v1." |
| 79 | ) |
| 80 | |
| 81 | with OpenAI( |
| 82 | provider=bedrock( |
| 83 | region=region, |
| 84 | profile=profile, |
| 85 | base_url=base_url, |
| 86 | api_key=None, |
| 87 | ), |
| 88 | timeout=60, |
| 89 | max_retries=2, |
| 90 | ) as client: |
| 91 | response = client.responses.create( |
| 92 | model=model, |
| 93 | input="Reply with exactly: bedrock live test ok", |
| 94 | store=False, |
| 95 | ) |
| 96 | |
| 97 | output_text = response.output_text.strip() |
| 98 | assert output_text, f"Bedrock returned no output text for response {response.id}" |
| 99 | assert "bedrock live test ok" in output_text.lower() |
| 100 | print(f"Bedrock live response {response.id}: {output_text}") |