ai icon indicating copy to clipboard operation
ai copied to clipboard

Add session token to AWS bedrock

Open shoopapa opened this issue 1 year ago • 3 comments

The default configuration of the bedrock provider doesn't account for session tokens, sessionTokens are common in local AWS environments and should be supported by default

shoopapa avatar Jul 25 '24 01:07 shoopapa

jfyi you can use local credential or IAM role credential directly by setting bedrockOptions instead.

For example.

import { createAmazonBedrock } from '@ai-sdk/amazon-bedrock';
import { streamText } from 'ai';

export const maxDuration = 30;

export async function POST(req: Request) {
  const { messages } = await req.json();

  const result = await streamText({
    model: createAmazonBedrock({ bedrockOptions: { region: 'us-east-1' } })('anthropic.claude-3-haiku-20240307-v1:0'),
    messages,
  });

  return result.toAIStreamResponse();
}

tmokmss avatar Jul 25 '24 02:07 tmokmss

jfyi

Thanks! I noticed that after I finished this code change lol I still feel like it makes sense to merge in. seems like most of the other providers just work without configuring

shoopapa avatar Jul 26 '24 21:07 shoopapa

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/[email protected] Transitive: environment, filesystem +10 97.3 MB rauchg, timneutkens, vercel-release-bot
npm/[email protected] environment +1 6.34 MB react-bot
npm/[email protected] environment 0 237 kB react-bot

🚮 Removed packages: npm/[email protected], npm/[email protected], npm/[email protected]

View full report↗︎

socket-security[bot] avatar Aug 10 '24 03:08 socket-security[bot]

Continued in #2755

lgrammel avatar Aug 21 '24 10:08 lgrammel