For the complete documentation index, see llms.txt. This page is also available as Markdown.

Python SDK

Structured predictions with lr.predict()

Minimal example

import lightningrod as lr

client = lr.LightningRod(api_key="your-api-key")

result = client.predict("Will the Fed cut interest rates in 2026?", model="foresight-v4")

print(result.content)

Response fields:

Field
Type
Description

content

str

Full response, including any <answer> tags.

thinking

str | None

Reasoning, when returned.

sources

list[Source]

URL citations from research. Each source has url and title.

usage

Usage

Token counts and cost fields.

model

str

Model that served the request.

id

str

Response ID.

binary

BinaryPrediction | None

Populated when answer_type="binary".

continuous

ContinuousPrediction | None

Populated when answer_type="continuous".

multiple_choice

MultiChoicePrediction | None

Populated when answer_type="multiple_choice".

free_response

FreeResponsePrediction | None

Populated when answer_type="free_response".

Answer formats

When answer_type is set, predict() parses the response tags into typed fields on PredictionResult.

answer_type

PredictionResult field

"binary"

result.binary.probability

"continuous"

result.continuous.mean, result.continuous.standard_deviation

"multiple_choice"

result.multiple_choice.probabilities

"free_response"

result.free_response.text

"auto"

One of the above fields, inferred from the server-classified answer type

answer_type="auto" classifies the question server-side and populates the matching prediction field. result.usage.classification_cost_usd is set when classification runs (cost is negligible).

See our API reference for more response examples.

Research

Pass research=True to query all default sources, or pass a list to restrict providers:

See our API reference for an up-to-date list of supported sources.

Reasoning effort

Recommendation: use low reasoning effort if cost and latency outweigh marginal improvements in accuracy.

See Recipes for more forecasting guidelines.

Last updated

Was this helpful?