PageSourceSearch

https://api-docs.deepseek.com/zh-cn/assets/js/d981f43f.f6db1c77.js

js deepseek.com collected 2026-09-24 07:10:19 UTC 14,560 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_deepseek_docs=self.webpackChunk_deepseek_docs||[]).push([[9806,9109,2567,9310],{80908:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>i,contentTitle:()=>o,default:()=>d,frontMatter:()=>a,metadata:()=>l,toc:()=>c});var s=t(80678),r=t(41759);const a={},o=void 0,l={id:"api_samples/chat_curl",title:"chat_curl",description:"",source:"@site/docs/api_samples/chat_curl.md",sourceDirName:"api_samples",slug:"/api_samples/chat_curl",permalink:"/api_samples/chat_curl",draft:!1,unlisted:!1,tags:[],version:"current",frontMatter:{}},i={},c=[];function u(e){const n={code:"code",pre:"pre",...(0,r.R)(),...e.components};return(0,s.jsx)(n.pre,{children:(0,s.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          {"role": "system", "content": "You are a helpful assistant."},\n          {"role": "user", "content": "Hello!"}\n        ],\n        "thinking": {"type": "enabled"},\n        "reasoning_effort": "high",\n        "stream": false\n      }\'\n'})})}function d(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(u,{...e})}):u(e)}},93321:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>i,contentTitle:()=>o,default:()=>d,frontMatter:()=>a,metadata:()=>l,toc:()=>c});var s=t(80678),r=t(41759);const a={},o=void 0,l={id:"api_samples/chat_nodejs",title:"chat_nodejs",description:"",source:"@site/docs/api_samples/chat_nodejs.md",sourceDirName:"api_samples",slug:"/api_samples/chat_nodejs",permalink:"/api_samples/chat_nodejs",draft:!1,unlisted:!1,tags:[],version:"current",frontMatter:{}},i={},c=[];function u(e){const n={code:"code",pre:"pre",...(0,r.R)(),...e.components};return(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-javascript",children:'// Please install OpenAI SDK first: `npm install openai`\n\nimport OpenAI from "openai";\n\nconst openai = new OpenAI({\n        baseURL: \'https://api.deepseek.com\',\n        apiKey: process.env.DEEPSEEK_API_KEY,\n});\n\nasync function main() {\n  const completion = await openai.chat.completions.create({\n    messages: [{ role: "system", content: "You are a helpful assistant." }],\n    model: "deepseek-flash",\n    thinking: {"type": "enabled"},\n    reasoning_effort: "high",\n    stream: false,\n  });\n\n  console.log(completion.choices[0].message.content);\n}\n\nmain();\n'})})}function d(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(u,{...e})}):u(e)}},36408:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>i,contentTitle:()=>o,default:()=>d,frontMatter:()=>a,metadata:()=>l,toc:()=>c});var s=t(80678),r=t(41759);const a={},o=void 0,l={id:"api_samples/chat_python",title:"chat_python",description:"",source:"@site/docs/api_samples/chat_python.md",sourceDirName:"api_samples",slug:"/api_samples/chat_python",permalink:"/api_samples/chat_python",draft:!1,unlisted:!1,tags:[],version:"current",frontMatter:{}},i={},c=[];function u(e){const n={code:"code",pre:"pre",...(0,r.R)(),...e.components};return(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-python",children:'# Please install OpenAI SDK first: `pip3 install openai`\nimport os\nfrom openai import OpenAI\n\nclient = OpenAI(\n    api_key=os.environ.get(\'DEEPSEEK_API_KEY\'),\n    base_url="https://api.deepseek.com")\n\nresponse = client.chat.completions.create(\n    model="deepseek-flash",\n    messages=[\n        {"role": "system", "content": "You are a helpful assistant"},\n        {"role": "user", "content": "Hello"},\n    ],\n    stream=False,\n    reasoning_effort="high",\n    extra_body={"thinking": {"type": "enabled"}}\n)\n\nprint(response.choices[0].message.content)\n'})})}function d(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(u,{...e})}):u(e)}},48559:(e,n,t)=>{t.r(n),t.d(n,{APISampleSwitch:()=>f,assets:()=>h,contentTitle:()=>d,default:()=>b,frontMatter:()=>u,metadata:()=>p,toc:()=>m});var s=t(80678),r=t(41759),a=t(5119),o=t(18045),l=t(80908),i=t(36408),c=t(93321);const u={slug:"/"},d="\u9996\u6b21\u8c03\u7528 API",p={id:"your_first_api_call",title:"\u9996\u6b21\u8c03\u7528 API",description:"DeepSeek API \u4f7f\u7528\u4e0e OpenAI/Anthropic \u517c\u5bb9\u7684 API \u683c\u5f0f\uff0c\u901a\u8fc7\u4fee\u6539\u914d\u7f6e\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 OpenAI/Anthropic SDK \u6765\u8bbf\u95ee DeepSeek API\uff0c\u6216\u4f7f\u7528\u4e0e OpenAI/Anthropic API \u517c\u5bb9\u7684\u8f6f\u4ef6\u3002",source:"@site/i18n/zh-cn/docusaurus-plugin-content-docs/current/your_first_api_call.mdx",sourceDirName:".",slug:"/",permalink:"/zh-cn/",draft:!1,unlisted:!1,tags:[],version:"current",frontMatter:{
1slug:"/"},sidebar:"tutorialSidebar",next:{title:"\u6a21\u578b & \u4ef7\u683c",permalink:"/zh-cn/quick_start/pricing"}},h={},m=[{value:"\u63a5\u5165 Agent \u5de5\u5177",id:"\u63a5\u5165-agent-\u5de5\u5177",level:2},{value:"\u8c03\u7528\u5bf9\u8bdd API",id:"\u8c03\u7528\u5bf9\u8bdd-api",level:2}];function f(){return(0,s.jsxs)(a.A,{children:[(0,s.jsx)(o.default,{value:"curl",label:"curl",default:!0,children:(0,s.jsx)(l.default,{})}),(0,s.jsx)(o.default,{value:"python",label:"python",children:(0,s.jsx)(i.default,{})}),(0,s.jsx)(o.default,{value:"nodejs",label:"nodejs",children:(0,s.jsx)(c.default,{})})]})}function x(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",p:"p",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,r.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.h1,{id:"\u9996\u6b21\u8c03\u7528-api",children:"\u9996\u6b21\u8c03\u7528 API"}),"\n",(0,s.jsx)(n.p,{children:"DeepSeek API \u4f7f\u7528\u4e0e OpenAI/Anthropic \u517c\u5bb9\u7684 API \u683c\u5f0f\uff0c\u901a\u8fc7\u4fee\u6539\u914d\u7f6e\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 OpenAI/Anthropic SDK \u6765\u8bbf\u95ee DeepSeek API\uff0c\u6216\u4f7f\u7528\u4e0e OpenAI/Anthropic API \u517c\u5bb9\u7684\u8f6f\u4ef6\u3002"}),"\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"PARAM"}),(0,s.jsx)(n.th,{children:"VALUE"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"base_url (OpenAI)"}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"https://api.deepseek.com"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"base_url (Anthropic)"}),(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"https://api.deepseek.com/anthropic"})})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"api_key"}),(0,s.jsxs)(n.td,{children:["\u7533\u8bf7\u4e00\u4e2a ",(0,s.jsx)(n.a,{href:"https://platform.deepseek.com/api_keys",children:"API key"})]})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:"model"}),(0,s.jsxs)(n.td,{children:[(0,s.jsx)(n.code,{children:"deepseek-flash"}),(0,s.jsx)("sup",{children:"(1)"}),(0,s.jsx)("br",{}),(0,s.jsx)(n.code,{children:"deepseek-v4-pro"})]})]})]})]}),"\n",(0,s.jsx)("div",{style:{fontSize:"14px"},children:(0,s.jsxs)(n.p,{children:["(1) \u6a21\u578b\u540d\u8bf7\u4f7f\u7528 ",(0,s.jsx)(n.code,{children:"deepseek-flash"}),"\u3002\u65e7\u6a21\u578b\u540d ",(0,s.jsx)(n.code,{children:"deepseek-v4-flash"}),"\u3001",(0,s.jsx)(n.code,{children:"deepseek-v4-flash-vision-exp"})," \u4ecd\u53ef\u8c03\u7528\uff0c\u4f46\u5bf9\u5e94\u6a21\u578b\u5df2\u4e0b\u7ebf\uff0c\u8bf7\u6c42\u5c06\u7531 DeepSeek-V4.1-Flash \u6a21\u578b\u63d0\u4f9b\u670d\u52a1\uff0c\u5e76\u6309 Flas
1h \u4ef7\u683c\u8ba1\u8d39\u3002"]})}),"\n",(0,s.jsx)(n.h2,{id:"\u63a5\u5165-agent-\u5de5\u5177",children:"\u63a5\u5165 Agent \u5de5\u5177"}),"\n",(0,s.jsxs)(n.p,{children:["DeepSeek Harness \u5f00\u53d1\u8005\u9884\u89c8\u7248\u9762\u5411\u5168\u7403 Harness \u5f00\u53d1\u8005\u5f00\u653e\u6d4b\u8bd5\u3002\u8be6\u89c1 ",(0,s.jsx)(n.a,{href:"https://deepseek-harness.github.io/deepseek-harness/guide/quickstart",children:"DeepSeek Harness \u5165\u95e8"}),"\u3002"]}),"\n",(0,s.jsx)(n.p,{children:"DeepSeek API \u5df2\u63a5\u5165\u591a\u79cd\u4e3b\u6d41 AI Agent \u4e0e\u7f16\u7a0b\u52a9\u624b\u5de5\u5177\u3002\u5982\u679c\u4f60\u4f7f\u7528 Claude Code\u3001GitHub Copilot\u3001OpenCode \u7b49\u5de5\u5177\uff0c\u53ef\u4ee5\u76f4\u63a5\u5c06 DeepSeek \u4f5c\u4e3a\u540e\u7aef\u6a21\u578b\uff0c\u65e0\u9700\u7f16\u5199\u4ee3\u7801\u5373\u53ef\u5f00\u59cb\u4f7f\u7528\u3002"}),"\n",(0,s.jsxs)(n.p,{children:["\u8be6\u89c1 ",(0,s.jsx)(n.a,{href:"quick_start/agent_integrations/claude_code",children:"Agent \u5de5\u5177\u63a5\u5165\u6307\u5357"}),"\u3002"]}),"\n",(0,s.jsx)(n.h2,{id:"\u8c03\u7528\u5bf9\u8bdd-api",children:"\u8c03\u7528\u5bf9\u8bdd API"}),"\n",(0,s.jsx)(n.p,{children:"\u5728\u521b\u5efa API key \u4e4b\u540e\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u6837\u4f8b\u811a\u672c\uff0c\u901a\u8fc7 OpenAI API \u683c\u5f0f\u6765\u8bbf\u95ee DeepSeek \u6a21\u578b\u3002\u6837\u4f8b\u4e3a\u975e\u6d41\u5f0f\u8f93\u51fa\uff0c\u60a8\u53ef\u4ee5\u5c06 stream \u8bbe\u7f6e\u4e3a true \u6765\u4f7f\u7528\u6d41\u5f0f\u8f93\u51fa\u3002"}),"\n",(0,s.jsxs)(n.p,{children:["Anthropic API \u683c\u5f0f\u7684\u8bbf\u95ee\u6837\u4f8b\uff0c\u8bf7\u53c2\u8003",(0,s.jsx)(n.a,{href:"guides/anthropic_api",children:"Anthropic API"}),"\u3002"]}),"\n","\n",(0,s.jsx)(f,{}),"\n",(0,s.jsx)("seealso",{})]})}function b(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(x,{...e})}):x(e)}},18045:(e,n,t)=>{t.r(n),t.d(n,{default:()=>o});t(26166);var s=t(20027);const r={tabItem:"tabItem_a2xS"};var a=t(80678);function o({children:e,hidden:n,className:t}){return(0,a.jsx)("div",{role:"tabpanel",className:(0,s.A)(r.tabItem,t),hidden:n,children:e})}},5119:(e,n,t)=>{t.d(n,{A:()=>h});var s=t(26166),r=t(20027),a=t(92287),o=t(57564),l=t(87170);const i={tabList:"tabList_MtDO",tabItem:"tabItem_P5_n"};var c=t(80678);function u({className:e,block:n,selectedValue:t,selectValue:s,tabValues:o}){const l=[],{blockElementScrollPositionUntilNextRender:u}=(0,a.a_)(),d=e=>{const n=e.currentTarget,r=l.indexOf(n),a=o[r].value;a!==t&&(u(n),s(a))},p=e=>{let n=null;switch(e.key){case"Enter":d(e);break;case"ArrowRight":{const t=l.indexOf(e.currentTarget)+1;n=l[t]??l[0];break}case"ArrowLeft":{const t=l.indexOf(e.currentTarget)-1;n=l[t]??l[l.length-1];break}}n?.focus()};return(0,c.jsx)("ul",{role:"tablist","aria-orientation":"horizontal",className:(0,r.A)("tabs",{"tabs--block":n},e),children:o.map(({value:e,label:n,attributes:s})=>(0,c.jsx)("li",{role:"tab",tabIndex:t===e?0:-1,"aria-selected":t===e,ref:e=>l.push(e),onKeyDown:p,onClick:d,...s,className:(0,r.A)("tabs__item",i.tabItem,s?.className,{"tabs__item--active":t===e}),children:n??e},e))})}function d({lazy:e,children:n,selectedValue:t}){const r=(Array.isArray(n)?n:[n]).filter(Boolean);if(e){const e=r.find(e=>e.props.value===t);return e?(0,s.cloneElement)(e,{className:"margin-top--md"}):null}return(0,c.jsx)("div",{className:"margin-top--md",children:r.map((e,n)=>(0,s.cloneElement)(e,{key:n,hidden:e.props.value!==t}))})}function p(e){const n=(0,o.u)(e);return(0,c.jsxs)("div",{className:(0,r.A)("tabs-container",i.tabList),children:[(0,c.jsx)(u,{...e,...n}),(0,c.jsx)(d,{...e,...n})]})}function h(e){const n=(0,l.default)();return(0,c.jsx)(p,{...e,children:(0,o.v)(e.children)},String(n))}},57564:(e,n,t)=>{t.d(n,{u:()=>h,v:()=>c});var s=t(26166),r=t(35261),a=t(43178),o=t(84160),l=t(72337),i=t(92867);function c(e){return s.Children.toArray(e).filter(e=>"\n"!==e).map(e=>{if(!e||(0,s.isValidElement)(e)&&function(e){const{props:n}=e;return!!n&&"object"==typeof n&&"value"in n}(e))return e;throw new Error(`Docusaurus error: Bad <Tabs>
1 child <${"string"==typeof e.type?e.type:e.type.name}>: all children of the <Tabs> component should be <TabItem>, and every <TabItem> should have a unique "value" prop.`)})?.filter(Boolean)??[]}function u(e){const{values:n,children:t}=e;return(0,s.useMemo)(()=>{const e=n??function(e){return c(e).map(({props:{value:e,label:n,attributes:t,default:s}})=>({value:e,label:n,attributes:t,default:s}))}(t);return function(e){const n=(0,l.X)(e,(e,n)=>e.value===n.value);if(n.length>0)throw new Error(`Docusaurus error: Duplicate values "${n.map(e=>e.value).join(", ")}" found in <Tabs>. Every value needs to be unique.`)}(e),e},[n,t])}function d({value:e,tabValues:n}){return n.some(n=>n.value===e)}function p({queryString:e=!1,groupId:n}){const t=(0,r.W6)(),a=function({queryString:e=!1,groupId:n}){if("string"==typeof e)return e;if(!1===e)return null;if(!0===e&&!n)throw new Error('Docusaurus error: The <Tabs> component groupId prop is required if queryString=true, because this value is used as the search param name. You can also provide an explicit value such as queryString="my-search-param".');return n??null}({queryString:e,groupId:n});return[(0,o.aZ)(a),(0,s.useCallback)(e=>{if(!a)return;const n=new URLSearchParams(t.location.search);n.set(a,e),t.replace({...t.location,search:n.toString()})},[a,t])]}function h(e){const{defaultValue:n,queryString:t=!1,groupId:r}=e,o=u(e),[l,c]=(0,s.useState)(()=>function({defaultValue:e,tabValues:n}){if(0===n.length)throw new Error("Docusaurus error: the <Tabs> component requires at least one <TabItem> children component");if(e){if(!d({value:e,tabValues:n}))throw new Error(`Docusaurus error: The <Tabs> has a defaultValue "${e}" but none of its children has the corresponding value. Available values are: ${n.map(e=>e.value).join(", ")}. If you intend to show no default tab, use defaultValue={null} instead.`);return e}const t=n.find(e=>e.default)??n[0];if(!t)throw new Error("Unexpected error: 0 tabValues");return t.value}({defaultValue:n,tabValues:o})),[h,m]=p({queryString:t,groupId:r}),[f,x]=function({groupId:e}){const n=function(e){return e?`docusaurus.tab.${e}`:null}(e),[t,r]=(0,i.Dv)(n);return[t,(0,s.useCallback)(e=>{n&&r.set(e)},[n,r])]}({groupId:r}),b=(()=>{const e=h??f;return d({value:e,tabValues:o})?e:null})();(0,a.A)(()=>{b&&c(b)},[b]);return{selectedValue:l,selectValue:(0,s.useCallback)(e=>{if(!d({value:e,tabValues:o}))throw new Error(`Can't select invalid tab value=${e}`);c(e),m(e),x(e)},[m,x,o]),tabValues:o}}},41759:(e,n,t)=>{t.d(n,{R:()=>o,x:()=>l});var s=t(26166);const r={},a=s.createContext(r);function o(e){const n=s.useContext(a);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function l(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:o(e.components),s.createElement(a.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.