Metadata-Version: 2.4
Name: arthur-observability-sdk
Version: 2.1.500.dev0
Summary: Arthur Observability SDK — telemetry, prompt management, and framework instrumentation
Author: Arthur AI
Author-email: engineering@arthur.ai
Requires-Python: >=3.10,<3.14
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Provides-Extra: agent-framework
Provides-Extra: agentspec
Provides-Extra: agno
Provides-Extra: all
Provides-Extra: anthropic
Provides-Extra: autogen
Provides-Extra: autogen-agentchat
Provides-Extra: bedrock
Provides-Extra: beeai
Provides-Extra: claude-agent-sdk
Provides-Extra: crewai
Provides-Extra: dspy
Provides-Extra: google-adk
Provides-Extra: google-genai
Provides-Extra: groq
Provides-Extra: guardrails
Provides-Extra: haystack
Provides-Extra: instructor
Provides-Extra: langchain
Provides-Extra: litellm
Provides-Extra: llama-index
Provides-Extra: mcp
Provides-Extra: mistralai
Provides-Extra: monkai-agent
Provides-Extra: openai
Provides-Extra: openai-agents
Provides-Extra: openlit
Provides-Extra: openllmetry
Provides-Extra: pipecat
Provides-Extra: portkey
Provides-Extra: pydantic-ai
Provides-Extra: smolagents
Provides-Extra: strands-agents
Provides-Extra: vertexai
Requires-Dist: httpx (>=0.28,<0.29)
Requires-Dist: openinference-instrumentation (>=0.1,<0.2)
Requires-Dist: openinference-instrumentation-agent-framework ; extra == "agent-framework" or extra == "all"
Requires-Dist: openinference-instrumentation-agentspec ; extra == "agentspec" or extra == "all"
Requires-Dist: openinference-instrumentation-agno ; extra == "agno" or extra == "all"
Requires-Dist: openinference-instrumentation-anthropic ; extra == "anthropic" or extra == "all"
Requires-Dist: openinference-instrumentation-autogen ; extra == "autogen" or extra == "all"
Requires-Dist: openinference-instrumentation-autogen-agentchat ; extra == "autogen-agentchat" or extra == "all"
Requires-Dist: openinference-instrumentation-bedrock ; extra == "bedrock" or extra == "all"
Requires-Dist: openinference-instrumentation-beeai ; (python_version >= "3.11") and (extra == "beeai" or extra == "all")
Requires-Dist: openinference-instrumentation-claude-agent-sdk ; extra == "claude-agent-sdk" or extra == "all"
Requires-Dist: openinference-instrumentation-crewai ; extra == "crewai" or extra == "all"
Requires-Dist: openinference-instrumentation-dspy ; extra == "dspy" or extra == "all"
Requires-Dist: openinference-instrumentation-google-adk ; extra == "google-adk" or extra == "all"
Requires-Dist: openinference-instrumentation-google-genai ; extra == "google-genai" or extra == "all"
Requires-Dist: openinference-instrumentation-groq ; extra == "groq" or extra == "all"
Requires-Dist: openinference-instrumentation-guardrails ; extra == "guardrails" or extra == "all"
Requires-Dist: openinference-instrumentation-haystack ; extra == "haystack" or extra == "all"
Requires-Dist: openinference-instrumentation-instructor ; extra == "instructor" or extra == "all"
Requires-Dist: openinference-instrumentation-langchain ; extra == "langchain" or extra == "all"
Requires-Dist: openinference-instrumentation-litellm ; extra == "litellm" or extra == "all"
Requires-Dist: openinference-instrumentation-llama-index ; extra == "llama-index" or extra == "all"
Requires-Dist: openinference-instrumentation-mcp ; extra == "mcp" or extra == "all"
Requires-Dist: openinference-instrumentation-mistralai ; extra == "mistralai" or extra == "all"
Requires-Dist: openinference-instrumentation-monkai-agent ; extra == "monkai-agent" or extra == "all"
Requires-Dist: openinference-instrumentation-openai ; extra == "openai" or extra == "all"
Requires-Dist: openinference-instrumentation-openai-agents ; extra == "openai-agents" or extra == "all"
Requires-Dist: openinference-instrumentation-openlit ; extra == "openlit" or extra == "all"
Requires-Dist: openinference-instrumentation-openllmetry ; extra == "openllmetry" or extra == "all"
Requires-Dist: openinference-instrumentation-pipecat ; extra == "pipecat" or extra == "all"
Requires-Dist: openinference-instrumentation-portkey ; extra == "portkey" or extra == "all"
Requires-Dist: openinference-instrumentation-pydantic-ai ; extra == "pydantic-ai" or extra == "all"
Requires-Dist: openinference-instrumentation-smolagents ; extra == "smolagents" or extra == "all"
Requires-Dist: openinference-instrumentation-strands-agents ; extra == "strands-agents" or extra == "all"
Requires-Dist: openinference-instrumentation-vertexai ; extra == "vertexai" or extra == "all"
Requires-Dist: openinference-semantic-conventions (>=0.1,<0.2)
Requires-Dist: opentelemetry-api (>=1.27,<2.0)
Requires-Dist: opentelemetry-exporter-otlp-proto-http (>=1.27,<2.0)
Requires-Dist: opentelemetry-sdk (>=1.27,<2.0)
Requires-Dist: pydantic (>=2)
Requires-Dist: python-dateutil (>=2.8.2)
Requires-Dist: typing-extensions (>=4.7.1)
Requires-Dist: urllib3 (>=1.25.3,<3.0.0)
Description-Content-Type: text/markdown

# Arthur Observability SDK

Python SDK for sending traces and managing prompts with the
[Arthur GenAI Engine](https://arthur.ai).

---

## Installation

```bash
pip install arthur-observability-sdk
```

To instrument a specific framework, install its extra:

```bash
pip install "arthur-observability-sdk[openai]"
pip install "arthur-observability-sdk[langchain]"
pip install "arthur-observability-sdk[anthropic]"
```

---

## How-to guides

Full guides are in [`docs/`](docs/):

- **[Getting started](docs/getting-started.md)** — initialisation, session/user context, framework instrumentation, shutdown
- **[Prompt management](docs/prompt-management.md)** — fetching and rendering versioned prompts, PROMPT span attributes

### Quick start

```python
from arthur_observability_sdk import Arthur

arthur = Arthur(
    api_key="your-api-key",       # or set ARTHUR_API_KEY env var
    task_id="<your-task-uuid>",
    service_name="my-app",
)
arthur.instrument_openai()

# Tag all spans in this block with session and user
with arthur.attributes(session_id="sess-1", user_id="user-42"):
    response = openai_client.chat.completions.create(...)

arthur.shutdown()
```

### Prompt management

```python
# Fetch a saved prompt by name (defaults to "latest" version)
prompt = arthur.get_prompt("system-instructions")

# Render with variable substitution
rendered = arthur.render_prompt(
    "rag-answer",
    variables={"context": "...", "question": "..."},
)
messages = rendered["messages"]
```

---

## Supported instrumentors

Pass `--extras` to install any of these alongside the SDK.

| Extra | Framework | Method |
|-------|-----------|--------|
| `agent-framework` | Agent Framework | `instrument_agent_framework()` |
| `agentspec` | AgentSpec | `instrument_agentspec()` |
| `agno` | Agno | `instrument_agno()` |
| `anthropic` | Anthropic | `instrument_anthropic()` |
| `autogen` | AutoGen | `instrument_autogen()` |
| `autogen-agentchat` | AutoGen AgentChat | `instrument_autogen_agentchat()` |
| `bedrock` | AWS Bedrock | `instrument_bedrock()` |
| `beeai` | BeeAI | `instrument_beeai()` |
| `crewai` | CrewAI | `instrument_crewai()` |
| `dspy` | DSPy | `instrument_dspy()` |
| `google-adk` | Google ADK | `instrument_google_adk()` |
| `google-genai` | Google GenAI | `instrument_google_genai()` |
| `groq` | Groq | `instrument_groq()` |
| `guardrails` | Guardrails AI | `instrument_guardrails()` |
| `haystack` | Haystack | `instrument_haystack()` |
| `instructor` | Instructor | `instrument_instructor()` |
| `langchain` | LangChain | `instrument_langchain()` |
| `litellm` | LiteLLM | `instrument_litellm()` |
| `llama-index` | LlamaIndex | `instrument_llama_index()` |
| `mcp` | MCP | `instrument_mcp()` |
| `mistralai` | Mistral AI | `instrument_mistralai()` |
| `monkai-agent` | Monkai Agent | `instrument_monkai_agent()` |
| `openai` | OpenAI | `instrument_openai()` |
| `openai-agents` | OpenAI Agents | `instrument_openai_agents()` |
| `openlit` | OpenLIT | `instrument_openlit()` |
| `openllmetry` | OpenLLMetry | `instrument_openllmetry()` |
| `pipecat` | Pipecat | `instrument_pipecat()` |
| `portkey` | Portkey | `instrument_portkey()` |
| `pydantic-ai` | Pydantic AI | `instrument_pydantic_ai()` |
| `smolagents` | SmolAgents | `instrument_smolagents()` |
| `strands-agents` | Strands Agents | `instrument_strands_agents()` |
| `vertexai` | Vertex AI | `instrument_vertexai()` |
| `claude-agent-sdk` | Claude Agent SDK | `instrument_claude_agent_sdk()` |

Install all at once: `pip install "arthur-observability-sdk[all]"`

---

## Developer guide

### Setup

```bash
cd arthur-observability-sdk

# 1. Generate the API client (requires Node.js and Java)
./scripts/generate_openapi_client.sh generate python

# 2. Install dependencies (also registers the generated client in the venv)
./scripts/generate_openapi_client.sh install python
```

> **Note:** `python/src/arthur_genai_client/` is auto-generated and gitignored. You must run
> `./scripts/generate_openapi_client.sh generate python` after cloning, and again whenever the
> GenAI Engine API changes. See [Regenerating the API client](#regenerating-the-api-client).

### Running tests

```bash
# Run from arthur-observability-sdk/python/
cd python

# Unit tests only (fast, no network)
poetry run pytest tests -m "unit_tests" -v

# Integration/smoke tests (builds wheel, installs into a fresh venv)
poetry run pytest tests -m "integration_tests" -v

# All tests
poetry run pytest tests -v
```

### Linting

```bash
# Run from arthur-observability-sdk/
./scripts/lint.sh
```

Or individually (from `arthur-observability-sdk/python/`):

```bash
cd python
poetry run black src tests
poetry run isort src tests --profile black
poetry run autoflake --remove-all-unused-imports --in-place --recursive src tests
poetry run mypy src/arthur_observability_sdk
```

### Regenerating the API client

`python/src/arthur_genai_client/` is auto-generated from the GenAI Engine OpenAPI spec
and is **not committed to the repository**. Regenerate it after cloning or whenever
the API changes:

```bash
./scripts/generate_openapi_client.sh generate python
```

Requires Node.js (any recent LTS) and Java 11+.

### Building the wheel

```bash
poetry build --format wheel
```

