Python으로 DeepSeek 활용하기
James Chapman
AI Curriculum Lead, DataCamp
response = client.chat.completions.create(
model="deepseek-ai/DeepSeek-V4-Pro",
messages=[{"role": "user", "content": "How many days are in October?"}]
)
print(response.choices[0].message.content)
October has **31 days**.
It's one of the seven months in the Gregorian calendar with 31 days...
$$
prompt = """
Update name to Maarten, pronouns to he/him, and job title to Senior Content Developer
in the following text:
Joanne is a Content Developer at DataCamp. Her favorite programming language is R,
which she uses for her statistical analyses.
"""
response = client.chat.completions.create( model="deepseek-ai/DeepSeek-V4-Pro",messages=[{"role": "user", "content": prompt}]) print(response.choices[0].message.content)
다음은 요청하신 변경 사항이 적용된 텍스트입니다:
Maarten is a Senior Content Developer at DataCamp. His favorite programming language
is R, which he uses for his statistical analyses.
추가 수정이 필요하시면 알려주세요!

text = """
Customer: Hi, I'm trying to log into
my account, but it keeps saying
my password is incorrect. I'm sure
I'm entering the right one.
Support: I'm sorry to hear that!
Have you tried resetting your password?
...
"""
prompt = f"""Summarize the customer support chat in three concise key points: {text}"""response = client.chat.completions.create( model="deepseek-ai/DeepSeek-V4-Pro", messages=[{"role": "user", "content": prompt}] ) print(response.choices[0].message.content)
1. **로그인 문제**: 비밀번호 오류 및 재설정 링크 미수신으로 고객이 로그인하지 못함.
2. **비밀번호 재설정 제안**: 상담원이 이메일 발송 여부를 확인 후 재설정 이메일을 재전송함.
3. **문제 해결**: 고객이 Google 로그인을 통해 문제를 해결함.
max_tokens = 5response = client.chat.completions.create(
model="deepseek-ai/DeepSeek-V4-Pro",
messages=[{"role":"user",
"content":"Write a haiku about AI."}],
max_tokens=5
)
**Silent circuits hum
max_tokens = 30response = client.chat.completions.create(
model="deepseek-ai/DeepSeek-V4-Pro",
messages=[{"role":"user",
"content":"Write a haiku about AI."}],
max_tokens=30
)
**Silent circuits hum,**
**thoughts of light and logic bloom—**
**minds beyond our own.**
$$
$$

API 사용 비용은 플랫폼, 모델, 토큰 수에 따라 결정됨 💰
max_tokens 증가 시 비용 증가 📈

prompt = f"""Summarize the customer support chat
in three concise key points: {text}"""
max_tokens = 500
response = client.chat.completions.create(
model="deepseek-ai/DeepSeek-V4-Pro",
messages=[{"role": "user", "content": prompt}],
max_tokens=max_tokens
)
# Define price per token input_token_price = 2.1 / 1_000_000 output_token_price = 4.4 / 1_000_000# Extract token usage input_tokens = response.usage.prompt_tokensoutput_tokens = max_tokens# Calculate cost cost = (input_tokens * input_token_price + output_tokens * output_token_price) print(f"Estimated cost: ${cost}")
Estimated cost: $0.0153964
Python으로 DeepSeek 활용하기