Metadata-Version: 2.4
Name: lightningrod-ai
Version: 0.1.28
Summary: Python SDK for dataset generation on LightningRod platform ⚡
Author-email: Lightning Rod Labs <support@lightningrod.ai>
License: MIT License
        
        Copyright (c) 2025 Lightning Rod Labs
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
        
        
Project-URL: Homepage, https://lightningrod.ai/sdk
Project-URL: Repository, https://github.com/lightning-rod-labs/lightningrod-python-sdk
Keywords: synthetic dataset generation,synthetic data,LLM training data,fine-tuning datasets
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.31.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: httpx>=0.25.0
Requires-Dist: attrs>=23.1.0
Requires-Dist: python-dateutil>=2.8.0
Requires-Dist: pyarrow>=14.0.0
Requires-Dist: fsspec>=2023.0.0
Requires-Dist: rich>=13.0.0
Provides-Extra: dev
Requires-Dist: build>=1.0.0; extra == "dev"
Requires-Dist: openapi-python-client>=0.15.0; extra == "dev"
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: twine>=5.0.0; extra == "dev"
Provides-Extra: transfer
Requires-Dist: google-cloud-storage>=2.0.0; extra == "transfer"
Provides-Extra: visual
Requires-Dist: PyMuPDF>=1.24.0; extra == "visual"
Requires-Dist: openai>=1.0.0; extra == "visual"
Provides-Extra: extract
Requires-Dist: openai>=1.0.0; extra == "extract"
Requires-Dist: pypdf>=4.0.0; extra == "extract"
Requires-Dist: pypdfium2>=4.0.0; extra == "extract"
Requires-Dist: pillow>=10.0.0; extra == "extract"
Dynamic: license-file



# Lightning Rod Python SDK

**Foresight** returns a calibrated probability for any question about the future — through an OpenAI-compatible API. No fine-tuning, no setup. Ranked **#1 for forecasting accuracy on ProphetArena**.

**Trusted for high-stakes predictions** by Numinous, Shore Capital Partners, Awardable (Tradewinds Solutions Marketplace), and ERIS Marketplace. Foresight processes **billions of tokens** and serves **100k+ inference requests every day**.

[Documentation](https://docs.lightningrod.ai/) · [Get an API key](https://dashboard.lightningrod.ai/sign-up?redirect=/api) · [Research paper](https://arxiv.org/abs/2601.06336)

## ⚡ Better predictions in seconds

Foresight is served behind an OpenAI-compatible endpoint, so any OpenAI client works — just point `base_url` at Lightning Rod.

```bash
pip install openai
```

```python
from openai import OpenAI

client = OpenAI(
    base_url="https://api.lightningrod.ai/api/public/v1/openai",
    api_key="your-api-key",
)

completion = client.chat.completions.create(
    model="LightningRodLabs/foresight-v4",
    messages=[
        {"role": "user", "content": "Will the Fed cut rates at its next meeting?"},
    ],
    extra_body={
        "research": True,       # gather live web evidence before forecasting
        "answer_type": "auto",  # append a structured answer in <answer></answer> tags
    },
)

print(completion.choices[0].message.content)
# Foresight weighs the evidence and returns a calibrated probability,
# e.g.: "... <answer>0.34</answer>"
```

That `0.34` is a **calibrated probability** — a 34% chance, not a confidence score or a yes/no. `0.5` means genuinely uncertain, and across many ~0.7 forecasts roughly 70% should come true. See the [forecasting reference](https://docs.lightningrod.ai/forecasting/reference) for answer types, research sources, and the full response shape.

### Prefer an SDK helper?

`lr.predict()` wraps the same API and parses the structured answer for you:

```bash
pip install lightningrod-ai openai
```

```python
import lightningrod as lr

client = lr.LightningRod(api_key="your-api-key")
result = client.predict(
    "Will the Fed cut rates by 25bp in March 2026?",
    answer_type="binary",
    research=True,
)
print(result.binary.probability)  # e.g. 0.62
```

## 🏗️ Train an expert on your domain

Need a model tuned to your domain? Our enterprise platform enables companies to turn raw sources into labeled datasets and fine-tunes models on them — served through the same API.

[**📅 Book a call with us**](https://calendly.com/d/ctq4-7gd-nyq/lightning-rod-demo)

```python
pipeline = QuestionPipeline(...)
dataset = client.transforms.run(pipeline)

train_dataset, test_dataset = prepare_for_training(dataset)
train_config = GRPOTrainingConfig(base_model_id="openai/gpt-oss-120b")
training_job = client.training.run(train_config, train_dataset)

# your fine-tuned model is served through the same predict() / OpenAI API
client.predict("Will the Fed cut rates by 25bp in the next 3 months?", model=training_job.model_id)
```

We used this to generate the [Future-as-Label training dataset](https://huggingface.co/datasets/LightningRodLabs/future-as-label-paper-training-dataset) from our paper, [Future-as-Label: Scalable Supervision from Real-World Outcomes](https://arxiv.org/abs/2601.06336).

## 📚 Learn more

- [Documentation](https://docs.lightningrod.ai/) — quickstart, guides, recipes, and the REST API reference
- [Example notebooks](notebooks/) — forecasting, dataset generation, training, and evaluation (runnable in Colab)
- [SDK API reference](API.md) — every class and method in this repo

