1:"$Sreact.fragment" 2:I[56271,["2545","static/chunks/c16f53c3-391a1f5a73546b11.js","2619","static/chunks/2619-eccd988d1e161df3.js","3353","static/chunks/3353-35c19838f8cf7b3b.js","7177","static/chunks/app/layout-cb4429a7e3e88a9f.js"],"ThemeProviders"] 3:I[41402,["2545","static/chunks/c16f53c3-391a1f5a73546b11.js","2619","static/chunks/2619-eccd988d1e161df3.js","3353","static/chunks/3353-35c19838f8cf7b3b.js","7177","static/chunks/app/layout-cb4429a7e3e88a9f.js"],""] 4:I[91367,["2545","static/chunks/c16f53c3-391a1f5a73546b11.js","2619","static/chunks/2619-eccd988d1e161df3.js","3353","static/chunks/3353-35c19838f8cf7b3b.js","7177","static/chunks/app/layout-cb4429a7e3e88a9f.js"],"KBarSearchProvider"] 5:I[52619,["2619","static/chunks/2619-eccd988d1e161df3.js","2806","static/chunks/app/tags/page-716f271631f278af.js"],""] 6:I[51350,["2545","static/chunks/c16f53c3-391a1f5a73546b11.js","2619","static/chunks/2619-eccd988d1e161df3.js","3353","static/chunks/3353-35c19838f8cf7b3b.js","7177","static/chunks/app/layout-cb4429a7e3e88a9f.js"],"KBarButton"] 10:I[57150,[],""] :HL["/_next/static/css/29ff447a95e95257.css","style"] :HL["/_next/static/css/77af622156c5e021.css","style"] 0:{"P":null,"b":"FUTryh0Sm2lrVLTvF5oMH","p":"","c":["","tags","cost"],"i":false,"f":[[["",{"children":["tags",{"children":[["tag","cost","d"],{"children":["__PAGE__",{}]}]}]},"$undefined","$undefined",true],["",["$","$1","c",{"children":[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/29ff447a95e95257.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}],["$","link","1",{"rel":"stylesheet","href":"/_next/static/css/77af622156c5e021.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}]],["$","html",null,{"lang":"zh-cn","className":"scroll-smooth","suppressHydrationWarning":true,"children":[["$","link",null,{"rel":"apple-touch-icon","sizes":"76x76","href":"/static/favicons/apple-touch-icon.png"}],["$","link",null,{"rel":"icon","type":"image/png","sizes":"32x32","href":"/static/favicons/favicon-32x32.png"}],["$","link",null,{"rel":"icon","type":"image/png","sizes":"16x16","href":"/static/favicons/favicon-16x16.png"}],["$","link",null,{"rel":"manifest","href":"/static/favicons/site.webmanifest"}],["$","link",null,{"rel":"mask-icon","href":"/static/favicons/safari-pinned-tab.svg","color":"#5bbad5"}],["$","meta",null,{"name":"msapplication-TileColor","content":"#4f46e5"}],["$","meta",null,{"name":"theme-color","media":"(prefers-color-scheme: light)","content":"#ffffff"}],["$","meta",null,{"name":"theme-color","media":"(prefers-color-scheme: dark)","content":"#0f172a"}],["$","link",null,{"rel":"alternate","type":"application/rss+xml","href":"/feed.xml"}],["$","body",null,{"className":"bg-white pl-[calc(100vw-100%)] text-black antialiased dark:bg-gray-950 dark:text-white","children":["$","$L2",null,{"children":[["$undefined","$undefined","$undefined",["$","$L3",null,{"async":true,"defer":true,"src":"https://analytics.umami.is/script.js"}],"$undefined","$undefined"],["$","section",null,{"className":"mx-auto max-w-3xl px-4 sm:px-6 xl:max-w-5xl xl:px-0","children":[["$","$L4",null,{"kbarConfig":{"searchDocumentsPath":"/search.json"},"children":[["$","header",null,{"className":"flex items-center w-full bg-white dark:bg-gray-950 justify-between py-10","children":[["$","$L5",null,{"className":"break-words","href":"/","aria-label":"TechLog","children":["$","div",null,{"className":"flex items-center justify-between","children":[["$","div",null,{"className":"mr-3","children":["$","svg",null,{"xmlns":"http://www.w3.org/2000/svg","xmlnsXlink":"http://www.w3.org/1999/xlink","width":53.87,"height":43.61,"viewBox":"344.564 330.278 111.737 91.218","children":[["$","defs",null,{"children":[["$","linearGradient",null,{"id":"logo_svg__b","x1":420.97,"x2":420.97,"y1":331.28,"y2":418.5,"gradientUnits":"userSpaceOnUse","children":[["$","stop",null,{"offset":"0%","style":{"stopColor":"#06b6d4","stopOpacity":1}}],["$","stop",null,{"offset":"100%","style":{"stopColor":"#67e8f9","stopOpacity":1}}]]}],["$","linearGradient",null,{"id":"logo_svg__d","x1":377.89,"x2":377.89,"y1":331.28,"y2":418.5,"gradientUnits":"userSpaceOnUse","children":[["$","stop",null,{"offset":"0%","style":{"stopColor":"#06b6d4","stopOpacity":1}}],["$","stop",null,{"offset":"100%","style":{"stopColor":"#67e8f9","stopOpacity":1}}]]}],["$","path",null,{"id":"logo_svg__a","d":"M453.3 331.28v28.57l-64.66 58.65v-30.08z"}],["$","path",null,{"id":"logo_svg__c","d":"M410.23 331.28v28.57l-64.67 58.65v-30.08z"}]]}],["$","use",null,{"xlinkHref":"#logo_svg__a","fill":"url(#logo_svg__b)"}],["$","use",null,{"xlinkHref":"#logo_svg__c","fill":"url(#logo_svg__d)"}]]}]}],["$","div",null,{"className":"hidden h-6 text-2xl font-semibold sm:block","children":"TechLog"}]]}]}],["$","div",null,{"className":"flex items-center space-x-4 leading-5 sm:-mr-6 sm:space-x-6","children":[["$","div",null,{"className":"no-scrollbar hidden max-w-40 items-center gap-x-4 overflow-x-auto sm:flex md:max-w-72 lg:max-w-96","children":[["$","$L5","博客",{"className":"hover:text-primary-500 dark:hover:text-primary-400 m-1 font-medium text-gray-900 dark:text-gray-100","href":"/blog.html","children":"博客"}],["$","$L5","标签",{"className":"hover:text-primary-500 dark:hover:text-primary-400 m-1 font-medium text-gray-900 dark:text-gray-100","href":"/tags.html","children":"标签"}],["$","$L5","项目",{"className":"hover:text-primary-500 dark:hover:text-primary-400 m-1 font-medium text-gray-900 dark:text-gray-100","href":"/projects.html","children":"项目"}],["$","$L5","关于",{"className":"hover:text-primary-500 dark:hover:text-primary-400 m-1 font-medium text-gray-900 dark:text-gray-100","href":"/about.html","children":"关于"}]]}],["$","$L6",null,{"aria-label":"Search","children":["$","svg",null,{"xmlns":"http://www.w3.org/2000/svg","fill":"none","viewBox":"0 0 24 24","strokeWidth":1.5,"stroke":"currentColor","className":"hover:text-primary-500 dark:hover:text-primary-400 h-6 w-6 text-gray-900 dark:text-gray-100","children":"$L7"}]}],"$L8","$L9"]}]]}],"$La"]}],"$Lb"]}]]}]}]]}]]}],{"children":["tags","$Lc",{"children":[["tag","cost","d"],"$Ld",{"children":["__PAGE__","$Le",{},null,false]},null,false]},null,false]},null,false],"$Lf",false]],"m":"$undefined","G":["$10",[]],"s":false,"S":true} 11:I[49217,["2545","static/chunks/c16f53c3-391a1f5a73546b11.js","2619","static/chunks/2619-eccd988d1e161df3.js","3353","static/chunks/3353-35c19838f8cf7b3b.js","7177","static/chunks/app/layout-cb4429a7e3e88a9f.js"],"default"] 12:I[394,["2545","static/chunks/c16f53c3-391a1f5a73546b11.js","2619","static/chunks/2619-eccd988d1e161df3.js","3353","static/chunks/3353-35c19838f8cf7b3b.js","7177","static/chunks/app/layout-cb4429a7e3e88a9f.js"],"default"] 13:I[9766,[],""] 14:I[98924,[],""] 16:I[24431,[],"OutletBoundary"] 18:I[15278,[],"AsyncMetadataOutlet"] 1a:I[24431,[],"ViewportBoundary"] 1c:I[24431,[],"MetadataBoundary"] 1d:"$Sreact.suspense" 7:["$","path",null,{"strokeLinecap":"round","strokeLinejoin":"round","d":"M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607z"}] 8:["$","$L11",null,{}] 9:["$","$L12",null,{}] a:["$","main",null,{"className":"mb-auto","children":["$","$L13",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L14",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[["$","div",null,{"className":"flex flex-col items-start justify-start md:mt-24 md:flex-row md:items-center md:justify-center md:space-x-6","children":[["$","div",null,{"className":"space-x-2 pt-6 pb-8 md:space-y-5","children":["$","h1",null,{"className":"text-6xl leading-9 font-extrabold tracking-tight text-gray-900 md:border-r-2 md:px-6 md:text-8xl md:leading-14 dark:text-gray-100","children":"404"}]}],["$","div",null,{"className":"max-w-md","children":[["$","p",null,{"className":"mb-4 text-xl leading-normal font-bold md:text-2xl","children":"Sorry we couldn't find this page."}],["$","p",null,{"className":"mb-8","children":"But dont worry, you can find plenty of other things on our homepage."}],["$","$L5",null,{"className":"focus:shadow-outline-blue inline rounded-lg border border-transparent bg-blue-600 px-4 py-2 text-sm leading-5 font-medium text-white shadow-xs transition-colors duration-150 hover:bg-blue-700 focus:outline-hidden dark:hover:bg-blue-500","href":"/","children":"Back to homepage"}]]}]]}],[]],"forbidden":"$undefined","unauthorized":"$undefined"}]}] b:["$","footer",null,{"children":["$","div",null,{"className":"mt-16 flex flex-col items-center","children":[["$","div",null,{"className":"mb-3 flex space-x-4","children":[["$","a",null,{"className":"text-sm text-gray-500 transition hover:text-gray-600","target":"_blank","rel":"noopener noreferrer","href":"mailto:birenwenmou@qq.com","children":[["$","span",null,{"className":"sr-only","children":"mail"}],["$","svg",null,{"xmlns":"http://www.w3.org/2000/svg","viewBox":"0 0 20 20","className":"hover:text-primary-500 dark:hover:text-primary-400 fill-current text-gray-700 dark:text-gray-200 h-6 w-6","children":[["$","title",null,{"children":"Mail"}],["$","path",null,{"d":"M2.003 5.884L10 9.882l7.997-3.998A2 2 0 0016 4H4a2 2 0 00-1.997 1.884z"}],["$","path",null,{"d":"M18 8.118l-8 4-8-4V14a2 2 0 002 2h12a2 2 0 002-2V8.118z"}]]}]]}],["$","a",null,{"className":"text-sm text-gray-500 transition hover:text-gray-600","target":"_blank","rel":"noopener noreferrer","href":"https://github.com/joker1point","children":[["$","span",null,{"className":"sr-only","children":"github"}],["$","svg",null,{"xmlns":"http://www.w3.org/2000/svg","viewBox":"0 0 24 24","className":"hover:text-primary-500 dark:hover:text-primary-400 fill-current text-gray-700 dark:text-gray-200 h-6 w-6","children":[["$","title",null,{"children":"GitHub"}],["$","path",null,{"d":"M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"}]]}]]}],null,null,null,null,null,null,null,null,null]}],["$","div",null,{"className":"mb-2 flex space-x-2 text-sm text-gray-500 dark:text-gray-400","children":[["$","div",null,{"children":"眠月"}],["$","div",null,{"children":" • "}],["$","div",null,{"children":"© 2026"}],["$","div",null,{"children":" • "}],["$","$L5",null,{"className":"break-words","href":"/","children":"TechLog"}]]}],["$","div",null,{"className":"mb-8 text-sm text-gray-500 dark:text-gray-400","children":["$","a",null,{"className":"break-words","target":"_blank","rel":"noopener noreferrer","href":"https://github.com/joker1point","children":"GitHub"}]}]]}]}] c:["$","$1","c",{"children":[null,["$","$L13",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L14",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","forbidden":"$undefined","unauthorized":"$undefined"}]]}] d:["$","$1","c",{"children":[null,["$","$L13",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L14",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","forbidden":"$undefined","unauthorized":"$undefined"}]]}] e:["$","$1","c",{"children":["$L15",null,["$","$L16",null,{"children":["$L17",["$","$L18",null,{"promise":"$@19"}]]}]]}] f:["$","$1","h",{"children":[null,[["$","$L1a",null,{"children":"$L1b"}],null],["$","$L1c",null,{"children":["$","div",null,{"hidden":true,"children":["$","$1d",null,{"fallback":null,"children":"$L1e"}]}]}]]}] 1f:I[97979,["2619","static/chunks/2619-eccd988d1e161df3.js","6775","static/chunks/6775-3fc538fd0daf2399.js","5755","static/chunks/app/tags/%5Btag%5D/page-3861b03ec5293832.js"],"default"] 15:["$","$L1f",null,{"posts":[{"title":"成本治理:付费 API 的计费安全与双重试状态机设计","date":"2026-09-06T00:00:00.000Z","tags":["engineering","api","cost","retry","billing","architecture"],"draft":false,"summary":"以 OpenAI 文生图 API 为例,解析生成请求与图片下载为什么必须是两个独立重试状态机:关键差异在计费语义——一个是未确认态可能重复扣费,一个是已付费的幂等免费操作。","type":"Blog","readingTime":{"text":"3 min read","minutes":2.94,"time":176400,"words":588},"wordCount":588,"slug":"billing-safety-retry-state-machine","path":"blog/billing-safety-retry-state-machine","filePath":"blog/billing-safety-retry-state-machine.mdx","toc":[{"value":"成本治理:付费 API 的计费安全与双重试状态机设计","url":"#成本治理付费-api-的计费安全与双重试状态机设计","depth":2},{"value":"状态机一:生成请求(_request_openai_image,L1290)","url":"#状态机一生成请求_request_openai_imagel1290","depth":2},{"value":"状态机二:图片下载(_openai_image_download_bytes,L1202)","url":"#状态机二图片下载_openai_image_download_bytesl1202","depth":2},{"value":"为什么必须是两个状态机","url":"#为什么必须是两个状态机","depth":2},{"value":"总结","url":"#总结","depth":2}],"structuredData":{"@context":"https://schema.org","@type":"BlogPosting","headline":"成本治理:付费 API 的计费安全与双重试状态机设计","datePublished":"2026-09-06T00:00:00.000Z","dateModified":"2026-09-06T00:00:00.000Z","description":"以 OpenAI 文生图 API 为例,解析生成请求与图片下载为什么必须是两个独立重试状态机:关键差异在计费语义——一个是未确认态可能重复扣费,一个是已付费的幂等免费操作。","image":"/static/images/twitter-card.png","url":"https://techlog-18328.app.workbuddy.host/blog/billing-safety-retry-state-machine"}}],"initialDisplayPosts":["$15:props:posts:0"],"pagination":{"currentPage":1,"totalPages":1},"title":"Cost"}] 1b:[["$","meta","0",{"charSet":"utf-8"}],["$","meta","1",{"name":"viewport","content":"width=device-width, initial-scale=1"}]] 17:null 19:{"metadata":[["$","title","0",{"children":"cost | TechLog"}],["$","meta","1",{"name":"description","content":"TechLog cost tagged content"}],["$","meta","2",{"name":"robots","content":"index, follow"}],["$","meta","3",{"name":"googlebot","content":"index, follow, max-video-preview:-1, max-image-preview:large, max-snippet:-1"}],["$","link","4",{"rel":"canonical","href":"https://techlog-18328.app.workbuddy.host/tags/cost"}],["$","link","5",{"rel":"alternate","type":"application/rss+xml","href":"https://techlog-18328.app.workbuddy.host/tags/cost/feed.xml"}],["$","meta","6",{"property":"og:title","content":"cost | TechLog"}],["$","meta","7",{"property":"og:description","content":"TechLog cost tagged content"}],["$","meta","8",{"property":"og:url","content":"https://techlog-18328.app.workbuddy.host/tags/cost"}],["$","meta","9",{"property":"og:site_name","content":"TechLog"}],["$","meta","10",{"property":"og:locale","content":"zh_CN"}],["$","meta","11",{"property":"og:image","content":"https://techlog-18328.app.workbuddy.host/static/images/twitter-card.png"}],["$","meta","12",{"property":"og:type","content":"website"}],["$","meta","13",{"name":"twitter:card","content":"summary_large_image"}],["$","meta","14",{"name":"twitter:title","content":"cost | TechLog"}],["$","meta","15",{"name":"twitter:description","content":"TechLog cost tagged content"}],["$","meta","16",{"name":"twitter:image","content":"https://techlog-18328.app.workbuddy.host/static/images/twitter-card.png"}]],"error":null,"digest":"$undefined"} 1e:"$19:metadata"