Goal: Deploy your Day 2 agent (with memory and tools) to the cloud using Railway, making it accessible via REST API from anywhere.
# 1. Login to Railway
railway login
# 2. Create a new project
cd day-3
railway init
# Enter a name for your project when prompted
# 3. Link to your project
railway link
# 4. Deploy (will fail - that's expected!)
railway up
# 5. Add your OpenAI API key
# Go to railway.app → Your Service → Variables → Add OPENAI_API_KEY
# 6. Deploy again (now it will work!)
railway up
# 7. Get your URL
railway domain
# 8. Test it
curl https://your-url.up.railway.app/health- Railway Account: Sign up at railway.app
- Railway CLI: Install Railway CLI
# macOS/Linux curl -fsSL https://railway.app/install.sh | sh # Or via npm npm install -g @railway/cli
- OpenAI API Key: From Day 1-2
Now add your OpenAI API key so the agent can work.
Option A: Via Railway Dashboard
- Go to railway.app
- Click your project → Click your service
- Go to Variables tab
- Click + New Variable
- Add
OPENAI_API_KEYwith your key value - (Optional) Add
SERPER_API_KEYfor web search tool - Railway automatically redeploys
Option B: Via CLI
# Set environment variables AFTER first deploy
railway variables --set "OPENAI_API_KEY=your-key-here"
# Optional: Add SERPER_API_KEY for web search
railway variables --set "SERPER_API_KEY=your-serper-key"
# Deploy again with variables
railway upWhat Railway does:
- Reads
railway.jsonfor config - Installs packages from
requirements.txt - Starts your FastAPI server
- Gives you a public URL
After deployment completes (takes 2-3 minutes):
Option A: CLI
railway domainOption B: Dashboard
- Go to railway.app → Your service → "Settings" tab
- Look for "Public URL" or click "Generate Domain"
Example output:
https://day-3-agent-production.up.railway.app
Save this URL - you'll use it to interact with your agent.
curl https://your-app.up.railway.app/healthExpected response:
{
"status": "healthy",
"memory_enabled": true,
"tools_count": 5
}curl -X POST https://your-app.up.railway.app/query \
-H "Content-Type: application/json" \
-d '{"question": "What is 123 * 456?"}'Expected response:
{
"answer": "The result of 123 * 456 is 56,088.",
"timestamp": "2026-01-24T10:30:00Z",
"processing_time": 2.5
}# First request - tell the agent something
curl -X POST https://your-app.up.railway.app/query \
-H "Content-Type: application/json" \
-d '{"question": "My name is Alex and I love Python"}'
# Second request - see if it remembers
curl -X POST https://your-app.up.railway.app/query \
-H "Content-Type: application/json" \
-d '{"question": "What is my name?"}'Expected: Agent should remember your name from the first request.