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.7.0.tar.gz (40.2 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.7.0-py3-none-any.whl (53.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for promptrails-0.7.0.tar.gz
Algorithm Hash digest
SHA256 d3ee706b9b90b0067c0592996e6dff456b071b8ec8d6f7b169bd55566583e9cc
MD5 eb314be267566837ceeefd268c222219
BLAKE2b-256 1ef4f24b03d936cbbe01141d6df8dc30862d43bf0baa28c34fd2759fee19a45e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: promptrails-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 53.4 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.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9df2ccf9cbe3d93bbf91f06e14a45c3356ae204fcaa2bee32edbadc60aca194a
MD5 6b8f48564cd7025df6cf67d4fab7a092
BLAKE2b-256 9ec388fdef3cd3099a61940949a05f3cb7665a338f165928a9a4a01926ee2137

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