1. Use Cases

In prefix completion, the user provides the desired prefix information, allowing the model to complete the rest of the content based on the prefix provided by the user.
With this capability, the model demonstrates better instruction-following abilities and can address user requirements for specific formats in certain scenarios.

2. How to Use

Add the following to your request:

extra_body={"prefix":"desired prefix content"}

3. Supported Models

Currently, large language models support the above parameter.

Note: The list of supported models may change. Please refer to this document for the latest list of supported models.

4. Example Usage

Below is an example of using prefix completion with the OpenAI library:

client = OpenAI(
    api_key="Your APIKEY", # Obtain from https://cloud.siliconflow.com/account/ak
    base_url="https://api.ap.siliconflow.com/v1"
)
 
messages = [
    {"role": "user", "content": "Please write quick sort code"},
]

response = client.chat.completions.create(
    model="deepseek-ai/DeepSeek-V2.5",
    messages=messages,
    extra_body={"prefix":"```python\n"}
)

print(response.choices[0].message.content)