Official Python SDK for PromptRails — the AI agent orchestration platform.
The SDK has two independent parts:
- API client — manage agents, prompts, executions, and more.
- Tracing (
promptrails.tracing) — send spans to PromptRails from any code, without managing your prompts/agents on the platform.
pip install promptrailsfrom promptrails import PromptRails
client = PromptRails(api_key="pr_key_...")
result = client.agents.execute("agent-id", input={"query": "Summarise this week's sales"})
print(result.output)
client.close()Async (AsyncPromptRails) and context-manager usage are also supported — see the
API client guide.
from promptrails.tracing import Tracer
tracer = Tracer(api_key="pr_...")
with tracer.span("agent-run", kind="agent") as root:
root.set_input({"q": "weather?"})
with tracer.span("llm-call", kind="llm") as llm:
llm.set_model("gpt-4o").set_usage(prompt_tokens=120, completion_tokens=30)
tracer.flush()See the tracing guide for decorators, manual spans, span kinds, and configuration. LangChain, OpenAI, and OpenTelemetry can be auto-instrumented — see integrations.
- API client — resources, error handling, media studio, configuration
- Tracing — spans, decorators, batching, configuration
- Integrations — LangChain, OpenAI, OpenTelemetry
pip install -e ".[dev]" # install dev dependencies
ruff check . # lint
ruff format . # format
pytest tests/ -v # testMIT