1"use strict";(self.webpackChunk_deepseek_docs=self.webpackChunk_deepseek_docs||[]).push([[3854],{31493:(e,n,s)=>{s.r(n),s.d(n,{assets:()=>t,contentTitle:()=>c,default:()=>a,frontMatter:()=>l,metadata:()=>r,toc:()=>h});var i=s(80678),d=s(41759);const l={},c="\u56fe\u50cf\u7406\u89e3",r={id:"guides/vision",title:"\u56fe\u50cf\u7406\u89e3",description:"deepseek-flash \u6a21\u578b\u652f\u6301\u5728\u6587\u672c\u4e4b\u5916\u8f93\u5165\u56fe\u7247\uff0c\u4f60\u53ef\u4ee5\u8ba9\u6a21\u578b\u63cf\u8ff0\u56fe\u7247\u3001\u8bc6\u522b\u622a\u56fe\u4e2d\u7684\u6587\u5b57\u3001\u5206\u6790\u56fe\u8868\u7b49\u3002\u65e7\u6a21\u578b\u540d deepseek-v4-flash-vision-exp \u4ecd\u53ef\u8c03\u7528\uff0c\u4f46\u8be5\u6a21\u578b\u5df2\u4e0b\u7ebf\uff0c\u5176\u8bf7\u6c42\u540c\u6837\u7531\u6700\u65b0\u7684 Flash \u6a21\u578b\u627f\u63a5\u3002",source:"@site/i18n/zh-cn/docusaurus-plugin-content-docs/current/guides/vision.md",sourceDirName:"guides",slug:"/guides/vision",permalink:"/zh-cn/guides/vision",draft:!1,unlisted:!1,tags:[],version:"current",frontMatter:{},sidebar:"tutorialSidebar",previous:{title:"Qoder",permalink:"/zh-cn/quick_start/agent_integrations/qoder"},next:{title:"\u601d\u8003\u6a21\u5f0f",permalink:"/zh-cn/guides/thinking_mode"}},t={},h=[{value:"\u4f20\u5165\u56fe\u7247",id:"\u4f20\u5165\u56fe\u7247",level:2},{value:"1. Base64 \u7f16\u7801\u56fe\u7247\uff08\u5185\u8054\uff09",id:"1-base64-\u7f16\u7801\u56fe\u7247\u5185\u8054",level:3},{value:"2. \u5916\u90e8\u56fe\u7247 URL",id:"2-\u5916\u90e8\u56fe\u7247-url",level:3},{value:"3. \u5f15\u7528\u901a\u8fc7 Files API \u4e0a\u4f20\u7684\u6587\u4ef6",id:"3-\u5f15\u7528\u901a\u8fc7-files-api-\u4e0a\u4f20\u7684\u6587\u4ef6",level:3},{value:"\u7ec6\u8282\u7ea7\u522b\uff08Detail Level\uff09",id:"\u7ec6\u8282\u7ea7\u522bdetail-level",level:2},{value:"\u4f55\u65f6\u4f7f\u7528 Files API",id:"\u4f55\u65f6\u4f7f\u7528-files-api",level:2},{value:"Token \u7528\u91cf",id:"token-usage",level:2},{value:"\u9650\u5236",id:"limits",level:2},{value:"\u4f7f\u7528\u9650\u5236",id:"\u4f7f\u7528\u9650\u5236",level:2},{value:"\u5728 Anthropic API \u4e2d\u4f7f\u7528\u56fe\u7247",id:"\u5728-anthropic-api-\u4e2d\u4f7f\u7528\u56fe\u7247",level:2},{value:"\u5728 Responses API \u4e2d\u4f7f\u7528\u56fe\u7247",id:"responses-api",level:2}];function o(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",h3:"h3",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,d.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.h1,{id:"\u56fe\u50cf\u7406\u89e3",children:"\u56fe\u50cf\u7406\u89e3"}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.code,{children:"deepseek-flash"})," \u6a21\u578b\u652f\u6301\u5728\u6587\u672c\u4e4b\u5916\u8f93\u5165\u56fe\u7247\uff0c\u4f60\u53ef\u4ee5\u8ba9\u6a21\u578b\u63cf\u8ff0\u56fe\u7247\u3001\u8bc6\u522b\u622a\u56fe\u4e2d\u7684\u6587\u5b57\u3001\u5206\u6790\u56fe\u8868\u7b49\u3002\u65e7\u6a21\u578b\u540d ",(0,i.jsx)(n.code,{children:"deepseek-v4-flash-vision-exp"})," \u4ecd\u53ef\u8c03\u7528\uff0c\u4f46\u8be5\u6a21\u578b\u5df2\u4e0b\u7ebf\uff0c\u5176\u8bf7\u6c42\u540c\u6837\u7531\u6700\u65b0\u7684 Flash \u6a21\u578b\u627f\u63a5\u3002"]}),"\n",(0,i.jsxs)(n.p,{children:["\u652f\u6301\u7684\u56fe\u7247\u683c\u5f0f\uff1a",(0,i.jsx)(n.strong,{children:"JPEG\u3001PNG\u3001GIF\u3001WebP"}),"\u3002\u683c\u5f0f\u7531\u6587\u4ef6\u5b9e\u9645\u5185\u5bb9\u5224\u65ad\uff0c\u800c\u975e\u6587\u4ef6\u540d\u6216\u58f0\u660e\u7684 MIME \u7c7b\u578b\u3002"]}),"\n",(0,i.jsx)("hr",{}),"\n",(0,i.jsx)(n.h2,{id:"\u4f20\u5165\u56fe\u7247",children:"\u4f20\u5165\u56fe\u7247"}),"\n",(0,i.jsxs)(n.p,{children:["\u5171\u6709\u4e09\u79cd\u65b9\u5f0f\u5411\u6a21\u578b\u63d0\u4f9b\u56fe\u7247\uff0c\u5747\u4f7f\u7528\u6807\u51c6\u7684 OpenAI \u517c\u5bb9\u5bf9\u8bdd\u8865\u5168\u683c\u5f0f\uff0c\u5373 ",(0,i.jsx)(n.code,{children:"content"})," \u4e3a\u4e00\u4e2a\u5757\uff08block\uff09\u6570\u7ec4\uff0c\u800c\u975e\u7eaf\u5b57\u7b26\u4e32\u3002\u540c\u6837\u7684\u4e09\u79cd\u65b9\u5f0f\u4e5f\u9002\u7528\u4e8e ",(0,i.jsx)(n.a,{href:"/guides/responses_api#image-input",children:"Responses API"}),"\uff0c\u56fe\u7247\u4ee5 ",(0,i.jsx)(n.code,{children:"input_image"})," \u5185\u5bb9\u5757\u627f\u8f7d\u3002"]}),"\n",(0,i.jsxs)(n.p,{children:["\u4ee5\u4e0b\u793a\u4f8b\u7684 ",(0,i.jsx)(n.code,{children:"base_url"})," \u4e3a ",(0,i.jsx)(n.code,{children:"https://api.deepseek.com"}),"\u3002"]}),"\n",(0,i.jsx)(n.h3,{id:"1-base64-\u7f16\u7801\u56fe\u7247\u5185\u8054",children:"1. Base64 \u7f16\u7801\u56fe\u7247\uff08\u5185\u8054\uff09"}),"\n",(0,i.jsxs)(n.p,{children:["\u5c06\u56fe\u7247\u7f16\u7801\u540e\u4ee5 ",(0,i.jsx)(n.code,{children:"data:"})," URL \u7684\u5f62\u5f0f\u76f4\u63a5\u5d4c\u5165\u8bf7\u6c42\u3002\u8fd9\u662f\u672c\u5730\u6587\u4ef6\u6700\u7b80\u5355\u7684\u65b9\u5f0f\u3002\u7f16\u7801\u540e\u7684\u6570\u636e\u4f1a\u8ba1\u5165 ",(0,i.jsx)(n.strong,{children:"48 MiB"})," \u8bf7\u6c42\u4f53\u5927\u5c0f\u9650\u5236\uff08\u89c1 ",(0,i.jsx)(n.a,{href:"#limits",children:"\u9650\u5236"}),"\uff09\u3002"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:'import base64\nfrom openai import OpenAI\n\nclient = OpenAI(api_key="<DeepSeek API Key>", base_url="https://api.deepseek.com")\n\nwith open("image.jpg", "rb") as f:\n b64 = base64.b64encode(f.read()).decode("utf-8")\n\nresponse = client.chat.completions.
1create(\n model="deepseek-flash",\n messages=[\n {\n "role": "user",\n "content": [\n {"type": "text", "text": "\u8fd9\u5f20\u56fe\u7247\u91cc\u6709\u4ec0\u4e48\uff1f"},\n {\n "type": "image_url",\n "image_url": {"url": f"data:image/jpeg;base64,{b64}"},\n },\n ],\n }\n ],\n)\nprint(response.choices[0].message.content)\n'})}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-bash",children:'curl https://api.deepseek.com/chat/completions \\\n -H "Content-Type: application/json" \\\n -H "Authorization: Bearer <DeepSeek API Key>" \\\n -d \'{\n "model": "deepseek-flash",\n "messages": [\n {\n "role": "user",\n "content": [\n {"type": "text", "text": "\u8fd9\u5f20\u56fe\u7247\u91cc\u6709\u4ec0\u4e48\uff1f"},\n {"type": "image_url", "image_url": {"url": "data:image/jpeg;base64,<BASE64_DATA>"}}\n ]\n }\n ]\n }\'\n'})}),"\n",(0,i.jsx)(n.h3,{id:"2-\u5916\u90e8\u56fe\u7247-url",children:"2. \u5916\u90e8\u56fe\u7247 URL"}),"\n",(0,i.jsxs)(n.p,{children:["\u4f20\u5165\u4e00\u4e2a\u53ef\u516c\u5f00\u8bbf\u95ee\u7684 ",(0,i.jsx)(n.code,{children:"http(s)"})," \u94fe\u63a5\uff0c\u6a21\u578b\u4f1a\u81ea\u52a8\u4e0b\u8f7d\u56fe\u7247\u3002URL \u957f\u5ea6\u6700\u591a ",(0,i.jsx)(n.strong,{children:"8192 \u4e2a\u5b57\u7b26"}),"\uff0c\u56fe\u7247\u6587\u4ef6\u6700\u5927 ",(0,i.jsx)(n.strong,{children:"32 MiB"}),"\uff0c\u4e14\u9700\u5728 ",(0,i.jsx)(n.strong,{children:"60 \u79d2"}),"\u5185\u5b8c\u6210\u4e0b\u8f7d\u3002\u5982\u679c\u94fe\u63a5\u8d85\u957f\uff0c\u8bf7\u6539\u7528 base64 data URL \u6216 Files API\u3002"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:'response = client.chat.completions.create(\n model="deepseek-flash",\n messages=[\n {\n "role": "user",\n "content": [\n {"type": "text", "text": "\u63cf\u8ff0\u4e00\u4e0b\u8fd9\u5f20\u56fe\u7247\u3002"},\n {\n "type": "image_url",\n "image_url": {"url": "https://example.com/image.jpg"},\n },\n ],\n }\n ],\n)\nprint(response.choices[0].message.content)\n'})}),"\n",(0,i.jsx)(n.h3,{id:"3-\u5f15\u7528\u901a\u8fc7-files-api-\u4e0a\u4f20\u7684\u6587\u4ef6",children:"3. \u5f15\u7528\u901a\u8fc7 Files API \u4e0a\u4f20\u7684\u6587\u4ef6"}),"\n",(0,i.jsxs)(n.p,{children:["\u901a\u8fc7 ",(0,i.jsx)(n.a,{href:"/guides/files_api",children:"Files API"})," \u4e0a\u4f20\u4e00\u6b21\u56fe\u7247\uff0c\u4e4b\u540e\u5728\u8bf7\u6c42\u4e2d\u7528\u5176 ",(0,i.jsx)(n.code,{children:"file_id"})," \u5f15\u7528\u3002\u5f53\u4f60\u9700\u8981\u5728\u591a\u4e2a\u8bf7\u6c42\u4e2d\u590d\u7528\u540c\u4e00\u5f20\u56fe\u7247\uff0c\u6216\u56fe\u7247\u4f1a\u8ba9\u8bf7\u6c42\u4f53\u8d85\u8fc7 48 MiB \u5185\u8054\u9650\u5236\u65f6\uff0c\u8fd9\u662f\u6700\u4f73\u9009\u62e9\u3002\u4e0e\u5185\u8054\u56fe\u7247\u4e0d\u540c\uff0c\u901a\u8fc7 Files API ",(0,i.jsx)(n.code,{children:"file_id"})," \u5f15\u7528\u7684\u56fe\u7247\u6700\u5927\u53ef\u8fbe 64 MiB\uff0c\u4e14\u4e0d\u53d7 32 MiB \u5355\u56fe\u68c0\u67e5\u9650\u5236\u3002"]}),"\n",(0,i.jsxs)(n.p,{children:["\u4f7f\u7528 ",(0,i.jsx)(n.code,{children:"file"})," \u5185\u5bb9\u5757\uff0c\u586b\u5165\u8fd4\u56de\u7684 ",(0,i.jsx)(n.code,{children:"file_id"}),"\uff08\u5f62\u5982 ",(0,i.jsx)(n.code,{children:"file-api-..."}),"\uff09\uff1a"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:'response = client.chat.completions.create(\n model="deepseek-flash",\n messages=[\n {\n "role": "user",\n "content": [\n {"type": "text", "text": "\u8fd9\u5f20\u56fe\u7247\u91cc\u6709\u4ec0\u4e48\uff1f"},\n {"type": "file", "file_id": "file-api-xxxxxxxxxxxxxxxx"},\n ],\n }\n ],\n)\nprint(response.choices[0].message.content)\n'})}),"\n",(0,i.jsxs)(n.p,{children:["\u6b64\u5916\uff0c",(0,i.jsx)(n.code,{children:"file"})," \u5757\u4e5f\u53ef\u4ee5\u901a\u8fc7 ",(0,i.jsx)(n.code,{children:"file_data"})," \u4ee5 base64 \u5f62\u5f0f\u5185\u8054\u643a\u5e26\u56fe\u7247\uff08",(0,i.jsx)(n.code,{children:"file_data"})," \u4e0e ",(0,i.jsx)(n.code,{children:"file_id"})," \u4e8c\u8005\u4e92\u65a5\uff09\uff1a"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-json",children:'{\n "type": "file",\n "file_data": "data:image/jpeg;base64,<BASE64_DATA>",\n "filename": "image.jpg"\n}\n'})}),"\n",(0,i.jsx)("hr",{}),"\n",(0,i.jsx)(n.h2,{id:"\u7ec6\u8282\u7ea7\u522bdetail-level",children:"\u7ec6\u8282\u7ea7\u522b\uff08Detail Level\uff09"}),"\n",(0,i.jsxs)(n.p,{children:["\u5bf9\u4e8e ",(0,i.jsx)(n.code,{children:"image_url"})," \u8f93\u5165\uff0c\u4f60\u53ef\u4ee5\u9009\u586b ",(0,i.jsx)(n.code,{children:"detail"})," \u5b57\u6bb5\u6765\u63a7\u5236\u56fe\u7247\u7684\u5904\u7406\u65b9\u5f0f\uff1a"]}),"\n",(0,i.jsxs)(n.table,{children:[(0,i.jsx)(n.thead,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.th,{children:"\u53d6\u503c"}),(0,i.jsx)(n.th,{children:"\u884c\u4e3a"})]})}),(0,i.jsxs)(n.tbody,{children:[(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:(0,i.jsx)(n.code,{children:"low"})}),(0,i.jsx)(n.td,{children:"\u63a8\u7406\u524d\u5c06\u56fe\u7247\u7f29\u653e\u5230 512\xd7512\u3002\u5f53\u4e0d\u9700\u8981\u7cbe\u7ec6\u89c6\u89c9\u7ec6\u8282\u65f6\u66f4\u5feb\u3001\u66f4\u7701 token\u3002"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:(0,i.jsx)(n.code,{children:"high"})}),(0,i.jsxs)(n.td,{children:["\u4fdd\u7559\u539f\u56fe\u3002\uff08\u4e3a\u517c\u5bb9\u6027\u63d0\u4f9b\uff0c\u7b49\u4ef7\u4e8e ",(0,i.jsx)(n.code,{children:"original"}),"\u3002\uff09"]})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:(0,i.jsx)(n.code,{children:"original"})}),(0,i.jsx)(n.td,{children:"\u4fdd\u7559\u539f\u56fe\u3002"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:(0,i.jsx)(n.code,{children:"auto"})}),(0,i.jsxs)(n.td,{children:["\u81ea\u52a8\u9009\u62e9\u3002\u5f53\u524d\u7b49\u4ef7\u4e8e ",(0,i.jsx)(n.code,{children:"original"}),"\u3002"]})]})]})]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-json",children:'{\n "type": "image_url",\n "image_url": {"url": "https://example.com/image.jpg", "detail": "low"}\n}\n'})}),"\n",(0,i.jsx)("hr",{}),"\n",(0,i.jsx)(n.h2,{id:"\u4f55\u65f6\u4f7f\u7528-files-api",children:"\u4f55\u65f6\u4f7f\u7528 Files API"}),"\n",(0,i.jsxs)(n.p,{children:["\u5185\u8054\u56fe\u7247\uff08base64 \u6216 ",(0,i.jsx)(n.code,{children:"file_data"}),"\uff09\u4f1a\u8ba1\u5165 ",(0,i.jsx)(n.strong,{children:"48 MiB"})," \u7684\u8bf7\u6c42\u4f53\u5927\u5c0f\u9650\u5236\u3002\u4ee5\u4e0b\u60c5\u51b5\u5efa\u8bae\u4f7f\u7528 ",(0,i.jsx)(n.a,{href:"/guides/files_api",children:"Files API"}),"\uff1a"]}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"\u5355\u4e2a\u8bf7\u6c42\u4f1a\u8d85\u8fc7\u8bf7\u6c42\u4f53\u5927\u5c0f\u9650\u5236\u3002"}),"\n",(0,i.jsx)(n.li,{children:"\u56fe\u7247\u8d85\u8fc7 32 MiB\uff08\u53ea\u6709\u901a\u8fc7 Files API \u624d\u80fd\u4f7f\u7528\uff09\u3002"}),"\n",(0,i.jsx)(n.li,{children:"\u4f60\u5728\u591a\u4e2a\u8bf7\u6c42\u4e2d\u5f15\u7528\u540c\u4e00\u5f20\u56fe\u7247\uff0c\u5e0c\u671b\u907f\u514d\u6bcf\u6b21\u91cd\u590d\u4e0a\u4f20\u3002"}),"\n"]}),"\n",(0,i.jsx)("hr",{}),"\n",(0,i.jsx)(n.h2,{id:"token-usage",children:"Token \u7528\u91cf"}),"\n",(0,i.jsx)(n.p,{children:"\u56fe\u7247\u4f1a\u6839\u636e\u5176\u5c3a\u5bf8\u6362\u7b97\u6210 token\uff0c\u5e76\u4e0e\u6587\u672c token \u4e00\u8d77\u8ba1\u8d39\u3002"}),"\n",(0,i.jsx)(n.p,{children:"\u5728\u8fdb\u5165\u6a21\u578b\u524d\uff0c\u6bcf\u5f20\u56fe\u7247\u90fd\u4f1a\u88ab\u81ea\u52a8\u7f29\u653e\uff1a"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"\u603b\u50cf\u7d20\u5c0f\u4e8e\u7ea6 544\xd7544 \u7684\u56fe\u7247\u4f1a\u88ab\u4fdd\u6301\u957f\u5bbd\u6bd4\u653e\u5927\uff1b"}),"\n",(0,i.jsxs)(n.li,{children:["\u66f4\u5927\u7684\u56fe\u7247\u4f1a\u88ab\u4fdd\u6301\u957f\u5bbd\u6bd4\u7f29\u5c0f\uff0c\u7f29\u5c0f\u540e\u7684\u603b\u50cf\u7d20\u7ea6\u76f8\u5f53\u4e8e ",(0,i.jsx)(n.strong,{children:"1300\xd71300"})," \u7684\u56fe\u7247\u3002"]}),"\n"]}),"\n",(0,i.jsxs)(n.p,{children:["\u56e0\u6b64\uff0c\u6bcf\u5f20\u56fe\u7247\u6d88\u8017\u7684 token \u6570\u5b58\u5728\u4e0a\u9650\uff08",(0,i.jsx)(n.strong,{children:"1024"})," \u4e2a\uff09\uff1a\u4f8b\u5982 2000\xd72000 \u548c 5000\xd75000 \u7684\u56fe\u7247\uff0c\u7ecf\u7f29\u653e\u540e\u6d88\u8017\u7684 token \u6570\u662f\u76f8\u540c\u7684\u3002\u5355\u4e2a\u8bf7\u6c42\u5305\u542b\u591a\u5f20\u56fe\u7247\u65f6\uff0c\u6bcf\u5f20\u56fe\u7247\u72ec\u7acb\u6309\u540c\u4e00\u89c4\u5219\u8ba1\u7b97\uff0c\u4e0d\u5b58\u5728\u989d\u5916\u7684\u8ba1\u7b97\u65b9\u5f0f\u3002"]}),"\n",(0,i.jsxs)(n.p,{children:["\u5982\u9700\u4f30\u7b97\u5177\u4f53\u5c3a\u5bf8\u56fe\u7247\u7684 token \u6d88\u8017\uff0c\u8bf7\u4f7f\u7528 ",(0,i.jsx)(n.a,{href:"/quick_start/token_usage",children:"Token \u4e0e\u7528\u91cf\u8ba1\u7b97"})," \u9875\u9762\u7684\u56fe\u7247 Token \u8ba1\u7b97\u5668\u3002"]}),"\n",(0,i.jsx)("hr",{}),"\n",(0,i.jsx)(n.h2,{id:"limits",children:"\u9650\u5236"}),"\n",(0,i.jsxs)(n.table,{children:[(0,i.jsx)(n.thead,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.th,{children:"\u9650\u5236\u9879"}),(0,i.jsx)(n.th,{children:"\u6570\u503c"})]})}),(0,i.jsxs)(n.tbody,{children:[(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"\u652f\u6301\u7684\u683c\u5f0f"}),(0,i.jsx)(n.td,{children:"JPEG\u3001PNG\u3001GIF\u3001WebP"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"\u5916\u90e8 URL \u957f\u5ea6"}),(0,i.jsx)(n.td,{children:"8192 \u4e2a\u5b57\u7b26"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"\u8bf7\u6c42\u4f53\u5927\u5c0f"}),(0,i.jsx)(n.td,{children:"48 MiB"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"\u5355\u5f20\u56fe\u7247\u6700\u5927\u5927\u5c0f\uff08base64 / \u5916\u90e8 URL\uff09"}),(0,i.jsx)(n.td,{children:"32 MiB"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsxs)(n.td,{children:["\u5355\u5f20\u56fe\u7247\u6700\u5927\u5927\u5c0f\uff08Files API ",(0,i.jsx)(n.code,{children:"file_id"}),"\uff09"]}),(0,i.jsx)(n.td,{children:"64 MiB"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"\u5355\u4e2a\u8bf7\u6c42\u6700\u5927\u56fe\u7247\u6570"}),(0,i.jsx)(n.td,{children:"600"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"\u5355\u4e2a\u8bf7\u6c42\u56fe\u7247\u603b\u5927\u5c0f"}),(0,i.jsxs)(n.td,{children:["\u4e0d\u542b ",(0,i.jsx)(n.code,{children:"file_id"})," \u56fe\u7247\u6700\u591a 64 MiB\uff1b\u5305\u542b ",(0,i.jsx)(n.code,{children:"file_id"})," \u56fe\u7247\u6700\u9ad8 200 MiB"]})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"\u56fe\u7247\u6700\u5927\u5c3a\u5bf8"}),(0,i.jsx)(n.td,{children:"\u5355\u8fb9\u6700\u957f 8192 \u50cf\u7d20\uff1b\u5355\u4e2a\u8bf7\u6c42\u5305\u542b 15 \u5f20\u53ca\u4ee5\u4e0a\u56fe\u7247\u65f6\uff0c\u964d\u4e3a\u5355\u8fb9\u6700\u957f 4096 \u50cf\u7d20"})]})]})]}),"\n",(0,i.jsxs)(n.p,{children:["Files API \u4e0a\u4f20\u6587\u4ef6\u7684\u5b58\u50a8\u4e0e\u4e0a\u4f20\u914d\u989d\u89c1 ",(0,i.jsx)(n.a,{href:"/guides/files_api#limits",children:"Files API\uff1a\u9650\u5236"}),"\u3002"]}),"\n",(0,i.jsx)("hr",{}),"\n",(0,i.jsx)(n.h2,{id:"\u4f7f\u7528\u9650\u5236",children:"\u4f7f\u7528\u9650\u5236"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["\u56fe\u7247\u4ec5\u652f\u6301\u51fa\u73b0\u5728 ",(0,i.jsx)(n.code,{children:"user"})," \u6d88\u606f\u4e2d\u3002",(0,i.jsx)(n.code,{children:"system"})," \u6216 ",(0,i.jsx)(n.code,{children:"assistant"})," \u6d88\u606f\u643a\u5e26\u56fe\u7247\u4f1a\u8fd4\u56de ",(0,i.jsx)(n.code,{children:"400"})," \u9519\u8bef\u3002"]}),"\n"]}),"\n",(0,i.jsx)("hr",{}),"\n",(0,i.jsx)(n.h2,{id:"\u5728-anthropic-api-\u4e2d\u4f7f\u7528\u56fe\u7247",children:"\u5728 Anthropic API \u4e2d\u4f7f\u7528\u56fe\u7247"}),"\n",(0,i.jsxs)(n.p,{children:["\u9664\u4e86\u4e0a\u9762\u7684 OpenAI \u517c\u5bb9\u7aef\u70b9\uff0c\u4f60\u4e5f\u53ef\u4ee5\u901a\u8fc7 Anthropic \u517c\u5bb9\u7684 ",(0,i.jsx)(n.code,{children:"/messages"})," \u7aef\u70b9\u53d1\u9001\u56fe\u7247\uff08",(0,i.jsx)(n.code,{children:"base_url"})," \u4e3a ",(0,i.jsx)(n.code,{children:"https://api.deepseek.com/anthropic"}),"\uff09\u3002\u57fa\u7840\u914d\u7f6e\u8bf7\u53c2\u8003 ",(0,i.jsx)(n.a,{href:"/guides/anthropic_api",children:"Anthropic API"}),"\u3002"]}),"\n",(0,i.jsxs)(n.p,{children:["\u533a\u522b\u5728\u4e8e\u56fe\u7247\u5185\u5bb9\u5757\u7684\u7ed3\u6784\u3002Anthropic \u4e0d\u4f7f\u7528 ",(0,i.jsx)(n.code,{children:"image_url"}),"\uff0c\u800c\u662f\u4f7f\u7528 ",(0,i.jsx)(n.code,{children:"image"})," \u5757\uff0c\u5176 ",(0,i.jsx)(n.code,{children:"source"})," \u5bf9\u8c61\u7684 ",(0,i.jsx)(n.code,{children:"type"})," \u4e3a ",(0,i.jsx)(n.code,{children:"base64"}),"\u3001",(0,i.jsx)(n.code,{children:"url"})," \u6216 ",(0,i.jsx)(n.code,{children:"file"})," \u4e4b\u4e00\uff1a"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:'import anthropic\n\nclient = anthropic.Anthropic() # ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic\n\nmessage = client.messages.create(\n model="deepseek-flash",\n max_tokens=1024,\n messages=[\n {\n "role": "user",\n "content": [\n {"type": "text", "text": "\u8fd9\u5f20\u56fe\u7247\u91cc\u6709\u4ec0\u4e48\uff1f"},\n {\n "type": "image",\n "source": {\n "type": "base64",\n "media_type": "image/jpeg",\n "data": "<BASE64_DATA>",\n },\n },\n ],\n }\n ],\n)\nprint(message.content)\n'})}),"\n",(0,i.jsxs)(n.p,{children:["\u4e09\u79cd ",(0,i.jsx)(n.code,{children:"source"})," \u53d8\u4f53\u4e0e\u4e0a\u9762\u7684 OpenAI \u65b9\u5f0f\u4e00\u4e00\u5bf9\u5e94\uff1a"]}),"\n",(0,i.jsxs)(n.table,{children:[(0,i.jsx)(n.thead,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.th,{children:(0,i.jsx)(n.code,{children:"source.type"})}),(0,i.jsx)(n.th,{children:"\u5bf9\u5e94\u7684 OpenAI \u65b9\u5f0f"}),(0,i.jsx)(n.th,{children:"\u8bf4\u660e"})]})}),(0,i.jsxs)(n.tbody,{children:[(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:(0,i.jsx)(n.code,{children:"base64"})}),(0,i.jsx)(n.td,{children:"Base64 \u7f16\u7801\u56fe\u7247"}),(0,i.jsxs)(n.td,{children:["\u9700\u8981 ",(0,i.jsx)(n.code,{children:"media_type"})," \u5b57\u6bb5\uff08",(0,i.jsx)(n.code,{children:"image/jpeg"}),"\u3001",(0,i.jsx)(n.code,{children:"image/png"}),"\u3001",(0,i.jsx)(n.code,{children:"image/gif"})," \u6216 ",(0,i.jsx)(n.code,{children:"image/webp"}),"\uff09\u3002"]})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:(0,i.jsx)(n.code,{children:"url"})}),(0,i.jsx)(n.td,{children:"\u5916\u90e8\u56fe\u7247 URL"}),(0,i.jsx)(n.td,{children:"\u6700\u591a 8192 \u4e2a\u5b57\u7b26\u3002"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:(0,i.jsx)(n.code,{children:"file"})}),(0,i.jsxs)(n.td,{children:["Files API ",(0,i.jsx)(n.code,{children:"file_id"})]}),(0,i.jsxs)(n.td,{children:["\u9700\u8981\u8bf7\u6c42\u5934 ",(0,i.jsx)(n.code,{children:"anthropic-beta: files-api-2025-04-14"}),"\u3002"]})]})]})]}),"\n",(0,i.jsx)("hr",{}),"\n",(0,i.jsx)(n.h2,{id:"responses-api",children:"\u5728 Responses API \u4e2d\u4f7f\u7528\u56fe\u7247"}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.code,{children:"deepseek-flash"})," \u6a21\u578b\u540c\u6837\u652f\u6301\u901a\u8fc7 OpenAI \u517c\u5bb9\u7684 ",(0,i.jsx)(n.a,{href:"/guides/responses_api#image-input",children:"Responses API"})," \u4f20\u5165\u56fe\u7247\u3002\u4e09\u79cd\u4f20\u5165\u65b9\u5f0f\uff08base64 data URL\u3001\u5916\u90e8 ",(0,i.jsx)(n.code,{children:"http(s)"})," URL\u3001Files API ",(0,i.jsx)(n.code,{children:"file_id"}),"\uff09\u4e0e",(0,i.jsx)(n.a,{href:"#limits",children:"\u9650\u5236"}),"\u5747\u4e0e\u4e0a\u6587\u4e00\u81f4\uff0c\u53ea\u6709\u5185\u5bb9\u5757\u7684\u7ed3\u6784\u4e0d\u540c\u2014\u2014\u56fe\u7247\u4ee5 ",(0,i.jsx)(n.code,{children:"input_image"})," \u5185\u5bb9\u5757\u627f\u8f7d\uff0c\u53ef\u51fa\u73b0\u5728 ",(0,i.jsx)(n.code,{children:"user"})," / ",(0,i.jsx)(n.code,{children:"developer"})," \u6d88\u606f\u6216 ",(0,i.jsx)(n.co
1de,{children:"function_call_output"})," / ",(0,i.jsx)(n.code,{children:"custom_tool_call_output"})," item \u7684 ",(0,i.jsx)(n.code,{children:"output"})," \u4e2d\uff1a"]}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:'response = client.responses.create(\n model="deepseek-flash",\n input=[\n {\n "role": "user",\n "content": [\n {"type": "input_text", "text": "\u8fd9\u5f20\u56fe\u7247\u91cc\u6709\u4ec0\u4e48\uff1f"},\n {"type": "input_image", "image_url": "https://example.com/image.jpg", "detail": "low"},\n ],\n }\n ],\n)\nprint(response.output_text)\n'})}),"\n",(0,i.jsxs)(n.p,{children:[(0,i.jsx)(n.code,{children:"input_image"})," \u5185\u5bb9\u5757\u652f\u6301 ",(0,i.jsx)(n.code,{children:"detail"})," \u5b57\u6bb5\uff0c\u8bed\u4e49\u4e0e\u4e0a\u6587\u4e00\u81f4\uff08",(0,i.jsx)(n.code,{children:"low"})," / ",(0,i.jsx)(n.code,{children:"high"})," / ",(0,i.jsx)(n.code,{children:"original"})," / ",(0,i.jsx)(n.code,{children:"auto"}),"\uff09\u3002\u901a\u8fc7 ",(0,i.jsx)(n.code,{children:"file_id"})," \u4f20\u56fe\u65f6 ",(0,i.jsx)(n.code,{children:"detail"})," \u88ab\u5ffd\u7565\uff1b",(0,i.jsx)(n.code,{children:"image_url"})," \u4e0e ",(0,i.jsx)(n.code,{children:"file_id"})," \u4e92\u65a5\u3002"]}),"\n",(0,i.jsxs)(n.p,{children:["\u5b57\u6bb5\u8bed\u4e49\u3001\u4f7f\u7528\u9650\u5236\uff08",(0,i.jsx)(n.code,{children:"system"})," / ",(0,i.jsx)(n.code,{children:"assistant"})," \u6d88\u606f\u4e2d\u7684\u56fe\u7247\u4f1a\u8fd4\u56de ",(0,i.jsx)(n.code,{children:"400"})," \u9519\u8bef\uff09\u4ee5\u53ca\u5de5\u5177\u8f93\u51fa\u4e2d\u7684\u56fe\u7247\uff0c\u8bf7\u53c2\u9605 ",(0,i.jsx)(n.a,{href:"/guides/responses_api#image-input",children:"Responses API \u6307\u5357"}),"\u3002"]})]})}function a(e={}){const{wrapper:n}={...(0,d.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(o,{...e})}):o(e)}},41759:(e,n,s)=>{s.d(n,{R:()=>c,x:()=>r});var i=s(26166);const d={},l=i.createContext(d);function c(e){const n=i.useContext(l);return i.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function r(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(d):e.components||d:c(e.components),i.createElement(l.Provider,{value:n},e.children)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.