News
New API Features 2024/07/25
News
New API Features 2024/07/25
Update API /chat/completions JSON Output Function Calling Chat Prefix Completion (Beta) 8K max_tokens (Beta)
JSON Output
Function Calling
Chat Prefix Completion (Beta)
8K max_tokens (Beta)
New API /completions FIM Completion (Beta)
FIM Completion (Beta)
Now Supporting Chat Prefix Completion, FIM, Function Calling and JSON Output
Today, the DeepSeek API releases a major update, equipped with new interface features to unlock more potential of the model:
Update API /chat/completions JSON Output Function Calling Chat Prefix Completion (Beta) 8K max_tokens (Beta)
JSON Output
Function Calling
Set response_format to {'type': 'json_object'}
Guide the model to output JSON format in the prompt to ensure that the output format meets your expectations
Set max_tokens appropriately to prevent the JSON string from being truncated midway
Chat Prefix Completion (Beta)
8K max_tokens (Beta)
New API /completions FIM Completion (Beta)
FIM Completion (Beta)
All new features above are open to the two models: deepseek-chat and deepseek-coder.
Update API /chat/completions
DeepSeek API now supports JSON Output,compatible with OpenAI API,enforces the model to output valid JSON format string.
When performing tasks such as data processing, this feature allows the model to return JSON in a predefined format, facilitating the subsequent parsing of the model's output and enhancing the automation capabilities of the program flow.
To use JSON Output,users need to :
Set base_url to https://api.deepseek.com/beta to enable the Beta features
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, for example: {"role": "assistant", "content": "Once upon a time,", "prefix": True}
Set response_format to {'type': 'json_object'}
Guide the model to output JSON format in the prompt to ensure that the output format meets your expectations
Set max_tokens appropriately to prevent the JSON string from being truncated midway
The following is an example of JSON Output.In this example, the user provides a piece of text, and the model formats the questions and answers within the text into JSON.
max_tokens is default to 4096. By enabling the Beta API,max_tokens can be set up to 8192
For detailed guide, please refer to JSON Output Guide.
DeepSeek API now supports Function Calling, compatible with OpenAI API, allows the model to interact with the physical world via externel tools.
Function Calling supports multiple functions in one call (up to 128). It supports parallel function calls.
The image below demonstrates the integration of deepseek-coder into the open-source large model frontend LobeChat. In this example, we enabled the "Website Crawler" plugin to perform website crawling and summarization.
The image below illustrates the interaction process using the Function Calling feature:
For detailed guide, please refer to Tool Calls Guide.
Chat Prefix Completion follows the API format of Chat Completion, allowing users to specify the prefix of the last assistant message for the model to complete. This feature can also be used to concatenate messages that were truncated due to reaching the max_tokens limit and resend the request to continue the truncated content.
To use Chat Prefix Completion, user needs to:
Set base_url to https://api.deepseek.com/beta to enable the Beta features
Now Supporting Chat Prefix Completion, FIM, Function Calling and JSON OutputUpdate API /chat/completionsNew API /completionsUpdate Statements
Update API /chat/completions
New API /completions
Update Statements