LLM Context
Paid LLM Context proxy via x402 pay-per-use (HTTP 402).
Prerequisites: This skill requires x402-payment. Complete the setup steps before first use.
Service URLs
| Role | Domain |
|---|
| API Provider | https://www.cpbox.io |
| Facilitator |
https://www.cppay.finance |
Endpoint (Agent Interface)
CODEBLOCK0
Payment Flow (x402 Protocol)
- 1. First request (no
PAYMENT-SIGNATURE) -> 402 Payment Required with requirements JSON - Client signs (EIP-712) -> INLINECODE2
- Retry with
PAYMENT-SIGNATURE -> Server settles and returns JSON
With @springmint/x402-payment or x402-sdk-go, payment is automatic.
LLM Context delivers pre-extracted, relevance-ranked web content optimized for grounding LLM responses in real-time search results. Unlike traditional web search APIs that return links and snippets, LLM Context extracts the actual page content—text chunks, tables, code blocks, and structured data—so your LLM or AI agent can reason over it directly.
LLM Context vs AI Grounding
| Feature | LLM Context (this) | AI Grounding (answers) |
|---|
| Output | Raw extracted content for YOUR LLM | End-to-end AI answers with citations |
| Interface |
REST API (GET/POST) | OpenAI-compatible
/chat/completions |
| Searches | Single search per request | Multi-search (iterative research) |
| Speed | Fast (<1s) | Slower |
| Plan | Search | Answers |
| Endpoint |
/res/v1/llm/context |
/res/v1/chat/completions |
| Best for | AI agents, RAG pipelines, tool calls | Chat interfaces, research mode |
Endpoint
CODEBLOCK1
Authentication: handled by x402 payment middleware
Optional Headers:
- -
Accept-Encoding: gzip — Enable gzip compression
Quick Start
GET Request
CODEBLOCK2
POST Request (JSON body)
CODEBLOCK3
With Goggles (Inline)
CODEBLOCK4
Using with x402-payment
CODEBLOCK5
Parameters
Query Parameters
| Parameter | Type | Required | Default | Description |
|---|
| INLINECODE11 | string | Yes | - | Search query (1-400 chars, max 50 words) |
| INLINECODE12 |
string | No |
US | Search country (2-letter country code or
ALL) |
|
search_lang | string | No |
en | Language preference (2+ char language code) |
|
count | int | No |
20 | Max search results to consider (1-50) |
Context Size Parameters
| Parameter | Type | Required | Default | Description |
|---|
| INLINECODE19 | int | No | INLINECODE20 | Max URLs in response (1-50) |
| INLINECODE21 |
int | No |
8192 | Approximate max tokens in context (1024-32768) |
|
maximum_number_of_snippets | int | No |
50 | Max snippets across all URLs (1-100) |
|
maximum_number_of_tokens_per_url | int | No |
4096 | Max tokens per individual URL (512-8192) |
|
maximum_number_of_snippets_per_url | int | No |
50 | Max snippets per individual URL (1-100) |
Filtering & Local Parameters
| Parameter | Type | Required | Default | Description |
|---|
| INLINECODE29 | string | No | INLINECODE30 | Relevance threshold for including content (strict/balanced/lenient) |
| INLINECODE34 |
bool | No |
null | Local recall control (
true/
false/
null, see below) |
|
goggles | string/list | No |
null | Goggle URL or inline definition for custom re-ranking |
Context Size Guidelines
| Task Type | count | max_tokens | Example |
|---|
| Simple factual | 5 | 2048 | "What year was Python created?" |
| Standard queries |
20 | 8192 | "Best practices for React hooks" |
| Complex research | 50 | 16384 | "Compare AI frameworks for production" |
Larger context windows provide more information but increase latency and cost (of your inference). Start with defaults and adjust.
Threshold Modes
| Mode | Behavior |
|---|
| INLINECODE41 | Higher threshold — fewer but more relevant results |
| INLINECODE42 |
Default — good balance between coverage and relevance |
|
lenient | Lower threshold — more results, may include less relevant content |
Local Recall
The enable_local parameter controls location-aware recall:
| Value | Behavior |
|---|
| INLINECODE45 (not set) | Auto-detect — local recall enabled when any location header is provided |
| INLINECODE46 |
Force local — always use local recall, even without location headers |
|
false |
Force standard — always use standard web ranking, even with location headers |
For most use cases, omit enable_local and let the API auto-detect from location headers.
Location Headers
| Header | Type | Description |
|---|
| INLINECODE49 | float | Latitude (-90.0 to 90.0) |
| INLINECODE50 |
float | Longitude (-180.0 to 180.0) |
|
X-Loc-City | string | City name |
|
X-Loc-State | string | State/region code (ISO 3166-2) |
|
X-Loc-State-Name | string | State/region name |
|
X-Loc-Country | string | 2-letter country code |
|
X-Loc-Postal-Code | string | Postal code |
Priority: X-Loc-Lat + X-Loc-Long take precedence. When provided, text-based headers (City, State, Country, Postal-Code) are not used for location resolution. Provide text-based headers only when you don't have coordinates.
Example: With Coordinates
CODEBLOCK6
Example: With Place Name
CODEBLOCK7
Goggles (Custom Ranking)
Goggles let you control which sources ground your LLM — essential for RAG quality.
| Use Case | Goggle Rules |
|---|
| Official docs only | INLINECODE58 |
| Exclude user content |
$discard,site=reddit.com\n$discard,site=stackoverflow.com |
| Academic sources |
$discard\n$site=arxiv.org\n$site=.edu |
| No paywalls |
$discard,site=medium.com |
| Method | Example |
|---|
| Hosted | INLINECODE62 |
| Inline |
--data-urlencode 'goggles=$discard\n$site=example.com' |
Hosted goggles should be hosted on a public URL and include ! name:, ! description:, ! author: headers. Inline rules need no registration.
Syntax: $boost=N / $downrank=N (1–10), $discard, $site=example.com. Combine with commas: $site=example.com,boost=3. Separate rules with \n (%0A).
Allow list: $discard\n$site=docs.python.org\n$site=developer.mozilla.org — Block list: INLINECODE75
Resources: See your upstream provider's Goggles documentation.
Response Format
Standard Response
CODEBLOCK8
Local Response (with enable_local)
CODEBLOCK9
Response Fields
| Field | Type | Description |
|---|
| INLINECODE77 | object | Container for all grounding content by type |
| INLINECODE78 |
array | Array of URL objects with extracted content (main grounding data) |
|
grounding.generic[].url | string | Source URL |
|
grounding.generic[].title | string | Page title |
|
grounding.generic[].snippets | array | Extracted smart chunks relevant to the query |
|
grounding.poi | object/null | Point of interest data (only with local recall) |
|
grounding.poi.name | string/null | Point of interest name |
|
grounding.poi.url | string/null | POI source URL |
|
grounding.poi.title | string/null | POI page title |
|
grounding.poi.snippets | array/null | POI text snippets |
|
grounding.map | array | Map/place results (only with local recall) |
|
grounding.map[].name | string/null | Place name |
|
grounding.map[].url | string/null | Place source URL |
|
grounding.map[].title | string/null | Place page title |
|
grounding.map[].snippets | array/null | Place text snippets |
|
sources | object | Metadata for all referenced URLs, keyed by URL |
|
sources[url].title | string | Page title |
|
sources[url].hostname | string | Source hostname |
|
sources[url].age | array/null | Page modification dates (when available) |
Note: Snippets may contain plain text OR JSON-serialized structured data (tables, schemas, code blocks). LLMs handle this mixed format well.
Use Cases
- - AI Agents: Give your agent a web search tool that returns ready-to-use content in a single call
- RAG Pipelines: Ground LLM responses in fresh, relevant web content
- AI Assistants & Chatbots: Provide factual answers backed by real sources
- Question Answering: Retrieve focused context for specific queries
- Fact Checking: Verify claims against current web content
- Content Research: Gather source material on any topic with one API call
Best Practices
- - Token budget: Start with defaults (
maximum_number_of_tokens=8192, count=20). Reduce for simple lookups, increase for complex research. - Source quality: Use Goggles to restrict to trusted sources. Set
context_threshold_mode=strict when precision > recall. - Performance: Use smallest
count and maximum_number_of_tokens that meet your needs. For local queries, provide location headers.
LLM 上下文
通过 x402 按使用付费(HTTP 402)提供的付费 LLM 上下文代理。
前置条件:此技能需要 x402 支付。首次使用前请完成设置步骤。
服务地址
| 角色 | 域名 |
|---|
| API 提供商 | https://www.cpbox.io |
| 协调方 |
https://www.cppay.finance |
端点(代理接口)
http
GET /api/x402/llm-context
POST /api/x402/llm-context/post
支付流程(x402 协议)
- 1. 首次请求(无 PAYMENT-SIGNATURE)-> 返回 402 Payment Required 及需求 JSON
- 客户端签名(EIP-712)-> PAYMENT-SIGNATURE
- 携带 PAYMENT-SIGNATURE 重试 -> 服务器结算并返回 JSON
使用 @springmint/x402-payment 或 x402-sdk-go 时,支付自动完成。
LLM 上下文提供预提取、按相关性排序的网页内容,专为在实时搜索结果中为 LLM 响应提供基础而优化。与传统返回链接和摘要的网络搜索 API 不同,LLM 上下文提取实际页面内容——文本块、表格、代码块和结构化数据——使您的 LLM 或 AI 代理能够直接基于这些内容进行推理。
LLM 上下文 vs AI 基础
| 特性 | LLM 上下文(本服务) | AI 基础(answers) |
|---|
| 输出 | 供您 LLM 使用的原始提取内容 | 带引用的端到端 AI 答案 |
| 接口 |
REST API(GET/POST) | 兼容 OpenAI 的 /chat/completions |
| 搜索 | 每次请求单次搜索 | 多次搜索(迭代研究) |
| 速度 | 快速(<1秒) | 较慢 |
| 方案 | 搜索 | 答案 |
| 端点 | /res/v1/llm/context | /res/v1/chat/completions |
| 最佳用途 | AI 代理、RAG 管道、工具调用 | 聊天界面、研究模式 |
端点
http
GET https://www.cpbox.io/api/x402/llm-context
POST https://www.cpbox.io/api/x402/llm-context/post
认证:由 x402 支付中间件处理
可选请求头:
- - Accept-Encoding: gzip — 启用 gzip 压缩
快速开始
GET 请求
bash
curl -s https://www.cpbox.io/api/x402/llm-context?q=世界最高山峰 \
-H Accept: application/json
POST 请求(JSON 请求体)
bash
curl -s --compressed -X POST https://www.cpbox.io/api/x402/llm-context/post \
-H Accept: application/json \
-H Accept-Encoding: gzip \
-H Content-Type: application/json \
-d {q: 世界最高山峰}
使用 Goggles(内联)
bash
curl -s https://www.cpbox.io/api/x402/llm-context \
-H Accept: application/json \
-G \
--data-urlencode q=rust 编程 \
--data-urlencode goggles=$discard
$site=docs.rs
$site=rust-lang.org
配合 x402-payment 使用
bash
npx @springmint/x402-payment \
--url https://www.cpbox.io/api/x402/llm-context?q=rust+所有权&maximumnumberof_tokens=4096 \
--method GET
参数
查询参数
| 参数 | 类型 | 必填 | 默认值 | 描述 |
|---|
| q | 字符串 | 是 | - | 搜索查询(1-400 字符,最多 50 个单词) |
| country |
字符串 | 否 | US | 搜索国家(2 字母国家代码或 ALL) |
| search_lang | 字符串 | 否 | en | 语言偏好(2+ 字符语言代码) |
| count | 整数 | 否 | 20 | 考虑的最大搜索结果数(1-50) |
上下文大小参数
| 参数 | 类型 | 必填 | 默认值 | 描述 |
|---|
| maximumnumberofurls | 整数 | 否 | 20 | 响应中最大 URL 数(1-50) |
| maximumnumberoftokens |
整数 | 否 | 8192 | 上下文中近似最大 token 数(1024-32768) |
| maximum
numberof_snippets | 整数 | 否 | 50 | 所有 URL 的最大摘要数(1-100) |
| maximum
numberof
tokensper_url | 整数 | 否 | 4096 | 单个 URL 的最大 token 数(512-8192) |
| maximum
numberof
snippetsper_url | 整数 | 否 | 50 | 单个 URL 的最大摘要数(1-100) |
过滤与本地参数
| 参数 | 类型 | 必填 | 默认值 | 描述 |
|---|
| contextthresholdmode | 字符串 | 否 | balanced | 内容包含的相关性阈值(strict/balanced/lenient) |
| enable_local |
布尔值 | 否 | null | 本地召回控制(true/false/null,见下文) |
| goggles | 字符串/列表 | 否 | null | Goggle URL 或用于自定义重排的内联定义 |
上下文大小指南
| 任务类型 | count | max_tokens | 示例 |
|---|
| 简单事实查询 | 5 | 2048 | Python 是哪一年创建的? |
| 标准查询 |
20 | 8192 | React hooks 最佳实践 |
| 复杂研究 | 50 | 16384 | 比较生产环境 AI 框架 |
更大的上下文窗口提供更多信息,但会增加延迟和成本(您的推理成本)。从默认值开始,然后进行调整。
阈值模式
| 模式 | 行为 |
|---|
| strict | 更高阈值 — 结果更少但更相关 |
| balanced |
默认 — 覆盖率和相关性之间良好平衡 |
| lenient | 较低阈值 — 更多结果,可能包含不太相关的内容 |
本地召回
enable_local 参数控制位置感知召回:
| 值 | 行为 |
|---|
| null(未设置) | 自动检测 — 提供任何位置请求头时启用本地召回 |
| true |
强制本地 — 始终使用本地召回,即使没有位置请求头 |
| false |
强制标准 — 始终使用标准网络排名,即使有位置请求头 |
对于大多数用例,省略 enable_local,让 API 从位置请求头自动检测。
位置请求头
| 请求头 | 类型 | 描述 |
|---|
| X-Loc-Lat | 浮点数 | 纬度(-90.0 到 90.0) |
| X-Loc-Long |
浮点数 | 经度(-180.0 到 180.0) |
| X-Loc-City | 字符串 | 城市名称 |
| X-Loc-State | 字符串 | 州/地区代码(ISO 3166-2) |
| X-Loc-State-Name | 字符串 | 州/地区名称 |
| X-Loc-Country | 字符串 | 2 字母国家代码 |
| X-Loc-Postal-Code | 字符串 | 邮政编码 |
优先级:X-Loc-Lat + X-Loc-Long 优先。提供时,基于文本的请求头(城市、州、国家、邮政编码)不用于位置解析。仅在没有坐标时提供基于文本的请求头。
示例:带坐标
bash
curl -s https://www.cpbox.io/api/x402/llm-context \
-H Accept: application/json \
-H X-Loc-Lat: 37.7749 \
-H X-L