[{"data":1,"prerenderedAt":291},["ShallowReactive",2],{"integration:\u002Fintegrations\u002Fpython-sdk":3},{"id":4,"title":5,"body":6,"description":280,"extension":281,"keywords":282,"logo":283,"meta":284,"navigation":120,"order":285,"path":286,"product":287,"seo":288,"stem":289,"__hash__":290},"integrations\u002Fintegrations\u002Fpython-sdk.md","Use 402.report from Python",{"type":7,"value":8,"toc":274},"minimark",[9,29,34,76,89,93,104,140,143,167,192,196,220,243,247,255,270],[10,11,12,13,23,24,28],"p",{},"The ",[14,15,19],"a",{"href":16,"rel":17},"https:\u002F\u002Fpypi.org\u002Fproject\u002Freport402",[18],"nofollow",[20,21,22],"code",{},"report402"," Python SDK routes your agents' HTTP through the\n402.report proxy — so every x402 (HTTP 402) challenge and payment is observed — and hands your MCP\nclient your spend, forensics, and preflight (\"is this safe to pay?\") tools. 402.report is\n",[25,26,27],"strong",{},"non-custodial",": it observes, it never holds or settles funds.",[30,31,33],"h2",{"id":32},"_1-install","1. Install",[35,36,41],"pre",{"className":37,"code":38,"language":39,"meta":40,"style":40},"language-bash shiki shiki-themes github-light github-dark","pip install report402            # core config helpers (dependency-free)\npip install \"report402[http]\"    # + the built-in httpx ProxyClient\n","bash","",[20,42,43,63],{"__ignoreMap":40},[44,45,48,52,56,59],"span",{"class":46,"line":47},"line",1,[44,49,51],{"class":50},"sScJk","pip",[44,53,55],{"class":54},"sZZnC"," install",[44,57,58],{"class":54}," report402",[44,60,62],{"class":61},"sJ8bj","            # core config helpers (dependency-free)\n",[44,64,66,68,70,73],{"class":46,"line":65},2,[44,67,51],{"class":50},[44,69,55],{"class":54},[44,71,72],{"class":54}," \"report402[http]\"",[44,74,75],{"class":61},"    # + the built-in httpx ProxyClient\n",[10,77,78,79,82,83,88],{},"Set your key as ",[20,80,81],{},"REPORT402_API_KEY"," (create one in the ",[14,84,87],{"href":85,"rel":86},"https:\u002F\u002F402.report",[18],"dashboard",").",[30,90,92],{"id":91},"_2-route-your-agents-http-through-the-proxy","2. Route your agent's HTTP through the proxy",[10,94,95,96,99,100,103],{},"Any client that takes a ",[20,97,98],{},"base_url"," + default headers (the OpenAI SDK, an ",[20,101,102],{},"httpx.Client",", …):",[35,105,109],{"className":106,"code":107,"language":108,"meta":40,"style":40},"language-python shiki shiki-themes github-light github-dark","from report402 import proxy_client_config\n\ncfg = proxy_client_config(api_key=\"ag_...\", target=\"https:\u002F\u002Fapi.example.com\")\n# -> {\"base_url\": \"https:\u002F\u002Fproxy.402.report\",\n#     \"headers\": {\"x-402report-key\": \"ag_...\", \"x-402report-target\": \"https:\u002F\u002Fapi.example.com\"}}\n","python",[20,110,111,116,122,128,134],{"__ignoreMap":40},[44,112,113],{"class":46,"line":47},[44,114,115],{},"from report402 import proxy_client_config\n",[44,117,118],{"class":46,"line":65},[44,119,121],{"emptyLinePlaceholder":120},true,"\n",[44,123,125],{"class":46,"line":124},3,[44,126,127],{},"cfg = proxy_client_config(api_key=\"ag_...\", target=\"https:\u002F\u002Fapi.example.com\")\n",[44,129,131],{"class":46,"line":130},4,[44,132,133],{},"# -> {\"base_url\": \"https:\u002F\u002Fproxy.402.report\",\n",[44,135,137],{"class":46,"line":136},5,[44,138,139],{},"#     \"headers\": {\"x-402report-key\": \"ag_...\", \"x-402report-target\": \"https:\u002F\u002Fapi.example.com\"}}\n",[10,141,142],{},"Or the built-in client:",[35,144,146],{"className":106,"code":145,"language":108,"meta":40,"style":40},"from report402 import ProxyClient\n\nwith ProxyClient(\"ag_...\") as http:\n    r = http.get(\"https:\u002F\u002Fapi.example.com\u002Fpremium\")   # the x402 challenge + payment are observed\n",[20,147,148,153,157,162],{"__ignoreMap":40},[44,149,150],{"class":46,"line":47},[44,151,152],{},"from report402 import ProxyClient\n",[44,154,155],{"class":46,"line":65},[44,156,121],{"emptyLinePlaceholder":120},[44,158,159],{"class":46,"line":124},[44,160,161],{},"with ProxyClient(\"ag_...\") as http:\n",[44,163,164],{"class":46,"line":130},[44,165,166],{},"    r = http.get(\"https:\u002F\u002Fapi.example.com\u002Fpremium\")   # the x402 challenge + payment are observed\n",[10,168,169,172,173,176,177,180,181,183,184,187,188,191],{},[25,170,171],{},"LangChain · CrewAI · OpenAI Agents SDK · LlamaIndex:"," point the agent's tool HTTP at the proxy —\nwrap calls in ",[20,174,175],{},"ProxyClient",", or pass ",[20,178,179],{},"proxy_client_config(...)","'s ",[20,182,98],{}," + ",[20,185,186],{},"headers"," to whatever\n",[20,189,190],{},"httpx","\u002FOpenAI client the tool uses. Nothing else in your agent changes.",[30,193,195],{"id":194},"_3-give-the-agent-its-spend-as-mcp-tools","3. Give the agent its spend as MCP tools",[35,197,199],{"className":106,"code":198,"language":108,"meta":40,"style":40},"from report402 import mcp_http_config, mcp_client_json\n\nmcp_http_config(\"ag_...\")   # {\"url\": \"...\u002Fmcp\", \"headers\": {\"Authorization\": \"Bearer ag_...\"}}\nmcp_client_json(\"ag_...\")   # a full {\"mcpServers\": {...}} block for Claude Desktop \u002F Cursor \u002F VS Code\n",[20,200,201,206,210,215],{"__ignoreMap":40},[44,202,203],{"class":46,"line":47},[44,204,205],{},"from report402 import mcp_http_config, mcp_client_json\n",[44,207,208],{"class":46,"line":65},[44,209,121],{"emptyLinePlaceholder":120},[44,211,212],{"class":46,"line":124},[44,213,214],{},"mcp_http_config(\"ag_...\")   # {\"url\": \"...\u002Fmcp\", \"headers\": {\"Authorization\": \"Bearer ag_...\"}}\n",[44,216,217],{"class":46,"line":130},[44,218,219],{},"mcp_client_json(\"ag_...\")   # a full {\"mcpServers\": {...}} block for Claude Desktop \u002F Cursor \u002F VS Code\n",[10,221,222,223,226,227,234,235,238,239,242],{},"Hand ",[20,224,225],{},"mcp_http_config(...)"," to the official ",[14,228,231],{"href":229,"rel":230},"https:\u002F\u002Fpypi.org\u002Fproject\u002Fmcp",[18],[20,232,233],{},"mcp"," Streamable-HTTP\nclient. The tools are read-only — spend summaries, per-domain\u002Fagent breakdowns, forensics, and the\npreflight ",[20,236,237],{},"check_endpoint"," \u002F ",[20,240,241],{},"check_payee"," safety checks.",[30,244,246],{"id":245},"_4-optional-present-an-agent-identity","4. (Optional) present an agent identity",[10,248,249,250,254],{},"If your agent carries a verifiable identity (a DID, name, or attestation), present it and the proxy\nrelays it to origins for fine-grained attribution — 402.report ",[251,252,253],"em",{},"consumes"," identity, it never issues it:",[35,256,258],{"className":106,"code":257,"language":108,"meta":40,"style":40},"proxy_client_config(\"ag_...\", target=\"https:\u002F\u002Fapi.example.com\", agent=\"did:example:my-bot\")\nProxyClient(\"ag_...\", agent=\"did:example:my-bot\")\n",[20,259,260,265],{"__ignoreMap":40},[44,261,262],{"class":46,"line":47},[44,263,264],{},"proxy_client_config(\"ag_...\", target=\"https:\u002F\u002Fapi.example.com\", agent=\"did:example:my-bot\")\n",[44,266,267],{"class":46,"line":65},[44,268,269],{},"ProxyClient(\"ag_...\", agent=\"did:example:my-bot\")\n",[271,272,273],"style",{},"html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":40,"searchDepth":65,"depth":65,"links":275},[276,277,278,279],{"id":32,"depth":65,"text":33},{"id":91,"depth":65,"text":92},{"id":194,"depth":65,"text":195},{"id":245,"depth":65,"text":246},"Route your Python AI agents' HTTP through 402.report and wire their MCP client to your spend — LangChain, CrewAI, OpenAI Agents SDK, LlamaIndex, or any httpx\u002FOpenAI client — with one API key.","md","x402 Python SDK, report402, LangChain Python x402, CrewAI agent spend, OpenAI Agents SDK payments, httpx proxy, MCP Python client, agent payment observability","\u002Fcode.svg",{},25,"\u002Fintegrations\u002Fpython-sdk","Python",{"title":5,"description":280},"integrations\u002Fpython-sdk","AdW5ac124lGk3YgvsQvHJYBt1PLSM48LNN4YTFhDlOk",1784841652774]