{"id":119,"date":"2026-09-14T02:14:26","date_gmt":"2026-09-14T02:14:26","guid":{"rendered":"https:\/\/ntokenx.com\/blog\/index.php\/2026\/09\/14\/pydantic-ai-gateway\/"},"modified":"2026-09-14T02:14:26","modified_gmt":"2026-09-14T02:14:26","slug":"pydantic-ai-gateway","status":"publish","type":"post","link":"https:\/\/ntokenx.com\/blog\/index.php\/2026\/09\/14\/pydantic-ai-gateway\/","title":{"rendered":"pydantic ai gateway \u67b6\u6784\u3001\u8def\u7531\u4e0e\u90e8\u7f72\u5b9e\u8df5"},"content":{"rendered":"<p><em>\u4f5c\u8005\uff1anTokenX\uff5c\u53d1\u5e03\u65e5\u671f\uff1a2026\u5e749\u670814\u65e5\uff5c\u66f4\u65b0\u65e5\u671f\uff1a2026\u5e749\u670814\u65e5<\/em><\/p>\n<p>pydantic ai gateway \u662f\u9762\u5411\u591a\u6a21\u578b\u5e94\u7528\u7684\u7edf\u4e00\u8bbf\u95ee\u5c42\uff1a\u5e94\u7528\u4f7f\u7528\u4e00\u4e2a\u7f51\u5173\u5bc6\u94a5\uff0c\u5373\u53ef\u901a\u8fc7\u7edf\u4e00\u5165\u53e3\u8c03\u7528 OpenAI\u3001Anthropic\u3001Google\u3001Groq\u3001AWS Bedrock \u7b49\u63d0\u4f9b\u5546\u7684\u6a21\u578b\uff0c\u5e76\u96c6\u4e2d\u5904\u7406\u8def\u7531\u3001\u9884\u7b97\u3001\u9274\u6743\u548c\u89c2\u6d4b\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u5b98\u65b9\u9879\u76ee\u76ee\u524d\u5df2\u8fc1\u79fb\u81f3 Pydantic Logfire\uff0c\u539f\u72ec\u7acb GitHub \u4ed3\u5e93\u5df2\u5f52\u6863\u3002<\/p>\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/ntokenx.com\/blog\/wp-content\/uploads\/2026\/09\/backend-2154-1.jpg\" alt=\"pydantic ai gateway \u591a\u6a21\u578b\u8def\u7531\u67b6\u6784\u793a\u610f\u56fe\" style=\"max-width:100%;height:auto;\"><\/figure>\n<h2>\u4ec0\u4e48\u662f pydantic ai gateway\uff1f<\/h2>\n<p>pydantic ai gateway \u672c\u8d28\u4e0a\u662f\u4f4d\u4e8e\u4e1a\u52a1\u5e94\u7528\u4e0e\u6a21\u578b\u63d0\u4f9b\u5546\u4e4b\u95f4\u7684 AI \u7f51\u5173\uff0c\u800c\u4e0d\u662f\u65b0\u7684\u5927\u6a21\u578b\u6216\u5b8c\u6574\u7684 Agent \u7f16\u6392\u6846\u67b6\u3002\u5b83\u901a\u8fc7\u7f51\u5173 API Key \u4fdd\u62a4\u540e\u7aef\u51ed\u8bc1\uff0c\u540c\u65f6\u8ba9\u5e94\u7528\u6309\u7167\u6a21\u578b\u540d\u79f0\u9009\u62e9\u4e0d\u540c\u4f9b\u5e94\u5546\u3002<\/p>\n<p>\u5b98\u65b9\u6587\u6863\u5f3a\u8c03\uff0c\u5b83\u4e0e\u4f20\u7edf\u201c\u7edf\u4e00\u683c\u5f0f\u8f6c\u6362\u578b\u201d\u7f51\u5173\u4e0d\u540c\uff1a\u8bf7\u6c42\u53ef\u4ee5\u4fdd\u7559\u63d0\u4f9b\u5546\u7684\u539f\u751f\u534f\u8bae\uff0c\u51cf\u5c11\u56e0\u6a21\u5f0f\u8f6c\u6362\u5e26\u6765\u7684\u529f\u80fd\u635f\u5931\u3002\u5f53\u6a21\u578b\u5382\u5546\u63a8\u51fa\u65b0\u53c2\u6570\u6216\u65b0\u80fd\u529b\u65f6\uff0c\u539f\u751f\u8f6c\u53d1\u901a\u5e38\u66f4\u5bb9\u6613\u53ca\u65f6\u652f\u6301\u3002<\/p>\n<p>\u622a\u81f3 2026 \u5e74 9 \u6708\uff0c\u5b98\u65b9\u80fd\u529b\u4e3b\u8981\u5305\u62ec\uff1a<\/p>\n<ul>\n<li>\u5355\u4e00\u7f51\u5173\u5bc6\u94a5\u8bbf\u95ee\u591a\u4e2a\u6a21\u578b\u63d0\u4f9b\u5546\uff1b<\/li>\n<li>BYOK\uff0c\u5373\u7ed1\u5b9a\u4f01\u4e1a\u81ea\u6709\u7684\u6a21\u578b\u5382\u5546 API Key\uff1b<\/li>\n<li>\u9884\u7f6e\u63d0\u4f9b\u5546\u989d\u5ea6\u6a21\u5f0f\uff1b<\/li>\n<li>\u6309\u9879\u76ee\u3001\u7528\u6237\u548c API Key \u8bbe\u7f6e\u652f\u51fa\u4e0a\u9650\uff1b<\/li>\n<li>\u901a\u8fc7\u4f18\u5148\u7ea7\u6216\u6743\u91cd\u5b9e\u73b0\u6545\u969c\u8f6c\u79fb\u3001\u8d1f\u8f7d\u5747\u8861\uff1b<\/li>\n<li>\u4f7f\u7528 Pydantic Logfire \u6216 OpenTelemetry \u8bb0\u5f55\u8c03\u7528\u94fe\u8def\uff1b<\/li>\n<li>\u63d0\u4f9b\u4e91\u7aef\u4f7f\u7528\u65b9\u5f0f\uff0c\u5e76\u652f\u6301\u4f01\u4e1a\u81ea\u6258\u7ba1\u65b9\u5411\u3002<\/li>\n<\/ul>\n<h2>\u5b83\u7684\u67b6\u6784\u5982\u4f55\u5de5\u4f5c\uff1f<\/h2>\n<p>\u4e00\u4e2a\u53ef\u843d\u5730\u7684 AI \u7f51\u5173\u901a\u5e38\u53ef\u4ee5\u62c6\u6210\u56db\u4e2a\u5e73\u9762\uff1a<strong>\u63a5\u5165\u5e73\u9762\u3001\u7b56\u7565\u5e73\u9762\u3001\u63d0\u4f9b\u5546\u5e73\u9762\u548c\u89c2\u6d4b\u5e73\u9762<\/strong>\u3002\u8fd9\u79cd\u62c6\u5206\u6bd4\u5355\u7eaf\u628a\u7f51\u5173\u7406\u89e3\u6210\u201cAPI \u8f6c\u53d1\u5668\u201d\u66f4\u9002\u5408\u4f01\u4e1a\u5b9e\u65bd\u3002<\/p>\n<h3>1. \u63a5\u5165\u5e73\u9762\uff1a\u7edf\u4e00\u5165\u53e3\u4e0e\u534f\u8bae\u9002\u914d<\/h3>\n<p>\u4e1a\u52a1\u670d\u52a1\u53ea\u8fde\u63a5\u7f51\u5173\u5730\u5740\uff0c\u4e0d\u518d\u628a\u591a\u4e2a\u5382\u5546\u5bc6\u94a5\u6563\u843d\u5728\u4ee3\u7801\u3001\u5bb9\u5668\u73af\u5883\u53d8\u91cf\u548c CI \u914d\u7f6e\u4e2d\u3002Pydantic AI \u53ef\u4ee5\u4f7f\u7528\u7c7b\u4f3c\u4e0b\u9762\u7684\u6a21\u578b\u5b57\u7b26\u4e32\uff1a<\/p>\n<pre><code class=\"language-python\">from pydantic_ai import Agent\n\nagent = Agent(&quot;gateway\/openai:gpt-5.2&quot;)\nresult = agent.run_sync(&quot;\u8bf7\u7528\u4e00\u53e5\u8bdd\u89e3\u91ca API \u7f51\u5173&quot;)\nprint(result.output)\n<\/code><\/pre>\n<p>\u5982\u679c\u4f7f\u7528 OpenAI SDK\uff0c\u4e5f\u53ef\u4ee5\u628a <code>base_url<\/code> \u6307\u5411\u5b98\u65b9\u63d0\u4f9b\u7684 Gateway \u4ee3\u7406\u5730\u5740\u3002\u7f8e\u56fd\u533a\u57df\u793a\u4f8b\u4e3a\uff1a<\/p>\n<pre><code class=\"language-python\">from openai import OpenAI\n\nclient = OpenAI(\n    base_url=&quot;https:\/\/gateway-us.pydantic.dev\/proxy\/openai&quot;,\n    api_key=&quot;pylf_v...&quot;\n)\n<\/code><\/pre>\n<p>\u751f\u4ea7\u73af\u5883\u4e2d\uff0c\u533a\u57df\u3001\u7f51\u7edc\u51fa\u53e3\u548c\u6570\u636e\u5904\u7406\u4f4d\u7f6e\u5e94\u5148\u7ecf\u8fc7\u5408\u89c4\u8bc4\u4f30\uff0c\u4e0d\u5e94\u53ea\u6839\u636e\u4ee3\u7801\u80fd\u5426\u8fd0\u884c\u6765\u51b3\u5b9a\u90e8\u7f72\u65b9\u6848\u3002<\/p>\n<h3>2. \u7b56\u7565\u5e73\u9762\uff1a\u6a21\u578b\u8def\u7531\u4e0e\u9884\u7b97\u63a7\u5236<\/h3>\n<p>\u7f51\u5173\u8def\u7531\u4e0d\u5e94\u53ea\u5199\u6210\u201c\u5931\u8d25\u540e\u6362\u53e6\u4e00\u4e2a\u6a21\u578b\u201d\u3002\u66f4\u7a33\u59a5\u7684\u505a\u6cd5\u662f\u628a\u8def\u7531\u6761\u4ef6\u62c6\u6210\u56db\u7c7b\uff1a<\/p>\n<div style=\"overflow-x:auto;\">\n<table style=\"width:100%;border-collapse:collapse;margin:1.5em 0;font-size:0.95em;\">\n<thead>\n<tr>\n<th style=\"border:1px solid #e3e6ea;padding:8px 12px;background:#f6f8fa;text-align:left;font-weight:600;\">\u8def\u7531\u6761\u4ef6<\/th>\n<th style=\"border:1px solid #e3e6ea;padding:8px 12px;background:#f6f8fa;text-align:left;font-weight:600;\">\u793a\u4f8b\u7b56\u7565<\/th>\n<th style=\"border:1px solid #e3e6ea;padding:8px 12px;background:#f6f8fa;text-align:left;font-weight:600;\">\u9700\u8981\u89c2\u5bdf\u7684\u6307\u6807<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"border:1px solid #e3e6ea;padding:8px 12px;vertical-align:top;\">\u80fd\u529b<\/td>\n<td style=\"border:1px solid #e3e6ea;padding:8px 12px;vertical-align:top;\">\u5de5\u5177\u8c03\u7528\u3001\u7ed3\u6784\u5316\u8f93\u51fa\u8d70\u6307\u5b9a\u6a21\u578b<\/td>\n<td style=\"border:1px solid #e3e6ea;padding:8px 12px;vertical-align:top;\">\u6210\u529f\u7387\u3001\u683c\u5f0f\u9519\u8bef\u7387<\/td>\n<\/tr>\n<tr>\n<td style=\"border:1px solid #e3e6ea;padding:8px 12px;vertical-align:top;\">\u53ef\u9760\u6027<\/td>\n<td style=\"border:1px solid #e3e6ea;padding:8px 12px;vertical-align:top;\">\u4e3b\u4f9b\u5e94\u5546\u5f02\u5e38\u65f6\u5207\u6362\u5907\u7528\u7aef\u70b9<\/td>\n<td style=\"border:1px solid #e3e6ea;padding:8px 12px;vertical-align:top;\">\u8d85\u65f6\u7387\u30015xx \u6bd4\u4f8b<\/td>\n<\/tr>\n<tr>\n<td style=\"border:1px solid #e3e6ea;padding:8px 12px;vertical-align:top;\">\u8d1f\u8f7d<\/td>\n<td style=\"border:1px solid #e3e6ea;padding:8px 12px;vertical-align:top;\">\u6309\u6743\u91cd\u5206\u914d\u4e0d\u540c\u7aef\u70b9<\/td>\n<td style=\"border:1px solid #e3e6ea;padding:8px 12px;vertical-align:top;\">\u5ef6\u8fdf\u3001\u5e76\u53d1\u3001\u6392\u961f\u65f6\u95f4<\/td>\n<\/tr>\n<tr>\n<td style=\"border:1px solid #e3e6ea;padding:8px 12px;vertical-align:top;\">\u9884\u7b97<\/td>\n<td style=\"border:1px solid #e3e6ea;padding:8px 12px;vertical-align:top;\">\u8d85\u51fa\u9879\u76ee\u6216 Key \u9650\u989d\u540e\u963b\u65ad<\/td>\n<td style=\"border:1px solid #e3e6ea;padding:8px 12px;vertical-align:top;\">\u65e5\/\u6708\u6d88\u8017\u3001\u5269\u4f59\u989d\u5ea6<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Pydantic AI Gateway \u7684 Endpoint \u53ef\u4ee5\u914d\u7f6e\u4f18\u5148\u7ea7\u548c\u6743\u91cd\uff0c\u4f46\u5b9e\u9645\u7b56\u7565\u4ecd\u9700\u7531\u4e1a\u52a1\u5b9a\u4e49\u3002\u4f8b\u5982\uff0c\u5ba2\u670d\u6458\u8981\u53ef\u4ee5\u5141\u8bb8\u6545\u969c\u8f6c\u79fb\uff1b\u6d89\u53ca\u4e25\u683c JSON Schema \u7684\u4efb\u52a1\uff0c\u5219\u5e94\u4f18\u5148\u4fdd\u8bc1\u6a21\u578b\u80fd\u529b\u548c\u8f93\u51fa\u4e00\u81f4\u6027\uff0c\u800c\u4e0d\u662f\u76f2\u76ee\u5207\u6362\u3002<\/p>\n<h2>\u9274\u6743\u3001\u5b89\u5168\u4e0e\u6570\u636e\u8fb9\u754c\u600e\u4e48\u8bbe\u8ba1\uff1f<\/h2>\n<p>\u9274\u6743\u7684\u6838\u5fc3\u4e0d\u662f\u201c\u7ed9\u6bcf\u4e2a\u5e94\u7528\u53d1\u4e00\u4e2a\u76f8\u540c\u7684 Key\u201d\uff0c\u800c\u662f\u5efa\u7acb<strong>\u6700\u5c0f\u6743\u9650\u3001\u53ef\u64a4\u9500\u3001\u53ef\u8ffd\u8e2a<\/strong>\u7684\u5bc6\u94a5\u4f53\u7cfb\u3002\u5b98\u65b9 Logfire \u6587\u6863\u63d0\u4f9b\u9879\u76ee\u7ea7\u548c\u4e2a\u4eba\u7ea7 API Key\uff0c\u5e76\u652f\u6301\u6709\u6548\u671f\u548c\u652f\u51fa\u9650\u5236\u3002<\/p>\n<p>\u63a8\u8350\u91c7\u7528\u4ee5\u4e0b\u505a\u6cd5\uff1a<\/p>\n<ol>\n<li>\u4e3a\u5f00\u53d1\u3001\u6d4b\u8bd5\u3001\u751f\u4ea7\u5efa\u7acb\u72ec\u7acb\u9879\u76ee\uff1b<\/li>\n<li>\u6309\u670d\u52a1\u6216\u5de5\u4f5c\u8d1f\u8f7d\u5212\u5206 API Key\uff0c\u800c\u4e0d\u662f\u5168\u516c\u53f8\u5171\u7528\uff1b<\/li>\n<li>\u8bbe\u7f6e\u6bcf\u65e5\u3001\u6bcf\u5468\u3001\u6bcf\u6708\u6216\u603b\u989d\u4e0a\u9650\uff1b<\/li>\n<li>\u901a\u8fc7\u5bc6\u94a5\u8f6e\u6362\u548c\u8fc7\u671f\u65f6\u95f4\u964d\u4f4e\u6cc4\u9732\u5f71\u54cd\uff1b<\/li>\n<li>\u660e\u786e\u662f\u5426\u8bb0\u5f55\u63d0\u793a\u8bcd\u3001\u5de5\u5177\u8f93\u5165\u548c\u6a21\u578b\u54cd\u5e94\uff1b<\/li>\n<li>\u5bf9\u654f\u611f\u5b57\u6bb5\u505a\u8131\u654f\u3001\u6700\u5c0f\u5316\u4f20\u8f93\u6216\u5728\u7f51\u5173\u524d\u7f6e\u62e6\u622a\u3002<\/li>\n<\/ol>\n<p>\u5b98\u65b9\u96c6\u6210\u8bf4\u660e\u6307\u51fa\uff0c\u542f\u7528\u7f51\u5173\u9065\u6d4b\u540e\uff0c\u63d0\u793a\u8bcd\u3001\u5de5\u5177\u8f93\u5165\u548c\u54cd\u5e94\u53ef\u80fd\u7ecf\u8fc7 Logfire \u4e0e\u6a21\u578b\u63d0\u4f9b\u5546\u3002\u56e0\u6b64\uff0c\u4f01\u4e1a\u9700\u8981\u5728\u67b6\u6784\u56fe\u4e2d\u660e\u786e\u201c\u6570\u636e\u7ecf\u8fc7\u54ea\u4e9b\u533a\u57df\u3001\u54ea\u4e9b\u7cfb\u7edf\u53ef\u4ee5\u770b\u5230\u539f\u6587\u3001\u65e5\u5fd7\u4fdd\u7559\u591a\u4e45\u201d\uff0c\u800c\u4e0d\u662f\u628a\u201c\u6709 HTTPS\u201d\u5f53\u4f5c\u5b8c\u6574\u7684\u6570\u636e\u5b89\u5168\u65b9\u6848\u3002<\/p>\n<h2>\u4e91\u7aef\u3001BYOK \u4e0e\u81ea\u6258\u7ba1\u5982\u4f55\u9009\u62e9\uff1f<\/h2>\n<p>\u8fd9\u7c7b\u5e73\u53f0\u901a\u5e38\u6709\u4e24\u79cd\u5f62\u6001\uff1a\u7b2c\u4e00\u7c7b\u662f\u6b63\u89c4 API \u805a\u5408\u6216\u7f51\u5173\uff0c\u4f01\u4e1a\u7ed1\u5b9a\u81ea\u5df1\u7684\u6a21\u578b\u5382\u5546 Key\uff0c\u7531\u5e73\u53f0\u7edf\u4e00\u8f6c\u53d1\u3001\u8ba1\u8d39\u548c\u76d1\u63a7\uff1b\u7b2c\u4e8c\u7c7b\u662f\u7b2c\u4e09\u65b9\u6a21\u578b\u4e2d\u8f6c\uff0c\u7531\u5e73\u53f0\u81ea\u884c\u91c7\u8d2d\u6216\u4ee3\u7406\u6a21\u578b\u989d\u5ea6\u3002\u7b2c\u4e8c\u7c7b\u670d\u52a1\u5728\u6388\u6743\u3001\u7a33\u5b9a\u6027\u548c\u6570\u636e\u5b89\u5168\u65b9\u9762\u5dee\u5f02\u8f83\u5927\uff0c\u91c7\u8d2d\u65f6\u5e94\u91cd\u70b9\u6838\u9a8c\u5408\u540c\u3001\u6570\u636e\u5904\u7406\u653f\u7b56\u548c\u4f9b\u5e94\u5546\u6765\u6e90\u3002<\/p>\n<p>\u9488\u5bf9 Pydantic AI Gateway\uff0c\u53ef\u6309\u4e0b\u8868\u5224\u65ad\uff1a<\/p>\n<div style=\"overflow-x:auto;\">\n<table style=\"width:100%;border-collapse:collapse;margin:1.5em 0;font-size:0.95em;\">\n<thead>\n<tr>\n<th style=\"border:1px solid #e3e6ea;padding:8px 12px;background:#f6f8fa;text-align:left;font-weight:600;\">\u573a\u666f<\/th>\n<th style=\"border:1px solid #e3e6ea;padding:8px 12px;background:#f6f8fa;text-align:left;font-weight:600;\">\u66f4\u9002\u5408\u7684\u65b9\u5f0f<\/th>\n<th style=\"border:1px solid #e3e6ea;padding:8px 12px;background:#f6f8fa;text-align:left;font-weight:600;\">\u5173\u952e\u68c0\u67e5\u9879<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"border:1px solid #e3e6ea;padding:8px 12px;vertical-align:top;\">\u5feb\u901f\u9a8c\u8bc1\u591a\u6a21\u578b\u8c03\u7528<\/td>\n<td style=\"border:1px solid #e3e6ea;padding:8px 12px;vertical-align:top;\">Logfire \u4e91\u7aef\u7f51\u5173<\/td>\n<td style=\"border:1px solid #e3e6ea;padding:8px 12px;vertical-align:top;\">\u533a\u57df\u3001\u989d\u5ea6\u3001\u65e5\u5fd7\u7b56\u7565<\/td>\n<\/tr>\n<tr>\n<td style=\"border:1px solid #e3e6ea;padding:8px 12px;vertical-align:top;\">\u5df2\u6709\u6a21\u578b\u4f9b\u5e94\u5546\u5408\u540c<\/td>\n<td style=\"border:1px solid #e3e6ea;padding:8px 12px;vertical-align:top;\">BYOK<\/td>\n<td style=\"border:1px solid #e3e6ea;padding:8px 12px;vertical-align:top;\">Key \u9694\u79bb\u3001\u8d26\u5355\u5f52\u5c5e\u3001\u5ba1\u8ba1<\/td>\n<\/tr>\n<tr>\n<td style=\"border:1px solid #e3e6ea;padding:8px 12px;vertical-align:top;\">\u5f3a\u76d1\u7ba1\u6216\u5185\u7f51\u90e8\u7f72<\/td>\n<td style=\"border:1px solid #e3e6ea;padding:8px 12px;vertical-align:top;\">\u81ea\u6258\u7ba1\u65b9\u6848<\/td>\n<td style=\"border:1px solid #e3e6ea;padding:8px 12px;vertical-align:top;\">\u955c\u50cf\u6765\u6e90\u3001\u5347\u7ea7\u673a\u5236\u3001\u5bc6\u94a5\u6258\u7ba1<\/td>\n<\/tr>\n<tr>\n<td style=\"border:1px solid #e3e6ea;padding:8px 12px;vertical-align:top;\">\u9700\u8981\u7edf\u4e00\u89c2\u5bdf Agent \u8c03\u7528<\/td>\n<td style=\"border:1px solid #e3e6ea;padding:8px 12px;vertical-align:top;\">Gateway + Logfire<\/td>\n<td style=\"border:1px solid #e3e6ea;padding:8px 12px;vertical-align:top;\">Trace \u5b57\u6bb5\u3001\u654f\u611f\u6570\u636e\u8131\u654f<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>\u72ec\u7acb\u4ed3\u5e93\u5f52\u6863\u610f\u5473\u7740\u4e0d\u5e94\u76f4\u63a5\u628a\u65e7\u4ed3\u5e93\u5f53\u4f5c\u957f\u671f\u7ef4\u62a4\u7684\u751f\u4ea7\u4f9d\u8d56\u3002\u82e5\u91c7\u7528\u81ea\u6258\u7ba1\uff0c\u5e94\u4f18\u5148\u786e\u8ba4\u5f53\u524d\u5b98\u65b9\u8fc1\u79fb\u8bf4\u660e\u3001\u90e8\u7f72\u6587\u6863\u548c\u7248\u672c\u7ef4\u62a4\u8d23\u4efb\uff0c\u518d\u51b3\u5b9a\u662f\u5426\u7ee7\u7eed\u4f7f\u7528\u65e7\u4ee3\u7801\u3002<\/p>\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/ntokenx.com\/blog\/wp-content\/uploads\/2026\/09\/backend-2154-2.jpg\" alt=\"AI \u7f51\u5173\u9274\u6743\u3001\u9884\u7b97\u4e0e\u53ef\u89c2\u6d4b\u6027\u6d41\u7a0b\u56fe\" style=\"max-width:100%;height:auto;\"><\/figure>\n<h2>\u4e0e\u5176\u4ed6 AI \u7f51\u5173\u6709\u4ec0\u4e48\u533a\u522b\uff1f<\/h2>\n<p>Pydantic AI Gateway \u7684\u4e3b\u8981\u7279\u70b9\u662f\u4e0e Pydantic AI\u3001Logfire \u548c\u539f\u751f\u6a21\u578b\u534f\u8bae\u7ed3\u5408\u7d27\u5bc6\uff0c\u9002\u5408\u5df2\u7ecf\u4f7f\u7528 Pydantic \u6280\u672f\u6808\u3001\u5e0c\u671b\u51cf\u5c11\u4e2d\u95f4\u62bd\u8c61\u5c42\u7684\u56e2\u961f\u3002<\/p>\n<p>\u5982\u679c\u91cd\u70b9\u662f\u7edf\u4e00\u63a5\u5165\u5927\u91cf\u4f9b\u5e94\u5546\u548c\u7075\u6d3b\u7684\u4ee3\u7406\u914d\u7f6e\uff0c\u53ef\u5bf9\u6bd4<a href=\"https:\/\/ntokenx.com\/blog\/index.php\/2026\/09\/11\/openrouter-guide\/\">OpenRouter \u7684\u6a21\u578b\u8def\u7531\u4e0e API \u805a\u5408\u673a\u5236<\/a>\uff1b\u5982\u679c\u56e2\u961f\u66f4\u5173\u6ce8\u81ea\u6258\u7ba1\u3001\u8def\u7531\u89c4\u5219\u548c\u6210\u672c\u63a7\u5236\uff0c\u5219\u53ef\u4ee5\u53c2\u8003<a href=\"https:\/\/ntokenx.com\/blog\/index.php\/2026\/09\/08\/litellm-ai-gateway\/\">LiteLLM AI Gateway \u7684\u90e8\u7f72\u4e0e\u8def\u7531\u5b9e\u8df5<\/a>\u3002\u5bf9\u4e8e\u4f01\u4e1a\u4e91\u73af\u5883\uff0c\u8fd8\u53ef\u7ed3\u5408<a href=\"https:\/\/ntokenx.com\/blog\/index.php\/2026\/09\/13\/azure-ai-gateway-2\/\">Azure AI Gateway \u7684\u6cbb\u7406\u4e0e\u96c6\u6210\u601d\u8def<\/a>\u8fdb\u884c\u67b6\u6784\u5bf9\u7167\u3002<\/p>\n<p>\u9009\u62e9\u65f6\u4e0d\u8981\u53ea\u6bd4\u8f83\u201c\u652f\u6301\u591a\u5c11\u6a21\u578b\u201d\uff0c\u66f4\u5e94\u6bd4\u8f83\u56db\u9879\uff1a<strong>\u534f\u8bae\u4fdd\u771f\u5ea6\u3001\u6545\u969c\u8f6c\u79fb\u7c92\u5ea6\u3001\u5bc6\u94a5\u4e0e\u9884\u7b97\u6cbb\u7406\u3001\u65e5\u5fd7\u4e2d\u7684\u6570\u636e\u66b4\u9732\u8303\u56f4<\/strong>\u3002<\/p>\n<h2>\u843d\u5730\u5b9e\u65bd\u7684\u63a8\u8350\u6b65\u9aa4<\/h2>\n<ol>\n<li><strong>\u76d8\u70b9\u8c03\u7528\u573a\u666f<\/strong>\uff1a\u533a\u5206\u804a\u5929\u3001\u7ed3\u6784\u5316\u62bd\u53d6\u3001\u5de5\u5177\u8c03\u7528\u3001\u6279\u5904\u7406\u548c\u9ad8\u53ef\u9760\u4efb\u52a1\u3002<\/li>\n<li><strong>\u5b9a\u4e49\u6a21\u578b\u5951\u7ea6<\/strong>\uff1a\u4e3a\u6bcf\u7c7b\u4efb\u52a1\u89c4\u5b9a\u6a21\u578b\u80fd\u529b\u3001\u4e0a\u4e0b\u6587\u957f\u5ea6\u3001\u8f93\u51fa\u683c\u5f0f\u548c\u8d85\u65f6\u8fb9\u754c\u3002<\/li>\n<li><strong>\u5efa\u7acb\u63d0\u4f9b\u5546\u6620\u5c04<\/strong>\uff1a\u8bb0\u5f55\u6a21\u578b\u540d\u79f0\u3001API \u683c\u5f0f\u3001\u533a\u57df\u3001\u5907\u7528\u7aef\u70b9\u4e0e\u8d1f\u8d23\u4eba\u3002<\/li>\n<li><strong>\u914d\u7f6e\u9274\u6743\u7b56\u7565<\/strong>\uff1a\u6309\u73af\u5883\u548c\u670d\u52a1\u62c6\u5206 Key\uff0c\u5e76\u8bbe\u7f6e\u8fc7\u671f\u65f6\u95f4\u548c\u9884\u7b97\u4e0a\u9650\u3002<\/li>\n<li><strong>\u8bbe\u8ba1\u6545\u969c\u8f6c\u79fb<\/strong>\uff1a\u660e\u786e\u54ea\u4e9b\u9519\u8bef\u53ef\u4ee5\u91cd\u8bd5\uff0c\u54ea\u4e9b\u9519\u8bef\u5fc5\u987b\u8fd4\u56de\u4e1a\u52a1\u5c42\u5904\u7406\u3002<\/li>\n<li><strong>\u63a5\u5165\u89c2\u6d4b\u7cfb\u7edf<\/strong>\uff1a\u81f3\u5c11\u8bb0\u5f55\u8bf7\u6c42 ID\u3001\u6a21\u578b\u3001\u5ef6\u8fdf\u3001Token \u7528\u91cf\u3001\u72b6\u6001\u7801\u548c\u8def\u7531\u7ed3\u679c\u3002<\/li>\n<li><strong>\u8fdb\u884c\u7070\u5ea6\u9a8c\u8bc1<\/strong>\uff1a\u5148\u8ba9\u4f4e\u98ce\u9669\u6d41\u91cf\u7ecf\u8fc7\u7f51\u5173\uff0c\u89c2\u5bdf\u6210\u529f\u7387\u3001P95 \u5ef6\u8fdf\u548c\u5f02\u5e38\u6210\u672c\uff0c\u518d\u6269\u5927\u8303\u56f4\u3002<\/li>\n<\/ol>\n<p>\u4e00\u5957\u5b9e\u7528\u7684\u9a8c\u6536\u6807\u51c6\u662f\uff1a<strong>\u80fd\u5426\u5728\u4e0d\u4fee\u6539\u4e1a\u52a1\u63d0\u793a\u8bcd\u7684\u524d\u63d0\u4e0b\u5207\u6362\u6a21\u578b\uff1b\u80fd\u5426\u5b9a\u4f4d\u4e00\u6b21\u5931\u8d25\u7a76\u7adf\u6765\u81ea\u5e94\u7528\u3001\u7f51\u5173\u8fd8\u662f\u4f9b\u5e94\u5546\uff1b\u80fd\u5426\u5728\u9884\u7b97\u8d85\u9650\u65f6\u53ca\u65f6\u963b\u65ad\uff1b\u80fd\u5426\u64a4\u9500\u6cc4\u9732\u7684 Key<\/strong>\u3002\u56db\u9879\u90fd\u80fd\u56de\u7b54\u6e05\u695a\uff0c\u7f51\u5173\u624d\u771f\u6b63\u5177\u5907\u751f\u4ea7\u4ef7\u503c\u3002<\/p>\n<h2>\u5e38\u89c1\u95ee\u9898<\/h2>\n<h3>Pydantic AI Gateway \u73b0\u5728\u8fd8\u662f\u72ec\u7acb\u4ea7\u54c1\u5417\uff1f<\/h3>\n<p>\u4e0d\u662f\u3002\u5b98\u65b9\u4fe1\u606f\u663e\u793a\uff0cPydantic AI Gateway \u5df2\u5e76\u5165 Pydantic Logfire\uff0c\u65e7\u7684\u72ec\u7acb\u9879\u76ee\u4ed3\u5e93\u5df2\u5f52\u6863\u3002\u65b0\u63a5\u5165\u5e94\u4ee5 Logfire \u4e2d\u7684 AI Gateway \u6587\u6863\u4e3a\u51c6\u3002<\/p>\n<h3>\u5fc5\u987b\u4f7f\u7528 Pydantic AI \u624d\u80fd\u63a5\u5165\u5417\uff1f<\/h3>\n<p>\u4e0d\u5fc5\u987b\u3002\u5b98\u65b9\u63d0\u4f9b OpenAI SDK\u3001Anthropic SDK\u3001Google GenAI SDK\u3001curl \u7b49\u63a5\u5165\u65b9\u5f0f\uff1bPydantic AI \u53ea\u662f\u5176\u4e2d\u96c6\u6210\u6700\u76f4\u63a5\u7684\u4e00\u79cd\u3002<\/p>\n<h3>BYOK \u662f\u4ec0\u4e48\uff1f<\/h3>\n<p>BYOK \u662f Bring Your Own Key \u7684\u7f29\u5199\uff0c\u6307\u4f01\u4e1a\u63d0\u4f9b\u81ea\u5df1\u7684\u6a21\u578b\u5382\u5546 API Key\uff0c\u7f51\u5173\u8d1f\u8d23\u7edf\u4e00\u4ee3\u7406\u3001\u8def\u7531\u548c\u89c2\u6d4b\u3002\u5b83\u4e0e\u7531\u7b2c\u4e09\u65b9\u7edf\u4e00\u91c7\u8d2d\u989d\u5ea6\u7684\u4e2d\u8f6c\u6a21\u5f0f\u5728\u8d26\u5355\u5f52\u5c5e\u548c\u4fe1\u4efb\u8fb9\u754c\u4e0a\u4e0d\u540c\u3002<\/p>\n<h3>\u539f\u751f\u534f\u8bae\u8f6c\u53d1\u6709\u4ec0\u4e48\u597d\u5904\uff1f<\/h3>\n<p>\u539f\u751f\u534f\u8bae\u8f6c\u53d1\u53ef\u4ee5\u51cf\u5c11\u7edf\u4e00 Schema \u8f6c\u6362\u5e26\u6765\u7684\u80fd\u529b\u635f\u5931\uff0c\u8ba9\u63d0\u4f9b\u5546\u7684\u65b0\u53c2\u6570\u66f4\u5bb9\u6613\u88ab\u4f7f\u7528\u3002\u4f46\u4ee3\u4ef7\u662f\u4e0d\u540c\u6a21\u578b\u7684\u8bf7\u6c42\u683c\u5f0f\u4ecd\u53ef\u80fd\u5b58\u5728\u5dee\u5f02\uff0c\u5e94\u7528\u4fa7\u5fc5\u987b\u505a\u597d\u6a21\u578b\u5951\u7ea6\u548c\u517c\u5bb9\u6027\u6d4b\u8bd5\u3002<\/p>\n<h3>\u4ec0\u4e48\u65f6\u5019\u4e0d\u9700\u8981 AI Gateway\uff1f<\/h3>\n<p>\u5982\u679c\u5e94\u7528\u53ea\u8c03\u7528\u4e00\u5bb6\u6a21\u578b\u63d0\u4f9b\u5546\uff0c\u4e14\u4e0d\u9700\u8981\u7edf\u4e00\u9884\u7b97\u3001\u5bc6\u94a5\u9694\u79bb\u3001\u6545\u969c\u8f6c\u79fb\u6216\u96c6\u4e2d\u5ba1\u8ba1\uff0c\u76f4\u63a5\u4f7f\u7528\u4f9b\u5e94\u5546 SDK \u53ef\u80fd\u66f4\u7b80\u5355\u3002\u7f51\u5173\u7684\u4ef7\u503c\u4e3b\u8981\u51fa\u73b0\u5728\u591a\u6a21\u578b\u3001\u591a\u73af\u5883\u548c\u591a\u4eba\u534f\u4f5c\u573a\u666f\u3002<\/p>\n<p>\u9700\u8981\u8bc4\u4f30\u591a\u6a21\u578b API \u805a\u5408\u5e73\u53f0\u3001\u7edf\u4e00\u5927\u6a21\u578b API \u6216\u4f01\u4e1a AI \u7f51\u5173\u7684\u843d\u5730\u8def\u5f84\u65f6\uff0c\u53ef\u7ed3\u5408\u4e1a\u52a1\u6a21\u578b\u3001\u6570\u636e\u8fb9\u754c\u548c\u8fd0\u7ef4\u80fd\u529b\u5236\u5b9a\u63a5\u5165\u65b9\u6848\uff0c\u8054\u7cfb <a href=\"https:\/\/ntokenx.com\/\">nTokenX<\/a> \u83b7\u53d6\u8fdb\u4e00\u6b65\u8ba8\u8bba\u3002<\/p>\n<p><script type=\"application\/ld+json\">\n{\n  \"@context\": \"https:\/\/schema.org\",\n  \"@type\": \"Article\",\n  \"headline\": \"pydantic ai gateway \u67b6\u6784\u3001\u8def\u7531\u4e0e\u90e8\u7f72\u5b9e\u8df5\",\n  \"description\": \"pydantic ai gateway \u662f\u8fde\u63a5\u591a\u5bb6\u6a21\u578b\u63d0\u4f9b\u5546\u7684\u7edf\u4e00\u7f51\u5173\uff0c\u672c\u6587\u89e3\u6790\u5176\u539f\u751f\u534f\u8bae\u8def\u7531\u3001BYOK\u3001\u9274\u6743\u3001\u6210\u672c\u63a7\u5236\u3001\u53ef\u89c2\u6d4b\u6027\u4e0e\u90e8\u7f72\u9009\u62e9\uff0c\u5e2e\u52a9\u56e2\u961f\u8bbe\u8ba1\u53ef\u7ef4\u62a4\u7684 AI \u63a5\u5165\u67b6\u6784\u3002\",\n  \"author\": {\n    \"@type\": \"Organization\",\n    \"name\": \"nTokenX\"\n  },\n  \"datePublished\": \"2026-09-14\",\n  \"dateModified\": \"2026-09-14\",\n  \"image\": \"image-placeholder\",\n  \"publisher\": {\n    \"@type\": \"Organization\",\n    \"name\": \"nTokenX\"\n  }\n}\n<\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>pydantic ai gateway \u662f\u8fde\u63a5\u591a\u5bb6\u6a21\u578b\u63d0\u4f9b\u5546\u7684\u7edf\u4e00\u7f51\u5173\uff0c\u672c\u6587\u89e3\u6790\u5176\u539f\u751f\u534f\u8bae\u8def\u7531\u3001BYOK\u3001\u9274\u6743\u3001\u6210\u672c\u63a7\u5236\u3001\u53ef\u89c2\u6d4b\u6027\u4e0e\u90e8\u7f72\u9009\u62e9\uff0c\u5e2e\u52a9\u56e2\u961f\u8bbe\u8ba1\u53ef\u7ef4\u62a4\u7684 AI \u63a5\u5165\u67b6\u6784\u3002<\/p>\n","protected":false},"author":1,"featured_media":118,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-119","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/ntokenx.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/119","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ntokenx.com\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ntokenx.com\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ntokenx.com\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ntokenx.com\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=119"}],"version-history":[{"count":0,"href":"https:\/\/ntokenx.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/119\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ntokenx.com\/blog\/index.php\/wp-json\/wp\/v2\/media\/118"}],"wp:attachment":[{"href":"https:\/\/ntokenx.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=119"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ntokenx.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=119"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ntokenx.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=119"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}