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 Voyager​

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

  • In the Voyager portal, open your profile's Keys tab and click Create API key. The full key is shown only once, so copy it then.
  • Open AI LLM → LLMs and copy one model ID available to your account, exactly as written. Note the model's context size and its Tools and Vision badges; step 5 uses them.
  • Use the full Chat Completions endpoint below for VS Code Custom Endpoint.
# 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 the 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 placeholder with your key. The model entry below is filled in for qwen38-27b; for another model, change the ID, name, and numbers to match it.

chatLanguageModels.json
[
{
"name": "ASU Air",
"vendor": "customendpoint",
"apiKey": "YOUR_RC_LLM_API_KEY",
"apiType": "chat-completions",
"models": [
{
"id": "qwen38-27b",
"name": "qwen38-27b",
"url": "https://openai.rc.asu.edu/v1/chat/completions",
"toolCalling": true,
"vision": true,
"maxInputTokens": 253952,
"maxOutputTokens": 8192
}
]
}
]
  • toolCalling and vision: true only if the model has the Tools or Vision badge in Voyager.
  • maxInputTokens: set it from the model's context window, shown as Context on the model's row in Voyager under AI LLM → LLMs. Voyager rounds it: 262.1K for qwen38-27b is 262144 tokens, and 65.5K for the olmo3 models is 65536. The window holds the prompt and the reply together, so subtract maxOutputTokens: 262144 - 8192 = 253952 for qwen38-27b.

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.