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 में **31 days** होते हैं.
यह Gregorian कैलेंडर के सात महीनों में से एक है जिनमें 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. **लॉगिन समस्या**: पासवर्ड इश्यू और reset लिंक न मिलने से ग्राहक लॉगिन नहीं कर सका.
2. **पासवर्ड रीसेट सुझाव**: पुष्टि के बाद सपोर्ट ने रीसेट ईमेल फिर से भेजा.
3. **त्वरित सहायता**: ग्राहक ने Google sign-in से समस्या हल की.
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
)
**मौन सर्किट्स गुनगुन
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
)
**मौन सर्किट्स गुनगुनाएँ,**
**रोशनी-तर्क के फूल खिलें—**
**हमसे परे मन.**
$$
$$

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-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 के साथ काम करना