Skip to main content

bedrock-inference

Contributors Forks Stargazers Issues MIT License

Status DOI

Keywords: generative AI, Amazon AWS, Bedrock, API, wrapper, LLM, inference, NLP.


Bedrock Inference is a simple python package to handle 2FA and on-demand calls to AWS Bedrock foundation models.

Requirements

  • An AWS IAM account
  • An Access key ID (es: AKIAIOSFODNN7EXAMPLE) and its correspondent secret access key (es: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY) for API requests
    • These credentials can be created through Home --> Security credentials --> Access Keys --> Create access key
    • If you have AWS CLI installed and set up on your machine, chances are your credentials are already stored at ~/.aws/credentials and/or in the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables. In this case, the package will retrieve them automatically.
      • Note: AWS CLI is not required to use bedrock-inference.
  • A Multi-factor authentication device ARN (es: arn:aws:iam::012345678910:mfa/example_username)
    • The ARN of your MFA device can be located at Home --> Security credentials --> Multi-factor authentication
  • The 6 digits temp token generated by the MDA device (es: 366 712)

Installation

  1. Make sure you have the latest version of pip installed
    pip install --upgrade pip
    
  2. Install araucanaxai through pip
    pip install bedrock_inference
    

Usage

import from bedrock_inference import bedrock

# Authenticates through MFA and establish a session
session = bedrock.aws_login_mfa(arn="MFA_device_arn", token="MFA_token", aws_access_key_id="your_ID", aws_secret_access_key="your_key")
#session =  bedrock.aws_login_mfa(arn="MFA_device_arn", token="MFA_token") #use this if you already have AWS credentials set up for API requests on your machine

# Instantiate youre Bedrock caller
caller = bedrock.Bedrock(session=session, region="your_aws_region")

#Check available models in your region
print(caller.list_models())

#Invoke the target AWS model and retrieve the generated answer
answer = caller.invoke_model(prompt="What's the conceptual opposite of 'Hello World'?", model_id="target_aws_model_id")
print(answer)

License

Distributed under MIT License. See LICENSE for more information.

Metadata

Release files for bedrock-inference 0.0.13

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-inference 0.0.13
File Size Uploaded Provenance Actions
bedrock_inference-0.0.13.tar.gz 7.5 kB Without provenance Details for bedrock_inference-0.0.13.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bedrock-inference 0.0.13
File Interpreter ABI Platform Actions
bedrock_inference-0.0.13-py3-none-any.whl Python 3 none any Details for bedrock_inference-0.0.13-py3-none-any.whl

Total release size: 15.1 kB

Release files / bedrock_inference-0.0.13.tar.gz

Download URL bedrock_inference-0.0.13.tar.gz
Size 7.5 kB
Tags Source
SHA-256 checksum
How to use checksums
c85ac16b731d8a1eb723ace3962e6d8587b3bdc5a8aa8d9c35e24b9687eedd99
BLAKE2b-256 checksum
How to use checksums
7169dd62848860b19ce7a5be1dff12c8caad2296319674a0e2d65831fe672fa3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.12

Release files / bedrock_inference-0.0.13-py3-none-any.whl

Download URL bedrock_inference-0.0.13-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2b4a7dd09174f2e2b733dea799743e68d50523a1cf1b88abe05744c95df96bb2
BLAKE2b-256 checksum
How to use checksums
3e11d65b476b3b20eceb0df013d15bb6232e480a4d680e4f9ae1afcb165eec12
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.12

Security for bedrock-inference 0.0.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.13 This release

2 release files No provenance

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