Visual Studio Code
Build your first asAi project in VS Code.
This tutorial creates a small Python project, keeps your API key outside the code, and sends one request through the OpenAI-compatible asAi gateway.
Before you start
- Install Visual Studio Code and a currently supported Python 3 release.
- Create an asAi account, verify your email, and add prepaid credit.
- Create an
asai_sk_...key under API keys. Copy it once and keep it private.
1. Create and open a project folder
- Create an empty folder named
asai-vscode. - In VS Code, choose File > Open Folder and select it.
- Choose Terminal > New Terminal. Run the remaining commands in this terminal.
2. Create a virtual environment
Windows PowerShell:
python -m venv .venv
.\.venv\Scripts\Activate.ps1
macOS or Linux:
python3 -m venv .venv
source .venv/bin/activate
When the environment is active, the terminal prompt normally begins with (.venv). In VS Code, press Ctrl+Shift+P (or Cmd+Shift+P on macOS), choose Python: Select Interpreter, then select the interpreter inside .venv.
3. Install the client libraries
python -m pip install --upgrade openai python-dotenv
The official OpenAI Python library works because asAi provides an OpenAI-compatible Chat Completions endpoint.
4. Store your key locally
Create a file named .env in the project root:
ASAI_API_KEY=asai_sk_...
Replace the placeholder with your real key. Do not add quotation marks or spaces around it.
Create a second file named .gitignore:
.env
.venv/
__pycache__/
Never paste a real key into Python code, screenshots, chat messages, or a Git repository. If a key is exposed, revoke it under API keys and create a replacement.
5. Add the Python code
Create asai_test.py and paste this code:
import os
from dotenv import load_dotenv
from openai import OpenAI
load_dotenv()
api_key = os.getenv("ASAI_API_KEY")
if not api_key:
raise RuntimeError("ASAI_API_KEY is missing from .env")
client = OpenAI(
api_key=api_key,
base_url="https://serveras.click/v1",
)
response = client.chat.completions.create(
model="asai/gpt-6-sol",
messages=[
{"role": "user", "content": "Reply with: asAi connection works"}
],
max_tokens=50,
)
print(response.choices[0].message.content)
Keep /v1 in the base URL. Model IDs must match the live Models catalog exactly.
6. Run and verify
python asai_test.py
The terminal should print the model's reply. Then open Logs to confirm the request, model, status, token usage, and charged credits.
Troubleshooting
pythonis not found: install Python, reopen VS Code, and trypyon Windows orpython3on macOS and Linux.- PowerShell blocks activation: open a Command Prompt terminal in VS Code and run
.venv\Scripts\activate.bat, or select the.venvinterpreter and use its Python directly. ASAI_API_KEY is missing: confirm the file is named exactly.env, it is besideasai_test.py, and you launched the command from the project folder.- 401: the key is missing, invalid, or revoked. Create a replacement under API keys.
- 402: your available credits cannot cover the request. Check Top up.
- 403: verify your email and confirm your account and key are active.
- 429: you reached the account request or concurrency limit. Let current requests finish, then wait and retry.
- 400 unsupported model: copy an available model ID from Models.
Set up Cline with asAi
If you already installed the Cline extension, connect it to asAi with these settings:
- Open Cline from the VS Code activity bar, then open Cline Settings using the gear icon.
- For API Provider, choose OpenAI Compatible.
- Set Base URL to
https://serveras.click/v1. - Paste your
asai_sk_...key into API Key. Create one under API keys if needed. - Set Model ID to
asai/gpt-6-sol, or copy another available model ID from Models. - Save the settings, open your project folder, and start a new Cline task.
For a safe connection check, send this prompt first:
Reply exactly: ASAI_CLINE_OK. Do not edit files or run commands.
Cline should reply with ASAI_CLINE_OK. Never paste your API key into Cline chat or save it in project files. Review each requested file edit or command before approving it.
Helpful VS Code extensions
These are optional. Install only what matches your workflow.
Python by Microsoft
Adds Python run, debug, test, and interpreter-selection support. Use it to select the project's .venv environment.
Pylance by Microsoft
Adds fast autocomplete, type information, import checks, and inline diagnostics while editing the Python example.
REST Client by Huachao Mao
Lets you send HTTP requests from .http files inside VS Code. It is useful for public requests such as GET https://serveras.click/v1/models. Do not save a real API key in a tracked .http file.
Continue
Adds AI chat, code editing, and autocomplete. Configure its OpenAI provider with API base https://serveras.click/v1, your asAi key, and an available asai/... model. Keep Responses API use disabled so it uses Chat Completions. Store the key through Continue's secrets support, not in a tracked workspace file.
Cline
Adds an AI coding agent that can inspect files, edit code, and run approved commands. Choose OpenAI Compatible, then enter base URL https://serveras.click/v1, your asAi key, and an available model ID. Review every requested action because agent tools can change your project.