deepseek.jpg
Cover image for joseph_appsmith

Joseph Petty Verified userVerified user

Head of Developer Relations

Appsmith

Building a Chat App with Deepseek-R1 and Together.ai in Under 5 Minutes

DeepSeek just released their new r1 reasoning model, an open source LLM with some impressive benchmarks that are comparable to OpenAI's o1 model. But unlike OpenAI's reasoning model, DeepSeek actually shows the reasoning thread, or chain of thought, and returns it in the API. 

You can test the model for free on their website. Although, currently signups have been restricted, so if you don't have an account yet you'll have to test the model by running it somewhere else. One way is to run it locally with Ollama and connect from a local Appsmith instance. But if you want to skip the server setup, you can use a service like Together.AI and chat with various models through the API, including DeepSeek-r1. 

In this guide, we'll show how you can use Together.AI to integrate with Appsmith and build an AI chat app in under 5 minutes. 

This guide will cover:

  • Setting up an account and API key for Together.AI
  • Chatting with the DeepSeek Model from Appsmith
  • Saving the API key securely to a datasource
  • Building a UI for chatting with the model

Let's get started! 

check out the video version of the tutorial here:

 

Setting up an account and API key for Together.AI

Start out by creating a free account for Together.AI. Once you're logged in, you should be provided an API in the onboarding flow. However, if you skipped the onboarding, create a new API as follows: 

  • Go to the API key section of the dashboard
  • Copy the existing key, or regenerate to create a new one
  • API key

 

Then leave this window open while setting up the API in Appsmith

Chatting with the DeepSeek Model from Appsmith

Open the Appsmith editor and go to the Queries tab. Then click + and select new curl import

Then paste in the following curl request (but don't click import yet!):

curl -X POST "https://api.together.xyz/v1/chat/completions" \
  -H "Authorization: Bearer $TOGETHER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-ai/DeepSeek-R1",
    "messages": [
        {
                "role": "user",
                "content": "what is DeepSeek?"
        }
],
    "max_tokens": null,
    "temperature": 0.7,
    "top_p": 0.7,
    "top_k": 50,
    "repetition_penalty": 1,
    "stop": ["<|end▁of▁sentence|>"],
    "stream": false
  }'

Next, go back and copy that API key from Together.ai, and replace $TOGETHER_API_KEY with it. 

Ok, now click Import. Then rename the API to sendMessage

 

import curl

Next, click the gear next to the run button, and increase the timeout to 60,000 (60 seconds). 

 

timeout setting

Then click Run. You should get back a response from the Together.AI API, using the DeepSeek-r1 reasoning model. 

Notice the <think></think> tags around the chain of thought, followed by the final response from the model. Actually, with this prompt, the think tags are empty. The model seems to respond directly with certain basic prompts like this, but usually you'll see a whole separate reasoning thread there. 

think tags

 

Saving the API key securely to a datasource

Next, click the Save URL button to save the API key to an Appsmith Datasource. This will open up a form to fill in any credentials, then save as a new datasource. 

Notice how the Bearer token is in plan text though? We need to move this to the Authentication section to store it in an encrypted field. 

  1. Change the Authentication type to Bearer token
  2. Paste in the API key for the value (without the word Bearer)
  3. Delete the original header from the top of the form
  4. Save the datasource

save datasource

Then re-run the API to ensure the datasource is configured properly. 

 

Building a UI for chatting with the model

Lastly, we'll build a simple UI for the chat app. Drag in a Text widget, Input widget, and Button widget, and lay them out like a chat app. Then configure the widget properties as follows: 

Text widget

  • Set Text to display the API response at {{sendMessage.data?choices[0].message.content}}
  • Change height to Fixed, and enable Scroll for the Overflow Text
  • Remove bold formatting and change text size to small

Input widget

  • Set the Data type to Multi-line

Button widget

  • Set the onClick event to run the sendMessage API
  • Set the button text to "Send" 

 

chat ui

You should now be able to chat with the model from the UI. Try entering a prompt and click Send. 

Conclusion

And there you have it! A complete chat app with DeepSeek in under 5 minutes! By using Together.AI and Appsmith, you can quickly connect to any open-source model and build a custom chat app without writing a single line of code! From here you can integrate with other APIs, or upload files from the user to perform Retrieval-augmented Generation (RAG).