Ottieni la chiave API
Dopo aver archiviato le chiavi API nell' AgentCore Identity vault, puoi recuperarle direttamente nel tuo agente utilizzando l' AgentCore SDK e l'annotazione. @requires_api_key Ad esempio, il codice seguente recupererà la chiave API dal provider di chiavi API «your-service-name» in modo da poterla utilizzare nella funzione. need_api_key
import asyncio from bedrock_agentcore.identity.auth import requires_api_key @requires_api_key( provider_name= "your-service-name" # replace with your own credential provider name ) async def need_api_key(*, api_key: str): # Use the API key pass # To invoke: # asyncio.run(need_api_key())