Unable to use trained custom model in AWS Bedrock

I have trained a custom model in AWS Bedrock, named amazon.titan-image-generator-v1. The generated ARN for this model is:
arn:aws:bedrock:us-east-1:901111142777:custom-model/amazon.titan-image-generator-v1:0/y2jixw0ucyyy

I’m trying to use this model in my NodeJS application to generate images based on text prompts. Here is the code I’m using:


const bedrock = new BedrockRuntimeClient({ region: 'us-east-1' });

async function createImage(prompt) {
  const params = {
    modelId: 'arn:aws:bedrock:us-east-1:901111142715:custom-model/amazon.titan-image-generator-v1:0/y2jixw0uccyk',
    // modelId: 'amazon.titan-image-generator-v1',
    body: JSON.stringify({
      textToImageParams: {
        text: prompt
      },
      taskType: "TEXT_IMAGE",
      imageGenerationConfig: {
        cfgScale: 8,
        seed: 0,
        quality: "standard",
        width: 1024,
        height: 1024,
        numberOfImages: 3
      }
    }),
    // TrainingDataConfig: {
    //   S3Uri: 's3://bedrock-poc-cocreate/bedrock/'
    // },
    // OutputConfig: {
    //   S3Bucket: 'bedrock-poc-cocreate',
    //   S3Prefix: 'fine-tuned-model/'
    // }
  };

  try {
    const command = new InvokeModelCommand(params);
    console.log('command: ', command);
    const response = await bedrock.send(command);
    console.log('Image creation initiated:', response);
    // Further processing can be done based on the response
  } catch (error) {
    console.error('Error creating image:', error);
  }
}

const prompt = 'A young Indian couple, both 21 years old, standing in the garden area of their new house, looking at the camera and posed, feeling happy and accomplished, background showcases the beautiful architecture of their entire house with minimal interiors, front view of their modern house, mid shot. Canon EOS 5D Mark IV, Sigma 35mm f/1.4 Art lens, f/1.8, ISO 4000, capturing a sense of joy and celebration'; // Example prompt
createImage(prompt);

Its throwing error:

Error creating image: ValidationException: 1 validation error detected: Value 'arn:aws:bedrock:us-east-1:901111142715:custom-model/amazon.titan-image-generator-v1:0/y2jixw0uccyk' at 'modelId' failed to satisfy constraint: Member must satisfy regular expression pattern: (arn:aws(-[^:]+)?:bedrock:[a-z0-9-]{1,20}:(([0-9]{12}:custom-model/[a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}/[a-z0-9]{12})|(:foundation-model/[a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}([.:]?[a-z0-9-]{1,63}))|([0-9]{12}:imported-model/[a-z0-9]{12})|([0-9]{12}:provisioned-model/[a-z0-9]{12})))|([a-z0-9-]{1,63}[.]{1}[a-z0-9-]{1,63}([.:]?[a-z0-9-]{1,63}))|(([0-9a-zA-Z][_-]?)+)|(arn:aws(|-us-gov|-cn|-iso|-iso-b):bedrock:(|[0-9a-z-]{1,20}):(|[0-9]{12}):model-gateway/[a-zA-Z0-9-:.]+)|([a-zA-Z0-9-:.]+)
  • I have double-checked the ARN for the custom model and ensured it is correct.
  • The AWS SDK for JavaScript (v3) is being used in the code.
  • The model ARN specified in the params.modelId is correctly formatted as per AWS guidelines.

What could be causing this ValidationException and how can I resolve it? Is there a specific way to format the modelId for custom models in AWS Bedrock, or is there something else I might be missing?

Not sure if this is a bug in the AWS SDK or an error in the ARN you provided, but just playing around with regex, I can see the colon in your ARN is causing the issue.
If I change the value to arn:aws:bedrock:us-east-1:901111142777:custom-model/amazon.titan-image-generator-v1/y2jixw0ucyyy(removed the :0) the regex is identified correctly. You might have to raise this to the SDK team.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật