Python में DeepSeek के साथ काम करना
James Chapman
AI Curriculum Lead, DataCamp
response = client.chat.completions.create(
model="deepseek-ai/DeepSeek-V4.1-Flash",
messages=[{"role": "user", "content": "How many days are in October?"}]
)
print(response.choices[0].message.content)
October में **31 दिन** होते हैं.
यह Gregorian कैलेंडर के सात महीनों में से एक है जिनमें 31 दिन होते हैं...
$$
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.1-Flash",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.1-Flash", messages=[{"role": "user", "content": prompt}] ) print(response.choices[0].message.content)
1. **लॉगिन समस्या**: पासवर्ड इश्यू और रिसेट लिंक न मिलने से कस्टमर लॉगिन नहीं कर पाया.
2. **पासवर्ड रीसेट सुझाव**: पुष्टि के बाद सपोर्ट ने रीसेट ईमेल दोबारा भेजा.
3. **त्वरित सहायता**: कस्टमर ने Google sign-in से समस्या सुलझाई.
max_tokens = 5response = client.chat.completions.create(
model="deepseek-ai/DeepSeek-V4.1-Flash",
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.1-Flash",
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 उपयोग लागत platform, model, और tokens की संख्या पर निर्भर करती है 💰
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.1-Flash",
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 के साथ काम करना