{"id":16088,"date":"2024-12-20T19:24:43","date_gmt":"2024-12-20T11:24:43","guid":{"rendered":"https:\/\/www.aisharenet.com\/?p=16088"},"modified":"2024-12-20T19:35:49","modified_gmt":"2024-12-20T11:35:49","slug":"shiyongdenoweirenyia","status":"publish","type":"post","link":"https:\/\/www.kdjingpai.com\/ja\/shiyongdenoweirenyia\/","title":{"rendered":"\u4f7f\u7528deno\u4e3a\u4efb\u610f\u5927\u6a21\u578b\u5b89\u5168\u7684\u4ee3\u7406API\uff0c\u907f\u514d\u6cc4\u9732\u771f\u5b9eIP\u548c\u57df\u540d\u4fe1\u606f"},"content":{"rendered":"<p>\u89e3\u51b3\u67d0\u4e9b\u5730\u533a\u65e0\u6cd5\u76f4\u63a5\u8bf7\u6c42api.openai.com\u7b49\u7b49\u5927\u6a21\u578bAPI\uff0c\u6216\u8005\u56e0\u4e3a\u4ee3\u7406\u6cc4\u9732\u4fe1\u606f\u5bfc\u81f4\u5c01\u5e10\u53f7\uff0c\u4e4b\u524d\u4f7f\u7528CF\u4ee3\u7406\uff0c\u53ef\u80fd\u4f1a\u6cc4\u9732\u4f60\u7684IP\uff0c\u73b0\u5728\u6709\u4e00\u4e2a\u8f83\u4e3a\u5b89\u5168\u7684\u65b9\u6848\u3002<\/p>\n<p><strong>1.\u9996\u5148\u8fdb\u5165deno\u5b98\u7f51\u6ce8\u518c\u8d26\u53f7<\/strong><\/p>\n<p><strong>2.\u521b\u5efa\u9879\u76ee<\/strong><\/p>\n<p>\u8bbf\u95ee https:\/\/dash.deno.com\/account\/projects\uff0c\u70b9\u51fb\u201cNew Playground\u201d<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-16089\" title=\"\u4f7f\u7528deno\u4e3a\u4efb\u610f\u5927\u6a21\u578b\u4ee3\u7406API\uff0c\u907f\u514d\u900f\u4f20\u6cc4\u9732\u771f\u5b9eIP\u5c01\u53f7-1\" src=\"https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/12\/393fe4e20434cba.png\" alt=\"\u4f7f\u7528deno\u4e3a\u4efb\u610f\u5927\u6a21\u578b\u4ee3\u7406API\uff0c\u907f\u514d\u900f\u4f20\u6cc4\u9732\u771f\u5b9eIP\u5c01\u53f7-1\" width=\"838\" height=\"408\" srcset=\"https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/12\/393fe4e20434cba.png 1259w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/12\/393fe4e20434cba-300x146.png 300w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/12\/393fe4e20434cba-1024x499.png 1024w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/12\/393fe4e20434cba-768x374.png 768w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/12\/393fe4e20434cba-18x9.png 18w\" sizes=\"auto, (max-width: 838px) 100vw, 838px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><strong>3.\u7c98\u8d34\u4ee3\u7801\u5e76\u4fdd\u5b58<\/strong><\/p>\n<pre>import { serve } from \"https:\/\/deno.land\/std\/http\/server.ts\";\r\n\r\nconst apiMapping = {\r\n'\/discord': 'https:\/\/discord.com\/api',\r\n'\/telegram': 'https:\/\/api.telegram.org',\r\n'\/openai': 'https:\/\/api.openai.com',\r\n'\/claude': 'https:\/\/api.anthropic.com',\r\n'\/gemini': 'https:\/\/generativelanguage.googleapis.com',\r\n'\/meta': 'https:\/\/www.meta.ai\/api',\r\n'\/groq': 'https:\/\/api.groq.com\/openai',\r\n'\/xai': 'https:\/\/api.x.ai',\r\n'\/cohere': 'https:\/\/api.cohere.ai',\r\n'\/huggingface': 'https:\/\/api-inference.huggingface.co',\r\n'\/together': 'https:\/\/api.together.xyz',\r\n'\/novita': 'https:\/\/api.novita.ai',\r\n'\/portkey': 'https:\/\/api.portkey.ai',\r\n'\/fireworks': 'https:\/\/api.fireworks.ai',\r\n'\/openrouter': 'https:\/\/openrouter.ai\/api'\r\n};\r\n\r\nserve(async (request) =&gt; {\r\nconst url = new URL(request.url);\r\nconst pathname = url.pathname;\r\n\r\nif (pathname === '\/' || pathname === '\/index.html') {\r\nreturn new Response('Service is running!', {\r\nstatus: 200,\r\nheaders: { 'Content-Type': 'text\/html' }\r\n});\r\n} \r\n\r\nif (pathname === '\/robots.txt') {\r\nreturn new Response('User-agent: *\\nDisallow: \/', {\r\nstatus: 200,\r\nheaders: { 'Content-Type': 'text\/plain' }\r\n});\r\n}\r\n\r\nconst [prefix, rest] = extractPrefixAndRest(pathname, Object.keys(apiMapping));\r\nif (!prefix) {\r\nreturn new Response('Not Found', { status: 404 });\r\n}\r\n\r\nconst targetUrl = `${apiMapping[prefix]}${rest}`;\r\n\r\ntry {\r\nconst headers = new Headers();\r\nconst allowedHeaders = ['accept', 'content-type', 'authorization'];\r\nfor (const [key, value] of request.headers.entries()) {\r\nif (allowedHeaders.includes(key.toLowerCase())) {\r\nheaders.set(key, value);\r\n}\r\n}\r\n\r\nconst response = await fetch(targetUrl, {\r\nmethod: request.method,\r\nheaders: headers,\r\nbody: request.body\r\n});\r\n\r\nconst responseHeaders = new Headers(response.headers);\r\nresponseHeaders.set('X-Content-Type-Options', 'nosniff');\r\nresponseHeaders.set('X-Frame-Options', 'DENY');\r\nresponseHeaders.set('Referrer-Policy', 'no-referrer');\r\n\r\nreturn new Response(response.body, {\r\nstatus: response.status,\r\nheaders: responseHeaders\r\n});\r\n\r\n} catch (error) {\r\nconsole.error('Failed to fetch:', error);\r\nreturn new Response('Internal Server Error', { status: 500 });\r\n}\r\n});\r\n\r\nfunction extractPrefixAndRest(pathname, prefixes) {\r\nfor (const prefix of prefixes) {\r\nif (pathname.startsWith(prefix)) {\r\nreturn [prefix, pathname.slice(prefix.length)];\r\n}\r\n}\r\nreturn [null, null];\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-16090\" title=\"\u4f7f\u7528deno\u4e3a\u4efb\u610f\u5927\u6a21\u578b\u4ee3\u7406API\uff0c\u907f\u514d\u900f\u4f20\u6cc4\u9732\u771f\u5b9eIP\u5c01\u53f7-1\" src=\"https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/12\/d8beac4da94d95b.png\" alt=\"\u4f7f\u7528deno\u4e3a\u4efb\u610f\u5927\u6a21\u578b\u4ee3\u7406API\uff0c\u907f\u514d\u900f\u4f20\u6cc4\u9732\u771f\u5b9eIP\u5c01\u53f7-1\" width=\"1073\" height=\"635\" srcset=\"https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/12\/d8beac4da94d95b.png 1453w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/12\/d8beac4da94d95b-300x178.png 300w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/12\/d8beac4da94d95b-1024x606.png 1024w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/12\/d8beac4da94d95b-768x455.png 768w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/12\/d8beac4da94d95b-18x12.png 18w\" sizes=\"auto, (max-width: 1073px) 100vw, 1073px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><strong>4.\u4f7f\u7528\u65b9\u6cd5<\/strong><\/p>\n<p>\u9ed8\u8ba4\u57df\u540d\u662f https:\/\/hungry-lamb-22.deno.dev\/<\/p>\n<p>\u8bbf\u95ee<code>https:\/\/hungry-lamb-22.deno.dev\/xai<\/code> \u7b49\u4e8e\u8bbf\u95ee <code>https:\/\/api.x.ai\/<\/code><\/p>\n<p>\u6309\u7167\u4ee3\u7801\u91cc\u7684\u683c\u5f0f\uff0c\u4f60\u53ef\u4ee5\u6dfb\u52a0\u65b0\u7684\u5927\u6a21\u578b\u8bf7\u6c42\u5730\u5740<\/p>\n<p>&nbsp;<\/p>\n<p><strong>5.\u81ea\u5b9a\u4e49\u57df\u540d<\/strong><\/p>\n<p>\u8fdb\u5165\u8bbe\u7f6e\uff0c\u7ed1\u5b9a\u4f60\u81ea\u5df1\u7684\u57df\u540d<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-16092\" title=\"\u4f7f\u7528deno\u4e3a\u4efb\u610f\u5927\u6a21\u578b\u5b89\u5168\u7684\u4ee3\u7406API\uff0c\u907f\u514d\u6cc4\u9732\u771f\u5b9eIP\u548c\u57df\u540d\u4fe1\u606f-1\" src=\"https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/12\/adaf026ec3341d4.png\" alt=\"\u4f7f\u7528deno\u4e3a\u4efb\u610f\u5927\u6a21\u578b\u5b89\u5168\u7684\u4ee3\u7406API\uff0c\u907f\u514d\u6cc4\u9732\u771f\u5b9eIP\u548c\u57df\u540d\u4fe1\u606f-1\" width=\"627\" height=\"350\" srcset=\"https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/12\/adaf026ec3341d4.png 854w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/12\/adaf026ec3341d4-300x168.png 300w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/12\/adaf026ec3341d4-768x429.png 768w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/12\/adaf026ec3341d4-18x10.png 18w\" sizes=\"auto, (max-width: 627px) 100vw, 627px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><strong>\u5171\u4eab\u4ee3\u7406\u5730\u5740<\/strong><br \/>\n<div class=\"huoduan_hide_box\" style=\"border:1px dashed #F60; padding:10px; margin:10px 0; line-height:200%; color:#F00; background-color:#FFF4FF; overflow:hidden; clear:both;\"><img loading=\"lazy\" decoding=\"async\" class=\"wxpic\" align=\"right\" src=\"https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2025\/05\/d8668ed8023fbe2.jpg\" style=\"width:150px;height:150px;margin-left:20px;display:inline;border:none\" width=\"150\" height=\"150\"  alt=\"AI\u751f\u4ea7\u529b\u5e94\u7528\" \/><span style=\"font-size:18px;\">\u6b64\u5904\u5185\u5bb9\u5df2\u7ecf\u88ab\u4f5c\u8005\u9690\u85cf\uff0c\u8bf7\u8f93\u5165\u9a8c\u8bc1\u7801\u67e5\u770b\u5185\u5bb9<\/span><form method=\"post\" style=\"margin:10px 0;\"><span class=\"yzts\" style=\"font-size:18px;float:left;\">\u9a8c\u8bc1\u7801\uff1a<\/span><input name=\"huoduan_verifycode\" id=\"verifycode\" type=\"text\" value=\"\" style=\"border:none;float:left;width:80px; height:32px; line-height:30px; padding:0 5px; border:1px solid #FF6600;-moz-border-radius: 0px;  -webkit-border-radius: 0px;  border-radius:0px;\" \/><input id=\"verifybtn\" style=\"border:none;float:left;width:80px; height:32px; line-height:32px; padding:0 5px; background-color:#F60; text-align:center; border:none; cursor:pointer; color:#FFF;-moz-border-radius: 0px; font-size:14px;  -webkit-border-radius: 0px;  border-radius:0px;\" name=\"\" type=\"submit\" value=\"\u63d0\u4ea4\u67e5\u770b\" \/><\/form><div style=\"clear:left;\"><\/div><span style=\"color:#00BF30\">\u8bf7\u5173\u6ce8\u672c\u7ad9\u5fae\u4fe1\u516c\u4f17\u53f7\uff0c\u56de\u590d\u201c<span style=\"color:blue\">\u9a8c\u8bc1\u7801<\/span>\u201d\uff0c\u83b7\u53d6\u9a8c\u8bc1\u7801\u3002\u5728\u5fae\u4fe1\u91cc\u641c\u7d22\u201c<span style=\"color:blue\">AI\u751f\u4ea7\u529b\u5e94\u7528<\/span>\u201d\u6216\u8005\u201c<span style=\"color:blue\">Artificial9527<\/span>\u201d\u6216\u8005\u5fae\u4fe1\u626b\u63cf\u53f3\u4fa7\u4e8c\u7ef4\u7801\u90fd\u53ef\u4ee5\u5173\u6ce8\u672c\u7ad9\u5fae\u4fe1\u516c\u4f17\u53f7\u3002<\/span><div class=\"cl\"><\/div><\/div><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u89e3\u51b3\u67d0\u4e9b\u5730\u533a\u65e0\u6cd5\u76f4\u63a5\u8bf7\u6c42api.openai.com\u7b49\u7b49\u5927\u6a21\u578bAPI\uff0c\u6216\u8005\u56e0\u4e3a\u4ee3\u7406\u6cc4\u9732\u4fe1\u606f\u5bfc\u81f4\u5c01\u5e10\u53f7\uff0c\u4e4b\u524d\u4f7f\u7528CF\u4ee3\u7406\uff0c\u53ef\u80fd\u4f1a\u6cc4\u9732\u4f60\u7684IP\uff0c\u73b0\u5728\u6709\u4e00\u4e2a\u8f83\u4e3a\u5b89\u5168\u7684\u65b9\u6848\u3002 1.\u9996\u5148\u8fdb\u5165deno\u5b98\u7f51\u6ce8\u518c\u8d26\u53f7 2.\u521b\u5efa\u9879\u76ee \u8bbf\u95ee https:\/\/d&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[182],"tags":[],"class_list":["post-16088","post","type-post","status-publish","format-standard","hentry","category-shicao"],"_links":{"self":[{"href":"https:\/\/www.kdjingpai.com\/ja\/wp-json\/wp\/v2\/posts\/16088","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kdjingpai.com\/ja\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kdjingpai.com\/ja\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kdjingpai.com\/ja\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kdjingpai.com\/ja\/wp-json\/wp\/v2\/comments?post=16088"}],"version-history":[{"count":0,"href":"https:\/\/www.kdjingpai.com\/ja\/wp-json\/wp\/v2\/posts\/16088\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.kdjingpai.com\/ja\/wp-json\/wp\/v2\/media?parent=16088"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kdjingpai.com\/ja\/wp-json\/wp\/v2\/categories?post=16088"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kdjingpai.com\/ja\/wp-json\/wp\/v2\/tags?post=16088"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}