I try to run the livekit base code using agent.py with the AWS stack like this:
# Load environment variables from .env and .env.local
load_dotenv() # Load .env from project root
dotenv_local_path = pathlib.Path(
file).parent.parent / ".env.local"
if dotenv_local_path.is_file():
logger.info(f"Loading environment from {dotenv_local_path}")
load_dotenv(dotenv_path=dotenv_local_path, override=True)
Then setup AgentSession like this:
session = AgentSession(
llm=aws.LLM(
model="anthropic.claude-3-5-sonnet-20240620-v1:0",
region=aws_region,
),
stt=aws.STT(
language="en-US",
region=aws_region,
),
tts=aws.TTS(
voice="Ruth",
speech_engine="generative",
language="en-US",
region=aws_region,
),
turn_detection=MultilingualModel(),
vad=ctx.proc.userdata["vad"],
preemptive_generation=True,
)
When I run the code using uv run python src/agent.py console, I get this message in logs:
Traceback (most recent call last):
File "/Users/Shresht/Documents/livekit-starter/.venv/lib/python3.13/site-packages/livekit/agents/stt/stt.py", line 253, in _main_task
return await self._run()
^^^^^^^^^^^^^^^^^
File "/Users/Shresht/Documents/livekit-starter/.venv/lib/python3.13/site-packages/livekit/plugins/aws/stt.py", line 151, in _run
stream = await client.start_stream_transcription(**filtered_config) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/Shresht/Documents/livekit-starter/.venv/lib/python3.13/site-packages/amazon_transcribe/client.py", line 242, in start_stream_transcription
raise self._response_parser.parse_exception(resolved_response, body_bytes)
amazon_transcribe.exceptions.UnknownServiceException: (403, 'ExpiredTokenException', 'The security token included in the request is expired')
2025-09-09 16
1950,317 - DEBUG livekit.agents - session closed {"room": "fake_room", "reason": "error", "error": "type='stt_error' timestamp=1757398790.314419 label='livekit.plugins.aws.stt.STT' error=UnknownServiceException(403, 'ExpiredTokenException', 'The security token included in the request is expired') recoverable=False"}
What could be the issue