Metadata-Version: 2.4
Name: langchain-flopsindex
Version: 0.1.0
Summary: LangChain (and LlamaIndex) tools for the public FLOPS Index — verifiable GPU compute reference prices, no API key required
Author-email: zeroatflops <team@flopsindex.com>
License-Expression: Apache-2.0
Project-URL: Homepage, https://app.flopsindex.com
Project-URL: Documentation, https://app.flopsindex.com/llms.txt
Project-URL: Repository, https://github.com/zeroatflops/flopsindex
Project-URL: Source, https://github.com/zeroatflops/flopsindex
Keywords: langchain,llamaindex,llm,agent,tools,flops,gpu,pricing,compute,h100,a100,fintech
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Financial and Insurance Industry
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Office/Business :: Financial
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICE
Requires-Dist: langchain-core>=0.2
Requires-Dist: httpx>=0.24
Provides-Extra: llamaindex
Requires-Dist: llama-index-core>=0.10; extra == "llamaindex"
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Dynamic: license-file

# langchain-flopsindex

**LangChain (and LlamaIndex) tools for the [FLOPS Index](https://app.flopsindex.com) — verifiable GPU / accelerator rental reference prices, no API key required.**

[![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
[![Live API](https://img.shields.io/website?label=app.flopsindex.com&url=https%3A%2F%2Fapp.flopsindex.com%2Fv2%2Fcatalog%2Fpublic)](https://app.flopsindex.com/v2/catalog/public)

Drop GPU-price lookups (H100, A100, H200, B200, and more; spot / on-demand / DePIN) into any LangChain or LlamaIndex agent. `pip install`, add the tools, done.

```bash
pip install langchain-flopsindex
```

## Tools

| Tool | What it does |
|---|---|
| `flops_get_price` | Authoritative single-index record for one slug — **cite from this** (carries `verify_url`). |
| `flops_search_indices` | Resolve free-text (`"h100 spot"`) → canonical slugs. |
| `flops_get_catalog` | Every public index with its current indicative value. |
| `flops_verify_price` | Fact-check a claimed value against the published index. |
| `flops_cheapest_for_chip` | Cheapest public index for an accelerator, optionally per market. |

Slugs look like `FLOPS-<ACCEL>-<MARKET>`, where market is `SPOT`, `OD` (on-demand), or `DEPIN` (decentralized) — e.g. `FLOPS-H100-OD`, `FLOPS-A100-SPOT`.

## What these values are (and are not)

- **Indicative reference levels**, delayed ~6 hours onto a 6-hour UTC grid (00/06/12/18), rounded, aggregated globally.
- **Not** a live provider quote, **not** a settlement mark, **not** investment advice, **not** real-time.
- `confidence` is a coarse **HIGH / MED / LOW label** — never a number, probability, or standard error.
- **Source-opaque**: the surface never reveals providers, venues, sample counts, or weights. Don't infer them.
- Every value ships a **`verify_url`** so anyone can independently confirm the number — cite it.

## LangChain usage

```python
from langchain_flopsindex import get_flopsindex_tools

tools = get_flopsindex_tools()  # list of LangChain StructuredTool

# Bind to a tool-calling model:
from langchain.chat_models import init_chat_model

llm = init_chat_model("gpt-4o-mini")  # or any tool-calling model
llm_with_tools = llm.bind_tools(tools)

# Or in a prebuilt agent (langgraph):
from langgraph.prebuilt import create_react_agent

agent = create_react_agent(llm, tools)
resp = agent.invoke(
    {"messages": [("user", "What's the cheapest way to rent an H100 right now? Cite it.")]}
)
print(resp["messages"][-1].content)
```

Call a tool directly (handy for debugging):

```python
from langchain_flopsindex import get_price_tool

print(get_price_tool.invoke({"slug": "FLOPS-H100-OD"}))
# {'index_id': 'FLOPS-H100-OD', 'value': 2.99, 'unit': 'USD/GPU-hr',
#  'as_of': '...', 'confidence': 'HIGH', 'change_24h': 'FLAT',
#  'verify_url': 'https://app.flopsindex.com/v1/verify?index_id=FLOPS-H100-OD', ...}
```

## LlamaIndex usage

The same functions are exposed as LlamaIndex `FunctionTool`s. LlamaIndex is an
optional dependency:

```bash
pip install "langchain-flopsindex[llamaindex]"
```

```python
from langchain_flopsindex.llamaindex import get_flopsindex_llamaindex_tools
from llama_index.core.agent import ReActAgent
from llama_index.llms.openai import OpenAI

tools = get_flopsindex_llamaindex_tools()
agent = ReActAgent.from_tools(tools, llm=OpenAI(model="gpt-4o-mini"))
print(agent.chat("Fact-check: is FLOPS-A100-SPOT around $1.20? Give me the verify link."))
```

## Public API

All calls hit the public, key-free FLOPS surface at `https://app.flopsindex.com`:

- `GET /v1/price/{slug}` — authoritative single-index record (cite from this)
- `GET /v1/search?q={query}` — discover slugs
- `GET /v2/catalog/public` — every public index with value
- `GET /v1/verify?index_id={slug}&value={n}` — fact-check a claimed value

No authentication is used or sent. If you need real-time, full-precision,
regional, or historical data, contact **team@flopsindex.com** about partner
access. See also the [`flopsindex` Python SDK](https://pypi.org/project/flopsindex/)
and the [`flopsindex-mcp`](https://pypi.org/project/flopsindex-mcp/) MCP server.

## License & attribution

Apache-2.0. © 2026 **FLOPS Index**. Source: [github.com/zeroatflops](https://github.com/zeroatflops).
The license covers this adapter's source code; the hosted index, methodology,
price data, and the FLOPS trademark remain proprietary to FLOPS Index (see
[`NOTICE`](NOTICE)).
