Tutorial: Connecting Cline to a Relay API for VS Code
Tutorial for setting up the open-source VS Code coding agent Cline: creating sk- keys and configuring the API Provider and Base URL to use Claude, GPT, or Gemini models.
1. What is Cline?
Cline is a popular open-source AI coding agent for VS Code. It can read codebases, modify files, and run terminal commands, with native support for various providers like Anthropic, OpenAI, and Google (Gemini). By pointing its API Provider to a relay gateway and entering your sk- key, you can call Claude, GPT, or Gemini models using your platform balance, billed per token.
2. Preparation
- Log in to the Jizhi API console, and create an
sk-xxxxxxkey under "API Keys" (this is only shown once, so please save it). - Confirm the model slug you intend to use (e.g.,
claude-sonnet-5,gpt-5.5,gemini-3.7-flash). - Confirm the gateway URL:
https://www.relay-api.com.
3. Configuring Cline
Open Cline → Gear icon (Settings) → API Provider, then choose based on the model type:
① Anthropic (for Claude)
Base URL : https://www.relay-api.com
API Key : sk-your-key
Model ID : claude-sonnet-5
② OpenAI Compatible (for GPT)
Base URL : https://www.relay-api.com/v1
API Key : sk-your-key
Model ID : gpt-5.5③ For Gemini: Select the Google Gemini (or OpenAI-compatible) provider, set the Base URL to https://www.relay-api.com/v1beta, and use gemini-3.7-flash as the Model ID (the model name follows the URL).
Once filled out, click Connect / Continue to verify. Use the table above for the appropriate Base URL entry points.
4. API Endpoint Reference
| Model Group | Entry Point (Base URL) | Protocol |
|---|---|---|
| Claude / Anthropic | https://www.relay-api.com | Anthropic Messages |
| GPT / OpenAI | https://www.relay-api.com/v1 | OpenAI Chat Completions |
| Gemini | https://www.relay-api.com/v1beta | Google generateContent |
5. Troubleshooting
| Issue | Resolution |
|---|---|
| 401 / 403 | Key is invalid, disabled, or has insufficient balance; verify the sk- key and check your balance. |
| 404 / Model Unavailable | The model name does not match the platform slug, or the model is not enabled; verify the Model ID. |
| Unknown model | Model IDs must be exact (case-sensitive); verify them in the model catalog. |
Security Recommendation: Do not commit keys to public repositories; use .env files or environment variables. Create separate keys for each tool to facilitate usage tracking and rate limiting.
Note on Base URL: This site accepts both /v1beta/models/... and /v1beta/v1beta/models/... (as well as /v1/... and /v1/v1/...), so whether the client automatically appends /v1 or /v1beta does not affect the call—you can use either the root domain or the address including the /v1beta suffix as your Base URL. Please copy the Model ID from the "Model ID" section in the top-right corner of the "Tokens" page in the console.
