DeepSeek API
🇰🇷 Korea
  • 🇺🇸 English
  • 🇯🇵 Japanese
  • 🇰🇷 Korea
  • 🇵🇹 Portuguese
  1. API 가이드
DeepSeek API
🇰🇷 Korea
  • 🇺🇸 English
  • 🇯🇵 Japanese
  • 🇰🇷 Korea
  • 🇵🇹 Portuguese
  • 빨리 시작하십시오
    • 첫 번째 API 호출
    • 모델 및 가격
    • 온도 매개 변수
    • 토큰 및 토큰 사용
    • 한계
    • 오류 코드
  • API 참조
    • 소개
    • 채팅 완료를 만듭니다
      POST
    • FIM 완료 생성 (Beta)
      POST
    • 모델을 나열합니다
      GET
    • 사용자 균형을 얻으십시오
      GET
  • API 가이드
    • 추론 모델 (Deepseek Reautoner)
    • 여러 라운드의 대화
    • 채팅 접두사 완료 (Beta)
    • FIM 완료 (Beta)
    • JSON 출력
    • 기능 호출
    • 컨텍스트 캐싱
  • FAQ
    • FAQ
  1. API 가이드

추론 모델 (Deepseek Reautoner)

deepseek-reasoner DeepSeek가 개발 한 추론 모델입니다. 최종 답변을 전달하기 전에 모델은 먼저 응답의 정확성을 향상시키기 위해 사고 체인 (COT)을 생성합니다. 당사의 API는 사용자에게 deepseek-reasoner 가 생성 한 COT 컨텐츠에 액세스 할 수 있도록하여이를보고, 표시 및 증류 할 수 있습니다.
deepseek-reasoner 사용하는 경우 OpenAI SDK를 먼저 업그레이드하여 새로운 매개 변수를 지원하십시오.
pip3 install -U openai

API 매개 변수#

입력 :
max_tokens : COT 출력이 완료된 후 최종 응답의 최대 길이는 최대 8K로 4K로 불이행됩니다. COT 출력은 최대 32k 토큰에 도달 할 수 있으며 COT 길이 ( reasoning_effort )를 제어하기위한 매개 변수를 곧 사용할 수 있습니다.
출력 :
reasoning_content : 출력 구조의 content 과 동일한 수준 인 침대의 내용. 자세한 내용은 API 예제를 참조하십시오
최종 답변의 내용을 content
컨텍스트 길이 : API는 최대 컨텍스트 길이 64K를 지원하며 출력 reasoning_content 의 길이는 64K 컨텍스트 길이 내에서 계산되지 않습니다.
지원되는 기능 : 채팅 완료 、 채팅 접두사 완료 (베타)
지원되는 기능 : 기능 호출 、 JSON 출력 、 fim (베타)
지원되는 매개 변수 : temperature 、 top_p 、 presence_penalty 、 frequency_penalty 、 logprobs 、 top_logprobs . 기존 소프트웨어와의 호환성을 보장하려면 temperature 설정 、 top_p 、 presence_penalty 、 frequency_penalty 오류를 유발하지 않지만 영향을 미치지 않습니다. logprobs 설정 s top_logprobs 오류가 트리거됩니다.

여러 라운드 대화#

대화의 각 라운드에서 모델은 COT ( reasoning_content ) 및 최종 답변 ( content )을 출력합니다. 대화의 다음 라운드에서, 이전 라운드의 침대는 다음 다이어그램과 같이 컨텍스트에 연결되지 않습니다.
img
추론 reasoning_content 필드가 입력 메시지 순서에 포함 된 경우 API는 400 오류를 반환합니다. 따라서 API 예제 에서 설명 된대로 API 요청을하기 전에 API 응답에서 reasoning_content 필드를 제거해야합니다.

API 예제#

Python을 예제로 사용하는 다음 코드는 COT에 액세스하는 방법과 최종 답변에 대한 다중 대화를 수행하는 방법을 보여줍니다.

코스트림#

from openai import OpenAI
client = OpenAI(api_key="<DeepSeek API Key>", base_url="https://api.deepseek.com")

# Round 1
messages = [{"role": "user", "content": "9.11 and 9.8, which is greater?"}]
response = client.chat.completions.create(
    model="deepseek-reasoner",
    messages=messages
)

reasoning_content = response.choices[0].message.reasoning_content
content = response.choices[0].message.content

# Round 2
messages.append({'role': 'assistant', 'content': content})
messages.append({'role': 'user', 'content': "How many Rs are there in the word 'strawberry'?"})
response = client.chat.completions.create(
    model="deepseek-reasoner",
    messages=messages
)
# ...

스트리밍#

from openai import OpenAI
client = OpenAI(api_key="<DeepSeek API Key>", base_url="https://api.deepseek.com")

# Round 1
messages = [{"role": "user", "content": "9.11 and 9.8, which is greater?"}]
response = client.chat.completions.create(
    model="deepseek-reasoner",
    messages=messages,
    stream=True
)

reasoning_content = ""
content = ""

for chunk in response:
    if chunk.choices[0].delta.reasoning_content:
        reasoning_content += chunk.choices[0].delta.reasoning_content
    else:
        content += chunk.choices[0].delta.content

# Round 2
messages.append({"role": "assistant", "content": content})
messages.append({'role': 'user', 'content': "How many Rs are there in the word 'strawberry'?"})
response = client.chat.completions.create(
    model="deepseek-reasoner",
    messages=messages,
    stream=True
)
# ...
Previous
사용자 균형을 얻으십시오
Next
여러 라운드의 대화
Built with