DeepSeek API
πŸ‡ΊπŸ‡Έ English
  • πŸ‡ΊπŸ‡Έ English
  • πŸ‡―πŸ‡΅ Japanese
  • πŸ‡°πŸ‡· Korea
  • πŸ‡΅πŸ‡Ή Portuguese
  1. API Guides
DeepSeek API
πŸ‡ΊπŸ‡Έ English
  • πŸ‡ΊπŸ‡Έ English
  • πŸ‡―πŸ‡΅ Japanese
  • πŸ‡°πŸ‡· Korea
  • πŸ‡΅πŸ‡Ή Portuguese
  • Start quickly
    • Your First API Call
    • Models & Pricing
    • The Temperature Parameter
    • Token & Token Usage
    • Rate Limit
    • Error Codes
  • API Reference
    • Introduction
    • Create Chat Completion
      POST
    • Create FIM Completion (Beta)
      POST
    • Lists Models
      GET
    • Get User Balance
      GET
  • API Guides
    • Reasoning Model (deepseek-reasoner)
    • Multiple rounds of conversations
    • Chat Prefix Completion (Beta)
    • FIM Completion (Beta)
    • JSON Output
    • Function Calling
    • Context Caching
  • FAQ
    • FAQ
  1. API Guides

Chat Prefix Completion (Beta)

The chat prefix completion follows the Chat Completion API, where users provide an assistant's prefix message for the model to complete the rest of the message.

Notice#

1.
When using chat prefix completion, users must ensure that the role of the last message in the messages list is assistant and set the prefix parameter of the last message to True.
2.
The user needs to set base_url="https://api.deepseek.com/beta" to enable the Beta feature.

Sample Code#

Below is a complete Python code example for chat prefix completion. In this example, we set the prefix message of the assistant to "```python\n" to force the model to output Python code, and set the stop parameter to ['```'] to prevent additional explanations from the model.
Previous
Multiple rounds of conversations
Next
FIM Completion (Beta)
Built with