Fetch prompts
This guide shows you how to fetch the deployed version of your prompt in your code using the Agenta SDK.
Fetching prompts with the Agenta SDK
Step 1: Setup
Make sure to install the latest version of the agenta Python SDK (pip -U install agenta).
- Set up environment variables:
- AGENTA_API_KEYfor cloud users.
- AGENTA_HOSTset to- http://localhostif you are self-hosting.
 
Step 2: Fetch the prompt
import agenta as ag
ag.init()
config = ag.ConfigManager.get_from_registry(
    app_slug="my-app",
    environment_slug="staging" # choose production, staging, or development
)
print("Fetched configuration from staging:")
print(config)
Sample Output:
Fetched configuration from staging:
{
    'temperature': 0.7,
    'model': 'gpt-3.5-turbo',
    'max_tokens': 150,
    'prompt_system': 'You are an assistant that provides concise answers.',
    'prompt_user': 'Explain {topic} in simple terms.',
    'top_p': 1.0,
    'frequency_penalty': 0.0,
    'presence_penalty': 0.0
}