Skip to main content

Official Python SDK for the PromptRails API

Project description

PromptRails Python SDK

PyPI version Python versions License: MIT

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.

Installation

pip install promptrails

Quick Start

API client

from 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.

Tracing

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.

Documentation

  • API client — resources, error handling, media studio, configuration
  • Tracing — spans, decorators, batching, configuration
  • Integrations — LangChain, OpenAI, OpenTelemetry

Contributing

pip install -e ".[dev]"   # install dev dependencies
ruff check .              # lint
ruff format .             # format
pytest tests/ -v          # test

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

promptrails-0.6.0.tar.gz (39.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

promptrails-0.6.0-py3-none-any.whl (51.1 kB view details)

Uploaded Python 3

File details

Details for the file promptrails-0.6.0.tar.gz.

File metadata

  • Download URL: promptrails-0.6.0.tar.gz
  • Upload date:
  • Size: 39.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for promptrails-0.6.0.tar.gz
Algorithm Hash digest
SHA256 ef8acdb62c117d3c21040a84a2acb747252f8f59fd64457aadf8b0068741907f
MD5 64f97c749c701be17864230b036828c1
BLAKE2b-256 3ebfc0ad52f9cf57ad267628fa1f07504257a2d20bbd0fa62c79c9eca87c0ad9

See more details on using hashes here.

File details

Details for the file promptrails-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: promptrails-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 51.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for promptrails-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e18f9bc765668480f98fcec0c6d3089055ec0263970e3178b4cda6077d8c681b
MD5 1f1a375a53a8b5e4fc33038836cef748
BLAKE2b-256 006e3c5d1fdc525616426cd75c23ebae2570b4f7b5c9a825ec759edece800eac

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page