Back to discover
ArticlesBuild with AICurioFuse editorial

DeepSeek API: carry context into a follow-up question

Send earlier messages again: the chat endpoint does not retain conversation context for you.

Jump to the practice exercise
Three ceramic speech bubbles sit together in a blue tray beside a freestanding cream arch.
CurioFuse · AI-generated illustration
In this article

Prepare the first call

Start with DeepSeek’s first-call example, intended here for readers comfortable editing a small Python script. Obtain a DeepSeek API key and install the OpenAI SDK as the guide specifies. Configure the client with https://api.deepseek.com as its base URL and read your key from DEEPSEEK_API_KEY, following its example. Use deepseek-flash and stream=False for this exercise. The example reads the answer from response.choices[0].message.content; inspect that value after your initial request.

Carry the messages forward

The conversation guide requires the client to resend history. Our illustrative exercise: ask which item comes first in ‘pear, plum’, then ask ‘And second?’. Append the actual assistant response to your messages, then the follow-up user question; submit that list again. Before sending, check the order: initial user message, assistant reply, new user message. Expect plum; this is a practice design, not a recorded model test.

Inspect completion and content separately

The API reference defines stop as natural completion or a stop sequence. Its finish_reason schema associates length with the requested token cap; its JSON-output warning also names the conversation context limit. Our suggested check: do not diagnose the cause from length alone, and inspect the answer separately. A stop status does not establish correctness. Input and generated tokens together must fit the model’s context length; max_tokens caps generation without removing the input limit.

Try it: a CurioFuse exercise

An original editorial exercise with a checkable outcome.

Inspect the handover between two turns

Use a fictional task list: 1. Draft the invitation. 2. Check its date. 3. Prepare the export. Ask “What is the first task?” Save the actual response. Then ask “What follows it?” This practice dataset needs no customer information.

Before the second request, inspect these three message entries in order:

  • user: the complete numbered list and the first question.
  • assistant: the actual first response, not a replacement you wrote yourself.
  • user: “What follows it?”

The intended answer is check its date. That is an answer key for the exercise, not a recorded API result. Sending only the final question leaves out what “it” refers to; including the list but omitting the actual assistant response changes the conversation you are evaluating.

Record the outgoing roles, the returned answer and any missing context separately. If you cannot reconstruct the second request from those records, fix your history handling before judging the model's conversational ability. Keep this small fixture when you revise the application.

Sources(3)

Original CurioFuse editorial. A guide to explore and evaluate AI, without an implied product test.

Sources & standardsReport a correction