← 返回
未分类 中文

cpbox-llm-context

USE FOR RAG/LLM grounding. Returns pre-extracted web content (text, tables, code) optimized for LLMs. GET + POST. Adjust max_tokens/count based on complexity...
用于RAG/LLM基础。返回为LLM优化的预提取网页内容(文本、表格、代码)。支持GET和POST。根据复杂度调整max_tokens/count。
sprintmint sprintmint 来源
未分类 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 2
Stars
📥 576
下载
💾 0
安装
1
版本
#latest

概述

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

RoleDomain
--------------
API Providerhttps://www.cpbox.io
Facilitatorhttps://www.cppay.finance

Endpoint (Agent Interface)

GET  /api/x402/llm-context
POST /api/x402/llm-context/post

Payment Flow (x402 Protocol)

  1. First request (no PAYMENT-SIGNATURE) -> 402 Payment Required with requirements JSON
  2. Client signs (EIP-712) -> PAYMENT-SIGNATURE
  3. 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

FeatureLLM Context (this)AI Grounding (answers)
------
OutputRaw extracted content for YOUR LLMEnd-to-end AI answers with citations
InterfaceREST API (GET/POST)OpenAI-compatible /chat/completions
SearchesSingle search per requestMulti-search (iterative research)
SpeedFast (<1s)Slower
PlanSearchAnswers
Endpoint/res/v1/llm/context/res/v1/chat/completions
Best forAI agents, RAG pipelines, tool callsChat interfaces, research mode

Endpoint

GET  https://www.cpbox.io/api/x402/llm-context
POST https://www.cpbox.io/api/x402/llm-context/post

Authentication: handled by x402 payment middleware

Optional Headers:

  • Accept-Encoding: gzip — Enable gzip compression

Quick Start

GET Request

curl -s "https://www.cpbox.io/api/x402/llm-context?q=tallest+mountains+in+the+world" \
  -H "Accept: application/json"

POST Request (JSON body)

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": "tallest mountains in the world"}'

With Goggles (Inline)

curl -s "https://www.cpbox.io/api/x402/llm-context" \
  -H "Accept: application/json" \
  -G \
  --data-urlencode "q=rust programming" \
  --data-urlencode 'goggles=$discard
$site=docs.rs
$site=rust-lang.org'

Using with x402-payment

npx @springmint/x402-payment \
  --url "https://www.cpbox.io/api/x402/llm-context?q=rust+ownership&maximum_number_of_tokens=4096" \
  --method GET

Parameters

Query Parameters

ParameterTypeRequiredDefaultDescription
----------
qstringYes-Search query (1-400 chars, max 50 words)
countrystringNoUSSearch country (2-letter country code or ALL)
search_langstringNoenLanguage preference (2+ char language code)
countintNo20Max search results to consider (1-50)

Context Size Parameters

ParameterTypeRequiredDefaultDescription
----------
maximum_number_of_urlsintNo20Max URLs in response (1-50)
maximum_number_of_tokensintNo8192Approximate max tokens in context (1024-32768)
maximum_number_of_snippetsintNo50Max snippets across all URLs (1-100)
maximum_number_of_tokens_per_urlintNo4096Max tokens per individual URL (512-8192)
maximum_number_of_snippets_per_urlintNo50Max snippets per individual URL (1-100)

Filtering & Local Parameters

ParameterTypeRequiredDefaultDescription
----------
context_threshold_modestringNobalancedRelevance threshold for including content (strict/balanced/lenient)
enable_localboolNonullLocal recall control (true/false/null, see below)
gogglesstring/listNonullGoggle URL or inline definition for custom re-ranking

Context Size Guidelines

Task Typecountmax_tokensExample
--------
Simple factual52048"What year was Python created?"
Standard queries208192"Best practices for React hooks"
Complex research5016384"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

ModeBehavior
----
strictHigher threshold — fewer but more relevant results
balancedDefault — good balance between coverage and relevance
lenientLower threshold — more results, may include less relevant content

Local Recall

The enable_local parameter controls location-aware recall:

ValueBehavior
----
null (not set)Auto-detect — local recall enabled when any location header is provided
trueForce local — always use local recall, even without location headers
falseForce 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

HeaderTypeDescription
------
X-Loc-LatfloatLatitude (-90.0 to 90.0)
X-Loc-LongfloatLongitude (-180.0 to 180.0)
X-Loc-CitystringCity name
X-Loc-StatestringState/region code (ISO 3166-2)
X-Loc-State-NamestringState/region name
X-Loc-Countrystring2-letter country code
X-Loc-Postal-CodestringPostal 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

curl -s "https://www.cpbox.io/api/x402/llm-context" \
  -H "Accept: application/json" \
  -H "X-Loc-Lat: 37.7749" \
  -H "X-Loc-Long: -122.4194" \
  -G \
  --data-urlencode "q=best coffee shops near me"

Example: With Place Name

curl -s "https://www.cpbox.io/api/x402/llm-context" \
  -H "Accept: application/json" \
  -H "X-Loc-City: San Francisco" \
  -H "X-Loc-State: CA" \
  -H "X-Loc-Country: US" \
  -G \
  --data-urlencode "q=best coffee shops near me"

Goggles (Custom Ranking)

Goggles let you control which sources ground your LLM — essential for RAG quality.

Use CaseGoggle Rules
----
Official docs only$discard\n$site=docs.python.org
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
MethodExample
----
Hosted--data-urlencode "goggles=https://"
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.orgBlock list: $discard,site=pinterest.com\n$discard,site=quora.com

Resources: See your upstream provider's Goggles documentation.

Response Format

Standard Response

{
  "grounding": {
    "generic": [
      {
        "url": "https://example.com/page",
        "title": "Page Title",
        "snippets": [
          "Relevant text chunk extracted from the page...",
          "Another relevant passage from the same page..."
        ]
      }
    ],
    "map": []
  },
  "sources": {
    "https://example.com/page": {
      "title": "Page Title",
      "hostname": "example.com",
      "age": ["Wednesday, January 15, 2025", "2025-01-15", "392 days ago"]
    }
  }
}

Local Response (with enable_local)

{
  "grounding": {
    "generic": [...],
    "poi": {
      "name": "Business Name",
      "url": "https://business.com",
      "title": "Title of business.com website",
      "snippets": ["Business details and information..."]
    },
    "map": [
      {
        "name": "Place Name",
        "url": "https://place.com",
        "title": "Title of place.com website",
        "snippets": ["Place information and details..."]
      }
    ]
  },
  "sources": {
    "https://business.com": {
      "title": "Business Name",
      "hostname": "business.com",
      "age": null
    }
  }
}

Response Fields

FieldTypeDescription
------
groundingobjectContainer for all grounding content by type
grounding.genericarrayArray of URL objects with extracted content (main grounding data)
grounding.generic[].urlstringSource URL
grounding.generic[].titlestringPage title
grounding.generic[].snippetsarrayExtracted smart chunks relevant to the query
grounding.poiobject/nullPoint of interest data (only with local recall)
grounding.poi.namestring/nullPoint of interest name
grounding.poi.urlstring/nullPOI source URL
grounding.poi.titlestring/nullPOI page title
grounding.poi.snippetsarray/nullPOI text snippets
grounding.maparrayMap/place results (only with local recall)
grounding.map[].namestring/nullPlace name
grounding.map[].urlstring/nullPlace source URL
grounding.map[].titlestring/nullPlace page title
grounding.map[].snippetsarray/nullPlace text snippets
sourcesobjectMetadata for all referenced URLs, keyed by URL
sources[url].titlestringPage title
sources[url].hostnamestringSource hostname
sources[url].agearray/nullPage 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.

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-05-03 06:52 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

ai-agent

Agent Browser

rez0
用于 AI 代理的浏览器自动化 CLI。当用户需要与网站交互(包括浏览页面、填写表单、点击按钮、截图等)时使用。
★ 865 📥 342,687
ai-agent

self-improving agent

pskoett
记录自身发现以实现自我改进的技能
★ 4,161 📥 931,472
dev-programming

cpbox-batch-balance

sprintmint
当用户询问批量余额查询或多调用(multicall)余额等问题时,指导其使用批量EVM地址余额查询API(/api/x402/batch-balance)。
★ 2 📥 692