test(integration): basic translation cases for the bedrock_invoke route (#44752)

* test(integration): bedrock_invoke-route basic translation cases on messages, chat completions and responses

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* test(integration): rename translation runner run to assert_translation

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* test(integration): call assert_translation in the bedrock_invoke basic cases

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: kerry <kerry@berri.ai>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
devin-ai-integration[bot] 2026-10-05 19:31:46 -07:00 • committed by GitHub
parent 2156d6c3c7
commit 7cdb3d3760
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 1469 additions and 0 deletions

View file

@ -175,6 +175,42 @@ model_list:
api_base: http://127.0.0.1:8191
api_key: synthetic-azure-key
api_version: "2025-04-01-preview"
- model_name: bedrock/invoke/us.anthropic.claude-haiku-4-5-20251001-v1:0
litellm_params:
model: bedrock/invoke/us.anthropic.claude-haiku-4-5-20251001-v1:0
api_base: http://127.0.0.1:8191
api_key: synthetic-bedrock-key
aws_region_name: us-east-1
- model_name: bedrock/invoke/us.anthropic.claude-sonnet-4-6
litellm_params:
model: bedrock/invoke/us.anthropic.claude-sonnet-4-6
api_base: http://127.0.0.1:8191
api_key: synthetic-bedrock-key
aws_region_name: us-east-1
- model_name: bedrock/invoke/us.anthropic.claude-sonnet-5
litellm_params:
model: bedrock/invoke/us.anthropic.claude-sonnet-5
api_base: http://127.0.0.1:8191
api_key: synthetic-bedrock-key
aws_region_name: us-east-1
- model_name: bedrock/invoke/us.anthropic.claude-opus-4-8
litellm_params:
model: bedrock/invoke/us.anthropic.claude-opus-4-8
api_base: http://127.0.0.1:8191
api_key: synthetic-bedrock-key
aws_region_name: us-east-1
- model_name: bedrock/invoke/us.anthropic.claude-sonnet-5-5
litellm_params:
model: bedrock/invoke/us.anthropic.claude-sonnet-5-5
api_base: http://127.0.0.1:8191
api_key: synthetic-bedrock-key
aws_region_name: us-east-1
- model_name: bedrock/invoke/us.anthropic.claude-opus-5-5
litellm_params:
model: bedrock/invoke/us.anthropic.claude-opus-5-5
api_base: http://127.0.0.1:8191
api_key: synthetic-bedrock-key
aws_region_name: us-east-1
general_settings:
master_key: os.environ/LITELLM_MASTER_KEY
database_url: os.environ/DATABASE_URL

View file

@ -0,0 +1,449 @@
from typing import Final
from unittest.mock import ANY
from integration.translation.case import TranslationTestCase
CLAUDE_HAIKU_4_5_TEST_CASE: Final = TranslationTestCase(
scenario="basic",
litellm_endpoint="/v1/chat/completions",
litellm_request={
"model": "bedrock/invoke/us.anthropic.claude-haiku-4-5-20251001-v1:0",
"max_tokens": 64,
"messages": [
{"role": "system", "content": "You are a terse assistant."},
{"role": "user", "content": "Say hello."},
],
"cache": {"no-cache": True},
},
expected_provider_endpoint="/model/us.anthropic.claude-haiku-4-5-20251001-v1:0/invoke",
expected_provider_headers={"authorization": "Bearer synthetic-bedrock-key", "content-type": "application/json"},
expected_provider_request={
"messages": [{"role": "user", "content": [{"type": "text", "text": "Say hello."}]}],
"max_tokens": 64,
"system": [{"type": "text", "text": "You are a terse assistant."}],
"anthropic_version": "bedrock-2023-05-31",
},
mock_provider_response={
"model": "anthropic.claude-haiku-4-5-20251001-v1:0",
"id": "msg_bdrk_uaxykqyuejauacvh6ordtb5bbst4xlruet5vju5zjinbcjhycmnq",
"type": "message",
"role": "assistant",
"content": [{"type": "text", "text": "Hello."}],
"container": None,
"stop_reason": "end_turn",
"stop_sequence": None,
"stop_details": None,
"usage": {
"input_tokens": 17,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0},
"output_tokens": 5,
"service_tier": "standard",
},
},
expected_litellm_response={
"id": ANY,
"created": ANY,
"model": "bedrock/invoke/us.anthropic.claude-haiku-4-5-20251001-v1:0",
"object": "chat.completion",
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "Hello.",
"role": "assistant",
"provider_specific_fields": {"citations": None, "thinking_blocks": None},
},
}
],
"usage": {
"completion_tokens": 5,
"prompt_tokens": 17,
"total_tokens": 22,
"completion_tokens_details": {"reasoning_tokens": 0, "text_tokens": 5},
"prompt_tokens_details": {
"cached_tokens": 0,
"text_tokens": 17,
"cache_write_tokens": 0,
"cache_creation_tokens": 0,
"cache_creation_token_details": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0},
},
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"service_tier": "standard",
},
},
)
CLAUDE_SONNET_4_6_TEST_CASE: Final = TranslationTestCase(
scenario="basic",
litellm_endpoint="/v1/chat/completions",
litellm_request={
"model": "bedrock/invoke/us.anthropic.claude-sonnet-4-6",
"max_tokens": 64,
"messages": [
{"role": "system", "content": "You are a terse assistant."},
{"role": "user", "content": "Say hello."},
],
"cache": {"no-cache": True},
},
expected_provider_endpoint="/model/us.anthropic.claude-sonnet-4-6/invoke",
expected_provider_headers={"authorization": "Bearer synthetic-bedrock-key", "content-type": "application/json"},
expected_provider_request={
"messages": [{"role": "user", "content": [{"type": "text", "text": "Say hello."}]}],
"max_tokens": 64,
"system": [{"type": "text", "text": "You are a terse assistant."}],
"anthropic_version": "bedrock-2023-05-31",
},
mock_provider_response={
"model": "claude-sonnet-4-6",
"id": "msg_bdrk_011CfjukowJGNdRPkmrmvmEU",
"type": "message",
"role": "assistant",
"content": [{"type": "text", "text": "Hello!"}],
"stop_reason": "end_turn",
"stop_sequence": None,
"stop_details": None,
"usage": {
"input_tokens": 18,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0},
"output_tokens": 5,
},
},
expected_litellm_response={
"id": ANY,
"created": ANY,
"model": "bedrock/invoke/us.anthropic.claude-sonnet-4-6",
"object": "chat.completion",
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "Hello!",
"role": "assistant",
"provider_specific_fields": {"citations": None, "thinking_blocks": None},
},
}
],
"usage": {
"completion_tokens": 5,
"prompt_tokens": 18,
"total_tokens": 23,
"completion_tokens_details": {"reasoning_tokens": 0, "text_tokens": 5},
"prompt_tokens_details": {
"cached_tokens": 0,
"text_tokens": 18,
"cache_write_tokens": 0,
"cache_creation_tokens": 0,
"cache_creation_token_details": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0},
},
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
},
},
)
CLAUDE_SONNET_5_TEST_CASE: Final = TranslationTestCase(
scenario="basic",
litellm_endpoint="/v1/chat/completions",
litellm_request={
"model": "bedrock/invoke/us.anthropic.claude-sonnet-5",
"max_tokens": 64,
"messages": [
{"role": "system", "content": "You are a terse assistant."},
{"role": "user", "content": "Say hello."},
],
"cache": {"no-cache": True},
},
expected_provider_endpoint="/model/us.anthropic.claude-sonnet-5/invoke",
expected_provider_headers={"authorization": "Bearer synthetic-bedrock-key", "content-type": "application/json"},
expected_provider_request={
"messages": [{"role": "user", "content": [{"type": "text", "text": "Say hello."}]}],
"max_tokens": 64,
"system": [{"type": "text", "text": "You are a terse assistant."}],
"anthropic_version": "bedrock-2023-05-31",
},
mock_provider_response={
"model": "claude-sonnet-5",
"id": "msg_bdrk_vrjdwnaebmlfxkxvd2a74ovr6xl6a3ovufg3gwh3hktoiockg56q",
"type": "message",
"role": "assistant",
"content": [{"type": "text", "text": "Hello."}],
"container": None,
"stop_reason": "end_turn",
"stop_sequence": None,
"stop_details": None,
"usage": {
"input_tokens": 21,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0},
"output_tokens": 6,
"output_tokens_details": {"thinking_tokens": 0},
"service_tier": "standard",
},
},
expected_litellm_response={
"id": ANY,
"created": ANY,
"model": "bedrock/invoke/us.anthropic.claude-sonnet-5",
"object": "chat.completion",
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "Hello.",
"role": "assistant",
"provider_specific_fields": {"citations": None, "thinking_blocks": None},
},
}
],
"usage": {
"completion_tokens": 6,
"prompt_tokens": 21,
"total_tokens": 27,
"completion_tokens_details": {"reasoning_tokens": 0, "text_tokens": 6},
"prompt_tokens_details": {
"cached_tokens": 0,
"text_tokens": 21,
"cache_write_tokens": 0,
"cache_creation_tokens": 0,
"cache_creation_token_details": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0},
},
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"service_tier": "standard",
},
},
)
CLAUDE_OPUS_4_8_TEST_CASE: Final = TranslationTestCase(
scenario="basic",
litellm_endpoint="/v1/chat/completions",
litellm_request={
"model": "bedrock/invoke/us.anthropic.claude-opus-4-8",
"max_tokens": 64,
"messages": [
{"role": "system", "content": "You are a terse assistant."},
{"role": "user", "content": "Say hello."},
],
"cache": {"no-cache": True},
},
expected_provider_endpoint="/model/us.anthropic.claude-opus-4-8/invoke",
expected_provider_headers={"authorization": "Bearer synthetic-bedrock-key", "content-type": "application/json"},
expected_provider_request={
"messages": [{"role": "user", "content": [{"type": "text", "text": "Say hello."}]}],
"max_tokens": 64,
"system": [{"type": "text", "text": "You are a terse assistant."}],
"anthropic_version": "bedrock-2023-05-31",
},
mock_provider_response={
"model": "claude-opus-4-8",
"id": "msg_bdrk_j2vze3iapymvotnltudlq6kyexytgav6tdiwmintqfjsdga266bq",
"type": "message",
"role": "assistant",
"content": [{"type": "text", "text": "Hello."}],
"container": None,
"stop_reason": "end_turn",
"stop_sequence": None,
"stop_details": None,
"usage": {
"input_tokens": 21,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0},
"output_tokens": 6,
"output_tokens_details": {"thinking_tokens": 0},
"service_tier": "standard",
},
},
expected_litellm_response={
"id": ANY,
"created": ANY,
"model": "bedrock/invoke/us.anthropic.claude-opus-4-8",
"object": "chat.completion",
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "Hello.",
"role": "assistant",
"provider_specific_fields": {"citations": None, "thinking_blocks": None},
},
}
],
"usage": {
"completion_tokens": 6,
"prompt_tokens": 21,
"total_tokens": 27,
"completion_tokens_details": {"reasoning_tokens": 0, "text_tokens": 6},
"prompt_tokens_details": {
"cached_tokens": 0,
"text_tokens": 21,
"cache_write_tokens": 0,
"cache_creation_tokens": 0,
"cache_creation_token_details": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0},
},
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"service_tier": "standard",
},
},
)
CLAUDE_SONNET_5_5_TEST_CASE: Final = TranslationTestCase(
scenario="basic",
litellm_endpoint="/v1/chat/completions",
litellm_request={
"model": "bedrock/invoke/us.anthropic.claude-sonnet-5-5",
"max_tokens": 64,
"messages": [
{"role": "system", "content": "You are a terse assistant."},
{"role": "user", "content": "Say hello."},
],
"cache": {"no-cache": True},
},
expected_provider_endpoint="/model/us.anthropic.claude-sonnet-5-5/invoke",
expected_provider_headers={"authorization": "Bearer synthetic-bedrock-key", "content-type": "application/json"},
expected_provider_request={
"messages": [{"role": "user", "content": [{"type": "text", "text": "Say hello."}]}],
"max_tokens": 64,
"system": [{"type": "text", "text": "You are a terse assistant."}],
"anthropic_version": "bedrock-2023-05-31",
},
mock_provider_response={
"model": "claude-sonnet-5-5",
"id": "msg_bdrk_tozg7mwrkjb7fisuua7q5ylekeypufs6he64a2tlncr4bvdg4dha",
"type": "message",
"role": "assistant",
"content": [{"type": "text", "text": "Hello."}],
"container": None,
"stop_reason": "end_turn",
"stop_sequence": None,
"stop_details": None,
"usage": {
"input_tokens": 23,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0},
"output_tokens": 6,
"output_tokens_details": {"thinking_tokens": 0},
"service_tier": "standard",
},
},
expected_litellm_response={
"id": ANY,
"created": ANY,
"model": "bedrock/invoke/us.anthropic.claude-sonnet-5-5",
"object": "chat.completion",
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "Hello.",
"role": "assistant",
"provider_specific_fields": {"citations": None, "thinking_blocks": None},
},
}
],
"usage": {
"completion_tokens": 6,
"prompt_tokens": 23,
"total_tokens": 29,
"completion_tokens_details": {"reasoning_tokens": 0, "text_tokens": 6},
"prompt_tokens_details": {
"cached_tokens": 0,
"text_tokens": 23,
"cache_write_tokens": 0,
"cache_creation_tokens": 0,
"cache_creation_token_details": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0},
},
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"service_tier": "standard",
},
},
)
CLAUDE_OPUS_5_5_TEST_CASE: Final = TranslationTestCase(
scenario="basic",
litellm_endpoint="/v1/chat/completions",
litellm_request={
"model": "bedrock/invoke/us.anthropic.claude-opus-5-5",
"max_tokens": 64,
"messages": [
{"role": "system", "content": "You are a terse assistant."},
{"role": "user", "content": "Say hello."},
],
"cache": {"no-cache": True},
},
expected_provider_endpoint="/model/us.anthropic.claude-opus-5-5/invoke",
expected_provider_headers={"authorization": "Bearer synthetic-bedrock-key", "content-type": "application/json"},
expected_provider_request={
"messages": [{"role": "user", "content": [{"type": "text", "text": "Say hello."}]}],
"max_tokens": 64,
"system": [{"type": "text", "text": "You are a terse assistant."}],
"anthropic_version": "bedrock-2023-05-31",
},
mock_provider_response={
"model": "claude-opus-5-5",
"id": "msg_bdrk_mxljoibckai4wqyt4wd7cmslqjtlkals5cbwms2hackerasjglha",
"type": "message",
"role": "assistant",
"content": [{"type": "text", "text": "Hello."}],
"container": None,
"stop_reason": "end_turn",
"stop_sequence": None,
"stop_details": None,
"usage": {
"input_tokens": 23,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0},
"output_tokens": 6,
"output_tokens_details": {"thinking_tokens": 0},
"service_tier": "standard",
},
},
expected_litellm_response={
"id": ANY,
"created": ANY,
"model": "bedrock/invoke/us.anthropic.claude-opus-5-5",
"object": "chat.completion",
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "Hello.",
"role": "assistant",
"provider_specific_fields": {"citations": None, "thinking_blocks": None},
},
}
],
"usage": {
"completion_tokens": 6,
"prompt_tokens": 23,
"total_tokens": 29,
"completion_tokens_details": {"reasoning_tokens": 0, "text_tokens": 6},
"prompt_tokens_details": {
"cached_tokens": 0,
"text_tokens": 23,
"cache_write_tokens": 0,
"cache_creation_tokens": 0,
"cache_creation_token_details": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0},
},
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"service_tier": "standard",
},
},
)

View file

@ -0,0 +1,31 @@
import pytest
from integration._support.client import Gateway
from integration._support.provider import SharedProvider
from integration.translation.case import TranslationTestCase
from integration.translation.chat_completions.bases.bedrock_invoke import (
CLAUDE_HAIKU_4_5_TEST_CASE,
CLAUDE_OPUS_4_8_TEST_CASE,
CLAUDE_OPUS_5_5_TEST_CASE,
CLAUDE_SONNET_4_6_TEST_CASE,
CLAUDE_SONNET_5_5_TEST_CASE,
CLAUDE_SONNET_5_TEST_CASE,
)
from integration.translation.runner import assert_translation
@pytest.mark.parametrize(
"case",
[
CLAUDE_HAIKU_4_5_TEST_CASE,
CLAUDE_SONNET_4_6_TEST_CASE,
CLAUDE_SONNET_5_TEST_CASE,
CLAUDE_OPUS_4_8_TEST_CASE,
CLAUDE_SONNET_5_5_TEST_CASE,
CLAUDE_OPUS_5_5_TEST_CASE,
],
ids=lambda case: case.id,
)
def test_chat_completions_basic_bedrock_invoke(
case: TranslationTestCase, gateway: Gateway, provider: SharedProvider
) -> None:
assert_translation(case, gateway, provider)

View file

@ -0,0 +1,355 @@
from typing import Final
from integration.translation.case import TranslationTestCase
CLAUDE_HAIKU_4_5_TEST_CASE: Final = TranslationTestCase(
scenario="basic",
litellm_endpoint="/v1/messages",
litellm_request={
"model": "bedrock/invoke/us.anthropic.claude-haiku-4-5-20251001-v1:0",
"max_tokens": 64,
"system": "You are a terse assistant.",
"messages": [{"role": "user", "content": "Say hello."}],
"cache": {"no-cache": True},
},
expected_provider_endpoint="/model/us.anthropic.claude-haiku-4-5-20251001-v1:0/invoke",
expected_provider_headers={"authorization": "Bearer synthetic-bedrock-key", "content-type": "application/json"},
expected_provider_request={
"messages": [{"role": "user", "content": "Say hello."}],
"max_tokens": 64,
"system": [{"type": "text", "text": "You are a terse assistant."}],
"anthropic_version": "bedrock-2023-05-31",
},
mock_provider_response={
"model": "anthropic.claude-haiku-4-5-20251001-v1:0",
"id": "msg_bdrk_tl6mgwwa5lgxbhipnkc6qb7landewz65mwxm553sydrxicheqe4a",
"type": "message",
"role": "assistant",
"content": [{"type": "text", "text": "Hello."}],
"container": None,
"stop_reason": "end_turn",
"stop_sequence": None,
"stop_details": None,
"usage": {
"input_tokens": 17,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0},
"output_tokens": 5,
"service_tier": "standard",
},
},
expected_litellm_response={
"model": "bedrock/invoke/us.anthropic.claude-haiku-4-5-20251001-v1:0",
"id": "msg_bdrk_tl6mgwwa5lgxbhipnkc6qb7landewz65mwxm553sydrxicheqe4a",
"type": "message",
"role": "assistant",
"content": [{"type": "text", "text": "Hello."}],
"container": None,
"stop_reason": "end_turn",
"stop_sequence": None,
"stop_details": None,
"usage": {
"input_tokens": 17,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0},
"output_tokens": 5,
"service_tier": "standard",
},
},
)
CLAUDE_SONNET_4_6_TEST_CASE: Final = TranslationTestCase(
scenario="basic",
litellm_endpoint="/v1/messages",
litellm_request={
"model": "bedrock/invoke/us.anthropic.claude-sonnet-4-6",
"max_tokens": 64,
"system": "You are a terse assistant.",
"messages": [{"role": "user", "content": "Say hello."}],
"cache": {"no-cache": True},
},
expected_provider_endpoint="/model/us.anthropic.claude-sonnet-4-6/invoke",
expected_provider_headers={"authorization": "Bearer synthetic-bedrock-key", "content-type": "application/json"},
expected_provider_request={
"messages": [{"role": "user", "content": "Say hello."}],
"max_tokens": 64,
"system": [{"type": "text", "text": "You are a terse assistant."}],
"anthropic_version": "bedrock-2023-05-31",
},
mock_provider_response={
"model": "claude-sonnet-4-6",
"id": "msg_bdrk_011CfjukiGyrRwzy4SYisy1x",
"type": "message",
"role": "assistant",
"content": [{"type": "text", "text": "Hello! How can I help you?"}],
"stop_reason": "end_turn",
"stop_sequence": None,
"stop_details": None,
"usage": {
"input_tokens": 18,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0},
"output_tokens": 11,
},
},
expected_litellm_response={
"model": "bedrock/invoke/us.anthropic.claude-sonnet-4-6",
"id": "msg_bdrk_011CfjukiGyrRwzy4SYisy1x",
"type": "message",
"role": "assistant",
"content": [{"type": "text", "text": "Hello! How can I help you?"}],
"stop_reason": "end_turn",
"stop_sequence": None,
"stop_details": None,
"usage": {
"input_tokens": 18,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0},
"output_tokens": 11,
},
},
)
CLAUDE_SONNET_5_TEST_CASE: Final = TranslationTestCase(
scenario="basic",
litellm_endpoint="/v1/messages",
litellm_request={
"model": "bedrock/invoke/us.anthropic.claude-sonnet-5",
"max_tokens": 64,
"system": "You are a terse assistant.",
"messages": [{"role": "user", "content": "Say hello."}],
"cache": {"no-cache": True},
},
expected_provider_endpoint="/model/us.anthropic.claude-sonnet-5/invoke",
expected_provider_headers={"authorization": "Bearer synthetic-bedrock-key", "content-type": "application/json"},
expected_provider_request={
"messages": [{"role": "user", "content": "Say hello."}],
"max_tokens": 64,
"system": [{"type": "text", "text": "You are a terse assistant."}],
"anthropic_version": "bedrock-2023-05-31",
},
mock_provider_response={
"model": "claude-sonnet-5",
"id": "msg_bdrk_ccbiw5fsz7qitzhh3dkgpdlk6l6cebry5wwwncia55axys522tfq",
"type": "message",
"role": "assistant",
"content": [{"type": "text", "text": "Hello!"}],
"container": None,
"stop_reason": "end_turn",
"stop_sequence": None,
"stop_details": None,
"usage": {
"input_tokens": 21,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0},
"output_tokens": 6,
"output_tokens_details": {"thinking_tokens": 0},
"service_tier": "standard",
},
},
expected_litellm_response={
"model": "bedrock/invoke/us.anthropic.claude-sonnet-5",
"id": "msg_bdrk_ccbiw5fsz7qitzhh3dkgpdlk6l6cebry5wwwncia55axys522tfq",
"type": "message",
"role": "assistant",
"content": [{"type": "text", "text": "Hello!"}],
"container": None,
"stop_reason": "end_turn",
"stop_sequence": None,
"stop_details": None,
"usage": {
"input_tokens": 21,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0},
"output_tokens": 6,
"output_tokens_details": {"thinking_tokens": 0},
"service_tier": "standard",
},
},
)
CLAUDE_OPUS_4_8_TEST_CASE: Final = TranslationTestCase(
scenario="basic",
litellm_endpoint="/v1/messages",
litellm_request={
"model": "bedrock/invoke/us.anthropic.claude-opus-4-8",
"max_tokens": 64,
"system": "You are a terse assistant.",
"messages": [{"role": "user", "content": "Say hello."}],
"cache": {"no-cache": True},
},
expected_provider_endpoint="/model/us.anthropic.claude-opus-4-8/invoke",
expected_provider_headers={"authorization": "Bearer synthetic-bedrock-key", "content-type": "application/json"},
expected_provider_request={
"messages": [{"role": "user", "content": "Say hello."}],
"max_tokens": 64,
"system": [{"type": "text", "text": "You are a terse assistant."}],
"anthropic_version": "bedrock-2023-05-31",
},
mock_provider_response={
"model": "claude-opus-4-8",
"id": "msg_bdrk_hii3yom4fpd564flttcopesy4ghq7mdw42s4xqmegk2fqmgc2suq",
"type": "message",
"role": "assistant",
"content": [{"type": "text", "text": "Hello."}],
"container": None,
"stop_reason": "end_turn",
"stop_sequence": None,
"stop_details": None,
"usage": {
"input_tokens": 21,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0},
"output_tokens": 6,
"output_tokens_details": {"thinking_tokens": 0},
"service_tier": "standard",
},
},
expected_litellm_response={
"model": "bedrock/invoke/us.anthropic.claude-opus-4-8",
"id": "msg_bdrk_hii3yom4fpd564flttcopesy4ghq7mdw42s4xqmegk2fqmgc2suq",
"type": "message",
"role": "assistant",
"content": [{"type": "text", "text": "Hello."}],
"container": None,
"stop_reason": "end_turn",
"stop_sequence": None,
"stop_details": None,
"usage": {
"input_tokens": 21,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0},
"output_tokens": 6,
"output_tokens_details": {"thinking_tokens": 0},
"service_tier": "standard",
},
},
)
CLAUDE_SONNET_5_5_TEST_CASE: Final = TranslationTestCase(
scenario="basic",
litellm_endpoint="/v1/messages",
litellm_request={
"model": "bedrock/invoke/us.anthropic.claude-sonnet-5-5",
"max_tokens": 64,
"system": "You are a terse assistant.",
"messages": [{"role": "user", "content": "Say hello."}],
"cache": {"no-cache": True},
},
expected_provider_endpoint="/model/us.anthropic.claude-sonnet-5-5/invoke",
expected_provider_headers={"authorization": "Bearer synthetic-bedrock-key", "content-type": "application/json"},
expected_provider_request={
"messages": [{"role": "user", "content": "Say hello."}],
"max_tokens": 64,
"system": [{"type": "text", "text": "You are a terse assistant."}],
"anthropic_version": "bedrock-2023-05-31",
},
mock_provider_response={
"model": "claude-sonnet-5-5",
"id": "msg_bdrk_g36x73tqvgb222xutjv3lkmjrff6fbfmtc23hkagpgosftu4tjda",
"type": "message",
"role": "assistant",
"content": [{"type": "text", "text": "Hello."}],
"container": None,
"stop_reason": "end_turn",
"stop_sequence": None,
"stop_details": None,
"usage": {
"input_tokens": 23,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0},
"output_tokens": 6,
"output_tokens_details": {"thinking_tokens": 0},
"service_tier": "standard",
},
},
expected_litellm_response={
"model": "bedrock/invoke/us.anthropic.claude-sonnet-5-5",
"id": "msg_bdrk_g36x73tqvgb222xutjv3lkmjrff6fbfmtc23hkagpgosftu4tjda",
"type": "message",
"role": "assistant",
"content": [{"type": "text", "text": "Hello."}],
"container": None,
"stop_reason": "end_turn",
"stop_sequence": None,
"stop_details": None,
"usage": {
"input_tokens": 23,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0},
"output_tokens": 6,
"output_tokens_details": {"thinking_tokens": 0},
"service_tier": "standard",
},
},
)
CLAUDE_OPUS_5_5_TEST_CASE: Final = TranslationTestCase(
scenario="basic",
litellm_endpoint="/v1/messages",
litellm_request={
"model": "bedrock/invoke/us.anthropic.claude-opus-5-5",
"max_tokens": 64,
"system": "You are a terse assistant.",
"messages": [{"role": "user", "content": "Say hello."}],
"cache": {"no-cache": True},
},
expected_provider_endpoint="/model/us.anthropic.claude-opus-5-5/invoke",
expected_provider_headers={"authorization": "Bearer synthetic-bedrock-key", "content-type": "application/json"},
expected_provider_request={
"messages": [{"role": "user", "content": "Say hello."}],
"max_tokens": 64,
"system": [{"type": "text", "text": "You are a terse assistant."}],
"anthropic_version": "bedrock-2023-05-31",
},
mock_provider_response={
"model": "claude-opus-5-5",
"id": "msg_bdrk_lq3occizkeecj263kns2j73zgj4lnn3kzlgll5xnqvk3etlf4pqq",
"type": "message",
"role": "assistant",
"content": [{"type": "text", "text": "Hello."}],
"container": None,
"stop_reason": "end_turn",
"stop_sequence": None,
"stop_details": None,
"usage": {
"input_tokens": 23,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0},
"output_tokens": 6,
"output_tokens_details": {"thinking_tokens": 0},
"service_tier": "standard",
},
},
expected_litellm_response={
"model": "bedrock/invoke/us.anthropic.claude-opus-5-5",
"id": "msg_bdrk_lq3occizkeecj263kns2j73zgj4lnn3kzlgll5xnqvk3etlf4pqq",
"type": "message",
"role": "assistant",
"content": [{"type": "text", "text": "Hello."}],
"container": None,
"stop_reason": "end_turn",
"stop_sequence": None,
"stop_details": None,
"usage": {
"input_tokens": 23,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0},
"output_tokens": 6,
"output_tokens_details": {"thinking_tokens": 0},
"service_tier": "standard",
},
},
)

View file

@ -0,0 +1,29 @@
import pytest
from integration._support.client import Gateway
from integration._support.provider import SharedProvider
from integration.translation.case import TranslationTestCase
from integration.translation.messages.bases.bedrock_invoke import (
CLAUDE_HAIKU_4_5_TEST_CASE,
CLAUDE_OPUS_4_8_TEST_CASE,
CLAUDE_OPUS_5_5_TEST_CASE,
CLAUDE_SONNET_4_6_TEST_CASE,
CLAUDE_SONNET_5_5_TEST_CASE,
CLAUDE_SONNET_5_TEST_CASE,
)
from integration.translation.runner import assert_translation
@pytest.mark.parametrize(
"case",
[
CLAUDE_HAIKU_4_5_TEST_CASE,
CLAUDE_SONNET_4_6_TEST_CASE,
CLAUDE_SONNET_5_TEST_CASE,
CLAUDE_OPUS_4_8_TEST_CASE,
CLAUDE_SONNET_5_5_TEST_CASE,
CLAUDE_OPUS_5_5_TEST_CASE,
],
ids=lambda case: case.id,
)
def test_messages_basic_bedrock_invoke(case: TranslationTestCase, gateway: Gateway, provider: SharedProvider) -> None:
assert_translation(case, gateway, provider)

View file

@ -0,0 +1,540 @@
from typing import Final
from unittest.mock import ANY
from integration.translation.case import TranslationTestCase
CLAUDE_HAIKU_4_5_TEST_CASE: Final = TranslationTestCase(
scenario="basic",
litellm_endpoint="/v1/responses",
litellm_request={
"model": "bedrock/invoke/us.anthropic.claude-haiku-4-5-20251001-v1:0",
"max_output_tokens": 64,
"instructions": "You are a terse assistant.",
"input": "Say hello.",
"cache": {"no-cache": True},
},
expected_provider_endpoint="/model/us.anthropic.claude-haiku-4-5-20251001-v1:0/invoke",
expected_provider_headers={"authorization": "Bearer synthetic-bedrock-key", "content-type": "application/json"},
expected_provider_request={
"messages": [{"role": "user", "content": [{"type": "text", "text": "Say hello."}]}],
"max_tokens": 64,
"system": [{"type": "text", "text": "You are a terse assistant."}],
"anthropic_version": "bedrock-2023-05-31",
},
mock_provider_response={
"model": "anthropic.claude-haiku-4-5-20251001-v1:0",
"id": "msg_bdrk_uaxykqyuejauacvh6ordtb5bbst4xlruet5vju5zjinbcjhycmnq",
"type": "message",
"role": "assistant",
"content": [{"type": "text", "text": "Hello."}],
"container": None,
"stop_reason": "end_turn",
"stop_sequence": None,
"stop_details": None,
"usage": {
"input_tokens": 17,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0},
"output_tokens": 5,
"service_tier": "standard",
},
},
expected_litellm_response={
"id": ANY,
"created_at": ANY,
"error": None,
"incomplete_details": None,
"instructions": "You are a terse assistant.",
"metadata": {},
"model": "bedrock/invoke/us.anthropic.claude-haiku-4-5-20251001-v1:0",
"object": "response",
"output": [
{
"type": "message",
"id": ANY,
"status": "completed",
"role": "assistant",
"content": [{"type": "output_text", "text": "Hello.", "annotations": []}],
"phase": None,
}
],
"parallel_tool_calls": False,
"temperature": None,
"tool_choice": "auto",
"tools": [],
"top_p": None,
"max_output_tokens": 64,
"previous_response_id": None,
"reasoning": None,
"status": "completed",
"text": {},
"truncation": None,
"usage": {
"input_tokens": 17,
"input_tokens_details": {
"audio_tokens": None,
"cached_tokens": 0,
"cached_tokens_details": None,
"image_tokens": None,
"text_tokens": 17,
"video_tokens": None,
"cache_write_tokens": 0,
},
"output_tokens": 5,
"output_tokens_details": {"audio_tokens": None, "reasoning_tokens": 0, "text_tokens": 5},
"total_tokens": 22,
"cost": None,
},
"user": None,
"store": None,
"provider_specific_fields": {"citations": None, "thinking_blocks": None},
},
)
CLAUDE_SONNET_4_6_TEST_CASE: Final = TranslationTestCase(
scenario="basic",
litellm_endpoint="/v1/responses",
litellm_request={
"model": "bedrock/invoke/us.anthropic.claude-sonnet-4-6",
"max_output_tokens": 64,
"instructions": "You are a terse assistant.",
"input": "Say hello.",
"cache": {"no-cache": True},
},
expected_provider_endpoint="/model/us.anthropic.claude-sonnet-4-6/invoke",
expected_provider_headers={"authorization": "Bearer synthetic-bedrock-key", "content-type": "application/json"},
expected_provider_request={
"messages": [{"role": "user", "content": [{"type": "text", "text": "Say hello."}]}],
"max_tokens": 64,
"system": [{"type": "text", "text": "You are a terse assistant."}],
"anthropic_version": "bedrock-2023-05-31",
},
mock_provider_response={
"model": "claude-sonnet-4-6",
"id": "msg_bdrk_011CfjukowJGNdRPkmrmvmEU",
"type": "message",
"role": "assistant",
"content": [{"type": "text", "text": "Hello!"}],
"stop_reason": "end_turn",
"stop_sequence": None,
"stop_details": None,
"usage": {
"input_tokens": 18,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0},
"output_tokens": 5,
},
},
expected_litellm_response={
"id": ANY,
"created_at": ANY,
"error": None,
"incomplete_details": None,
"instructions": "You are a terse assistant.",
"metadata": {},
"model": "bedrock/invoke/us.anthropic.claude-sonnet-4-6",
"object": "response",
"output": [
{
"type": "message",
"id": ANY,
"status": "completed",
"role": "assistant",
"content": [{"type": "output_text", "text": "Hello!", "annotations": []}],
"phase": None,
}
],
"parallel_tool_calls": False,
"temperature": None,
"tool_choice": "auto",
"tools": [],
"top_p": None,
"max_output_tokens": 64,
"previous_response_id": None,
"reasoning": None,
"status": "completed",
"text": {},
"truncation": None,
"usage": {
"input_tokens": 18,
"input_tokens_details": {
"audio_tokens": None,
"cached_tokens": 0,
"cached_tokens_details": None,
"image_tokens": None,
"text_tokens": 18,
"video_tokens": None,
"cache_write_tokens": 0,
},
"output_tokens": 5,
"output_tokens_details": {"audio_tokens": None, "reasoning_tokens": 0, "text_tokens": 5},
"total_tokens": 23,
"cost": None,
},
"user": None,
"store": None,
"provider_specific_fields": {"citations": None, "thinking_blocks": None},
},
)
CLAUDE_SONNET_5_TEST_CASE: Final = TranslationTestCase(
scenario="basic",
litellm_endpoint="/v1/responses",
litellm_request={
"model": "bedrock/invoke/us.anthropic.claude-sonnet-5",
"max_output_tokens": 64,
"instructions": "You are a terse assistant.",
"input": "Say hello.",
"cache": {"no-cache": True},
},
expected_provider_endpoint="/model/us.anthropic.claude-sonnet-5/invoke",
expected_provider_headers={"authorization": "Bearer synthetic-bedrock-key", "content-type": "application/json"},
expected_provider_request={
"messages": [{"role": "user", "content": [{"type": "text", "text": "Say hello."}]}],
"max_tokens": 64,
"system": [{"type": "text", "text": "You are a terse assistant."}],
"anthropic_version": "bedrock-2023-05-31",
},
mock_provider_response={
"model": "claude-sonnet-5",
"id": "msg_bdrk_vrjdwnaebmlfxkxvd2a74ovr6xl6a3ovufg3gwh3hktoiockg56q",
"type": "message",
"role": "assistant",
"content": [{"type": "text", "text": "Hello."}],
"container": None,
"stop_reason": "end_turn",
"stop_sequence": None,
"stop_details": None,
"usage": {
"input_tokens": 21,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0},
"output_tokens": 6,
"output_tokens_details": {"thinking_tokens": 0},
"service_tier": "standard",
},
},
expected_litellm_response={
"id": ANY,
"created_at": ANY,
"error": None,
"incomplete_details": None,
"instructions": "You are a terse assistant.",
"metadata": {},
"model": "bedrock/invoke/us.anthropic.claude-sonnet-5",
"object": "response",
"output": [
{
"type": "message",
"id": ANY,
"status": "completed",
"role": "assistant",
"content": [{"type": "output_text", "text": "Hello.", "annotations": []}],
"phase": None,
}
],
"parallel_tool_calls": False,
"temperature": None,
"tool_choice": "auto",
"tools": [],
"top_p": None,
"max_output_tokens": 64,
"previous_response_id": None,
"reasoning": None,
"status": "completed",
"text": {},
"truncation": None,
"usage": {
"input_tokens": 21,
"input_tokens_details": {
"audio_tokens": None,
"cached_tokens": 0,
"cached_tokens_details": None,
"image_tokens": None,
"text_tokens": 21,
"video_tokens": None,
"cache_write_tokens": 0,
},
"output_tokens": 6,
"output_tokens_details": {"audio_tokens": None, "reasoning_tokens": 0, "text_tokens": 6},
"total_tokens": 27,
"cost": None,
},
"user": None,
"store": None,
"provider_specific_fields": {"citations": None, "thinking_blocks": None},
},
)
CLAUDE_OPUS_4_8_TEST_CASE: Final = TranslationTestCase(
scenario="basic",
litellm_endpoint="/v1/responses",
litellm_request={
"model": "bedrock/invoke/us.anthropic.claude-opus-4-8",
"max_output_tokens": 64,
"instructions": "You are a terse assistant.",
"input": "Say hello.",
"cache": {"no-cache": True},
},
expected_provider_endpoint="/model/us.anthropic.claude-opus-4-8/invoke",
expected_provider_headers={"authorization": "Bearer synthetic-bedrock-key", "content-type": "application/json"},
expected_provider_request={
"messages": [{"role": "user", "content": [{"type": "text", "text": "Say hello."}]}],
"max_tokens": 64,
"system": [{"type": "text", "text": "You are a terse assistant."}],
"anthropic_version": "bedrock-2023-05-31",
},
mock_provider_response={
"model": "claude-opus-4-8",
"id": "msg_bdrk_j2vze3iapymvotnltudlq6kyexytgav6tdiwmintqfjsdga266bq",
"type": "message",
"role": "assistant",
"content": [{"type": "text", "text": "Hello."}],
"container": None,
"stop_reason": "end_turn",
"stop_sequence": None,
"stop_details": None,
"usage": {
"input_tokens": 21,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0},
"output_tokens": 6,
"output_tokens_details": {"thinking_tokens": 0},
"service_tier": "standard",
},
},
expected_litellm_response={
"id": ANY,
"created_at": ANY,
"error": None,
"incomplete_details": None,
"instructions": "You are a terse assistant.",
"metadata": {},
"model": "bedrock/invoke/us.anthropic.claude-opus-4-8",
"object": "response",
"output": [
{
"type": "message",
"id": ANY,
"status": "completed",
"role": "assistant",
"content": [{"type": "output_text", "text": "Hello.", "annotations": []}],
"phase": None,
}
],
"parallel_tool_calls": False,
"temperature": None,
"tool_choice": "auto",
"tools": [],
"top_p": None,
"max_output_tokens": 64,
"previous_response_id": None,
"reasoning": None,
"status": "completed",
"text": {},
"truncation": None,
"usage": {
"input_tokens": 21,
"input_tokens_details": {
"audio_tokens": None,
"cached_tokens": 0,
"cached_tokens_details": None,
"image_tokens": None,
"text_tokens": 21,
"video_tokens": None,
"cache_write_tokens": 0,
},
"output_tokens": 6,
"output_tokens_details": {"audio_tokens": None, "reasoning_tokens": 0, "text_tokens": 6},
"total_tokens": 27,
"cost": None,
},
"user": None,
"store": None,
"provider_specific_fields": {"citations": None, "thinking_blocks": None},
},
)
CLAUDE_SONNET_5_5_TEST_CASE: Final = TranslationTestCase(
scenario="basic",
litellm_endpoint="/v1/responses",
litellm_request={
"model": "bedrock/invoke/us.anthropic.claude-sonnet-5-5",
"max_output_tokens": 64,
"instructions": "You are a terse assistant.",
"input": "Say hello.",
"cache": {"no-cache": True},
},
expected_provider_endpoint="/model/us.anthropic.claude-sonnet-5-5/invoke",
expected_provider_headers={"authorization": "Bearer synthetic-bedrock-key", "content-type": "application/json"},
expected_provider_request={
"messages": [{"role": "user", "content": [{"type": "text", "text": "Say hello."}]}],
"max_tokens": 64,
"system": [{"type": "text", "text": "You are a terse assistant."}],
"anthropic_version": "bedrock-2023-05-31",
},
mock_provider_response={
"model": "claude-sonnet-5-5",
"id": "msg_bdrk_tozg7mwrkjb7fisuua7q5ylekeypufs6he64a2tlncr4bvdg4dha",
"type": "message",
"role": "assistant",
"content": [{"type": "text", "text": "Hello."}],
"container": None,
"stop_reason": "end_turn",
"stop_sequence": None,
"stop_details": None,
"usage": {
"input_tokens": 23,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0},
"output_tokens": 6,
"output_tokens_details": {"thinking_tokens": 0},
"service_tier": "standard",
},
},
expected_litellm_response={
"id": ANY,
"created_at": ANY,
"error": None,
"incomplete_details": None,
"instructions": "You are a terse assistant.",
"metadata": {},
"model": "bedrock/invoke/us.anthropic.claude-sonnet-5-5",
"object": "response",
"output": [
{
"type": "message",
"id": ANY,
"status": "completed",
"role": "assistant",
"content": [{"type": "output_text", "text": "Hello.", "annotations": []}],
"phase": None,
}
],
"parallel_tool_calls": False,
"temperature": None,
"tool_choice": "auto",
"tools": [],
"top_p": None,
"max_output_tokens": 64,
"previous_response_id": None,
"reasoning": None,
"status": "completed",
"text": {},
"truncation": None,
"usage": {
"input_tokens": 23,
"input_tokens_details": {
"audio_tokens": None,
"cached_tokens": 0,
"cached_tokens_details": None,
"image_tokens": None,
"text_tokens": 23,
"video_tokens": None,
"cache_write_tokens": 0,
},
"output_tokens": 6,
"output_tokens_details": {"audio_tokens": None, "reasoning_tokens": 0, "text_tokens": 6},
"total_tokens": 29,
"cost": None,
},
"user": None,
"store": None,
"provider_specific_fields": {"citations": None, "thinking_blocks": None},
},
)
CLAUDE_OPUS_5_5_TEST_CASE: Final = TranslationTestCase(
scenario="basic",
litellm_endpoint="/v1/responses",
litellm_request={
"model": "bedrock/invoke/us.anthropic.claude-opus-5-5",
"max_output_tokens": 64,
"instructions": "You are a terse assistant.",
"input": "Say hello.",
"cache": {"no-cache": True},
},
expected_provider_endpoint="/model/us.anthropic.claude-opus-5-5/invoke",
expected_provider_headers={"authorization": "Bearer synthetic-bedrock-key", "content-type": "application/json"},
expected_provider_request={
"messages": [{"role": "user", "content": [{"type": "text", "text": "Say hello."}]}],
"max_tokens": 64,
"system": [{"type": "text", "text": "You are a terse assistant."}],
"anthropic_version": "bedrock-2023-05-31",
},
mock_provider_response={
"model": "claude-opus-5-5",
"id": "msg_bdrk_mxljoibckai4wqyt4wd7cmslqjtlkals5cbwms2hackerasjglha",
"type": "message",
"role": "assistant",
"content": [{"type": "text", "text": "Hello."}],
"container": None,
"stop_reason": "end_turn",
"stop_sequence": None,
"stop_details": None,
"usage": {
"input_tokens": 23,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"cache_creation": {"ephemeral_5m_input_tokens": 0, "ephemeral_1h_input_tokens": 0},
"output_tokens": 6,
"output_tokens_details": {"thinking_tokens": 0},
"service_tier": "standard",
},
},
expected_litellm_response={
"id": ANY,
"created_at": ANY,
"error": None,
"incomplete_details": None,
"instructions": "You are a terse assistant.",
"metadata": {},
"model": "bedrock/invoke/us.anthropic.claude-opus-5-5",
"object": "response",
"output": [
{
"type": "message",
"id": ANY,
"status": "completed",
"role": "assistant",
"content": [{"type": "output_text", "text": "Hello.", "annotations": []}],
"phase": None,
}
],
"parallel_tool_calls": False,
"temperature": None,
"tool_choice": "auto",
"tools": [],
"top_p": None,
"max_output_tokens": 64,
"previous_response_id": None,
"reasoning": None,
"status": "completed",
"text": {},
"truncation": None,
"usage": {
"input_tokens": 23,
"input_tokens_details": {
"audio_tokens": None,
"cached_tokens": 0,
"cached_tokens_details": None,
"image_tokens": None,
"text_tokens": 23,
"video_tokens": None,
"cache_write_tokens": 0,
},
"output_tokens": 6,
"output_tokens_details": {"audio_tokens": None, "reasoning_tokens": 0, "text_tokens": 6},
"total_tokens": 29,
"cost": None,
},
"user": None,
"store": None,
"provider_specific_fields": {"citations": None, "thinking_blocks": None},
},
)

View file

@ -0,0 +1,29 @@
import pytest
from integration._support.client import Gateway
from integration._support.provider import SharedProvider
from integration.translation.case import TranslationTestCase
from integration.translation.responses.bases.bedrock_invoke import (
CLAUDE_HAIKU_4_5_TEST_CASE,
CLAUDE_OPUS_4_8_TEST_CASE,
CLAUDE_OPUS_5_5_TEST_CASE,
CLAUDE_SONNET_4_6_TEST_CASE,
CLAUDE_SONNET_5_5_TEST_CASE,
CLAUDE_SONNET_5_TEST_CASE,
)
from integration.translation.runner import assert_translation
@pytest.mark.parametrize(
"case",
[
CLAUDE_HAIKU_4_5_TEST_CASE,
CLAUDE_SONNET_4_6_TEST_CASE,
CLAUDE_SONNET_5_TEST_CASE,
CLAUDE_OPUS_4_8_TEST_CASE,
CLAUDE_SONNET_5_5_TEST_CASE,
CLAUDE_OPUS_5_5_TEST_CASE,
],
ids=lambda case: case.id,
)
def test_responses_basic_bedrock_invoke(case: TranslationTestCase, gateway: Gateway, provider: SharedProvider) -> None:
assert_translation(case, gateway, provider)