始める無料で始める

Specifying a DeepSeek model

OpenAI offers multiple models for different use cases. In this exercise, you'll specify the model and define the role to structure your API requests.

The OpenAI class has already been imported for you from the openai library.

この演習はコースの一部です

Working with DeepSeek in Python

コースを見る

演習の手順

  • Specify the deepseek-ai/DeepSeek-V4-Pro model.
  • Assign the correct role in the messages list.

実践的なインタラクティブ演習

このサンプルコードを完成させて、この演習に挑戦してみましょう。

client = OpenAI(api_key="", base_url="https://api.together.xyz/v1")

response = client.chat.completions.create(
    # Specify the model
    model="____",
    max_tokens=400,
    messages=[
        # Assign the correct role
        {"role": "____", 
         "content": "Write a post to announce my new AI Engineer role on LinkedIn. Only output the post."}]
)

print(response.choices[0].message.content)
コードを編集して実行