Quickly Building a Code Editor Using a ModelArts Studio (MaaS) DeepSeek API and Cursor
This guide describes how to use Cursor to call a DeepSeek model deployed on ModelArts Studio to build a code editor.
Operation Scenarios
The Cursor code editor uses AI to enhance developer productivity with its modern features. It combines the strong features of traditional editors like VS Code with AI-powered smart coding tools. These include smart code completion, natural language programming, and code library understanding, which boost development speed. Cursor also supports popular AI models like OpenAI's GPT-4 and DeepSeek, and offers flexible customization. This makes it ideal for users from beginners to professionals.
MaaS deploys DeepSeek models on its platform, allowing developers use them via API calls.
Prerequisites
- You have created a Huawei Cloud account. For details, see Signing Up for a HUAWEI ID and Enabling Huawei Cloud Services.
- You have completed ModelArts agency authorization. For details, see Configuring ModelArts Studio (MaaS) Access Authorization.
Step 1: Downloading and Installing Cursor
Download and install Cursor from the official website.
Step 2: Preparing for MaaS Model API Access
- Create an API key.
You can create up to 30 keys. Each key is displayed only once after creation. Keep it secure. If the key is lost, it cannot be retrieved. In this case, create a new API key.
- Log in to the ModelArts Studio (MaaS) console and select CN-Hong Kong from the top navigation bar.
- In the navigation pane, choose API Key Management.
- On the API Key Management page, click Create API Key, enter the tag and description, and click OK.
The tag and description cannot be modified after the key is created.
Table 1 Parameters Parameter
Description
Tag
Tag of the API key. The tag must be unique. The tag can contain 1 to 100 characters. Only letters, digits, underscores (_), and hyphens (-) are allowed.
Description
Description of the custom API key. The value can contain 1 to 100 characters.
- In the Your Key dialog box, copy the key and store it securely.
- After the key is saved, click Close.
After you click Close, the key cannot be viewed again.
- Use a model from My Services.
The following uses My Services as an example. You can also use commercial services to call APIs. For details, see Subscribing to a Built-in Commercial Service in ModelArts Studio (MaaS).
- In the navigation pane of ModelArts Studio (MaaS) console, choose Real-Time Inference.
- Click the My Services tab and click Deploy Model in the upper right corner to create a model service. For details, see Deploying a Model Service in ModelArts Studio (MaaS).
- Choose More > View Call Description in the Operation column of the target running model service.
- Check the basic API URL and model name on the page. You will need these for the next steps in configuring Cursor.
Step 3: Configuring the MaaS API in Cursor
- Click the settings icon in the upper right corner of the Cursor platform.
- In the Cursor Settings area, choose Models and click Add model.
Figure 1 Adding a model
- Enter the model name obtained in Step 2.2 in the text box and click Add model on the right.
- Select only the added MaaS model. Choosing others might cause the verification to fail.
Figure 2 Selecting a MaaS model
- In the OpenAI Key area, enter the API key created in Step 2.1.
Figure 3 Entering the API key
- Click Override Openai Base URL. Change the basic API URL to the one from Step 2.2, removing /chat/completions at the end. Then click Save.
- Click Verify to verify the API connectivity. If no errors show, the setup is complete and you can start using the API.
Figure 4 Verifying connectivity
Step 4: Using the MaaS API in Cursor to Generate Code
On the code editing page, choose the configured model in the red box for tasks like dialog, code generation, and code parsing.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot