Skip to content

Which message roles and content format does DeepSeek accept?

Use a messages array containing objects with role and non-empty text content. Supported roles are system, user and assistant, and at least one user message is required. The current route does not accept tool-role messages, multimodal content arrays or extra message properties. Preserve role boundaries when your application constructs history.

BUILD NON-STREAMING TEXT WORKFLOWSAISwapLab team · Editorial methodPublished 2 min read
Open API documentationExplore 67 Image SkillsPrivate keys · Explicit credit approval
Article workflow: Validate each message object; Separate user and application text; Quote the final array.
Workflow diagram: Validate each message object → Separate user and application text → Quote the final array. Read the article for evidence and limits.

Do not infer every familiar chat schema is compatible

Some clients send content as an array of text blocks, add name fields or include tool-call metadata. Those patterns are outside this customer's documented contract even if another endpoint supports them. System instructions guide the task, but they are not a secure place for secrets that must never appear in model context.

What to do next

  1. 01

    Validate each message object

    Allow only role and content, confirm a supported role, and reject empty or non-string content before the network call. Keep the total message and byte limits in view.

  2. 02

    Separate user and application text

    Place application instructions and user requests deliberately rather than relabeling untrusted content as system policy. Keep prior assistant output identifiable when including conversation history.

  3. 03

    Quote the final array

    Use the exact validated messages for estimation and creation. If the user edits the conversation before submission, treat that as changed input and review the new quote.

A concrete example

Illustrative mismatch: an SDK sends content:[{type:text,text:Hello}]. The current route expects content as a plain string. Convert the supported text deliberately rather than forwarding the entire SDK object or silently dropping it.

Before you call it ready

  • Every message uses a supported role.
  • Content is a non-empty string.
  • The payload includes an actual user message.

When to stop or choose another method

If your workflow requires tool messages or multimodal blocks, stop and choose a contract that supports them. Flattening them blindly can lose meaning and produce misleading answers.

Sources

One task. A recoverable workflow.

Check the contract, approve the quote and retain the job.

Open API documentation