Skip to main content

Create and Execute Remote Quick Commands

You can use the quick commands you’ve created in the StackSpot AI Portal beyond IDEs. These commands can help you use the StackSpot infrastructure, such as Workspaces, Stack AI, and Knowledge Sources, to accelerate GenAI use cases via API.

When used remotely, the Quick Commands should seamlessly leverage the StackSpot infrastructure, including Stack AI and Knowledge Sources. Additionally, remote quick commands support the handling of parameters, allowing you to input variables or arguments to customize the behavior of the commands.

The purpose of the Remote Quick Command is its use and integration with third-party software.

tip

What’s the main difference between Quick Command IDE and Remote Quick Command?

Quick Command is a custom feature that works only on your IDE. You can use it by right-clicking your mouse. On the other hand, you can execute Remote Quick Command via API and generate payloads for external services through the internet. It is perfect for integrations and processing beyond the local environment.

Create a Remote Quick Command

Requirements

Step 1. Create a Remote Quick Command

1. Navigate to ‘Contents > Quick Command’;

2. Click ‘Create Quick Command’ and select the ‘Remote’ option; Fill in the required fields:

  • Quick Command Name: Add a descriptive name for your Quick Command.

  • Command (Slug): Define a unique slug for the command (e.g., my-remote-command); it should follow the slug pattern. For more information about Slugs, see the slug pattern.

  • Description: Provide a brief description of what the command does.

You can create a RQC using an available template or create one from scratch. It can be prompt or web request.

- Prompt

Click on the Prompt box, drag it to the 'Start' box, and connect it using the line.

On the Prompt box, fill out the fields:

  • Prompt name: Add a slug identifier following the slug pattern.
  • Insert your prompt: Write down what you want your command to do. Include the Jinja variable {{input_data}} to pass dynamic data.
  • Select a Knowledge Source and/or an Agent.

- Web Request

Click on the Web Request box, drag it to the 'Start' box, and connect it using the line.

On the Web Request box, configure the URL, headers, and request body for an HTTP Request.

  • Web request name: Add a request name following the slug pattern.
  • HTTP Method: Choose a HTTP method.
  • URL Endpoint: Add the Endpoint URL.
  • Headers
  • Request Body

Connectivity is limited to StackSpot AI, and your service is available online. When using a Quick Command in the IDE extension, the Web Request operates within it, enabling functionality on private networks. If this is your requirement, opt for the Quick Command IDE.

3. Click 'Finish' and fill out the Quick Command Utilization. Add:

{{the-name-of-yourQC.answer}}

It represents the expected result displayed in the service.

Step 3. Execute the Remote Quick Command via API

You will execute the Remote Quick Command via API on the ‘How to use’ tab. Follow these steps:

3.1. Authenticate and obtain a Bearer Token

  1. Open your API client (e.g., Postman);
  2. Create a new POST request to the following URL:
POST https://idm.stackspot.com/stackspot/oidc/oauth/token
  1. Add the following headers: Content-Type: application/x-www-form-urlencoded

  2. In the request body, include your client credentials:

{
"grant_type": "client_credentials",
"client_id": "your_client_id",
"client_secret": "your_client_secret"
}
  1. Send the request and copy the access_token from the response.

3.2. Create an execution

  1. Create a new POST request to the StackSpot API endpoint for your Quick Command:
POST https://genai-code-buddy-api.stackspot.com/v1/quick-commands/create-execution/{{quick_command_slug}}
  1. Replace {{quick_command_slug}} with the slug of your Quick Command (e.g., my-remote-command).

  2. Add the following headers:

  • Authorization: Bearer your_access_token
  • Content-Type: application/json
  1. In the request body, include the input data for the Quick Command:
{
"input_data": "Your input data here"
}

  1. Send the request. The response will include an execution_id.

3.3. Monitor execution status

  1. Create a new GET request to the following URL:
GET https://genai-code-buddy-api.stackspot.com/v1/quick-commands/callback/{{execution_id}}

Replace execution_id with the ID returned in the previous step.

  1. Add the following header:
  • Authorization: Bearer your_access_token
  1. Send the request. The response will include the execution status and result.

Monitor the response on the page for progress status, start and end times, duration, execution percentage, and status.

You will receive updates on the status at each step, including the final result, which you can use anywhere.

info
  • Remote Quick Command Rate Limit

There is a limit on the number of times you can use the Remote Quick Command within a 24-hour period. The limit varies based on the type of token you are using.

  1. Personal Access Token (PAT)

If you have already used it more than 100 times in the last 24 hours, you won't be able to use it again until the time limit has expired. In this case, you will receive an HTTP status 429 error. See an example below:

{
"type": "TooManyRequests",
"code": "CODEBUDDY_1044_QUICK_COMMAND_RATE_LIMIT_EXCEEDED",
"details": "Maximum number of requests reached. Your limit is 100 requests in the last 1440 minutes"
}

Please wait until the time limit has expired before using the Remote Quick Command again.

  1. Service Credential: If you use a Service Credential for the account, you have a a limit of 20 requests per minute and up to 6,000 requests per day.

Only Account Holders can create Service Credentials and the limit is for the whole Account.

Share Quick Command

You can share the Quick Command you created with other users. This will enable direct use within the IDEs in the Account.

  • On the 'Quick Commands' screen, click the 'Share' button.

Next Steps