One endpoint
Note: Install the server extra first: pip install "praisonaiagents[os]". Set OPENAI_API_KEY in the same terminal.
launch instead of start
start answers one question and stops. launch keeps the agent running and waits for questions on a path.
Save this as server.py and run it. The terminal stays busy while the server is up.
Example
from praisonaiagents import Agent
agent = Agent(
name="Assistant",
instructions="You are a helpful assistant.",
llm="gpt-4o-mini"
)
agent.launch(path="/ask", port=8000)Example explained
- launch — Starts a web server for the agent and keeps it running.
- path — The part of the address that reaches this agent.
- port — The number after the colon in the address. 8000 is the default.
What you should see
The server prints its address, http://127.0.0.1:8000, and lists /ask as an endpoint.
Open http://127.0.0.1:8000/docs in a browser. That page lists every path the server answers.
Reference: documentation