Skip to content
OPENSHUNT DOCS / START

Tutorial

Connect your local environment, SDKs, and AI coding tools to the OpenShunt gateway. One API Key gives you a consistent way to call supported models.

API endpointhttps://api.novarelay.cn/v1
Get an API Key →About 10 minutes
1
Prepare your accountSign in to the sub2api console
2
Create an API KeyStore it securely
3
Choose an integrationConfigure an SDK or coding tool
ENVIRONMENT · 01 / PREPARATION

Install Node.js

Claude Code, Codex, and Gemini CLI can all be installed with npm. Use Node.js 20 LTS or newer.

STEP 1

Install Node.js

Download the LTS release for your operating system. Reopen your terminal after installation so the updated environment is loaded.

Download Node.js LTS →
STEP 2

Verify the installation

Both commands should print a version number. Node.js v20 or newer is recommended.

TERMINAL
node -v
npm -v
02 / API KEY

Define access boundaries when creating a key

Set usage limits, expiration, and access restrictions so every project starts with a clear security boundary.

STEP 1

Open key settings

Go to API Key management in the OpenShunt console and select “Create Key.” Give it a recognizable name and configure the available controls before saving.

Open the console →

Configure three controls for your use case

USAGE LIMIT

Usage limit

Set an acceptable budget for each project and stop consumption at the limit.

EXPIRATION

Expiration

Use short-lived keys for testing and rotate production credentials regularly.

ACCESS CONTROL

Access restrictions

When available, bind IP sources or project permissions to reduce exposure.

Recommended setup

Set a usage limit first, then configure expiration and access restrictions. Never put a key in frontend code, screenshots, logs, or a public repository.

03 / OPENAI SDK

Use the OpenAI-compatible API

Existing OpenAI SDK integrations usually require only a new API Key and Base URL.

CURL
curl https://api.novarelay.cn/v1/chat/completions \
  -H "Authorization: Bearer nr_live_xxx" \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-4o","messages":[{"role":"user","content":"Hello"}]}'
PYTHON
from openai import OpenAI

client = OpenAI(
    api_key="nr_live_xxx",
    base_url="https://api.novarelay.cn/v1",
)

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello"}],
)

print(response.choices[0].message.content)
04 / CLAUDE CODE

Configure Claude Code

Install Claude Code, then point its authentication token and request URL to OpenShunt.

STEP 1

Install the CLI

NPM
npm install -g @anthropic-ai/claude-code
claude --version
STEP 2

Add the user configuration

Save the following to ~/.claude/settings.json and replace the example key.

JSON
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.novarelay.cn",
    "ANTHROPIC_AUTH_TOKEN": "nr_live_xxx"
  }
}
05 / CODEX

Configure Codex CLI

Use an OpenAI-compatible endpoint through a custom model provider stored in your user configuration.

STEP 1

Install Codex

NPM
npm install -g @openai/codex@latest
codex --version
STEP 2

Add a model provider

Edit ~/.codex/config.toml. Use a model identifier currently supported by the console.

TOML
model = "gpt-4o"
model_provider = "openshunt"

[model_providers.openshunt]
name = "OpenShunt"
base_url = "https://api.novarelay.cn/v1"
wire_api = "responses"
requires_openai_auth = true
STEP 3

Add your credentials

Save the following to ~/.codex/auth.json and replace the example key.

JSON
{
  "OPENAI_API_KEY": "nr_live_xxx",
  "auth_mode": "apikey"
}
Protect configuration files

Local files may contain a plaintext key. Restrict file access and exclude them from version control.

AI CODING TOOLS · 06 / GEMINI CLI

Configure Gemini CLI

Use API Key authentication and direct Gemini CLI requests through the OpenShunt-compatible gateway.

STEP 1

Install Gemini CLI

NPM
npm install -g @google/gemini-cli
gemini --version
STEP 2

Add the user environment file

Save the following to ~/.gemini/.env. Confirm that the console currently provides a Gemini-compatible endpoint and model.

ENV
GEMINI_API_KEY=nr_live_xxx
GOOGLE_GEMINI_BASE_URL=https://api.novarelay.cn
GEMINI_MODEL=gemini-2.5-pro
STEP 3

Start using Gemini CLI

Run gemini from your project and choose API Key authentication on first launch.

07 / TROUBLESHOOTING

Common issues

The API returns 401 or 403

Verify the Bearer authorization format, confirm that the key is active, and check its permissions or source restrictions.

The request succeeds but the model is unavailable

Match the model identifier shown in the console. Some clients require the corresponding model alias.

Requests time out or fail repeatedly

Check the request log to separate local network, parameter, and upstream errors. Keep the request ID when contacting support.

READY TO BUILD

Configuration complete

Manage API Keys, usage, and request logs in the console.

Open the console →

Reliable infrastructure for every AI request.