Skip to main content
Get started with PraisonAI and OpenAI in under 5 minutes, with instructions that work on Windows, macOS, and Linux.

Quick Start

1

Choose Your Installation

For Python SDK only:
pip install praisonaiagents
For CLI + YAML + Full Features:
pip install praisonai
Package Choice Guide:
  • praisonaiagents - Python SDK for building agent scripts
  • praisonai - CLI tools, YAML workflows, and full toolkit
2

Set Your OpenAI API Key

export OPENAI_API_KEY="sk-your-api-key-here"
Get your API key from OpenAI Dashboard. Never commit API keys to version control.
3

Verify Your Setup

# Install praisonai first if you haven't
pip install praisonai

# Check your environment and API key
praisonai doctor env --json
You should see "openai_api_key": "pass" in the output.
Windows users: Use --json flag if text output shows encoding errors.
4

Run Your First Agent

from praisonaiagents import Agent

# Create a simple agent
agent = Agent(
    name="Assistant",
    instructions="You are a helpful AI assistant."
)

# Get a response
result = agent.start("What is the capital of France?")
print(result)
Save this as first_agent.py and run:
python first_agent.py

How It Works

The agent workflow follows these steps:
StepDescription
CreateInitialize agent with instructions and configuration
ExecuteProcess user input with OpenAI’s LLM
ReturnFormat and return the response

Configuration Options

Environment Variables

VariableDescriptionExample
OPENAI_API_KEYYour OpenAI API keysk-proj-abc123...
OPENAI_BASE_URLCustom API endpoint (optional)https://api.openai.com/v1
OPENAI_MODELDefault model (optional)gpt-4o-mini

Agent Configuration

from praisonaiagents import Agent

agent = Agent(
    name="Research Assistant",
    instructions="You are an expert researcher.",
    model="gpt-4o",           # Specify model
    temperature=0.7,          # Creativity (0-1)
    max_tokens=1000,          # Response length
    output=True              # Enable verbose output
)

Common Patterns

Simple Q&A Agent

from praisonaiagents import Agent

agent = Agent(
    name="Helper",
    instructions="Answer questions clearly and concisely."
)

response = agent.start("Explain photosynthesis in simple terms")
print(response)

Agent with Memory

from praisonaiagents import Agent

agent = Agent(
    name="Personal Assistant",
    instructions="Remember our conversation and provide personalized help.",
    memory=True  # Enable conversation memory
)

# First interaction
agent.start("My name is Alex and I like Python")

# Later interaction - agent remembers
response = agent.start("What programming language do I like?")
print(response)

CLI Usage (requires pip install praisonai)

# Simple prompt
praisonai "What are the benefits of renewable energy?"

# Save output to file
praisonai "Write a haiku about coding" > poem.txt

# Use specific model
praisonai --model gpt-4o "Explain quantum computing"

Advanced Features

from praisonaiagents import Agent, Agents

# Create specialized agents
researcher = Agent(
    name="Researcher", 
    instructions="Research topics thoroughly"
)

writer = Agent(
    name="Writer", 
    instructions="Write clear, engaging content"
)

# Create team
team = Agents(agents=[researcher, writer])
result = team.start("Write a blog post about AI safety")
print(result)
Multi-agent functionality requires the latest version. If you encounter issues, ensure you have the newest release.

Troubleshooting

Windows doesn’t recognize the export command. Use these alternatives:PowerShell:
$env:OPENAI_API_KEY="your-key"
Command Prompt:
set OPENAI_API_KEY=your-key
Permanent solution: Use a .env file in your project directory.
This means you installed praisonaiagents (Python SDK only) but need the CLI tools.Solution:
pip install praisonai
The packages serve different purposes:
  • praisonaiagents - Python SDK for scripting
  • praisonai - CLI tools and YAML workflows
If praisonai doctor env shows API key errors:
  1. Check the key format: Should start with sk-
  2. Verify environment: Run echo $OPENAI_API_KEY (bash) or echo $env:OPENAI_API_KEY (PowerShell)
  3. Use .env file: More reliable than environment variables
  4. Check permissions: Ensure you have valid OpenAI credits/usage limits
If you see garbled text or encoding errors:
  1. Use JSON output: Add --json flag to CLI commands
  2. Check terminal encoding: Use Windows Terminal instead of Command Prompt
  3. Set encoding: Add chcp 65001 before running commands

Best Practices

  • Never hardcode API keys in source code
  • Use .env files for local development
  • Set proper file permissions: chmod 600 .env
  • Use environment variables in production
  • Rotate keys regularly
  • gpt-4o-mini - Fast and cost-effective for simple tasks
  • gpt-4o - Best performance for complex reasoning
  • gpt-3.5-turbo - Good balance of speed and capability
  • Start with gpt-4o-mini and upgrade as needed
  • Use temperature=0 for consistent, factual responses
  • Use temperature=0.7-1.0 for creative tasks
  • Set appropriate max_tokens to control response length
  • Enable memory=True for conversational agents
  • Check your OpenAI dashboard regularly
  • Set usage alerts in OpenAI console
  • Use shorter prompts when possible
  • Cache responses for repeated queries

Next Steps

Advanced Agent Features

Explore planning, reflection, and advanced reasoning capabilities

Multi-Agent Teams

Build collaborative agent teams for complex workflows

Tools & Integrations

Add web search, file tools, and custom integrations

Memory & Knowledge

Implement persistent memory and knowledge bases

Installation Guide

Complete installation instructions for all platforms

CLI Reference

Full command-line interface documentation