Skip to main content

Connect VS Code to the RC OpenAI-Compatible API

Level: Beginner · Time: 10–15 min · Category: How-to

Tags: VS Code · BYOK · Custom Endpoint

Configure VS Code BYOK (Bring Your Own Key) with the Research Computing LLM gateway, then send a successful test query from VS Code Chat.

Use this when you want VS Code Chat to send requests to the RC OpenAI-compatible API instead of a built-in provider. You need VS Code with Chat available, one RC LLM API key, and one model ID that your key can use.

Prerequisites​

What you will do​

  • Collect the exact API key, model ID, and endpoint URL values.
  • Add the RC LLM gateway as a VS Code Custom Endpoint provider.
  • Configure chatLanguageModels.json if VS Code opens it.
  • Select the RC model in VS Code Chat and send a successful test query.

1. Collect the values from this portal​

Start with the portal values so VS Code setup is just data entry, not guesswork.

  • Create or copy an API key from the AI LLM area of your profile.
  • Open the model list and copy one model ID available to your account.
  • Use the full Chat Completions endpoint below for VS Code Custom Endpoint.
  • If you are using a different local gateway in development, use that gateway's full /v1/chat/completions URL instead.
# Base URL
https://openai.rc.asu.edu/v1

# Full Chat Completions endpoint for VS Code Custom Endpoint
https://openai.rc.asu.edu/v1/chat/completions

2. Preflight the API once from a terminal​

This step proves the key, model ID, and endpoint work before VS Code is involved. If this fails, fix the portal key/model first.

  • A successful response includes an assistant message with the preflight text.
  • A 401 usually means the key is wrong, expired, or not set in this terminal.
  • A 404/model error usually means the model ID is wrong for your account.

Read the key in from a prompt rather than typing it into the command, so it does not land in your shell history:

read -rs RC_LLM_API_KEY   # paste your key, then press Enter (nothing is echoed)
export RC_LLM_API_KEY
export RC_LLM_MODEL="paste-model-id-here"

curl -sS https://openai.rc.asu.edu/v1/chat/completions \
-H "Authorization: Bearer $RC_LLM_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "'"$RC_LLM_MODEL"'",
"messages": [
{
"role": "user",
"content": "Reply with exactly: RC API preflight ok"
}
],
"temperature": 0
}'
Keep the key out of your shell history

Anything you type at a prompt is saved in plain text to ~/.zsh_history, ~/.bash_history, or PowerShell's ConsoleHost_history.txt. read -rs above avoids that. If your key does end up in history, a screenshot, or a commit, regenerate it in the portal — rotating a key invalidates the exposed one.

3. Open VS Code Language Models​

Use VS Code's built-in BYOK flow. For an OpenAI-compatible gateway like RC LLM, choose Custom Endpoint.

  • Update VS Code first if the Chat view or Language Models editor is missing.
  • Open Command Palette with Ctrl+Shift+P or Cmd+Shift+P.
  • Run Chat: Manage Language Models.
  • Select Add Models.
  • Choose Custom Endpoint.

4. Enter the Custom Endpoint provider details​

VS Code will ask for provider information. The labels can vary slightly by version, but these are the values to use.

  • Group name: ASU Air — this is the heading models appear under in the picker. Use the same label as the OpenCode setup so both tools read the same way.
  • Display name: the model name you copied from the portal. This names one model inside the ASU Air group, so use the model's own name here rather than repeating the provider.
  • API key: paste your RC LLM API key when VS Code asks for it.
  • API type: Chat Completions.
  • Endpoint URL: https://openai.rc.asu.edu/v1/chat/completions.
  • Model ID: use a model ID available to your API key.
  • Do not share screenshots that show your API key.

5. Save the model configuration if VS Code opens JSON​

Some Custom Endpoint setups open chatLanguageModels.json so you can finish the model details. Use this shape, replacing the placeholders with your key and model ID.

chatLanguageModels.json
[
{
"name": "ASU Air",
"vendor": "customendpoint",
"apiKey": "YOUR_RC_LLM_API_KEY",
"apiType": "chat-completions",
"models": [
{
"id": "MODEL_ID_FROM_PORTAL",
"name": "MODEL_NAME_FROM_PORTAL",
"url": "https://openai.rc.asu.edu/v1/chat/completions",
"toolCalling": true,
"vision": false,
"maxInputTokens": 128000,
"maxOutputTokens": 8192
}
]
}
]

6. Select the RC model in VS Code Chat​

After saving the provider configuration, switch the Chat view to the RC model before sending a test message.

  • Open the VS Code Chat view.
  • Open the model picker in the chat input.
  • Choose your model under the ASU Air heading. The heading is the provider group you named in step 4; your model is listed beneath it.
  • If it does not appear, reload VS Code and check that it is visible in Chat: Manage Language Models.

7. Send a successful test query​

Use a harmless chat prompt first. This confirms VS Code can send a request through BYOK and receive a response from the RC OpenAI-compatible API.

  • Paste the prompt below into VS Code Chat with the RC model selected.
  • A successful result is a normal assistant response in VS Code Chat.
  • The exact wording can vary, but there should be no authentication, provider, or model-not-found error.
  • After this works, try explanation prompts before asking VS Code to edit files.
You are connected to VS Code through the ASU Research Computing OpenAI-compatible API. Reply with one short sentence that starts with: Connected:

A good next prompt:

Explain what this workspace does from the README and package files. Do not edit files yet. List the files you inspected.

Troubleshooting​

  • If Custom Endpoint is missing, update VS Code and confirm BYOK is not disabled by organization policy.
  • If the terminal preflight fails, fix the API key, model ID, or endpoint before changing VS Code.
  • If authentication fails in VS Code but cURL works, update the provider details from Chat: Manage Language Models and re-enter the API key.
  • If VS Code opens chatLanguageModels.json, do not put that file in a project repo and do not share screenshots that include apiKey.
  • If the model does not appear in the picker, confirm the model is visible in the Language Models editor, then reload VS Code.
  • If chat works but agent edits fail, the model may not support tool calling; use explanation/review prompts or choose a tool-capable model.
  • If standard inline completions do not use this model, that is expected: VS Code BYOK applies to chat and utility tasks, not every Copilot feature.

Next steps​

  • Getting Started with AI — agents, skills, and the prompting habits that make locally hosted models work well.
  • LLM API Guide — return here if the key, endpoint, or model ID fails outside VS Code.
  • Create a lab portal — use the configured VS Code model on a beginner web project.
  • Create a Slurm CLI — practice using BYOK assistance on a command-line project.