Metadata-Version: 2.4
Name: respan-instrumentation-replicate
Version: 0.1.0
Summary: Respan instrumentation plugin for the Replicate Python SDK
License: Apache 2.0
Author: Respan
Author-email: team@respan.ai
Requires-Python: >=3.11,<3.14
Classifier: License :: Other/Proprietary License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Dist: opentelemetry-semantic-conventions-ai (>=0.4.1)
Requires-Dist: replicate (>=1.0.0)
Requires-Dist: respan-sdk (>=2.6.1)
Requires-Dist: respan-tracing (>=2.17.0,<3.0.0)
Description-Content-Type: text/markdown

# Respan Replicate Instrumentation

Trace the official `replicate` Python SDK with Respan.

The instrumentation patches the Replicate client lifecycle and emits canonical
Respan spans for `run`, `async_run`, `stream`, `async_stream`, prediction
creation, prediction waiting, and prediction lookup/cancel operations.

## Install

```bash
pip install respan-ai respan-instrumentation-replicate replicate
```

## Usage

```python
import os

import replicate
from respan import Respan, workflow
from respan_instrumentation_replicate import ReplicateInstrumentor

respan = Respan(
    api_key=os.environ["RESPAN_API_KEY"],
    instrumentations=[ReplicateInstrumentor()],
)


@workflow(name="replicate_quickstart.workflow")
def run_prediction() -> str:
    output = replicate.run(
        "meta/meta-llama-3-8b-instruct",
        input={"prompt": "Reply with one concise sentence about tracing."},
    )
    return "".join(str(chunk) for chunk in output) if not isinstance(output, str) else output


print(run_prediction())
respan.flush()
respan.shutdown()
```

Use `Respan(..., customer_identifier=..., thread_identifier=..., metadata=...)`
or `respan.propagate_attributes(...)` to attach Respan attributes to Replicate
spans.

