Connect Cline to Codex4Less: OpenAI-Compatible API Setup
Cline is an open-source coding agent that works inside VS Code (with an official CLI as well). It reads files, writes code and runs commands with your approval — and it can talk to any provider that implements an OpenAI-compatible API. This guide connects Cline to Codex4Less using the OpenAI Compatible provider, so Cline's requests are served by Codex4Less models.
Every configuration value below was verified against the live Codex4Less API. The provider configuration was tested with the Cline CLI v3.0.72 end-to-end (connection, a real coding task with file writes and command execution). The VS Code extension settings mirror the same provider fields; the extension version current at the time of writing is 4.1.25. Where something was not executed during testing, it is marked as such.
Prerequisites
- VS Code with the Cline extension, or Node.js for the Cline CLI. (The CLI printed a trust-store warning on Node 20.20; its own message recommends Node ≥ 22.15 for corporate/self-signed CAs. The tests for this guide passed on Node 20.20.)
- A Codex4Less account and API key — you can create both for free and pay per token.
- Five minutes for configuration. No other tools are required.
Step 1 — Create Your Codex4Less API Key
- Create an account: codex4less.com/register
- Sign in and open API Keys in the dashboard: codex4less.com/dashboard/api-keys
- Click Create New API Key and copy the key. It is shown only once.
Security: never paste a real API key into screenshots, chat messages or source code. Cline stores provider keys in its own settings/config — treat that file as a secret.
Step 2 — Install Cline
VS Code extension: open the Extensions view in VS Code, search for Cline (publisher saoudrizwan) or use the Marketplace page, and install it. Open Cline from the Cline icon in the activity bar (or Ctrl/Cmd+Shift+P → “Cline: Open”).
Cline CLI (alternative, used for this guide's live tests):
npm install -g cline
cline --versionAt the time of writing this installs 3.0.72.
Step 3 — Configure the OpenAI-Compatible Provider
Option A — VS Code extension
- Open the Cline settings panel (the ⚙️ icon in the Cline view).
- Set API Provider to OpenAI Compatible.
- Fill in:
- Base URL:
https://api.codex4less.com/v1— use the API root, not a full endpoint path. - API Key: the
sk-...key from Step 1. - Model ID:
gpt-6.1-sol(a verified model — see Step 4).
- Base URL:
- Click Verify to confirm the connection. Cline shows a success indicator when the endpoint and key are accepted.
- Optional — Model Configuration: you can set context window size, max output tokens, and capability flags such as image support or computer use (tool calling). Only enable capabilities your chosen model actually provides.
Option B — Cline CLI (exact commands tested for this guide)
cline auth -p openai-compatible -k "sk-..." -b "https://api.codex4less.com/v1" -m "gpt-6.1-sol"This stores the provider, key, base URL and model in Cline's configuration (~/.cline by default). You can keep an isolated config directory with --config <dir> if you want to test without touching your main setup.
Step 4 — Select a Supported Model
Codex4Less exposes its live model catalog in two places — always trust these over any article:
- The pricing page: codex4less.com/pricing
- The API:
GET https://api.codex4less.com/v1/models
At the time of writing the catalog contains gpt-6.1-sol, gpt-5.6-sol and gpt-6-astra. This guide uses `gpt-6.1-sol`, which was verified end-to-end with Cline. If you pick a different ID, confirm it appears in the list above first.
Step 5 — Verify the Connection
With the CLI, ask for a fixed answer and inspect the machine-readable result:
cline --json "Reply with exactly: CONNECTED"A working setup ends with a run_result line like:
{"type":"run_result","finishReason":"completed","text":"CONNECTED","model":{"id":"gpt-6.1-sol","provider":"openai-compatible"}}In VS Code, the Verify button in settings (Step 3) is the equivalent check. A successful reply alone does not prove the request went through Codex4Less — confirm it in Dashboard → Usage: codex4less.com/dashboard/usage shows the model, token counts and cost for every request.
Step 6 — Run a Small Coding Task
This exact task was executed during testing. From the CLI, inside a project directory:
cline "Create a file named hello.js that prints exactly READY when run with node. Then run it and report the output."Observed result: Cline used its file-writing and command-execution tools across several iterations, created hello.js, ran it with node and reported the output READY. In VS Code the same workflow runs in the chat panel; tool actions (file edits, terminal commands) appear as approval prompts unless auto-approve is enabled.
What this proves: the model served through Codex4Less supports the OpenAI-style function calling that Cline's agent loop requires — the agent successfully wrote a file and executed a command. Other capabilities (vision, very long context, provider-specific features) depend on the model and were not part of this test.
Troubleshooting
“Invalid API Key” / 401
- The key must be the full
sk-...value from the dashboard, with no surrounding quotes or spaces. - A revoked or deleted key stops working immediately — create a new one.
- Make sure you pasted the key into the OpenAI Compatible provider — not into the built-in “OpenAI” provider (which targets
api.openai.com).
404 or connection errors
- The Base URL must be exactly
https://api.codex4less.com/v1. Cline appends the endpoint paths itself; a base URL likehttps://api.codex4less.com/v1/chat/completionsproduces a doubled path and 404s. - If the request fails instantly, check your network/firewall; the endpoint is reachable over standard HTTPS (verified).
“Model Not Found”
- Use an ID copied from
GET /v1/modelsor the pricing page. Catalog entries change over time.
The agent doesn't call tools / edits fail
- Open Model Configuration in Cline's settings and make sure the model is not marked as lacking tool support — Cline needs tool calling for agentic file edits.
- If a specific model rejects tool-calling requests while plain chat works, switch to
gpt-6.1-soland restart the task.
CLI trust-store warning on older Node
The Cline CLI may warn that Node 20 cannot read the OS trust store. This did not affect the tests here; if you use a corporate proxy or self-signed certificates, upgrade to Node ≥ 22.15 or set NODE_EXTRA_CA_CERTS.
FAQ
Can I use a custom API provider with Cline? Yes — that is exactly what the OpenAI Compatible provider is for: any endpoint implementing the OpenAI API standard works. See the official Cline documentation.
Where should I store my API key?
In Cline's provider settings (extension) or via cline auth (CLI). Do not commit it to a repository or share screenshots of the settings screen.
Which API format does the endpoint support?
Codex4Less serves OpenAI-compatible APIs. Cline's chat and tool calls were verified against POST https://api.codex4less.com/v1/chat/completions; the model catalog is at GET /v1/models. More details in the API documentation.
What should I do if my selected model is unavailable?
Check the current list (GET /v1/models or the pricing page) and switch the Model ID in Cline. Availability can change as the catalog evolves.
Does the VS Code extension and the CLI share configuration? No — they are separate installs with separate configuration. Configure the provider in each one you plan to use.
Conclusion and CTA
You have connected Cline to Codex4Less, verified the endpoint and ran a real coding task with file edits and command execution. Tool calling works end-to-end, so Cline's agentic features are available with Codex4Less models.
Ready to get started?
Create your Codex4Less account, generate an API key and point Cline at https://api.codex4less.com/v1.
Related reading: Using Codex CLI with Codex4Less · API documentation
