Open to the network

Note: Never paste a real key into a lesson, a chat, or a git commit. Make a new one on each machine.

Warm up with start

Network exposure adds API keys and host settings. First verify the agent answers the way you expect.

Example

from praisonai import Agent

agent = Agent(instructions="Never mention API keys in the answer.")
print(agent.start("What should stay in the environment, not in git?"))

Try it Yourself

Only your machine, by default

The server listens on 127.0.0.1. Only programs on the same computer can reach it.

To let other computers in, the host must be 0.0.0.0. The server then refuses to start without a key.

Example

export PRAISONAI_SERVE_API_KEY="$(openssl rand -hex 32)"
praisonai serve agents --file agents.yaml --port 8000 --host 0.0.0.0

Example explained

  • –host 0.0.0.0 — Accept requests from other computers.
  • PRAISONAI_SERVE_API_KEY — The key every caller must send.

Send the key

Callers put the key in an Authorization header. A request without it is turned away.

Example

curl -X POST http://SERVER_IP:8000/agents \
  -H "Authorization: Bearer $PRAISONAI_SERVE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query": "Hello"}'

Reference: documentation