# market-preview API

> The Markdown form of https://openfill.ai/models/market-preview. The index of every docs page is https://openfill.ai/llms.txt.

Model

# market-preview

market-preview is its own market on OpenFill. A request names `market-preview`, sets a price limit, and pays the level the market is clearing at when it runs.

A preview of the market that opens once there is traction and compute behind it. Its prices are simulated until then; [fixed-price models](https://openfill.ai/models#fixed-price) run today.

[Open market](https://openfill.ai/market?model=market-preview)

## Datasheet

| Field | Value |
| --- | --- |
| Model id | market-preview |
| Also answers to | No other id |
| Context length | 262,144 tokens |
| Max output | 128,000 tokens |
| Pricing ratio | 1:10:20 |

The ratio weights a cache-hit, a cache-miss and an output token in the price. `max_tokens` above the max output is clamped down to it.

## The market now

The clearing level, the price of each token kind at that level, and the quote a locked request bids.

The live level and quote: GET https://api.openfill.ai/v1/market?model=market-preview and GET https://api.openfill.ai/v1/market/price-lock?model=market-preview.

## Uptime, last 24 hours

Each check is a chat completion through the public API, run the way the [models board](https://openfill.ai/models) describes.

The probe results: GET https://api.openfill.ai/v1/uptime?range=24h&model=market-preview.

## The first call

Set `OPENFILL_API_KEY` to a key from [API keys](https://openfill.ai/keys) before running an example. A key starts with `of_live_` and is shown once.

```python
import os
from openai import OpenAI

client = OpenAI(
    base_url=(
        "https://api.openfill.ai/v1"
    ),
    api_key=os.environ[
        "OPENFILL_API_KEY"
    ],
)

r = client.chat.completions.create(
    model="market-preview",
    messages=[
        {"role": "user", "content": "hi"}
    ],
    extra_body={"price_limit": 0.10},
)
print(r.choices[0].message.content)
print(r.usage)
```

```typescript
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.openfill.ai/v1",
  apiKey: process.env.OPENFILL_API_KEY,
});

const r = await client.chat.completions.create(
  {
    model: "market-preview",
    messages: [{ role: "user", content: "hi" }],
  },
  { headers: { "X-Price-Limit": "0.10" } },
);
console.log(r.choices[0].message.content);
console.log(r.usage);
```

**curl**

```bash
curl "https://api.openfill.ai/v1/chat/completions" \
  -H "Authorization: Bearer $OPENFILL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "market-preview",
    "messages": [
      {"role": "user", "content": "hi"}
    ],
    "price_limit": 0.10
  }'
```

**claude code**

```bash
# The base URL without /v1; Claude Code appends /v1/messages
export ANTHROPIC_BASE_URL="https://api.openfill.ai"
export ANTHROPIC_AUTH_TOKEN="$OPENFILL_API_KEY"
export ANTHROPIC_API_KEY=""

# Every model slot by hand: discovery keeps only ids that name Claude
export ANTHROPIC_MODEL="market-preview"
export ANTHROPIC_DEFAULT_SONNET_MODEL="market-preview"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="market-preview"
export CLAUDE_CODE_SUBAGENT_MODEL="market-preview"

# The price limit and the wait, merged into every request body
export CLAUDE_CODE_EXTRA_BODY='{"price_limit": 0.10, "max_wait": 600}'
export CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1
claude
```

**codex**

```toml
# ~/.codex/config.toml
model_provider = "openfill"
model = "market-preview"
model_context_window = 262144
web_search = "disabled"
show_raw_agent_reasoning = true

[model_providers.openfill]
name = "OpenFill"
base_url = "https://api.openfill.ai/v1"
env_key = "OPENFILL_API_KEY"
wire_api = "responses"
http_headers = { "X-Price-Limit" = "0.10" }
```

**opencode**

```json
// opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "openfill": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "OpenFill",
      "options": {
        "baseURL": "https://api.openfill.ai/v1",
        "apiKey": "{env:OPENFILL_API_KEY}",
        "headers": { "X-Price-Limit": "0.10" }
      },
      "models": {
        "market-preview": { "name": "market-preview" }
      }
    }
  }
}
```

**cline**

```text
# Cline, Roo Code and Kilo Code
# Settings > API Provider: OpenAI Compatible

Base URL   https://api.openfill.ai/v1
API Key    (your OPENFILL_API_KEY)
Model ID   market-preview

# These tools send no price limit of their
# own. Set one on the key, on Bidding.
```

**shell**

```bash
# A key from API keys, shown once when made
export OPENFILL_API_KEY="of_live_..."

# Any tool that reads the OpenAI variables
export OPENAI_BASE_URL="https://api.openfill.ai/v1"
export OPENAI_API_KEY="$OPENFILL_API_KEY"

# The price limit comes from the key or the
# account default, set on Bidding.
curl -s "$OPENAI_BASE_URL/models" \
  -H "Authorization: Bearer $OPENAI_API_KEY"
```

**ai sdk**

```typescript
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
import { generateText } from "ai";

const openfill = createOpenAICompatible({
  name: "openfill",
  baseURL: "https://api.openfill.ai/v1",
  apiKey: process.env.OPENFILL_API_KEY,
  headers: { "X-Price-Limit": "0.10" },
});

const { text } = await generateText({
  model: openfill.chatModel("market-preview"),
  prompt: "hi",
});
console.log(text);
```

**langchain**

```python
import os
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    model="market-preview",
    base_url="https://api.openfill.ai/v1",
    api_key=os.environ["OPENFILL_API_KEY"],
    default_headers={"X-Price-Limit": "0.10"},
)
print(llm.invoke("hi").content)
```

**litellm**

```python
import os
from litellm import completion

r = completion(
    model="openai/market-preview",
    api_base="https://api.openfill.ai/v1",
    api_key=os.environ["OPENFILL_API_KEY"],
    messages=[
        {"role": "user", "content": "hi"}
    ],
    extra_headers={"X-Price-Limit": "0.10"},
)
print(r.choices[0].message.content)
```

**agents sdk**

```python
import os
from openai import AsyncOpenAI
from agents import (
    Agent, Runner,
    set_default_openai_api,
    set_default_openai_client,
    set_tracing_disabled,
)

set_default_openai_client(AsyncOpenAI(
    base_url="https://api.openfill.ai/v1",
    api_key=os.environ["OPENFILL_API_KEY"],
    default_headers={"X-Price-Limit": "0.10"},
))
set_default_openai_api("chat_completions")
set_tracing_disabled(True)

agent = Agent(name="assistant", model="market-preview")
print(Runner.run_sync(agent, "hi").final_output)
```

## Questions

### What does market-preview cost on OpenFill?

The clearing level when the request runs, up to the price limit you set, shared across the three token kinds by the ratio 1:10:20.

[How pricing works](https://openfill.ai/docs/pricing)

### What happens while the level is above my price limit?

The request waits in the book while capacity is short and runs when there is room, for up to `max_wait` (10 seconds to 30 days). Past that it expires with 408 and no charge.

[Waiting and timeouts](https://openfill.ai/docs/orders#waiting)

### How do I know the price before I send?

With `price_lock: true` the request bids the published quote, or your price limit if lower, and starts within 10 seconds or cancels with 429 and no charge.

[Price lock](https://openfill.ai/docs/price-lock)

### What are the rate limits?

1,200 inference requests a minute per key, 2,000 queued orders per account, and a request body of up to 8 MB. Every rate limit is on `GET /v1/rate-limits`.

[Rate limits](https://openfill.ai/docs/rate-limits)

### What is stored?

Storage is off by default: a prompt and its response exist only while the request runs. With it on, results are kept up to 30 days; `store: false` keeps less.

[Data storage](https://openfill.ai/docs/storage)
