---
title: "Context Window Optimize (x402)"
method: GET
path: "/x402/v2/context-window-optimize"
tags: ["x402"]
---

# Context Window Optimize (x402)

`GET /x402/v2/context-window-optimize`

## Request

- Base URL: `https://api.strale.io`
- URL: `https://api.strale.io/x402/v2/context-window-optimize`
- Auth: none required

Rank and select document chunks by relevance to fit within a token budget. Returns selected/excluded chunks with scores.

## Query parameters

- `query` string, required
- `documents` unknown[], required: Array of {id, text}
  - unknown
- `max_tokens` integer

## Response `200`

Success

- object
  - `excluded` unknown[]
    - unknown
  - `selected` unknown[]
    - unknown
  - `tokens_remaining` integer
  - `total_tokens_used` integer

## Other responses

- `402`: Payment required (x402 — pay with USDC on Base)

---

[API](https://skmtc.dev/strale/apis/strale-api-2.md) · [All operations](https://skmtc.dev/strale/apis/strale-api-2/llms.txt) · [OpenAPI document](https://skmtc.dev/strale/apis/strale-api-2/revisions/a5293878cfc6?raw)
