Skip to main content

Amazon Bedrock Converse API Data Types

PyPI version release PyPI - Python Version Pydantic v2

This project is a Pydantic implementation of Amazon Bedrock Runtime Converse API Data Types.

Example Usage

from bedrock_types import ConverseResponse

...

response = client.converse(
    modelId=model_id,
    messages=messages,
    system=system_prompts,
    inferenceConfig=inference_config,
    additionalModelRequestFields=additional_model_fields,
)

parsed = ConverseResponse.model_validate(response)
print(parsed.model_dump_json(indent=4, exclude_unset=True))
print(parsed.ResponseMetadata)

Output

ResponseMetadata={'RequestId': '427c73bb-df2d-4c1a-8744-db1b5b3c4897', 'HTTPStatusCode': 200, 'HTTPHeaders': {'date': 'Thu, 13 Jun 2024 09:11:25 GMT', 'content-type': 'application/json', 'content-length': '247', 'connection': 'keep-alive', 'x-amzn-requestid': '427c73bb-df2d-4c1a-8744-db1b5b3c4897'}, 'RetryAttempts': 0} additionalModelResponseFields=None metrics=ConverseMetrics(latencyMs=740) output=ConverseOutput(message=Message(content=[ContentBlock(image=None, text="Why don't scientists trust atoms? Because they make up everything!", toolResult=None, toolUse=None)], role='assistant')) stopReason='end_turn' usage=TokenUsage(inputTokens=22, outputTokens=16, totalTokens=38)
{
    "ResponseMetadata": {
        "RequestId": "427c73bb-df2d-4c1a-8744-db1b5b3c4897",
        "HTTPStatusCode": 200,
        "HTTPHeaders": {
            "date": "Thu, 13 Jun 2024 09:11:25 GMT",
            "content-type": "application/json",
            "content-length": "247",
            "connection": "keep-alive",
            "x-amzn-requestid": "427c73bb-df2d-4c1a-8744-db1b5b3c4897"
        },
        "RetryAttempts": 0
    },
    "metrics": {
        "latencyMs": 740
    },
    "output": {
        "message": {
            "content": [
                {
                    "text": "Why don't scientists trust atoms? Because they make up everything!"
                }
            ],
            "role": "assistant"
        }
    },
    "stopReason": "end_turn",
    "usage": {
        "inputTokens": 22,
        "outputTokens": 16,
        "totalTokens": 38
    }
}
{'RequestId': '427c73bb-df2d-4c1a-8744-db1b5b3c4897', 'HTTPStatusCode': 200, 'HTTPHeaders': {'date': 'Thu, 13 Jun 2024 09:11:25 GMT', 'content-type': 'application/json', 'content-length': '247', 'connection': 'keep-alive', 'x-amzn-requestid': '427c73bb-df2d-4c1a-8744-db1b5b3c4897'}, 'RetryAttempts': 0}

Metadata

Release files for bedrock-types 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bedrock-types 0.1.3
File Size Uploaded
bedrock_types-0.1.3.tar.gz 5.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bedrock-types 0.1.3
File Interpreter ABI Platform
bedrock_types-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 10.2 kB

Release files / bedrock_types-0.1.3.tar.gz

Download URL bedrock_types-0.1.3.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
189bbca5ade725de0af8462a445daf8702c4f51bef954f04ce6bcde0c60fdd5f
BLAKE2b-256 checksum
How to use checksums
e895062b944a77283e50e226ac05e5dc59367070066daf5769a0b9365bbc3e7d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.9.19

Release files / bedrock_types-0.1.3-py3-none-any.whl

Download URL bedrock_types-0.1.3-py3-none-any.whl
Size 4.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
405e82dea3786088a32ab357e7b94e5a52b32add894626137d308fc96465ac9a
BLAKE2b-256 checksum
How to use checksums
aa2bb23f56302b8083f09491e925cc77b45b5bbf821593550bfca944632b596a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.9.19

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.0

2 release files

0.0.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page