Skip to content

feat: add local Monad exact and upto examples - #48

Merged
gitctrlx merged 3 commits into
mainfrom
feat/local-monad-exact-upto-examples
Sep 5, 2026
Merged

feat: add local Monad exact and upto examples#48
gitctrlx merged 3 commits into
mainfrom
feat/local-monad-exact-upto-examples

Conversation

@gitctrlx

@gitctrlx gitctrlx commented Sep 5, 2026

Copy link
Copy Markdown
Member

中文

问题

本地要把 o402 + facilitator 在 Monad 主网(eip155:143)和测试网(eip155:10143)上跑通 exactupto。已有 chat_evm.py / chat_upto.py

  1. 默认 base_url 是生产 https://llm.qntx.org/v1
  2. 没有 prefer_network,会付 402 的第一条(主网)。
  3. Python x402 的 default assets 没有 Monad 测试网 USDC。默认 spend controls 丢掉测试网 accept 后,prefer_network("eip155:10143") passthrough,测试网请求实际 settle 在主网。
  4. o402 对 POST /v1/chat/completionsupto;exact 要走 /v1/images/generations
  5. 本机若有系统代理,httpx 打 127.0.0.1RemoteProtocolError。必须 NO_PROXY=127.0.0.1,localhost,::1

为什么要改

需要和 TS 包对称的本地矩阵。测试网 USDC 必须写进 spend_controls.allowed_assetsEvmConfig.rpc_url 按网切换。密钥只从 .env / 环境变量读。

改动

  • examples/local_monad_upto.py
  • examples/local_monad_exact.pyimages.generate → exact)
  • examples/local_monad_matrix.py
  • 允许测试网 USDC;示例内 setdefault NO_PROXY

用法

NO_PROXY=127.0.0.1,localhost,::1 python examples/local_monad_upto.py
NETWORK=eip155:10143 python examples/local_monad_exact.py

.env 已被 gitignore,不要提交私钥。


English

Problem

Local o402 + facilitator must exercise exact and upto on Monad mainnet (eip155:143) and testnet (eip155:10143). Existing chat_evm.py / chat_upto.py:

  1. Default base_url is production https://llm.qntx.org/v1.
  2. No prefer_network, so accepts[0] (mainnet) wins.
  3. Python x402 default assets omit Monad testnet USDC. Spend controls drop it; prefer_network("eip155:10143") passthrough-pays mainnet.
  4. o402 bills chat completions as upto. Exact needs /v1/images/generations.
  5. A system HTTP proxy makes httpx to 127.0.0.1 raise RemoteProtocolError. NO_PROXY=127.0.0.1,localhost,::1 is required.

Why this change

Parity with the TS package: two nets × two schemes, keys from env, testnet USDC in spend_controls.allowed_assets, per-net EvmConfig.rpc_url.

Changes

  • examples/local_monad_upto.py
  • examples/local_monad_exact.py (images.generate → exact)
  • examples/local_monad_matrix.py
  • Allow testnet USDC; setdefault NO_PROXY in the examples.

Usage

NO_PROXY=127.0.0.1,localhost,::1 python examples/local_monad_upto.py
NETWORK=eip155:10143 python examples/local_monad_exact.py

.env is gitignored. Do not commit keys.

Copilot AI lite review requested due to automatic review settings September 5, 2026 05:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@gitctrlx
gitctrlx merged commit 4708053 into main Sep 5, 2026
2 checks passed
@gitctrlx
gitctrlx deleted the feat/local-monad-exact-upto-examples branch September 5, 2026 06:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants